Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- #SingleInstance force
- ;httpProxy := "157.85.34.94:8080"
- user := ""
- pass := ""
- httpQueryOps:="storeHeader"
- httpAgent := "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7"
- httpQueryDwFlags:=(INTERNET_FLAG_NO_COOKIES:=0x00080000|INTERNET_FLAG_NO_AUTO_REDIRECT:=0x00200000|INTERNET_FLAG_SECURE=0x00800000)
- httpQuery(data:="", "http://m.facebook.com")
- varSetCapacity(data, -1)
- form := regexreplace(data, ".*post_form_id"" value=""(.*?)"".*", "$1")
- time := regexreplace(data, ".*m_ts"" value=""(.*?)"".*", "$1")
- some := regexreplace(data, ".*li"" value=""(.*?)"".*", "$1")
- char := regexreplace(data, ".*charset_test"" value=""(.*?)"".*", "$1")
- link := "https://m.facebook.com/login.php?refid=8"
- httpQueryDwFlags:=(INTERNET_FLAG_SECURE=0x00800000)
- post := "post_form_id=" form "&email=" user "&pass=" pass "&m_ts=" time "&li=" some "&charset_test=" char "&login=Войти&version=1&ajax=1&width=1280&pxr=1&gps=1"
- httpQuery(data:="", lpszUrl:=link, POSTDATA:=post)
- varSetCapacity(data, -1)
- data := UTF82Ansi(data)
- user := regexreplace(data, ".*logout"">(.*?)</a> \((.*?)\)</span>.*", "$2")
- if (user)
- {
- msgbox, 64, Success!, Authorized as %user%!
- }
- else
- {
- msgbox, 64, Fail!, Not autorized, try again!
- }
- ExitApp
- EncodeURL( p_data, p_reserved=true, p_encode=true )
- {
- old_FormatInteger := A_FormatInteger
- SetFormat, Integer, hex
- unsafe =
- ( Join LTrim
- 25000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20
- 22233C3E5B5C5D5E607B7C7D7F808182838485868788898A8B8C8D8E8F9091929394
- 95969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6
- B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8
- D9DADBDCDDDEDF7EE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9
- FAFBFCFDFEFF
- )
- if ( p_reserved )
- unsafe = %unsafe%24262B2C2F3A3B3D3F40
- if ( p_encode )
- loop, % StrLen( unsafe )//2
- {
- StringMid, token, unsafe, A_Index*2-1, 2
- StringReplace, p_data, p_data, % Chr( "0x" token ), `%%token%, all
- }
- else
- loop, % StrLen( unsafe )//2
- {
- StringMid, token, unsafe, A_Index*2-1, 2
- StringReplace, p_data, p_data, `%%token%, % Chr( "0x" token ), all
- }
- SetFormat, Integer, %old_FormatInteger%
- return, p_data
- }
- DecodeURL( p_data )
- {
- return, EncodeURL( p_data, true, false )
- }
- Ansi2Oem(sString)
- {
- Ansi2Unicode(sString, wString, 0)
- Unicode2Ansi(wString, zString, 1)
- Return zString
- }
- Oem2Ansi(zString)
- {
- Ansi2Unicode(zString, wString, 1)
- Unicode2Ansi(wString, sString, 0)
- Return sString
- }
- Ansi2UTF8(sString)
- {
- Ansi2Unicode(sString, wString, 0)
- Unicode2Ansi(wString, zString, 65001)
- Return zString
- }
- UTF82Ansi(zString)
- {
- Ansi2Unicode(zString, wString, 65001)
- Unicode2Ansi(wString, sString, 0)
- Return sString
- }
- Ansi2Unicode(ByRef sString, ByRef wString, CP = 0)
- {
- nSize := DllCall("MultiByteToWideChar"
- , "Uint", CP
- , "Uint", 0
- , "Uint", &sString
- , "int", -1
- , "Uint", 0
- , "int", 0)
- VarSetCapacity(wString, nSize * 2)
- DllCall("MultiByteToWideChar"
- , "Uint", CP
- , "Uint", 0
- , "Uint", &sString
- , "int", -1
- , "Uint", &wString
- , "int", nSize)
- }
- Unicode2Ansi(ByRef wString, ByRef sString, CP = 0)
- {
- nSize := DllCall("WideCharToMultiByte"
- , "Uint", CP
- , "Uint", 0
- , "Uint", &wString
- , "int", -1
- , "Uint", 0
- , "int", 0
- , "Uint", 0
- , "Uint", 0)
- VarSetCapacity(sString, nSize)
- DllCall("WideCharToMultiByte"
- , "Uint", CP
- , "Uint", 0
- , "Uint", &wString
- , "int", -1
- , "str", sString
- , "int", nSize
- , "Uint", 0
- , "Uint", 0)
- }
- httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")
- { global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
- , httpQueryDwFlags
- defaultOps =
- (LTrim Join|
- httpAgent=script|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
- SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
- SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
- INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
- )
- Loop,Parse,defaultOps,|
- {
- RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
- if StrLen(%httpOption%)=0
- %httpOption% := httpDefault
- }
- hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")
- offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
- . "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
- VarSetCapacity(URL_COMPONENTS,60,0)
- NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)
- Loop,Parse,offset_name_length,|
- {
- RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
- VarSetCapacity(%iCU_Name%,iCU_Size,0)
- NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
- NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
- }
- DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)
- Loop,Parse,offset_name_length,|
- {
- RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
- VarSetCapacity(%iCU_Name%,-1)
- }
- nPort:=NumGet(URL_COMPONENTS,24,"uInt")
- dwFlags := httpQueryDwFlags
- if (lpszScheme = "https")
- dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
- |SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)
- if (lpszScheme="unknown") {
- Result := "ERR: No Valid URL supplied."
- Return StrLen(Result)
- }
- hInternet := DllCall("WinINet\InternetOpenA"
- ,"Str",httpAgent,"UInt"
- ,(httpProxy != 0 ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
- ,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)
- hConnect := DllCall("WinINet\InternetConnectA"
- ,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
- ,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
- ,"uInt",0,"uInt*",0)
- if (Strlen(POSTDATA)>0) {
- HTTPVerb:="POST"
- if StrLen(Headers)=0
- Headers:="Content-Type: application/x-www-form-urlencoded"
- } else
- HTTPVerb:="GET"
- hRequest := DllCall("WinINet\HttpOpenRequestA"
- ,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
- ,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
- ,"uInt",dwFlags,"uInt",Context:=0 )
- sRequest := DllCall("WinINet\HttpSendRequestA"
- , "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers)
- , "Str",POSTData,"uInt",Strlen(POSTData))
- VarSetCapacity(header, 2048, 0) ; max 2K header data for httpResponseHeader
- VarSetCapacity(header_len, 4, 0)
- Loop, 5
- if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
- ,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
- break
- If (headerRequest=1) {
- VarSetCapacity(res,headerLength:=NumGet(header_len),32)
- DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
- Loop,% headerLength
- if (*(&res-1+a_index)=0) ; Change binary zero to linefeed
- NumPut(Asc("`n"),res,a_index-1,"uChar")
- VarSetCapacity(res,-1)
- } else
- res := "timeout"
- Loop,Parse,res,`n,`r
- {
- RetValue := A_LoopField
- break
- }
- If (RetValue="timeout") {
- html := "Error: timeout"
- return -1
- }
- RetValue := RegExReplace(RetValue,"HTTP/1\.[01]\s+")
- RetValue := SubStr(RetValue,1,3)
- if strlen(HTTPQueryOps)>0 {
- if (instr(HTTPQueryOps,"showHeader"))
- MsgBox % res
- if (instr(HTTPQueryOps,"storeHeader"))
- global HttpQueryHeader := res
- if (instr(HTTPQueryOps,"updateSize")) {
- Loop,Parse,res,`n
- If RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
- global HttpQueryFullSize := fullSize
- break
- }
- if (fullSize+0=0)
- HttpQueryFullSize := "size unavailable"
- }
- }
- if !(InStr("100 200 201 202 302 500 502",RetValue)) {
- Result := RetValue " " RetMsg
- return StrLen(Result)
- }
- VarSetCapacity(BytesRead,4,0)
- fsize := 0
- Loop
- { bc := A_Index
- VarSetCapacity(buffer%bc%,1024,0) ; setup new chunk for this receive round
- ReadFile := DllCall("wininet\InternetReadFile"
- ,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
- ReadBytes := NumGet(BytesRead)
- If ((ReadFile!=0)&&(!ReadBytes))
- break
- Else {
- fsize += ReadBytes
- sizeArray .= ReadBytes "|"
- }
- if (instr(HTTPQueryOps,"updateSize"))
- Global HttpQueryCurrentSize := fsize
- }
- sizeArray := SubStr(sizeArray,1,-1)
- VarSetCapacity(result,fSize+1,0)
- Dest := &result
- Loop,Parse,SizeArray,|
- DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
- , Dest += A_LoopField
- DllCall("WinINet\InternetCloseHandle", "uInt", hRequest)
- DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
- DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
- DllCall("FreeLibrary", "UInt", hModule)
- return fSize
- }
- Generate_POST_Body(fields, ByRef postbody, ByRef headers){
- ; generate boundary
- static chars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- boundary = --
- Loop, 8 {
- Random, RChar, 1, % StrLen(chars)
- boundary .= SubStr(chars, RChar, 1)
- }
- ; generate postbody
- #LTrim
- postbody =
- Loop, Parse, fields, `n, `r%A_Space%%A_Tab%
- {
- if RegExMatch(A_LoopField, "i)(?<name>.+?)=(?<isFile>@)?(?<val>.+)", field_)
- {
- postbody = %postbody%
- (Join`r`n
- --%boundary%
- Content-Disposition: form-data; name="%field_name%"
- )
- if field_isFile and FileExist(field_val)
- {
- FileRead, file, %field_val%
- fileType := MimeType(file)
- SplitPath, field_val, filename
- FileGetSize, fileSize, %field_val%
- VarSetCapacity(placeholder, fileSize, 32)
- postbody = %postbody%; filename="%filename%"
- (Join`r`n
- Content-Type: %fileType%
- )
- field_val := placeholder
- }
- postbody .= "`r`n`r`n" . field_val . "`r`n"
- }
- }
- postbody .= "--" boundary "--`r`n"
- #LTrim Off
- ; generate headers
- headers .= (StrLen(headers) ? "`r`n" : "")
- . "Content-type: multipart/form-data; boundary=" boundary "`r`n"
- . "Content-Length: " strlen(postbody)
- if field_isFile
- DllCall("RtlMoveMemory"
- , "uInt", (offset:=&postbody+strlen(postbody)-strlen(boundary)-fileSize-8)
- , "uInt", &file
- , "uInt", filesize)
- return boundary
- }
- MimeType(ByRef Binary) {
- MimeTypes:="424d image/bmp|4749463 image/gif|ffd8ffe image/jpeg|89504e4 image/png|4657530"
- . " application/x-shockwave-flash|49492a0 image/tiff"
- @:="0123456789abcdef"
- Loop,8
- hex .= substr(@,(*(a:=&Binary-1+a_index)>>4)+1,1) substr(@,((*a)&15)+1,1)
- Loop,Parse,MimeTypes,|
- if ((substr(hex,1,strlen(n:=RegExReplace(A_Loopfield,"\s.*"))))=n)
- Mime := RegExReplace(A_LoopField,".*?\s")
- Return (Mime!="") ? Mime : "application/octet-stream"
- }
Advertisement
Add Comment
Please, Sign In to add comment