Jump to content

Recommended Posts

Posted (edited)

Hello.

I try to login on my Gmail Inbox via WinHttp. I have done 50% of process (enter email adress and press next). Next step required enter password and also press next. This i can not pass. In my opinion problem is in $sAction2.

Using Live HTTP Headers i received this data durning second step (final login to gmail)

POST /signin/challenge/sl/password HTTP/1.1
Host: accounts.google.com:443
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7
Content-Type: application/x-www-form-urlencoded
Cookie: CONSENT=YES+PL.pl+20150628-20-0; 1P_JAR=2018-1-24-15; NID=122=DzTr2OFvhgZQaiok08rlH2L8LKvRxo10hQmbkrx0n1iVRfTQOeThuGbY9x9e4igcZYhRnZC-KcKaVq1zu59JSw9Co2QA7NVKlVXA9yOWoVKZ7NOFq9OcpmxmqhtqL9TMVVbxPqVNJuLdjhxyTFRjTxvwwPHCruWAWq6Qmf0k62phpPFHYR5xe-QiyoQZ; ACCOUNT_CHOOSER=AFx_qI6F5ksoZUmQPMD3bjEjVlJRYo2LkBUEct2QALOkh1If4LuP2U4L4YaXuSNle5KP0b_nfBeW; GAPS=1:xUr80PGiUjGeBjiGsYIAsmOypnwQqz-2fxOrcT1VxRKuv03VefxM2Y3IBe5NY1AiFsyr71P6dux7jhUybEBoo2Gb3wWnIbzjTAVQBuDbqVo2gQ:JqQYqaHr8RO9oWrR
Origin: null
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
X-Chrome-Connected: mode=0,enable_account_consistency=false
X-Chrome-UMA-Enabled: 1
X-Client-Data: CIu2yQEIorbJAQjBtskBCIqSygEI+pzKAQipncoBCKijygE=

HTTP/1.1 302
alt-svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-encoding: gzip
content-length: 284
content-type: text/html; charset=UTF-8
date: Wed, 24 Jan 2018 16:39:37 GMT
expires: Mon, 01 Jan 1990 00:00:00 GMT
location: https://accounts.google.com/AccountChooser?Email=myemail%40gmail.com&continue=https%3A%2F%2Fwww.google.pl%2Fwebhp%3Fei%3DlqBoWseSO-KKmgWV45CwDQ%26yv%3D2%26rct%3Dj&hl=pl
pragma: no-cache
server: GSE
set-cookie: GAPS=1:yMRhZscrWUUvDTajt2ZRaYXJASx9xouIxKCpiptr8ytyQrzy7i8oY-E3d0HOy1d2FYF-q0FmVc0nk4iVQhQAPv3hYIJ923GASx5ppLAsm-i7OQ:cHBZRHMjwa4o_J6V;Path=/;Expires=Fri, 24-Jan-2020 16:39:37 GMT;Secure;HttpOnly;Priority=HIGH
status: 302
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block

My code below.

#include <WinHttp.au3>

Func _GmailLogin($sEmail, $sPasswd)
    Local $hOpen = _WinHttpOpen() ; Open session
    Local $hConnect = _WinHttpConnect($hOpen, "https://accounts.google.com") ; Connection to make
    Local $sAction = "/ServiceLogin/identifier?hl=pl&passive=true&continue=https%3A%2F%2Fwww.google.pl%2Fwebhp%3Fei%3DlqBoWseSO-KKmgWV45CwDQ%26yv%3D2%26rct%3Dj&flowName=GlifWebSignIn&flowEntry=AddSession"
    Local $sRead = _WinHttpSimpleFormFill($hConnect, $sAction, Default, "name:Email", $sEmail)
    _StoreHtmlWebsite('Name.html', $sRead) ; Create a file *html with respond text
    Local $sAction2 = "/signin/challenge/sl/password"
    $sRead = _WinHttpSimpleFormFill($hConnect, $sAction2, Default, "name:Passwd", $sPasswd)
    _StoreHtmlWebsite('Password.html', $sRead)
    _WinHttpCloseHandle($hConnect) ;Close handles
    _WinHttpCloseHandle($hOpen)
    Return $sRead
EndFunc

Func _StoreHtmlWebsite($sFile, $sData)
    FileDelete($sFile)
    FileWrite($sFile, $sData)
EndFunc ;==> Write copy of website to file *html

_GmailLogin('myemail@gmail.com', 'mypassword')

@trancexx 

Regards,

Ascer

Edited by Ascer

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...