Become authorized on ebay.com

Just starting out? Need help? Post your questions and find answers here.
souk
User
User
Posts: 10
Joined: Thu Oct 17, 2019 7:30 am

Become authorized on ebay.com

Post by souk »

Hello.
I can 't log in programmatically, the problem is cookies, but I can 't figure it out.
The site collects and sends a lot of information about the connected user to the server with this script:
https://dropmefiles.com/eZ5Uf

At the back are sent cookies with the flag http ponly, so js by the team from the webgajet it is not possible to intercept these cookies, and without these cook immediately throws on a recapture.
I understand if I threw after a failed attempt, as a protection against password overruns, but here on the first attempt and with the correct data.
How is it possible to let this script work on the machine and its output intercept and send it to the server?
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Become authorized on ebay.com

Post by infratec »

You have to use libcurl.pbi.

With the native libcurl stuff it is possible to handle the cookies.
souk
User
User
Posts: 10
Joined: Thu Oct 17, 2019 7:30 am

Re: Become authorized on ebay.com

Post by souk »

infratec wrote:You have to use libcurl.pbi.

With the native libcurl stuff it is possible to handle the cookies.
The fact is that the js-loaded script

Code: Select all

< script type = "text/javascript" src = "/nkfytkqtoxtljvzb.js" defer > </script >
(15 line of the source code of the https://signin.ebay.com/ws/eBayISAPI.dl ... bay.com%2F page)
generates cookies with the flag httponly,Which I can 't get.
Here 's the code I used to get these cookie:

Code: Select all

IncludeFile "libcurl.pbi"


Procedure.s HttpTest(URL.s, PostData.s = "", Cookie.s = "", User_agent.s = "", Referer.s = "", Proxy.s = "",json.l = #False, Timeout.l = 1000)

Protected curl, Result$, newCookie.s,tmp.s, p.l
curl  = curl_easy_init()
If curl

  curl_easy_setopt(curl, #CURLOPT_URL, str2curl(URL))
  If Cookie
    Cookie = str2curl(Cookie)
    curl_easy_setopt(curl,#CURLOPT_COOKIE,@Cookie)
  EndIf
  User_agent = str2curl(User_agent)
  curl_easy_setopt(curl,#CURLOPT_USERAGENT,@User_agent)
  
  If PostData
    PostData =  str2curl(PostData)
  curl_easy_setopt(curl, #CURLOPT_POST, 1)
  curl_easy_setopt(curl, #CURLOPT_POSTFIELDS, @PostData)
 EndIf
  curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
  curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
  curl_easy_setopt(curl, #CURLOPT_HEADER, @"")
  curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @curlWriteData())
  curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
  If Proxy
    Proxy = str2curl(Proxy)
    
    curl_easy_setopt(curl, #CURLOPT_PROXY, @Proxy)
    EndIf
  curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
  If Referer
    Referer = str2curl(Referer)
    curl_easy_setopt(curl, #CURLOPT_REFERER, @Referer)
  EndIf
  
  res = curl_easy_perform(curl)
  If res = #CURLE_OK
    Result$ = curlGetData()
  EndIf
  curl_easy_cleanup(curl)
EndIf

For p = 1 To 100
  tmp = StringField(Result$, p, #CRLF$)
  If Not tmp = ""
    If FindString(tmp,"Set-Cookie:")
      newCookie = newCookie + StringField(tmp, 2,"Set-Cookie:")
;       Debug tmp
    EndIf
  Else
    Break
  EndIf
  
Next

ProcedureReturn  newCookie+" ###ENDCookie### "+ #CRLF$ +Result$
EndProcedure

Procedure.s FindCoockiElement(element.s,cookie.s)
  Protected.s name_element, value_element, tmp_element, name_tmp_element, tmp_cookie
  Protected.i count_elements,i
  
  name_element = StringField(element, 1, "=")
  value_element = StringField(element, 2, "=")
  
  If FindString(cookie,name_element)

    count_elements = CountString(cookie,";")
    For i=1 To count_elements + 1
      tmp_element = Trim(StringField(cookie, i, ";"))
      name_tmp_element = StringField(tmp_element,1,"=")
      If name_tmp_element = name_element
        tmp_element = element
      EndIf
      tmp_cookie = tmp_cookie + tmp_element +"; "
    Next
  Else
    tmp_cookie = cookie +"; "+ element 
  EndIf

  ProcedureReturn RTrim(RTrim(tmp_cookie),";")
  
EndProcedure

Procedure.s GetCookies(html.s, old_cookies.s)
  Protected.s StringCookies, tmp_cookie, temp_text, tmp2_cookie
  Protected.i count_space, j, count_element

  
  tmp_cookie = StringField(html, 1, " ###ENDCookie### ")
      tmp_cookie = ReplaceString(tmp_cookie, #CR$,"; ")
          tmp_cookie = ReplaceString(tmp_cookie, #LF$,"; ")
          tmp_cookie = ReplaceString(tmp_cookie, #CRLF$,"; ")
          
          tmp_cookie = RemoveString(tmp_cookie,"HttpOnly") 
          tmp_cookie = RemoveString(tmp_cookie,"Domain=.ebay.com") 
          tmp_cookie = RemoveString(tmp_cookie,"Path=/")
          
          count_space = CountString(tmp_cookie, ";")
          
          For j = 1 To count_space + 1
            temp_text = Trim(StringField(tmp_cookie, j, ";"))

            If Not temp_text =""
             
              If FindString(temp_text,"Expires",1, #PB_String_NoCase) = 0

              count_element = CountString(tmp_cookie, temp_text)
              If count_element > 1
                tmp2_cookie = tmp2_cookie + RemoveString(tmp_cookie, temp_text+"; ", #PB_String_CaseSensitive, 1, count_element - 1)
          
              Else
               tmp2_cookie = tmp2_cookie + temp_text + "; "
            EndIf
          EndIf          
        EndIf

            Next
            StringCookies = RTrim(RTrim(ReplaceString(tmp2_cookie, "; ; ", "; ")),";")
            If Not old_cookies = ""
              count_element = CountString(StringCookies+old_cookies, ";")
              For j = 1 To count_element
                temp_text = Trim(StringField(StringCookies, j, ";")) 
                If Not temp_text =""

                old_cookies =  FindCoockiElement(temp_text, old_cookies)
                                 EndIf
               Next
               StringCookies = old_cookies

          EndIf

  ProcedureReturn StringCookies
EndProcedure

htmll$ = HttpTest("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&en=https%3A%2F%2Fwww.ebay.com%2F", "", "", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")
Debug GetCookies( htmll$,"")

I get these cookies

Code: Select all

dp1=bu1p/QEBfX0BAX19AQA**61704f1f^pbf/%23200000000000000000000000000045f8f1b9f^tzo/1a45dadf62f^bl/RU61704f1f^; ebay=%5Ejs%3D1%5Esbf%3D%23000000%5E; cid=LJNqC6xuB6BDrPJ9%23421247636
In fact, full cookies will have this kind of look

Code: Select all

cookie: dp1=btzo/1a45d95b2de^u1p/QEBfX0BAX19AQA**61580bce^bl/US61580bce^pbf/%23c000e000000000000000005f76d84e^
cookie: nonsession=BAQAAAW2EndDnAAaAADMAAV922E4/AMsAAV2Vq9Y1AMoAIGFYC845MDhiYjIxZTE2ZDBhYzNkMTMyODQ3YmVmZmZmMmU5YdeFg3dVZ4YgKivVeV8yea9OdG+m
cookie: s=CgAD4ACBdlvZOOTA4YmIyMWUxNmQwYWMzZDEzMjg0N2JlZmZmZjJlOWEXV7s9
cookie: ebay=%5Esbf%3D%23%5Ejs%3D1%5E
cookie: ak_bmsc=96F94774331BE2B5250B9EAD3329585172BF95AF6700000C9A4955D6F4A3431~pl3Dj0kKj/4fmfUKKXa6wECpuv7nd2IaJ7isI/3cE2Gzsa1BvtnGqDW1i0U5PBdhL1qJ4K9j0/DM/B2Y3RtHwg5siYMkHZHEE1+h/rHEE75rnPHrSlbX/vOSGghKUcJUr+zrzVh74tiJqxOIVK4lEZ9lgLo64PpzP2HFnXRfAMEdcsg6gDdx8HMe/vc4AdG7dpdcu+vMakeJu7pEnqEvR5cLY+gBtKTE8Ttv15Ftn4nw8=
cookie: npii=btguid/908bb31e16d0ac3d1322beffff2e9a61580bcc^cguid/908bb94726d0ad4bb892b7c1feebd96b61580bcc^
cookie: bm_sv=E46D2035DA0ABBCC92348B23DF36CE67~qTjwbs0CAi0tfSCjuRJLAuSRj4jYkK4HBIGPpZQm4plSYXoRkvASDGz1i4K9RZL/PVZ6FdRjShhAsPQaKEfxN7FmvacaDCqdrqPGGCBBprs4r3PEY4mztSgzpkvXn5U7pEFl508QwOqPylIFhMywsw==
cookie: cid=76B0JrtnIayTeoJW%231583462297
cookie: DG_IID=D71943C2-6F23-31CA-A69B-09248A93907D
cookie: DG_UID=2B043DF3-B82A-3AF4-B844-80EB8473DD69
cookie: DG_ZID=531141D7-EA2B-3BFB-8320-1FFB9E2BB4B3
cookie: DG_ZUID=6D1600D9-884D-3ECF-BF58-10760E08669B
cookie: DG_HID=E61D4AA2-E581-3487-ADF7-D33453186032
cookie: DG_SID=167.202.144.236:w7q5ZZE2kWN50lPh48SMGfxOkm1ukcP+obEesRE3xuY
Using only libcurl I can 't get all the cookies, so I tried to get the cookies from webgadget
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Become authorized on ebay.com

Post by infratec »

Hmmm...

I adapted your code to my latest version of libcurl.pbi

https://www.von-der-salierburg.de/download/LibCurl.pbi

Code: Select all

EnableExplicit

IncludeFile "libcurl.pbi"


Procedure.s HttpTest(URL$, PostData$ = "", Cookie$ = "", User_agent$ = "", Referer$ = "", Proxy$ = "",json.i = #False, Timeout.i = 3000)
  
  Protected curl.i, Result$, newCookie$, tmp$, i.i, res.i, Header$
  
  curl  = curl_easy_init()
  If curl
    curl_easy_setopt_str(curl, #CURLOPT_URL, URL$)
    
    If Cookie$ <> ""
      curl_easy_setopt_str(curl, #CURLOPT_COOKIE, Cookie$)
    EndIf
    
    If User_agent$ <> ""
      curl_easy_setopt_str(curl, #CURLOPT_USERAGENT, User_agent$)
    EndIf
    
    If PostData$ <> ""
      curl_easy_setopt(curl, #CURLOPT_POST, 1)
      curl_easy_setopt_str(curl, #CURLOPT_COPYPOSTFIELDS, PostData$)
    EndIf
    
    curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
    curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
    curl_easy_setopt(curl, #CURLOPT_HEADER, 1)
    curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @LibCurl_WriteFunction())
    curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
    
    If Proxy$ <> ""
      curl_easy_setopt_str(curl, #CURLOPT_PROXY, Proxy$)
    EndIf
    
    curl_easy_setopt(curl, #CURLOPT_TIMEOUT_MS, Timeout)
    
    If Referer$ <> ""
      curl_easy_setopt_str(curl, #CURLOPT_REFERER, Referer$)
    EndIf
    
    res = curl_easy_perform(curl)
    If res = #CURLE_OK
      Result$ = LibCurl_GetData()
      Debug Result$
      
      i = FindString(Result$, #CRLF$ + #CRLF$)
      If i
        Header$ = Left(Result$, i)
        
        i = 1
        Repeat
          tmp$ = StringField(Header$, i, #CRLF$)
          If tmp$ <> ""
            Debug "Headerfield: " + tmp$
            If Left(tmp$, 11) = "Set-Cookie:"
              newCookie$ + Mid(tmp$, 13) + #CRLF$
              Debug newCookie$
            EndIf
            i + 1
          EndIf
        Until tmp$ = ""
        
      EndIf
      
    Else
      Debug curl_easy_strerror(res)
    EndIf
    curl_easy_cleanup(curl)
  EndIf
  
  ProcedureReturn newCookie$ + " ###ENDCookie### "+ #CRLF$ + Result$
  
EndProcedure

Procedure.s FindCoockiElement(element.s,cookie.s)
  Protected.s name_element, value_element, tmp_element, name_tmp_element, tmp_cookie
  Protected.i count_elements,i
  
  name_element = StringField(element, 1, "=")
  value_element = StringField(element, 2, "=")
  
  If FindString(cookie,name_element)
    
    count_elements = CountString(cookie,";")
    For i=1 To count_elements + 1
      tmp_element = Trim(StringField(cookie, i, ";"))
      name_tmp_element = StringField(tmp_element,1,"=")
      If name_tmp_element = name_element
        tmp_element = element
      EndIf
      tmp_cookie = tmp_cookie + tmp_element +"; "
    Next
  Else
    tmp_cookie = cookie +"; "+ element
  EndIf
  
  ProcedureReturn RTrim(RTrim(tmp_cookie),";")
  
EndProcedure

Procedure.s GetCookies(html.s, old_cookies.s)
  Protected.s StringCookies, tmp_cookie, temp_text, tmp2_cookie
  Protected.i count_space, j, count_element
  
  
  tmp_cookie = StringField(html, 1, " ###ENDCookie### ")
  tmp_cookie = ReplaceString(tmp_cookie, #CR$,"; ")
  tmp_cookie = ReplaceString(tmp_cookie, #LF$,"; ")
  tmp_cookie = ReplaceString(tmp_cookie, #CRLF$,"; ")
  
  tmp_cookie = RemoveString(tmp_cookie,"HttpOnly")
  tmp_cookie = RemoveString(tmp_cookie,"Domain=.ebay.com")
  tmp_cookie = RemoveString(tmp_cookie,"Path=/")
  
  count_space = CountString(tmp_cookie, ";")
  
  For j = 1 To count_space + 1
    temp_text = Trim(StringField(tmp_cookie, j, ";"))
    
    If Not temp_text =""
      
      If FindString(temp_text,"Expires",1, #PB_String_NoCase) = 0
        
        count_element = CountString(tmp_cookie, temp_text)
        If count_element > 1
          tmp2_cookie = tmp2_cookie + RemoveString(tmp_cookie, temp_text+"; ", #PB_String_CaseSensitive, 1, count_element - 1)
          
        Else
          tmp2_cookie = tmp2_cookie + temp_text + "; "
        EndIf
      EndIf         
    EndIf
    
  Next
  StringCookies = RTrim(RTrim(ReplaceString(tmp2_cookie, "; ; ", "; ")),";")
  If Not old_cookies = ""
    count_element = CountString(StringCookies+old_cookies, ";")
    For j = 1 To count_element
      temp_text = Trim(StringField(StringCookies, j, ";"))
      If Not temp_text =""
        
        old_cookies =  FindCoockiElement(temp_text, old_cookies)
      EndIf
    Next
    StringCookies = old_cookies
    
  EndIf
  
  ProcedureReturn StringCookies
EndProcedure

Define htmll$

htmll$ = HttpTest("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&en=https%3A%2F%2Fwww.ebay.com%2F", "", "", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")
Debug GetCookies( htmll$,"")
But in the answer is no cookie ...
souk
User
User
Posts: 10
Joined: Thu Oct 17, 2019 7:30 am

Re: Become authorized on ebay.com

Post by souk »

The fact is that this script processes on the client side, collects data and sends it to the server, on the basis of this data cookies are generated.
It turns out that to get these cookies, it is necessary to send to the ebay server the data that collects this script, or to let this script work in webgadgete and intercept the sent data.
Webgadget does not allow to read headers, so I am unable to intercept received cookies, to intercept sent data too.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Become authorized on ebay.com

Post by infratec »

Post Reply