0x000000 Posted March 19, 2015 Posted March 19, 2015 I've tried on and off for over a year now, but without any success.What I'm trying to do is simply make a script that will disconnect the router, wait about 12 seconds then reconnect. - Tried adapting the script from my old router, but no dice: $sPOST = 'STOP0=%C4%E4%BB%DF&sWebSessionnum=0&sWebSessionid=-0000000000' $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "http://192.168.11.1/cgi-bin/cgi?req=frm&frm=info.html", False, "admin","password") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($sPOST) - Tried reading up on how to make AutoIt click a webpage button... but the guides were rather obtuse from my point of view, couldn't even get a basic script together. - Tried using packets with TCPStartup>TCPConnect>TCPSend ... also didn't work, packet data was pulled from 2 sources, Wireshark and JDownloader. No difference, it didn't throw any errors, but didn't cut the connection either, so I'm without any ideas to where to go from here. $packet1 = 'GET / HTTP/1.1'&@CRLF& _ 'source: 192.168.11.2'&@CRLF& _ 'Host: 192.168.11.1'&@CRLF& _ 'user-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'&@CRLF& _ 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'&@CRLF& _ 'accept-language: en-US,en;q=0.5'&@CRLF& _ 'accept-encoding: gzip, deflate'&@CRLF& _ 'authorization: Basic YWRtaW46cGFzc3dvcmQ='&@CRLF& _ 'credentials: admin:password'&@CRLF& _ 'connection: keep-alive'&@CRLF& _ 'if-modified-since: Tue, 30 Jul 2013 04:17:10 GMT'&@CRLF& _ 'cache-control: max-age=0'&@CRLF&@CRLF $packet2 = 'POST /cgi-bin/cgi?req=frm&frm=info.html HTTP/1.1'&@CRLF& _ 'source: 192.168.11.2'&@CRLF& _ 'Host: 192.168.11.1'&@CRLF& _ 'user-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'&@CRLF& _ 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'&@CRLF& _ 'accept-language: en-US,en;q=0.5'&@CRLF& _ 'accept-encoding: gzip, deflate'&@CRLF& _ 'authorization: Basic YWRtaW46cGFzc3dvcmQ='&@CRLF& _ 'credentials: admin:password'&@CRLF& _ 'connection: keep-alive'&@CRLF& _ 'content-type: application/x-www-form-urlencoded'&@CRLF& _ 'content-length: 5'&@CRLF& _ 'STOP0'&@CRLF&@CRLF TCPStartup() $socket = TCPConnect('192.168.11.1', 80) $bytes = TCPSend($socket, $packet1) $bytes = TCPSend($socket, $packet2) TCPCloseSocket($socket) TCPShutdown() It's a Buffalo WZR-450HP Ver.1.96, the http://192.168.11.1/cgi-bin/cgi?req=frm&frm=info.html address is the "Status" page, it's contains general text and 2 buttons, Start/Stop and an "Update" button, much simpler than the main router page that is full of frames, links and buttons.
Bert Posted March 19, 2015 Posted March 19, 2015 what browser are you using to do this? IE? The Vollatran project My blog: http://www.vollysinterestingshit.com/
0x000000 Posted March 19, 2015 Author Posted March 19, 2015 I mainly use Firefox or Opera to access the router normally, rarely use IE. I think I saw some script examples that spawned an IE window, but I didn't think it could apply to my case. On my old router (TP-Link), the script used XML instead of just HTTP and it worked silently sending a GET request + username and password, so I was expecting my attempts to result in something similar.
Scriptonize Posted March 19, 2015 Posted March 19, 2015 Can you show us the source of the router login page? If you learn from It, it's not a mistake
0x000000 Posted March 21, 2015 Author Posted March 21, 2015 Can you show us the source of the router login page? The default page that is viewed after login in? There's no actual login page, by typing the router's IP, a login popup appears (native to the browser, nothing to do with the router), after typing the credentials, this is the default page: https://www.dropbox.com/s/io6itzj4wkb5g5c/AirStationSettings.mht?dl=0 The address shown for this page is http://192.168.11.1/cgi-bin/cgi?req=twz This is the status page: https://www.dropbox.com/s/11p7b82uig6y3vw/AirStationStatus.mht?dl=0 The address shown for this page is http://192.168.11.1/cgi-bin/cgi?req=frm&frm=info.html "停止" is the Stop button. Sorry for the MHT format, saving as HTML, the pages don't seem to render correctly to me, css styles don't load or something, you can try vieweing it https://www.dropbox.com/s/57kxxsgjflrd22j/AirStationHTM.zip?dl=0
Kyan Posted March 21, 2015 Posted March 21, 2015 (edited) I have a TP-Link too (its full of security vulnerabilities, was been fixing some access permissions 1min ago xD) For this you would use _WinHTTP UDF, you need to include this header: authorization: Basic YWRtaW46cGFzc3dvcmQ= for authenticating (you don't need to login, once you use this header the router checks this out and lets you access rompager pages.... the usr and pass is in base64 of username:password (damn stupid, atleast they should had used some salted hash) This may help youexpandcollapse popup#include <WinHttp.au3> #cs Function: _Post() By: kyan #Includes: WinHttp.au3 $__url: http://domain.xx/ ... $__postdata: String to post (you need to check if it needs to be url encoded) $__data: 1=Retrive response data | 0=do not retrieve anything except the headers in the index [0] Return: [0] Response Headers [1] Response Data (optional) #ce Func _Post($__url, $__postdata, $__data = 1) Local $PostReturn[2] = ['', ''] Global $hOpen = _WinHttpOpen('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0') _WinHttpSetTimeouts($hOpen, 600, 1500, 1500, 1500) $aSplitAddr = _WinHttpCrackUrl($__url) If @error Then Return $PostReturn Global $hConnect = _WinHttpConnect($hOpen, $aSplitAddr[2], 80) ; Get connection handle Global $hRequest = _WinHttpOpenRequest($hConnect, _ "POST", _ $aSplitAddr[6], _ "HTTP/1.1", _ $__url, _ "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") Sleep(50) _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded") _WinHttpAddRequestHeaders($hRequest, "Host: "&$aSplitAddr[2]) _WinHttpAddRequestHeaders($hRequest, "Accept-Language: en-US,en;q=0.8,en-US;q=0.6,en;q=0.4") _WinHttpAddRequestHeaders($hRequest, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3") _WinHttpAddRequestHeaders($hRequest, "Connection: keep-alive") ;_WinHttpSetOption($hRequest,$WINHTTP_OPTION_DISABLE_FEATURE,$WINHTTP_DISABLE_REDIRECTS) ;_WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC, $sUserName, $sPassword) ;_WinHttpSetOption($hRequest, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_COOKIES) Sleep(50) _WinHttpSendRequest($hRequest, -1, $__postdata) _WinHttpReceiveResponse($hRequest) Local $sHeader If _WinHttpQueryDataAvailable($hRequest) Then $PostReturn[0] = _WinHttpQueryHeaders($hRequest) Sleep(50) ;cookies ;$cookieResp = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_SET_COOKIE) While 1 $chunky = _WinHttpReadData($hRequest) If @error Then ExitLoop $PostReturn[1] &= $chunky Sleep(20) WEnd Else $PostReturn[0] = '' $PostReturn[1] = '' EndIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $PostReturn EndFunc ;==>_PostEDIT: btw, what you're trying to accomplish you just need to restart or update wan settings, it will reconnect you again to the internet (takes about 5-10seconds) but only works if your ISP gives you a dynamic ip address.I'm using SNMP to retrieve connected devices, uptime, and external IP address, but so far no one helped on how do I get SNMP data in bulk :s '?do=embed' frameborder='0' data-embedContent>> Edited March 21, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
0x000000 Posted March 30, 2015 Author Posted March 30, 2015 Thanks for the reply, but still no change, I should make it clear that I have no experience with coding. Guess I'll just leave it as it is, may try to tackle it again later on.
ViciousXUSMC Posted March 30, 2015 Posted March 30, 2015 (edited) Cool Example Kyan I have no use for getting into my router now, but never know what kind of cool things I may use it for later. I think this thread has the baseline information that I may need to interface directly with my WeMo switches so that I can create a GUI to turn off/on lights in the house. Edited March 30, 2015 by ViciousXUSMC
Kyan Posted March 30, 2015 Posted March 30, 2015 @ViciousXUSMC, glad it helped somehow SNMP to quickly get router's information (connected ip's/mac's/external ip/connection status/etc) WEB config page to change router's setting Telnet to get router's information/change You just search for your device and you will find out what interfaces it has Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now