Sign in to follow this  
Followers 0
russell

Cant figuer this out in HTTP

1 post in this topic

ok old works new does't The old will return the vaule but Im not sure if its staying logged in. Becuase i can use the same user and pass in IE and no probs. The new i cant seem to find how to verify an output. CAn someone help me?

OLD

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://mysite.com/dir/wp-login.php" , False)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
$oHTTP.SetRequestHeader("Referrer", "http://www.google.com")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.SetRequestHeader("Connection", "keep-alive")
$oHTTP.Send("user=user" & "&pwd=password")
$oReceived = $oHTTP.ResponseText

While 1
If StringInStr($oReceived, "You have a Access Level of 0") Then 
$Level=0
EndIf

If StringInStr($oReceived, "You have a Access Level of 1") Then 
$Level=1
EndIf
If StringInStr($oReceived, "You have a Access Level of 2") Then 
$Level=2
EndIf
If StringInStr($oReceived, "You have a Access Level of 3") Then 
$Level=3
EndIf
If StringInStr($oReceived, "You have a Access Level of 4") Then 
$Level=4
EndIf

MsgBox (0, "Access Level", "Your access level is " & $Level,3)


Sleep (5000)
WEnd

NEW

#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 = "mywebsiteip"
; 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
        "dir/wp-login.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, "user", "pass")

; Send request
;_WinHttpSendRequest($hRequest)
; Wait for the response
_WinHttpReceiveResponse($hRequest)

MsgBox (0, "TITLE", $hRequest)

; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

muppet hands are so soft :)

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