Advertisement
Guest User

insta login vb.net

a guest
Feb 13th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. Imports System.Text
  2. Imports System.Net.Sockets
  3. Imports System.Net.Security
  4. Imports System.Security.Authentication
  5. Imports System.Security.Cryptography.X509Certificates
  6. Public Class Form1
  7.  
  8. Private Shared Function ValidateServerCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors__1 As SslPolicyErrors) As Boolean
  9. If sslPolicyErrors__1 = SslPolicyErrors.None Then
  10. Return True
  11. End If
  12. Return False
  13. End Function
  14. Public Shared Sub Main(ByVal args As String())
  15. Dim id As [String] = ""
  16. Dim pass As [String] = ""
  17. Dim csrftoken As [String] = ""
  18. Dim mid As [String] = ""
  19. Dim cooks As [String] = ""
  20. Dim request1 = "GET /" + " HTTP/1.1" & vbCr & vbLf + "Host: www.instagram.com" & vbCr & vbLf + vbCr & vbLf
  21.  
  22. Console.WriteLine("Insta login via tcp client By [ZeR0]" & vbLf)
  23. While id = ""
  24. Console.WriteLine("Enter id or email and press enter")
  25. id = Console.ReadLine().ToString()
  26. End While
  27. Console.WriteLine("Id set to => " + id + vbLf)
  28. While pass = ""
  29. Console.WriteLine("Enter email password and press enter")
  30. pass = Console.ReadLine().ToString()
  31. End While
  32. Console.WriteLine("Pass set to => " + pass + vbLf & "Start login ..." & vbLf)
  33. Try
  34. Dim client As New TcpClient("52.20.205.154", 443)
  35. Dim sslStream As New SslStream(client.GetStream(), False, New RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate), Nothing)
  36. Try
  37. sslStream.AuthenticateAsClient("instagram.com")
  38. Catch e As AuthenticationException
  39. Console.WriteLine("Authentication failed with instagram.com" & vbLf & "press any key to exit ..")
  40. client.Close()
  41. Console.ReadKey()
  42. Return
  43. End Try
  44. '#Region "Get Cookies"
  45. Dim messsage As Byte() = Encoding.UTF8.GetBytes(request1)
  46. sslStream.Write(messsage)
  47. sslStream.Flush()
  48. Dim buffer As Byte() = New Byte(client.ReceiveBufferSize - 1) {}
  49. Dim head As [String] = ""
  50. While Not (head.Contains("</html>"))
  51. sslStream.Read(buffer, 0, buffer.Length)
  52. head += System.Text.Encoding.UTF8.GetString(buffer)
  53. End While
  54.  
  55. csrftoken = head.Substring(head.IndexOf("csrftoken=") + "csrftoken=".Length)
  56. csrftoken = csrftoken.Substring(0, csrftoken.IndexOf(";") - 0)
  57. mid = head.Substring(head.IndexOf("mid=") + "mid=".Length)
  58. mid = mid.Substring(0, mid.IndexOf(";") - 0)
  59. cooks += "mid=" + mid + ";csrftoken=" + csrftoken
  60. head = ""
  61. '#End Region
  62. '#Region "Login"
  63. Dim x As String = "username=" + id + "&password=" + pass
  64. Dim request2 = Convert.ToString("POST /accounts/login/ajax/" + " HTTP/1.1" & vbCr & vbLf + "Host: www.instagram.com" & vbCr & vbLf + "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.3.0" & vbCr & vbLf + "Referer: https://www.instagram.com/" & vbCr & vbLf + "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" & vbCr & vbLf + "X-CSRFToken: " + csrftoken + vbCr & vbLf + "Cookie: " + cooks + vbCr & vbLf + "Content-Length: " + x.Length.ToString() + vbCr & vbLf & vbCr & vbLf) & x
  65. messsage = Encoding.UTF8.GetBytes(request2)
  66. sslStream.Write(messsage)
  67. sslStream.Flush()
  68. buffer = New Byte(2047) {}
  69. head = ""
  70. sslStream.Read(buffer, 0, buffer.Length)
  71. head = System.Text.Encoding.UTF8.GetString(buffer)
  72. If head.Contains("""authenticated"": false") Then
  73. Console.WriteLine("Login faild" & vbLf & "Press any key to exit..")
  74. Console.ReadKey()
  75. client.Close()
  76. Return
  77. ElseIf head.Contains("""authenticated"": true") Then
  78. Console.WriteLine("Login Ok" & vbLf & "Press any key to exit..")
  79. Console.ReadKey()
  80. client.Close()
  81. Return
  82. Else
  83. Console.WriteLine("Bad status" & vbLf & "Press any key to exit..")
  84. Console.ReadKey()
  85. client.Close()
  86. Return
  87. '#End Region
  88. End If
  89. Catch
  90. Console.WriteLine("Error in request" & vbLf & "Press any key to exit..")
  91. Console.ReadKey()
  92. Return
  93. End Try
  94. End Sub
  95. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement