msgbox

о_О

Jul 3rd, 2011
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Login:=""
  2.     Pass:=""
  3. httpQueryOps:="storeHeader"
  4. httpAgent := "Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.8.131 Version/11.10"
  5. httpQueryDwFlags:=(INTERNET_FLAG_NO_COOKIES:=0x00080000|INTERNET_FLAG_NO_AUTO_REDIRECT:=0x00200000)
  6.     URL:="http://login.vk.com/?act=login&email=" Login "&pass=" Pass ""
  7.     length:=httpQuery(data:="",URL)
  8.     varSetCapacity(data,-1)
  9.     RegExMatch(HttpQueryHeader,"hash=(.*?)&",hash)
  10.     URL:="http://vk.com/login.php?act=slogin&fast=1&hash=" hash1 "&redirect=1&s=1"
  11.     httpQuery(data:="",URL)
  12.     varSetCapacity(data,-1)
  13.     If StrLen(RegExMatch(HttpQueryHeader,"remixsid=(.*?);",SID))=60
  14.     {
  15.     Lenght := StrLen(SID1)
  16.     MsgBox, 16, Error - SID Lenght (%Lenght%), SID: %SID1%
  17.     ExitApp
  18.     }else{
  19.     HEADERS:= "Cookie: remixsid=" SID1 ";"
  20.     MsgBox, %HEADERS%
  21.     }
  22.     ExitApp
  23.  
  24.  
  25.  
  26. URLEncode( p_data,p_reserved=true,p_encode=true)  {
  27.    old_FormatInteger := A_FormatInteger
  28.    SetFormat, Integer, hex
  29.     unsafe := "25000102030405060708090A0B0C0D0E"
  30.     . "0F101112131415161718191A1B1C1D1E1F20222"
  31.     . "33C3E5B5C5D5E607B7C7D7F808182838485868"
  32.     . "788898A8B8C8D8E8F909192939495969798999A"
  33.     . "9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABAC"
  34.     . "ADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDB"
  35.     . "EBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCEC"
  36.     . "FD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF7"
  37.     . "EE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0"
  38.     . "F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"
  39.    if (p_reserved)
  40.       unsafe = %unsafe%24262B2C2F3A3B3D3F40
  41.    if ( p_encode )
  42.     loop, % StrLen(unsafe)//2
  43.     {
  44.     StringMid, token, unsafe, A_Index*2-1, 2
  45.     StringReplace, p_data, p_data, % Chr( "0x" token ), `%%token%, all
  46.     }else
  47.     loop, % StrLen(unsafe)//2
  48.     {
  49.     StringMid, token, unsafe, A_Index*2-1, 2
  50.     StringReplace, p_data, p_data, `%%token%, % Chr("0x"token), all
  51.     }
  52.    SetFormat, Integer, %old_FormatInteger%
  53. return, p_data
  54. }
  55.  
  56.  
  57.  
  58. URLDecode( p_data )  {
  59. return, URLEncode( p_data, true, false )
  60. }
  61.  
  62. httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")  {
  63.    global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
  64.        , httpQueryDwFlags
  65.    defaultOps =
  66.    (LTrim Join|
  67.       httpAgent=script|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
  68.       SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
  69.       SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
  70.       INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
  71.    )
  72.    Loop,Parse,defaultOps,|
  73.    {
  74.       RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
  75.       if StrLen(%httpOption%)=0
  76.          %httpOption% := httpDefault
  77.    }
  78.  
  79.    hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")
  80.  
  81.    offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
  82.                   . "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
  83.    VarSetCapacity(URL_COMPONENTS,60,0)
  84.    NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)
  85.    
  86.    Loop,Parse,offset_name_length,|
  87.    {
  88.       RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
  89.       VarSetCapacity(%iCU_Name%,iCU_Size,0)
  90.       NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
  91.       NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
  92.    }
  93.  
  94.    DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)
  95.  
  96.    Loop,Parse,offset_name_length,|
  97.    {
  98.       RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
  99.       VarSetCapacity(%iCU_Name%,-1)
  100.    }
  101.    nPort:=NumGet(URL_COMPONENTS,24,"uInt")
  102.    
  103.    dwFlags := httpQueryDwFlags
  104.    if (lpszScheme = "https")
  105.       dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
  106.                |SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)
  107.  
  108.    if (lpszScheme="unknown") {
  109.       Result := "ERR: No Valid URL supplied."
  110.       Return StrLen(Result)
  111.    }
  112.  
  113.    hInternet := DllCall("WinINet\InternetOpenA"
  114.                   ,"Str",httpAgent,"UInt"
  115.                   ,(httpProxy != 0 ?  INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
  116.                   ,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)
  117.  
  118.    hConnect := DllCall("WinINet\InternetConnectA"
  119.                   ,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
  120.                   ,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
  121.                   ,"uInt",0,"uInt*",0)
  122.  
  123.    if (Strlen(POSTDATA)>0) {
  124.       HTTPVerb:="POST"
  125.       if StrLen(Headers)=0
  126.          Headers:="Content-Type: application/x-www-form-urlencoded"
  127.    } else
  128.       HTTPVerb:="GET"    
  129.  
  130.    hRequest := DllCall("WinINet\HttpOpenRequestA"
  131.                   ,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
  132.                   ,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
  133.                   ,"uInt",dwFlags,"uInt",Context:=0 )
  134.  
  135.    sRequest := DllCall("WinINet\HttpSendRequestA"
  136.                   , "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers)
  137.                   , "Str",POSTData,"uInt",Strlen(POSTData))
  138.  
  139.    VarSetCapacity(header, 2048, 0)
  140.    VarSetCapacity(header_len, 4, 0)
  141.    
  142.    Loop, 5
  143.      if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
  144.       ,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
  145.       break
  146.  
  147.    If (headerRequest=1) {
  148.       VarSetCapacity(res,headerLength:=NumGet(header_len),32)
  149.       DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
  150.       Loop,% headerLength
  151.          if (*(&res-1+a_index)=0)
  152.             NumPut(Asc("`n"),res,a_index-1,"uChar")
  153.       VarSetCapacity(res,-1)
  154.    } else
  155.       res := "timeout"
  156.  
  157.    Loop,Parse,res,`n,`r
  158.    {
  159.       RetValue := A_LoopField
  160.       break
  161.    }
  162.    
  163.    If (RetValue="timeout") {
  164.       html := "Error: timeout"
  165.       return -1
  166.    }
  167.    RetValue := RegExReplace(RetValue,"HTTP/1\.[01]\s+")
  168.    
  169.    RetValue := SubStr(RetValue,1,3)
  170.    
  171.    if strlen(HTTPQueryOps)>0 {
  172.       if (instr(HTTPQueryOps,"showHeader"))
  173.          MsgBox % res
  174.       if (instr(HTTPQueryOps,"storeHeader"))
  175.          global HttpQueryHeader := res
  176.       if (instr(HTTPQueryOps,"updateSize")) {
  177.          Loop,Parse,res,`n
  178.             If RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
  179.                global HttpQueryFullSize := fullSize
  180.                break
  181.             }
  182.          if (fullSize+0=0)
  183.             HttpQueryFullSize := "size unavailable"
  184.       }
  185.    }
  186.  
  187.    if !(InStr("100 200 201 202 302",RetValue)) {
  188.       Result := RetValue " " RetMsg
  189.       return StrLen(Result)
  190.    }
  191.  
  192.    VarSetCapacity(BytesRead,4,0)
  193.    fsize := 0
  194.    Loop            
  195.    {  bc := A_Index
  196.       VarSetCapacity(buffer%bc%,1024,0)
  197.       ReadFile := DllCall("wininet\InternetReadFile"
  198.                   ,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
  199.       ReadBytes := NumGet(BytesRead)  
  200.       If ((ReadFile!=0)&&(!ReadBytes))  
  201.          break                      
  202.       Else {
  203.          fsize += ReadBytes  
  204.          sizeArray .= ReadBytes "|"
  205.       }
  206.       if (instr(HTTPQueryOps,"updateSize"))
  207.          Global HttpQueryCurrentSize := fsize
  208.    }
  209.    sizeArray := SubStr(sizeArray,1,-1)  
  210.    
  211.    VarSetCapacity(result,fSize+1,0)      
  212.    Dest := &result            
  213.    Loop,Parse,SizeArray,|
  214.       DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
  215.       , Dest += A_LoopField
  216.      
  217.    DllCall("WinINet\InternetCloseHandle", "uInt", hRequest)  
  218.    DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
  219.    DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
  220.    DllCall("FreeLibrary", "UInt", hModule)              
  221.    return fSize
  222. }
Advertisement
Add Comment
Please, Sign In to add comment