Login mit Token !

  • VB.NET

SSL ist deaktiviert! Aktivieren Sie SSL für diese Sitzung, um eine sichere Verbindung herzustellen.

    Login mit Token !

    Damit ich das Programmieren lerne, habe ich mir eine Internetseite zufällig ausgesucht und versuche dort das Login hinzukriegen.

    ich komme aber irgendwie nicht weiter. Vielleicht findet ihr den Fehler ?

    VB.NET-Quellcode

    1. Imports System.IO, System.Net, System.Text, System.Text.RegularExpressions
    2. Public Class Form1
    3. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    4. Label5.Text = ""
    5. Dim xtraHeaders As New WebHeaderCollection
    6. Dim cookieJar As New CookieContainer
    7. Label5.Text = "Rebuy login"
    8. Application.DoEvents()
    9. 'Login
    10. Dim User = "xxx@xx.de", pw = "xxxxxx"
    11. Dim Request As HttpWebRequest = DirectCast(WebRequest.Create("https://www.rebuy.de/verkaufen/login_check"), HttpWebRequest)
    12. request.Method = "POST"
    13. request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:55.0) Gecko/20100101 Firefox/55.0"
    14. request.ContentType = "application/x-www-form-urlencoded"
    15. request.CookieContainer = New CookieContainer()
    16. Using webClient As New Net.WebClient With {.Proxy = Nothing}
    17. Dim Input As String = webClient.DownloadString("https://www.rebuy.de/verkaufen/login_check")
    18. Dim Pattern As String = "(?<=<input type=""hidden"" name=""_csrf_token"" value="").*?(?="" id=""csrf_token"" />)"
    19. Dim Token As String = Regex.Match(Input, Pattern).Value
    20. Dim Post As String = "_username=" & User & "_password=" & pw & "&submit=&_csrf_token=" & Token
    21. Dim byteArray() As Byte = Encoding.UTF8.GetBytes(Post)
    22. request.ContentLength = byteArray.Length
    23. Dim DataStream As Stream = request.GetRequestStream()
    24. DataStream.Write(byteArray, 0, byteArray.Length)
    25. DataStream.Close()
    26. Dim Response As HttpWebResponse = request.GetResponse()
    27. DataStream = Response.GetResponseStream()
    28. Dim reader As New StreamReader(DataStream)
    29. Dim ServerResponse As String = reader.ReadToEnd()
    30. reader.Close()
    31. DataStream.Close()
    32. Response.Close()
    33. If InStr(ServerResponse, "Alex") Then
    34. MessageBox.Show("Login OK")
    35. Else
    36. MessageBox.Show("Login nicht OK")
    37. End If
    38. End Using
    39. End Sub
    40. End Class



    Dazu der Inhalt der seite

    rebuy.de/verkaufen/login_check

    POST /verkaufen/login_check HTTP/1.1
    Host: rebuy.de
    User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:55.0) Gecko/20100101 Firefox/55.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de,en-US;q=0.7,en;q=0.3
    Accept-Encoding: gzip, deflate, br
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 113
    Referer: rebuy.de/verkaufen/auth
    Cookie: PHPSESSID=jdff3itvlm0205fuh7r6519d7h; hl=de; green-web-features=%7B%22GREEN_164%22%3A78%7D; abtcid=8189ba7d-1fd4-4ed3-be9a-720fbc7d3b63; abtcnew=1; ud=92; wxn_g=CUX-330__ab_test_29%3Acontrol%3BGREEN-456__ab_test_14%3Avariation; _uetsid=_uetb7e7ce22
    DNT: 1
    Connection: keep-alive
    Upgrade-Insecure-Requests: 1
    _username=xxxx@xxx.de&_password=xxxxxxx&submit=&_csrf_token=O2R3uYRTZbXo_frcL36SYHZceHKkDG6f7m_Tsg0KAzU: undefined

    HTTP/2.0 302 Found
    server: myracloud
    date: Sun, 24 Sep 2017 10:32:49 GMT
    content-type: text/html; charset=UTF-8
    content-length: 368
    cache-control: no-cache, private
    location: rebuy.de/verkaufen/
    p3p: CP="reBuy does not have a P3P policy"
    set-cookie: PHPSESSID=hcevbmcr7jjjnritu89hrmiblk; path=/; HttpOnly
    set-cookie: ry_previous=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; HttpOnly
    set-cookie: rbauth=auth%3A09b6debe-d9f8-4b7a-9cc9-7038b9769198; expires=Mon, 24-Sep-2018 10:32:48 GMT; Max-Age=31535999; path=/; secure; HttpOnly
    set-cookie: x-rebuy-internal=b0a9212e-04eb-498c-a33f-c998e2bc6df2; path=/; secure; HttpOnly
    set-cookie: cart=246b2977-953e-4beb-b5d6-7f79d5a9c3fb; path=/; HttpOnly
    set-cookie: phraseapp=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; HttpOnly
    set-cookie: ud=92; expires=Mon, 24-Sep-2018 10:32:49 GMT; Max-Age=31536000; path=/; domain=rebuy.de
    strict-transport-security: max-age=31536000
    x-frame-options: SAMEORIGIN
    x-source: k8s-public-ingress
    X-Firefox-Spdy: h2
    ----------------------------------------------------------
    rebuy.de/verkaufen/

    GET /verkaufen/ HTTP/1.1
    Host: rebuy.de
    User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:55.0) Gecko/20100101 Firefox/55.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de,en-US;q=0.7,en;q=0.3
    Accept-Encoding: gzip, deflate, br
    Referer: rebuy.de/verkaufen/auth
    Cookie: PHPSESSID=hcevbmcr7jjjnritu89hrmiblk; hl=de; green-web-features=%7B%22GREEN_164%22%3A78%7D; abtcid=8189ba7d-1fd4-4ed3-be9a-720fbc7d3b63; abtcnew=1; ud=92; wxn_g=CUX-330__ab_test_29%3Acontrol%3BGREEN-456__ab_test_14%3Avariation; _uetsid=_uetb7e7ce22; rbauth=auth%3A09b6debe-d9f8-4b7a-9cc9-7038b9769198; x-rebuy-internal=b0a9212e-04eb-498c-a33f-c998e2bc6df2; cart=246b2977-953e-4beb-b5d6-7f79d5a9c3fb
    DNT: 1
    Connection: keep-alive
    Upgrade-Insecure-Requests: 1

    HTTP/2.0 200 OK
    server: myracloud
    date: Sun, 24 Sep 2017 10:32:49 GMT
    content-type: text/html; charset=UTF-8
    cache-control: max-age=600
    content-encoding: gzip
    p3p: CP="reBuy does not have a P3P policy"
    set-cookie: cart=246b2977-953e-4beb-b5d6-7f79d5a9c3fb; path=/; HttpOnly
    set-cookie: phraseapp=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; HttpOnly
    set-cookie: abtcnew=1; expires=Sun, 24-Sep-2017 11:02:49 GMT; Max-Age=1800; path=/; domain=rebuy.de; HttpOnly
    set-cookie: ud=92; expires=Mon, 24-Sep-2018 10:32:49 GMT; Max-Age=31536000; path=/; domain=rebuy.de
    strict-transport-security: max-age=31536000
    vary: cookie, accept-encoding, accept-language
    x-frame-options: SAMEORIGIN
    x-source: k8s-public-ingress
    expires: Sun, 24 Sep 2017 10:42:49 GMT
    etag: "myra-1dd393b5"
    X-Firefox-Spdy: h2


    Danke ! vlielleicht kann mir ein schlauer Kopf helfen :)