1 (изменено: Malcev, 2023-05-06 18:18:01)

Тема: AHK: авторизация в фейсбуке facebook

email := "blah-blah@gmail.com"
password := "pass"

HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", "https://facebook.com", true)
HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36")
HTTP.SetRequestHeader("Pragma", "no-cache")
HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
HTTP.SetRequestHeader("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
HTTP.SetRequestHeader("sec-fetch-dest", "document")
HTTP.SetRequestHeader("sec-fetch-mode", "navigate")
HTTP.SetRequestHeader("sec-fetch-site", "same-origin")
HTTP.SetRequestHeader("sec-fetch-user", "?1")
HTTP.SetRequestHeader("upgrade-insecure-requests", "1")
HTTP.Send()
HTTP.WaitForResponse()
RegExMatch(HTTP.ResponseText, "s)""__spin_t"":(.+?),.+?<input type=""hidden"" name=""(.+?)"" value=""(.+?)"".+?name=""(.+?)"" value=""(.+?)"".+?_js_datr"",""(.+?)""", match)
datr := match6

HTTP.Open("POST", "https://www.facebook.com/login/?privacy_mutation_token=" URIEncode(b64Encode("{""type"":0,""creation_time"":" match1 ",""callsite_id"":381229079575946}")), true)
HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36")
HTTP.SetRequestHeader("Pragma", "no-cache")
HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
HTTP.SetRequestHeader("content-type", "application/x-www-form-urlencoded")
HTTP.SetRequestHeader("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
HTTP.SetRequestHeader("origin", "https://www.facebook.com")
HTTP.SetRequestHeader("referer", "https://www.facebook.com")
HTTP.SetRequestHeader("sec-fetch-dest", "document")
HTTP.SetRequestHeader("sec-fetch-mode", "navigate")
HTTP.SetRequestHeader("sec-fetch-site", "same-origin")
HTTP.SetRequestHeader("sec-fetch-user", "?1")
HTTP.SetRequestHeader("upgrade-insecure-requests", "1")
HTTP.SetRequestHeader("cookie", "datr=" datr)
HTTP.Send(match2 "=" match3 "&" match4 "=" match5 "&email=" URIEncode(email) "&login_source=comet_headerless_login&next=&encpass=" URIEncode(password))
HTTP.WaitForResponse()
msgbox % HTTP.ResponseText



URIEncode(str, encoding := "UTF-8")
{
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &var, encoding)

   While code := NumGet(Var, A_Index - 1, "UChar")  {
      bool := (code > 0x7F || code < 0x30 || code = 0x3D)
      UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)
   }
   Return UrlStr
}

b64Encode(string)
{
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1|0x40000000, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1|0x40000000, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

Тема для обсуждения