Help with winhttp

09/21/2011 19:47 montuy#1
Hi there,
I'm trying to learn winhttp functions from winhttp udf.

I would like to automate facebook forms with it. but i don't know how to get fb forms info for headers and etc. does anyone here knows a good documentation or even better a working example code for fb?

-Note: i've tried wireshark but it doesnt support my network interface.
09/21/2011 19:52 BlackHybrid#2
Try the AddOn LiveHTTP headers for Firefox.
09/21/2011 20:30 montuy#3
Quote:
Originally Posted by BlackHybrid View Post
Try the AddOn LiveHTTP headers for Firefox.
Hi, thank you for your help. I'm testing it right now.

Do you or anyone has live example code for, lets say update a post on fb profile with winhttp? it would be amazing to take a peek at it :)
09/21/2011 20:38 BlackHybrid#4
I can suggest you to do it with TCP.
My first steps with winhttp failed and i dont know how.
With the same packet and TCP it worked.
You can read the TuT from Shadow992
[Only registered and activated users can see links. Click Here To Register...]
09/21/2011 21:22 montuy#5
only if i knew german :)
but thanks anyways. i didn't know it could be done by tcp. and it IS seems like a little easier.
Sorry to bother you any good tuts in english like this?
if not i will check google anyways.

thx a lot.
09/21/2011 21:54 BlackHybrid#6
I think if you watch at these funktions and know a bit how it woks with packets you schould understand it.

You just try to rebuild the packet. If you got a GET packet set the parameter $sPost to a empty string. You also need to get the cookies. When you send the first GET packet you should get the cookies. They are in the source, the return of TCPRequest. You get the cookies by using the GetCookies funktion. From now you need to set the cookies in TCPRequest.

Just try it a bit and show the return in a MsgBox to see if you created a packet succesfull.

PHP Code:
#include<String.au3>

Func GetCookies($sQuellcode)
    
Local $sCookies$i$aCookies
    $sCookies 
''
    
$aCookies _StringBetween($sQuellcode'Set-Cookie: '';'1)
    For 
$i 0 To UBound($aCookies) - 1
        $sCookies 
&= $aCookies[$i] & ';'
    
Next
    
Return $sCookies
EndFunc   
;==>GetCookies

Func TCPRequest
($sIp$sHost,$msg=0$sSeite ""$sPost ''$sCookies ''$sReferer ''$iMaxTime 10000)
    
Local $sPacket$iSocket$iTimer

    
If $sPost '' Then
        $sPacket 
'GET /' $sSeite ' HTTP/1.1' & @CRLF
    
Else
        
$sPacket 'POST /' $sSeite ' HTTP/1.1' & @CRLF
    
EndIf
    
$sPacket &= 'Host: ' $sHost & @CRLF _
            
'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)' & @CRLF _
            
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' & @CRLF _
            
'Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3' & @CRLF _
            
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' & @CRLF _
            
'Keep-Alive: 300' & @CRLF _
            
'Content-Type: application/x-www-form-urlencoded' & @CRLF _
            
'Connection: keep-alive' & @CRLF
    
If $sReferer <> '' Then
        $sPacket 
&= 'Referer: ' $sReferer & @CRLF
    
EndIf
    If 
$sCookies <> '' Then
        $sCookies
=StringStripCR($sCookies)
        
$sCookies=StringStripWS($sCookies,8)
        
$sPacket &= 'Cookie: ' $sCookies & @CRLF
    
EndIf
    If 
$sPost <> '' Then
        $sPacket 
&= 'Content-Length: ' StringLen($sPost) & @CRLF
    
EndIf
    
$sPacket &= @CRLF
    
If $sPost <> '' Then
        $sPacket 
&= $sPost
    
EndIf
    If 
$msg=1 Then
    MsgBox
(0,"Packet",$sPacket)
    EndIf
    
TCPStartup()
    If @
error Then Return SetError(10"")
    
$iSocket TCPConnect($sIp80)
    If @
error Then Return SetError(20"")
    
TCPSend($iSocket$sPacket)
    If @
error Then Return SetError(30"")
    
$iTimer TimerInit()
    Do
        
$sRecv TCPRecv($iSocket1024)
        If 
TimerDiff($iTimer) > $iMaxTime Then Return SetError(40"")
    
Until $sRecv <> ""
    
Do
        
$sRecv &= TCPRecv($iSocket1024)
    
Until @error Or StringInStr($sRecv'</html>')
    
TCPCloseSocket($iSocket)
    
TCPShutdown()
    Return 
$sRecv
EndFunc   
;==>TCPRequest

Func Change
($string)
    
$string StringReplace($string"%""%25")
        
$string StringReplace($string"†""%E2%80%A0")
    
$string StringReplace($string"ä""%C3%A4")
    
$string StringReplace($string"ö""%C3%B6")
    
$string StringReplace($string"ü""%C3%BC")
    
$string StringReplace($string"!""%21")
    
$string StringReplace($string'"'"%22")
    
$string StringReplace($string"§""%C2%A7")
    
$string StringReplace($string"$""%24")
    
$string StringReplace($string"&""%26")
    
$string StringReplace($string"/""%2F")
    
$string StringReplace($string"+""%2B")
    
$string StringReplace($string" ""+")
    
$string StringReplace($string"(""%28")
    
$string StringReplace($string")""%29")
    
$string StringReplace($string"=""%3D")
    
$string StringReplace($string"?""%3F")
    
$string StringReplace($string"[""%5B")
    
$string StringReplace($string"]""%5D")
    
$string StringReplace($string"{""%7B")
    
$string StringReplace($string"}""%7D")
    
$string StringReplace($string"ß""%C3%9F")
    
$string StringReplace($string",""%2C")
    
$string StringReplace($string":""%3A")
    
$string StringReplace($string";""%3B")
    
$string StringReplace($string"#""%23")
    
$string StringReplace($string"~""%7E")
    
$string StringReplace($string"²""%C2%B2")
    
$string StringReplace($string"³""%C2%B3")
    
$string StringReplace($string"<""%3C")
    
$string StringReplace($string">""%3E")
    
$string StringReplace($string"|""%7C")
    
$string StringReplace($string"^""%5E")
    
$string StringReplace($string"°""%C2%B0")
    
$string StringReplace($string"´""%C2%B4")
    
$string StringReplace($string"@""%40")
    
$string StringReplace($string"€""%E2%82%AC")
    Return 
$string
EndFunc   
;==>Change