Mithrandir Posted October 21, 2010 Posted October 21, 2010 I'm trying to improve a script made with IE.au3 to reconnect my router now using winhttp.au3. I saw the example of _WinHttpSetCredentials: expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; !!! The result of this script will be this sent to the server: #cs POST /admin.php HTTP/1.1 Connection: Keep-Alive Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8 User-Agent: AutoIt/3.3 Content-Length: 0 Host: 127.0.0.1 Authorization: Basic YWRtaW46YWRtaW4= #ce ; My server Global $sLocalIP = "127.0.0.1" ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, $sLocalIP) ; Specify the reguest Global $hRequest = _WinHttpOpenRequest($hConnect, _ "POST", _ ; verb "admin.php", _ ; object Default, _ ; version Default, _ ; referrer "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") ; accept types ; Set credentials _WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC, "admin", "admin") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ; .... The rest of the code here... ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) I tried the same code but using livehttpheaders to trace the login process I found that the type of authorization is not Authorization: Basic YWRtaW46YWRtaW4= as in the example. How can I input mine? I saw that it uses $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC and when I look at these constants in winhttpconstants.au3 I saw they seem to be memory adress or hexadecimal should I use binary to string or something like that or what do I have to input in $iAuthTargets and $iAuthScheme? I would appreciate some guidance in this The object of the request I think it is sys_status.htm and the method is GET (all info obtained using live http headers plugin for firefox) Needless to say I tried the code with my user and pass and $WINHTTP_AUTH_TARGET_SERVER and $WINHTTP_AUTH_SCHEME_BASIC as parameters in _WinHttpSetCredentials and it gave me this response: <HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD> <BODY BGCOLOR="#cc9999"><H4>401 Unauthorized</H4> Authorization required. </BODY></HTML> I am a bit reliant of posting my code because I'm not sure -and sorry if this is a newbie believing- but could someone login my router from internet knowing the IP (192.168 ... ) and my user and password? I have remote management disabled but I would like to be sure. IF not, I will reply from now on with what I have done but first I need to know what to input in the parameters of _WinHttpSetCredentials. Thanks for your help! Help with SOAP message!!
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