Jump to content

Dont know if this is possible...


Recommended Posts

I am trying to get this working for my router, as a simple IP reset tool for my router.

Basically I need to convert the following, so it works with autoit. (Currently it is a script for another program running through http headers

[HSRC]
[STEP]
[REQUEST]
AUTH /? HTTP/1.1
Host: %%%routerip%%%
Authorization: Basic %%%basicauth%%%
[/REQUEST]
[/STEP]
[STEP]
[REQUEST]
GET /apply.cgi?submit_button=Status&submit_type=Disconnect&change_action=gozila_cgi&wan_proto=pppoe HTTP/1.1
Host: %%%routerip%%%
[/REQUEST]
[/STEP]
[STEP]
[REQUEST]
GET /apply.cgi?submit_button=Status&submit_type=Connect&change_action=gozila_cgi&wan_proto=pppoe HTTP/1.1
Host: %%%routerip%%%
[/REQUEST]
[/STEP]
[/HSRC]

I could use some INI Read's for %%%routerip%% and for the basicauth I dont know how I can do this but username: admin and password: admin = YWRtaW46YWRtaW4=

If i can't make autoit change the username/password into basic then I shall just use that code...

Edited by XxXGoD
Link to comment
Share on other sites

Don't know how it's for your router but for my TP-LINK it's like this, maybe it'll help you:

$oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect=Disconnect&wan=1", True, "Username","Password")
$oXML.Send
Sleep(2000)
$oXML.Open("GET", "http://192.168.1.1/userRpm/StatusRpm.htm?Connect=Connect&wan=1", True, "Username", "PAssword")
$oXML.Send

with the little help of searching.... :)

Link to comment
Share on other sites

Don't know how it's for your router but for my TP-LINK it's like this, maybe it'll help you:

$oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect=Disconnect&wan=1", True, "Username","Password")
$oXML.Send
Sleep(2000)
$oXML.Open("GET", "http://192.168.1.1/userRpm/StatusRpm.htm?Connect=Connect&wan=1", True, "Username", "PAssword")
$oXML.Send

with the little help of searching.... :)

It works but not great.

Before disconnect it to detect my IP and remember this IP, After it sends the disconnect, it should ping: 192.168.1.1 and when it does it successfully it should check the IP again and if it is 0.0.0.0 then it can reconnect.

When reconnected it will check the IP again and if its the same as the first detected IP then it will re-connect once more, if not it will leave it.

If you can give me some pointers to right sections and a small example i should be able to get this going.

Link to comment
Share on other sites

Dim $oXML = ObjCreate('Microsoft.XMLHTTP')

Dim $sIPPattern = '\b(?>(?:[01]?\d?\d|25[0-5]|2[0-4]\d)\.){3}(?:[01]?\d?\d|25[0-5]|2[0-4]\d)\b'
Dim $sArrayPattern = '(?i)var\s+wanpara\s+=\s+new\s+array\s*(\([^)]+\))'
Dim $sIP1, $sIP2
Dim $aMatch

$oXML.Open('GET', 'http://192.168.1.1/userRpm/StatusRpm.htm', True, 'Username', 'Password')
$oXML.Send
$sIP1 = _SingleMatch(_SingleMatch($oXML.responseText, $sArrayPattern), $sIPPattern)
If $sIP1 = '' Then Exit MsgBox(0x10, 'Error', 'Could not retrieve IP address')

Do
    $oXML.Open('GET', 'http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect=Disconnect&wan=1', True, 'Username', 'Password')
    $oXML.Send
    Sleep(2000)

    $oXML.Open('GET', 'http://192.168.1.1/userRpm/StatusRpm.htm?Connect=Connect&wan=1', True, 'Username', 'Password')
    $oXML.Send
    $sIP2 = _SingleMatch(_SingleMatch($oXML.responseText, $sArrayPattern), $sIPPattern)
    
Until ($sIP1 <> $sIP2 And $sIP2 <> '0.0.0.0')

$oXML = 0
Exit


Func _SingleMatch($sString, $sPatt)
    Local $aRet = StringRegExp($sString, $sPatt, 1)
    If IsArray($aRet) Then Return $aRet[0]
    Return ''
EndFunc

Link to comment
Share on other sites

Did you try the script above on linksys? :) Basically the concept is similar but the pages and StrinRegExp pattern to get your current IP address are different. You need to see which page contain the disconnect and connect buttons or submits to send a GET or POST request to... If you can post the pages or frames (if necessary) source it'll help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...