ienthach Posted June 7, 2010 Share Posted June 7, 2010 (edited) Here is my script to login to paypal and get info, but it require java and cookie. Any body can help me. And ConsoleWrite(_WinHttpReadData($request))don't receive full source of site response include<WinHTTP.au3> $Login='login_cmd=&login_params=&login_email=tamthoiban%40aol.com&login_password=1qaz1qaz' $session=_winhttpopen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729") $connect=_winhttpconnect($session,'www.paypal.com',$INTERNET_DEFAULT_HTTPS_PORT) $request=_winhttpopenrequest($connect,'POST','/us/cgi-bin/webscr?cmd=', 'HTTP/1.1','https://www.paypal.com',"",$WINHTTP_FLAG_SECURE) _WinHttpSendRequest($request) _WinHttpReceiveResponse($request) $cookie=Getcookie($request) _WinHttpAddRequestHeaders($request,'Content-Type: application/x-www-form-urlencoded') _WinHttpAddRequestHeaders($request,'Cookie: '&$cookie) _WinHttpSendRequest($request,'Content-Type: application/x-www-form-urlencoded',$Login) _WinHttpReceiveResponse($request) ConsoleWrite(_WinHttpReadData($request)) Func GetCookie($request) $a =_WinHttpQueryHeaders($request) $sm = StringSplit($a, "Set-Cookie:", 1) Global $sm2, $coki For $i = 2 To $sm[0] Step +1 $sm2 = StringSplit($sm[$i], ";", 1) $coki &= $sm2[1] & ";" Next ConsoleWrite($coki &@CRLF&@CRLF) Return $coki EndFunc _WinHttpCloseHandle($request) _WinHttpCloseHandle($connect) _WinHttpCloseHandle($session) expandcollapse popuphttps://www.paypal.com/vn/cgi-bin/webscr?cmd=_login-submit&dispatch=5885d80a13c0db1f22d2300ef60a67593b79a4d03747447e1e8d0f800ad65e80 POST /vn/cgi-bin/webscr?cmd=_login-submit&dispatch=5885d80a13c0db1f22d2300ef60a67593b79a4d03747447e1e8d0f800ad65e80 HTTP/1.1 Host: www.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: https://www.paypal.com/vn/cgi-bin/webscr?cmd=_login-run Cookie: LANG=en_US%3bVN; KHcl0EuY7AKSMgfvHl7J5E7hPtK=8OWLNroNN3d3OLZOpkg2r1ZUKsMWchXsO1HFB0i0fMAkAwOt6fzwrwicj3ggsMshfq-61BFKce-pSvmP; cookie_check=yes; consumer_display=USER_HOMEPAGE%3d2%26USER_TARGETPAGE%3d0%26USER_FILTER_CHOICE%3d7%26BALANCE_MODULE_STATE%3d1%26GIFT_BALANCE_MODULE_STATE%3d1%26LAST_SELECTED_ALIAS_ID%3d0; navlns=0; login_email=tamthoiban%40aol.com; upct=43; qzEHJNXWEv49JLf5WP_uDZ_-fGO=8lAtEH_-gOJY4uqV4QjqrSvWKSiIUq5ZWMRz_YioUpADppMszR0Wy_HNJBShrRe-t5S-soNix5a_WDnvMcgupRvZTc1D6vrmx1Zxw0; BS-4bMC2MqFSsLpP26xJsq3yChO=TJofe8_R6hrQZqi-QD30U3lBzAj_tEadEGk25DqWyh45oofOQyjbwY-epxtOV4Fho-Xblm; 3tgj_m4qG_miZ9jcKUkxX0QuE8u=U-AVNSYjT1Kf8XC3zia4LQfpwHzpM84ri71FTxQCwSqgsJITv0y2BL7Q5FgYDBCdoDgEv0; cwrClyrK4LoCV1fydGbAxiNL6iG=rr4NBzX6KSM9Izv-M-EborVHCzZyi2FztaBwNTyqTFJNgo_Gx0WBJVfGDrvX9drDbyl3vhBUwOrdgyr6_JBvLOle302IfVBpxEIfy3UMgYAVIBtoaQVNRO1KZIxGFE5UfSt9u0%7cP0E82bi16ceN33T1X2cQle4KY8SHweapZ03U9bN4ayuZA8eEDEzk75DRjC3WgYWw5SWkj0%7cOWyhIbhxVBSPSS1Ai_btITv6atNjpPzAxPtkRFVl9v8cjnSc2K-qErauZQtJeXzUU6-ZSW%7c1275915283; navcmd=_login-run; s_sess=%20s_cc%3Dtrue%3B%20s_refresh%3DLog%2520In%3B%20s_sq%3Dpaypalglobal%253D%252526pid%25253DLog%25252520In%252526pidt%25253D1%252526oid%25253DLog%25252520In%252526oidt%25253D3%252526ot%25253DSUBMIT%3B; Uw0ufNNdbGrsQ4szefJG8iIna38=QQA7zWCELsAHAMZk_FX8DHvi7maXAlHf6RuNLKvI4VOQ7jIxu-PKWafyv5UCVXKoU8xiW0; HaC80bwXscjqZ7KM6VOxULOB534=; cookie_welcome=; tkkUEuFUb_mahcIlS49RY52hwu8=Scj32sUSsaDAdnw_mftUk3ugyOqrYDeQPgif_FrfqU8AHEIrXGEiG22UF_dlle2K9WSnOYMh0rFB66x0WtLxIo9H48OSalt8gRDc7m; VmyeHxjTc5yWtKApgk8-f2SgjEC=SjjF3I0GW-Ugpd-fBGXzGq5MhCWHByVgCo2gcFBo0h7iCr8fHI-AHvv41aipeaRX_K1cSCIUpbQ2FQGOTcfVyfHohIq Content-Type: application/x-www-form-urlencoded Content-Length: 1347 login_cmd=&login_params=&login_email=tamthoiban%40aol.com&login_password=1qaz1qaz&target_page=0&submit.x=Log+In&form_charset=UTF-8&browser_name=undefined&browser_version=undefined&operating_system=Windows&flow_name=p%2Fgen%2Flogin&bp_mid=v%3D1%3Ba1%3Dna%7Ea2%3Dna%7Ea3%3Dna%7Ea4%3DMozilla%7Ea5%3DNetscape%7Ea6%3D5.0+%28Windows%3B+en-US%29%7Ea7%3D20100401%7Ea8%3Dna%7Ea9%3Dtrue%7Ea10%3DWindows+NT+5.1%7Ea11%3Dtrue%7Ea12%3DWin32%7Ea13%3Dna%7Ea14%3DMozilla%2F5.0+%28Windows%3B+U%3B+Windows+NT+5.1%3B+en-US%3B+rv%3A1.9.2.3%29+Gecko%2F20100401+Firefox%2F3.6.3+%28.NET+CLR+3.5.30729%29%7Ea15%3Dtrue%7Ea16%3Den-US%7Ea17%3Dna%7Ea18%3Dwww.paypal.com%7Ea19%3Dna%7Ea20%3Dna%7Ea21%3Dna%7Ea22%3Dna%7Ea23%3D1067%7Ea24%3D600%7Ea25%3D24%7Ea26%3D580%7Ea27%3Dna%7Ea28%3DMon+Jun+07+2010+19%3A54%3A46+GMT%2B0700+%28SE+Asia+Standard+Time%29%7Ea29%3D7%7Ea30%3Dmso%7Crpv%7Crpl%7Cdef%7Cqt1%7Cqt2%7Cqt3%7Cqt4%7Cqt5%7Cqt6%7Cswf%7Cdrn%7Cwpm%7Cdrm%7C%7Ea31%3Dyes%7Ea32%3Dna%7Ea33%3Dna%7Ea34%3Dyes%7Ea35%3Dno%7Ea36%3Dyes%7Ea37%3Dno%7Ea38%3Donline%7Ea39%3Dno%7Ea40%3DWindows+NT+5.1%7Ea41%3Dno%7Ea42%3Dno%7E&bp_ks1=v%3D1%3Bl%3D8%3BDi0%3A392742Ui0%3A93Di1%3A132Ui1%3A138Di2%3A131Ui2%3A94Di3%3A132Ui3%3A138Dk8%3A396Uk8%3A5Dk8%3A1Uk8%3A3Uiundefined%3A1Ui0%3A83Dk8%3A88Uk8%3A7Dk8%3A1Uk8%3A7Uiundefined%3A4Ui0%3A74Di4%3A661Ui4%3A137Di5%3A132Ui5%3A138Di6%3A88Ui6%3A139&bp_ks2=&bp_ks3= HTTP/1.1 302 Found Date: Mon, 07 Jun 2010 13:01:25 GMT Server: Apache Cache-Control: private Pragma: no-cache Expires: Thu, 05 Jan 1995 22:00:00 GMT Set-Cookie: navcmd=_login-submit; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: consumer_display=USER_HOMEPAGE%3d2%26USER_TARGETPAGE%3d0%26USER_FILTER_CHOICE%3d7%26BALANCE_MODULE_STATE%3d1%26GIFT_BALANCE_MODULE_STATE%3d1%26LAST_SELECTED_ALIAS_ID%3d0; expires=Tue, 07-Jun-2011 13:01:26 GMT; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: login_email=tamthoiban%40aol.com; expires=Sat, 04-Dec-2010 13:01:26 GMT; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: Uw0ufNNdbGrsQ4szefJG8iIna38=QQA7zWCELsAHAMZk_FX8DHvi7maXAlHf6RuNLKvI4VOQ7jIxu-PKWafyv5UCVXKoU8xiW0; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=2hvmTx_CSGc87JjrJxdFpM2SbTpM3syiAlz-VySXdxeVGP48wJdFvRbRSoiujOTSJOyckcnEvVm74f3Rv1ECtMsV9PHksV2xIiPpLBSYoOPu0tHYByvIMFED-mBGig9ayev3LG%7cP0E82bi16ceN33T1X2cQle4KY8SHweapZ03U9bN4ayuZA8eEDEzk75DRjC3WgYWw5SWkj0%7cOWyhIbhxVBSPSS1Ai_btITv6atNjpPzAxPtkRFVl9v8cjnSc2K-qErauZQtJeXzUU6-ZSW%7c1275915686; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: HaC80bwXscjqZ7KM6VOxULOB534=d98VPu2B5VdHMe6vvN5unlnNo_QBS4ebl0Kchd2FwxeXOplKyCa79MP48d7LQW23UhUl7shKUs_uC_b3-BG4wVUXZonromX_EP24YyjOm8gkj9-n7hSzq6VRoOMkcectC9KA0m; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: LANG=en_US%3bVN; expires=Thu, 04-Jun-2020 13:01:26 GMT; domain=.paypal.com; path=/; Secure; HttpOnly Set-Cookie: Apache=10.190.11.249.1275915685190592; path=/; expires=Sun, 24-Apr-04 06:33:09 GMT Location: https://www.paypal.com/vn/cgi-bin/webscr?cmd=_login-processing&login_cmd=_login-done&login_access=1275915685 Vary: Accept-Encoding Content-Encoding: gzip Strict-Transport-Security: max-age=500 Keep-Alive: timeout=5, max=92 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html Edited June 7, 2010 by ienthach Link to comment Share on other sites More sharing options...
GEOSoft Posted June 7, 2010 Share Posted June 7, 2010 (edited) First, don't use stringsplit on a string like Set-Cookie: that will only lead to problems at some point. Use a reg expression but remember the array will be 0 based.Using For $i = 2 To $a[0] is also a bad practice. It works right now but at some point in the future it may not. Use Ubound($a) -1 instead.Third Step +1 is the default so there is no need for it at all. and there is never a need for the + anyway Step 1 would do exactly the same. Only use Step if the number is greater than 1 or if you are stepping backwards then use a - sign with a number, for example Step -1So the function now becomes thisFunc GetCookie($request) $a =_WinHttpQueryHeaders($request) $sm = StringRegExp($a, "(?i)Set-Cookie:\s*(.*)(?:\v+)", 3) Global $sm2, $coki For $i = 0 To Ubound($sm) -1 $sm2 = StringSplit($sm[$i], ";", 1) $coki &= $sm2[1] & ";" Next ConsoleWrite($coki &@CRLF&@CRLF) Return $coki EndFuncEdit; Removed a code comment because I just realized why you were starting at the second element. Edited June 7, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 7, 2010 Share Posted June 7, 2010 I really do hope that is not your real Username and Password. If so, edit your post ASAP!!!! 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
ienthach Posted June 7, 2010 Author Share Posted June 7, 2010 First, don't use stringsplit on a string like Set-Cookie: that will only lead to problems at some point. Use a reg expression but remember the array will be 0 based. Using For $i = 2 To $a[0] is also a bad practice. It works right now but at some point in the future it may not. Use Ubound($a) -1 instead. Third Step +1 is the default so there is no need for it at all. and there is never a need for the + anyway Step 1 would do exactly the same. Only use Step if the number is greater than 1 or if you are stepping backwards then use a - sign with a number, for example Step -1 So the function now becomes this Thank you for editing, this is my first coding, But i still can not login, could you tell me the way to solve this problem? I really do hope that is not your real Username and Password. If so, edit your post ASAP!!!! don't worry. it is my example account, but it can log in successfully Link to comment Share on other sites More sharing options...
ienthach Posted June 7, 2010 Author Share Posted June 7, 2010 (edited) So please help me. Finally, i done!!! HIHIHI Edited June 7, 2010 by ienthach Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now