WinHTTP Problem

09/13/2013 08:20 smirk#1
Hi,

also ich spiele derzeit mit WinHttp rum undzwar möchte ich mir per WinHTTP Accounts erstellen, diese arbeiten mit einem Captcha (fülle ich selber aus).
Dieser ändert sich bei jedem Reload

Nun rufe ich die Seite auf, ziehe mir den Quellcode und lade dann das Bild herunter.
Nun Submit ich meine Informationen + Captcha text, jedoch wird hierbei die Seite neu geladen und ich müsste einen anderen Captcha angeben, hat jemand eine Idee wie ich das umgehen kann? Habe ich etwas falsch verstanden?
09/13/2013 14:14 Brendan Jordan#2
Warum lädst du denn die Seite neue, wenn du das Captcha geholt hast?
09/13/2013 14:19 smirk#3
Er läd beim abschicken die Seite neu, code folgt gleich

Code:
region WINHTTP Auslesen
$hSession = _WinhttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0")
$hConnect = _WinhttpConnect($hSession, "xxx-shop.com")

$sHtml = _WinhttpSimpleRequest($hConnect, "GET", "/create_account.php")

FileWrite($temppath&"Test.htm", $sHtml)
FileClose($temppath&"Test.htm")
#endregion WINHTTP Auslesen

#region LINK AUSLESEN
FileWriteLine($temppath&"HTML.txt", $sHtml)
$file = FileOpen($temppath&"HTML.txt")
		While 1
			$line = FileReadLine($file)
			If @error = -1 Then ExitLoop
			$result = StringInStr($line, 'name="Captcha"')
			If $result >0 Then
					$picresult = _StringBetween ($line,"validation_png.php?",'" alt="')
					FileWriteLine ($temppath&"pic.txt",$picresult[0])
					FileWriteLine ($path&"pic.txt",$picresult[0])
					FileClose($temppath&"pic.txt")
				EndIf
		Wend
$caplink = "https://xxx-shop.com/validation_png.php?"&$picresult[0]
#endregion LINK AUSLESEN


#region GUI
InetGet( $caplink, $temppath&$counter&".png",1,0) ;Hinzugefügt
$uebergabe = "["&$counter&"]["&$temppath&"]["&$path&"]"
ShellExecuteWait($path&"convert.exe",$uebergabe)

GUICreate("PressCopyNator",300,220,500,260)
$guicaptcha = GUICtrlCreatePic ($temppath&$counter&".jpg",10,10,230,50)
GUISetState (@SW_SHOW)

$button1 = GUICtrlCreateButton("Refresh",245,10,50,50)
$button2 = GUICtrlCreateButton("Start",245,70,50,40)

$IPCaptcha = GUICtrlCreateInput ("",10,70,230,40)
GUICtrlSetFont($IPCaptcha, 20)
#endregion GUI

while 1
	$guiaction = GUIGetMsg()

	Select
		;EXIT
		Case $guiaction = -3
			Run($path&"delete.dll")
			Exit

		;REFRESH BUTTON
		Case $guiaction = $button1
			InetGet ( $caplink, $temppath&$counter&".png",1,0)
			$uebergabe = "["&$counter&"]["&$temppath&"]["&$path&"]"
			ShellExecuteWait($path&"convert.exe",$uebergabe)
			GUICtrlSetImage (3,$temppath&$counter&".jpg")

		;ABSCHICKEN BUTTON
		Case $guiaction = $button2

			$GuiReadIPCaptcha = GUICtrlRead($IPCaptcha)

			$Finalstring =  StringReplace($GuiReadIPCaptcha, "!","%21")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, '"',"%22")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "§","%23")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "$","%24")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "%","%25")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "&","%26")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "/","%27")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "(","%28")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, ")","%21")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "=","%3D")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "?","%3F")
			$Finalstring =  StringReplace($GuiReadIPCaptcha, "+","%2B")
;~ 			MsgBox(0,"",$Finalstring)
			$antirobotreg = $Finalstring
			$createdata = "action=process&gender="&$gender&"&firstname="&$firstname&"&lastname="&$lastname&"&email_address="&$email_address&"&street_address="&$street_address&"&suburb=&postcode="&$postcode&"&city="&$city&"&country="&$country&"&password="&$password&"&confirmation="&$password&"&antirobotreg="&$antirobotreg&"&x="&$x&"&y="&$y

			$sHTML = _WinhttpSimpleRequest($hConnect, "POST", "create_account_success.php", "www.xxxx-shop.com/create_account.php", $createdata)
			FileWrite("test2.html", $sHtml)
09/13/2013 14:32 c0w#4
Hab nur kurz rein geschaut, holst du captcha mit integet und Rest per winhttp? Falls ja liegt da schon ein Fehler captcha muss per winhttp Binary gesaugt werden da du sonst das captcha einer anderen Session kriegst
09/13/2013 14:37 smirk#5
ah ok danke :) werd es dann mal so testen - doof gefragt wie lad ich was per Binary
09/13/2013 15:39 c0w#6
so wie im skype beprochen post ich nochmal hier, damit auch andere ne lösung finden:

der winhttpteil sieht wie folgt aus wenn man captchas macht

Code:
$hagent = _winhttpopen("euer useragent")
$hconnect = _winhttpconnect($hagent, "server auf dem die regpage liegt")
$html = winhttpsimplerequest($hconnect, "GET", "regpage")
$captcha_url = StringRegExp($html, 'pattern zb:"img src="validation_png.php?(.+)" alt="" name="Captcha"',3)
$captcha_binary = _winhttpsimplerequest($hconnect, "GET", validation_png.php?$captcha_url[0],"","","",false,2); lädt das bild binär herunter
$captcha_datei = FileOpen("captcha.jpg",18); parameter 18 = 16(überschreiben) + 2(write binary)
FileWrite($captcha_datei, $captcha_binary)
FileClose($captcha_datei)
;diese datei danch in die gui laden per createpic, bei png  _gdiplus verwenden
is keine c&p lösung, vor allem weil syntaxfehler drin sind :D aber wer sich ein wenig mit regexp und winhttp auskennt sollte sich hier zurecht finden
09/13/2013 15:41 smirk#7
Auch hier noch einmal ein Danke!