msgbox

Check message

Jul 24th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2. #NoTrayIcon
  3. #Persistent
  4. SetBatchLines -1
  5. Menu, Tray, NoStandard
  6. Menu, Tray, Add, Exit?, GuiClose
  7.  
  8.     Pass := "mypassw0rd" ; Password
  9.     Login := "[email protected]" ; Login
  10.     NeedleText := "this is a test message" ; Text
  11.  
  12.     httpQueryOps:="storeHeader"
  13.     httpAgent :="Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.8.131 Version/11.10"
  14.     httpQueryDwFlags:=
  15.     (Join LTrim
  16.     INTERNET_FLAG_NO_COOKIES:=0x00080000|
  17.     INTERNET_FLAG_NO_AUTO_REDIRECT:=0x00200000
  18.     )
  19.     URL:="http://login.vk.com/?act=login&email=" Login "&pass=" Pass ""
  20.     length:=httpQuery(data:="",URL)
  21.     varSetCapacity(data,-1)
  22.     RegExMatch(HttpQueryHeader,"hash=(.*?)&",hash)
  23.     URL:="http://vk.com/login.php?act=slogin&fast=1&hash=" hash1 "&redirect=1&s=1"
  24.     httpQuery(data:="",URL)
  25.     varSetCapacity(data,-1)
  26.     if HttpQueryHeader contains deleted
  27.     {
  28.     MsgBox, 64, %a_space%, Auth failed!
  29.     ExitApp
  30.     }else{
  31.     SID := RegexReplace(HttpQueryHeader, ".*remixsid=(.*?); .*", "$1")
  32.     Cookie:= "Cookie: remixsid=" SID ";"
  33.     httpQueryDwFlags:=(INTERNET_FLAG_NO_COOKIES:=0x00080000)
  34.     }
  35.     SetTimer, check_wall, 15000
  36.     return
  37.  
  38. check_wall:
  39.     httpQuery(data:="", "http://vk.com/wall.php", POSTdata, HEADERS:=Cookie)
  40.     VarsetCapacity(data, -1)
  41.     Loop
  42.     {
  43.     Msg := RegexReplace(data, ".*<div class=""wall_post_text"">(.*?)</div></div>.*", "$1")
  44.     if (Msg==NeedleText){
  45.       msgbox, 64, %Msg%, Yes!
  46.       Exitapp
  47.       }
  48.     StringReplace, data, data, <div class=`"wall_post_text`">%Msg%</div></div>,, All
  49.     if data not contains <div class=`"wall_post_text`">
  50.     break
  51.     }
  52. return
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. GuiClose:
  92. ExitApp
  93.  
  94. UtfDecode( str )  {
  95.   RawLen := StrLen(str)
  96.   Charset := 0
  97.   BufSize := (RawLen + 1) * 2
  98.   VarSetCapacity(Buf, BufSize, 0)
  99.   DllCall("MultiByteToWideChar", "uint", 65001, "int", 0, "str", str
  100.   , "int", -1, "uint", &Buf, "uint", RawLen + 1)
  101.   DllCall("WideCharToMultiByte", "uint", Charset, "int", 0, "uint", &Buf, "int", -1
  102.   , "str", str, "uint", RawLen + 1
  103.   , "int", 0, "int", 0)
  104. Return str
  105. }
  106.  
  107. MimeType(ByRef Binary) {
  108. MimeTypes:="424d image/bmp|4749463 image/gif|ffd8ffe image/jpg|89504e4 image/png|4657530"
  109.    . " application/x-shockwave-flash|49492a0 image/tiff"
  110.    @:="0123456789abcdef"
  111.    Loop,8
  112.    hex .= substr(@,(*(a:=&Binary-1+a_index)>>4)+1,1) substr(@,((*a)&15)+1,1)
  113.    Loop,Parse,MimeTypes,|
  114.    if ((substr(hex,1,strlen(n:=RegExReplace(A_Loopfield,"\s.*"))))=n)
  115.    Mime := RegExReplace(A_LoopField,".*?\s")
  116. Return (Mime!="") ? Mime : "application/octet-stream"
  117. }
  118.    
  119.  
  120. URLEncode( p_data,p_reserved=true,p_encode=true)  {
  121.    old_FormatInteger := A_FormatInteger
  122.    SetFormat, Integer, hex
  123.     unsafe := "25000102030405060708090A0B0C0D0E"
  124.     . "0F101112131415161718191A1B1C1D1E1F20222"
  125.     . "33C3E5B5C5D5E607B7C7D7F808182838485868"
  126.     . "788898A8B8C8D8E8F909192939495969798999A"
  127.     . "9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABAC"
  128.     . "ADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDB"
  129.     . "EBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCEC"
  130.     . "FD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF7"
  131.     . "EE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0"
  132.     . "F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"
  133.    if (p_reserved)
  134.       unsafe = %unsafe%24262B2C2F3A3B3D3F40
  135.    if ( p_encode )
  136.     loop, % StrLen(unsafe)//2
  137.     {
  138.     StringMid, token, unsafe, A_Index*2-1, 2
  139.     StringReplace, p_data, p_data, % Chr( "0x" token ), `%%token%, all
  140.     }else
  141.     loop, % StrLen(unsafe)//2
  142.     {
  143.     StringMid, token, unsafe, A_Index*2-1, 2
  144.     StringReplace, p_data, p_data, `%%token%, % Chr("0x"token), all
  145.     }
  146.    SetFormat, Integer, %old_FormatInteger%
  147. return, p_data
  148. }
  149.  
  150.  
  151.  
  152. URLDecode( p_data )  {
  153. return, URLEncode( p_data, true, false )
  154. }
  155.  
  156. httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")  {
  157.    global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
  158.        , httpQueryDwFlags
  159.    defaultOps =
  160.    (LTrim Join|
  161.       httpAgent=script|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
  162.       SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
  163.       SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
  164.       INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
  165.    )
  166.    Loop,Parse,defaultOps,|
  167.    {
  168.       RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
  169.       if StrLen(%httpOption%)=0
  170.          %httpOption% := httpDefault
  171.    }
  172.  
  173.    hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")
  174.  
  175.    offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
  176.                   . "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
  177.    VarSetCapacity(URL_COMPONENTS,60,0)
  178.    NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)
  179.    
  180.    Loop,Parse,offset_name_length,|
  181.    {
  182.       RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
  183.       VarSetCapacity(%iCU_Name%,iCU_Size,0)
  184.       NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
  185.       NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
  186.    }
  187.  
  188.    DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)
  189.  
  190.    Loop,Parse,offset_name_length,|
  191.    {
  192.       RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
  193.       VarSetCapacity(%iCU_Name%,-1)
  194.    }
  195.    nPort:=NumGet(URL_COMPONENTS,24,"uInt")
  196.    
  197.    dwFlags := httpQueryDwFlags
  198.    if (lpszScheme = "https")
  199.       dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
  200.                |SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)
  201.  
  202.    if (lpszScheme="unknown") {
  203.       Result := "ERR: No Valid URL supplied."
  204.       Return StrLen(Result)
  205.    }
  206.  
  207.    hInternet := DllCall("WinINet\InternetOpenA"
  208.                   ,"Str",httpAgent,"UInt"
  209.                   ,(httpProxy != 0 ?  INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
  210.                   ,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)
  211.  
  212.    hConnect := DllCall("WinINet\InternetConnectA"
  213.                   ,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
  214.                   ,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
  215.                   ,"uInt",0,"uInt*",0)
  216.  
  217.    if (Strlen(POSTDATA)>0) {
  218.       HTTPVerb:="POST"
  219.       if StrLen(Headers)=0
  220.          Headers:="Content-Type: application/x-www-form-urlencoded"
  221.    } else
  222.       HTTPVerb:="GET"    
  223.  
  224.    hRequest := DllCall("WinINet\HttpOpenRequestA"
  225.                   ,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
  226.                   ,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
  227.                   ,"uInt",dwFlags,"uInt",Context:=0 )
  228.  
  229.    sRequest := DllCall("WinINet\HttpSendRequestA"
  230.                   , "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers)
  231.                   , "Str",POSTData,"uInt",Strlen(POSTData))
  232.  
  233.    VarSetCapacity(header, 2048, 0)
  234.    VarSetCapacity(header_len, 4, 0)
  235.    
  236.    Loop, 5
  237.      if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
  238.       ,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
  239.       break
  240.  
  241.    If (headerRequest=1) {
  242.       VarSetCapacity(res,headerLength:=NumGet(header_len),32)
  243.       DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
  244.       Loop,% headerLength
  245.          if (*(&res-1+a_index)=0)
  246.             NumPut(Asc("`n"),res,a_index-1,"uChar")
  247.       VarSetCapacity(res,-1)
  248.    } else
  249.       res := "timeout"
  250.  
  251.    Loop,Parse,res,`n,`r
  252.    {
  253.       RetValue := A_LoopField
  254.       break
  255.    }
  256.    
  257.    If (RetValue="timeout") {
  258.       html := "Error: timeout"
  259.       return -1
  260.    }
  261.    RetValue := RegExReplace(RetValue,"HTTP/1\.[01]\s+")
  262.    
  263.    RetValue := SubStr(RetValue,1,3)
  264.    
  265.    if strlen(HTTPQueryOps)>0 {
  266.       if (instr(HTTPQueryOps,"showHeader"))
  267.          MsgBox % res
  268.       if (instr(HTTPQueryOps,"storeHeader"))
  269.          global HttpQueryHeader := res
  270.       if (instr(HTTPQueryOps,"updateSize")) {
  271.          Loop,Parse,res,`n
  272.             If RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
  273.                global HttpQueryFullSize := fullSize
  274.                break
  275.             }
  276.          if (fullSize+0=0)
  277.             HttpQueryFullSize := "size unavailable"
  278.       }
  279.    }
  280.  
  281.    if !(InStr("100 200 201 202 302",RetValue)) {
  282.       Result := RetValue " " RetMsg
  283.       return StrLen(Result)
  284.    }
  285.  
  286.    VarSetCapacity(BytesRead,4,0)
  287.    fsize := 0
  288.    Loop            
  289.    {  bc := A_Index
  290.       VarSetCapacity(buffer%bc%,1024,0)
  291.       ReadFile := DllCall("wininet\InternetReadFile"
  292.                   ,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
  293.       ReadBytes := NumGet(BytesRead)  
  294.       If ((ReadFile!=0)&&(!ReadBytes))  
  295.          break                      
  296.       Else {
  297.          fsize += ReadBytes  
  298.          sizeArray .= ReadBytes "|"
  299.       }
  300.       if (instr(HTTPQueryOps,"updateSize"))
  301.          Global HttpQueryCurrentSize := fsize
  302.    }
  303.    sizeArray := SubStr(sizeArray,1,-1)  
  304.    
  305.    VarSetCapacity(result,fSize+1,0)      
  306.    Dest := &result            
  307.    Loop,Parse,SizeArray,|
  308.       DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
  309.       , Dest += A_LoopField
  310.      
  311.    DllCall("WinINet\InternetCloseHandle", "uInt", hRequest)  
  312.    DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
  313.    DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
  314.    DllCall("FreeLibrary", "UInt", hModule)              
  315.    return fSize
  316. }
Advertisement
Add Comment
Please, Sign In to add comment