Sign in to follow this  
Followers 0
Hyflex

Dont know if this is possible...

10 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Anyone?

Share this post


Link to post
Share on other sites

Anyone?

I still can't find a way to get this to work.. anyone able o help?

Share this post


Link to post
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.... :)

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

It can not ever retrieve IP address...

Share this post


Link to post
Share on other sites

You asked for pointers not a fully written - functional script right? Anyway, if you can tell what router are you using or what is the problem...

Share this post


Link to post
Share on other sites

You asked for pointers not a fully written - functional script right? Anyway, if you can tell what router are you using or what is the problem...

Im using a LinkSys: AG241V2

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0