339r

INSTAGRAM & LOGIN Ajax (Fix 400 http req)

Jun 22nd, 2020
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.19 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.Text.RegularExpressions
  3. Imports System.Web
  4. Public Class Form1
  5.     Dim Cookies As String
  6.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  7.         Dim stringPOSTData As String = "username=" & TextBox1.Text & "&enc_password=#PWD_INSTAGRAM_BROWSER:0:" & Get_time() & ":" & TextBox2.Text & "&queryParams={}&optIntoOneTap=false"
  8.         Dim responString As String
  9.         Using w As New WebClient
  10.             w.Headers.Add("accept", "*/*")
  11.             w.Headers.Add("content-type: application/x-www-form-urlencoded")
  12.             w.Headers.Add("x-csrftoken", "missing")
  13.             w.Headers.Add("user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36")
  14.             w.Headers.Add("x-instagram-ajax", "1")
  15.             w.Headers.Add("x-requested-with: XMLHttpRequest")
  16.             Try
  17.                 responString = w.UploadString("https://www.instagram.com/accounts/login/ajax/", "POST", Uri.EscapeUriString(stringPOSTData))
  18.                 'MsgBox(responString)
  19.                 If w.ResponseHeaders("set-cookie").ToString.Contains("sessionid") Then
  20.                     ' Done login
  21.                     ' MsgBox("Done LOGIN")
  22.                     Dim resCookies As String = w.ResponseHeaders("set-cookie").ToString
  23.                     Cookies = Regex.Match(resCookies, "sessionid=(.*?);").Value & " " & Regex.Match(resCookies, "mid=(.*?);").Value & " " & Regex.Match(resCookies, "csrftoken=(.*?);").Value & " " & Regex.Match(resCookies, "ig_did=(.*?);").Value & " " & Regex.Match(resCookies, "rur=(.*?);").Value
  24.                     MsgBox(Cookies)
  25.                 Else
  26.                     ' Info Worng
  27.                     MsgBox("Error LOGIN")
  28.                 End If
  29.             Catch ex As WebException
  30.                 Dim respon As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
  31.                 ' Error Login
  32.                 MsgBox(respon)
  33.             End Try
  34.         End Using
  35.     End Sub
  36.     Function Get_time() As String
  37.         Return CLng(DateTime.UtcNow.Subtract(New DateTime(1970, 1, 1)).TotalMilliseconds)
  38.     End Function
  39.  
  40. End Class
Add Comment
Please, Sign In to add comment