339r

INSTAGRAM LOGIN with Secure Code - VB.Net

Jun 24th, 2020
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.00 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.Text.RegularExpressions
  3. Imports System.Web
  4. Imports System.Web.Script.Serialization
  5.  
  6. Public Class Form1
  7.     Dim Cookies As String
  8.     Dim tempCookies As String
  9.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  10.         Dim stringPOSTData As String = "username=" & TextBox1.Text & "&enc_password=#PWD_INSTAGRAM_BROWSER:0:" & Get_time() & ":" & TextBox2.Text & "&queryParams={}&optIntoOneTap=false"
  11.         Dim responString As String
  12.         Using w As New WebClient
  13.             w.Headers.Add("accept", "*/*")
  14.             w.Headers.Add("content-type: application/x-www-form-urlencoded")
  15.             w.Headers.Add("x-csrftoken", "missing")
  16.             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")
  17.             w.Headers.Add("x-instagram-ajax", "1")
  18.             w.Headers.Add("x-requested-with: XMLHttpRequest")
  19.             Try
  20.                 responString = w.UploadString("https://www.instagram.com/accounts/login/ajax/", "POST", Uri.EscapeUriString(stringPOSTData))
  21.                 'MsgBox(responString)
  22.                 If w.ResponseHeaders("set-cookie").ToString.Contains("sessionid") Then
  23.                     ' Done login
  24.                     ' MsgBox("Done LOGIN")
  25.                     Dim resCookies As String = w.ResponseHeaders("set-cookie").ToString
  26.                     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
  27.                     MsgBox(Cookies)
  28.                 Else
  29.                     ' Info Worng
  30.                     MsgBox("Error LOGIN")
  31.                 End If
  32.             Catch ex As WebException
  33.                 Dim respon As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
  34.                 If respon.Contains("checkpoint_required") Then
  35.                     ' Error Secure!
  36.                     ' MsgBox("Secure!")
  37.                     Dim url_sce As String = Regex.Match(respon, "checkpoint_url"": ""(.*?)""").Groups(1).Value
  38.                     Dim resCookies As String = ex.Response.Headers("set-cookie")
  39.                     tempCookies = Regex.Match(resCookies, "mid=(.*?);").Value & " " & Regex.Match(resCookies, "csrftoken=(.*?);").Value & " " & Regex.Match(resCookies, "ig_did=(.*?);").Value & " " & Regex.Match(resCookies, "rur=(.*?);").Value
  40.                     Dim secureINFO As String = Get_Secure_info(url_sce, tempCookies)
  41.                     If Not IsNothing(secureINFO) Then
  42.                         Dim i_json As Object
  43.                         i_json = New JavaScriptSerializer().Deserialize(Of Object)(secureINFO)
  44.                         If i_json("challengeType") = "SelectVerificationMethodForm" Then
  45.                             'MsgBox(New JavaScriptSerializer().Serialize(i_json("extraData")("content")(3)("fields")(0)("values")))
  46.                             Dim raidobtn As New List(Of Control)
  47.                             For Each item_ As Control In Form2.Controls
  48.                                 If item_.Name.Contains("RadioButton") Then
  49.                                     raidobtn.Add(item_)
  50.                                 End If
  51.                             Next
  52.                             Dim index_loop As Integer
  53.                             For Each i_ As Object In i_json("extraData")("content")(3)("fields")(0)("values")
  54.                                 raidobtn(index_loop).Text = i_("label")
  55.                                 raidobtn(index_loop).Tag = i_("value")
  56.                                 index_loop += 1
  57.                             Next
  58.                             Form2.url_path = url_sce
  59.                             Form2.Show()
  60.                         End If
  61.                     Else
  62.                         MsgBox("Error can't get info")
  63.                     End If
  64.                 Else
  65.                     ' Error Login
  66.                     MsgBox(respon)
  67.                 End If
  68.  
  69.             End Try
  70.         End Using
  71.     End Sub
  72.     Function Get_Secure_info(url_path As String, responcookie As String)
  73.         Dim stringRespon As String
  74.         Using w As New WebClient
  75.             w.Headers.Add("accept", "*/*")
  76.             w.Headers.Add("content-type: application/x-www-form-urlencoded")
  77.             w.Headers.Add("cookie", responcookie)
  78.             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")
  79.             Try
  80.                 stringRespon = w.DownloadString("https://i.instagram.com" & url_path & "?__a=1")
  81.                 Return stringRespon
  82.             Catch ex As Exception
  83.  
  84.             End Try
  85.             Return Nothing
  86.         End Using
  87.     End Function
  88.     Function Send_code(url_path As String, valueIs As String) As Boolean
  89.         Dim stringRespon As String
  90.         Using w As New WebClient
  91.             w.Headers.Add("accept", "*/*")
  92.             w.Headers.Add("content-type: application/x-www-form-urlencoded")
  93.             w.Headers.Add("x-csrftoken", "missing")
  94.             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")
  95.             w.Headers.Add("x-instagram-ajax", "1")
  96.             w.Headers.Add("x-requested-with: XMLHttpRequest")
  97.             w.Headers.Add("cookie", tempCookies)
  98.             Try
  99.                 stringRespon = w.UploadString("https://i.instagram.com" & url_path, "POST", "choice=" & valueIs)
  100.                 Return stringRespon.Contains("""status"": ""ok""")
  101.             Catch ex As Exception
  102.  
  103.             End Try
  104.             Return False
  105.         End Using
  106.     End Function
  107.     Function Get_time() As String
  108.         Return CLng(DateTime.UtcNow.Subtract(New DateTime(1970, 1, 1)).TotalMilliseconds)
  109.     End Function
  110. End Class
Add Comment
Please, Sign In to add comment