Advertisement
Guest User

xxxxxx

a guest
Feb 13th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1.  
  2. Imports System.IO
  3. Imports System.Net
  4. Imports System.Text
  5.  
  6. Public Class Form1
  7.  
  8. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  9. Dim html As String = GetResponse("https://instagram.com/accounts/login/", "")
  10. Dim token As String = html.Substring(html.IndexOf("csrfmiddlewaretoken")).Split(""""c)(2)
  11. Dim username As String = TextBox1.Text
  12. Dim password As String = TextBox2.Text
  13.  
  14. Dim S_B As New StringBuilder
  15. S_B.Append("csrfmiddlewaretoken=" & token)
  16. S_B.Append("&username=" & username)
  17. S_B.Append("&password=" & password)
  18.  
  19. html = GetResponse("https://instagram.com/accounts/login/", S_B.ToString, "https://instagram.com/accounts/login/")
  20.  
  21. If html.Contains("""username"":""" & username) Then
  22. MsgBox("Successfully Logged In", MessageBoxIcon.Information)
  23. ElseIf html.Contains("Please enter a correct username and password.") Then
  24. MsgBox("Invalid Username or Password", MessageBoxIcon.Error)
  25. Else
  26. MsgBox("Unable Login Error", MessageBoxIcon.Error)
  27. End If
  28. End Sub
  29.  
  30.  
  31. Dim CC As New CookieContainer
  32. Dim RQ As HttpWebRequest
  33. Dim RP As HttpWebResponse
  34. Public Function GetResponse(ByVal url As String, ByVal referer As String) As String
  35. RQ = CType(HttpWebRequest.Create(url), HttpWebRequest)
  36. RQ.CookieContainer = CC
  37.  
  38. If referer <> "" Then
  39. RQ.Referer = referer
  40. End If
  41.  
  42. RP = CType(RQ.GetResponse(), HttpWebResponse)
  43.  
  44. Return New StreamReader(RP.GetResponseStream()).ReadToEnd()
  45. End Function
  46.  
  47. Public Function GetResponse(ByVal url As String, ByVal post As String, ByVal referer As String) As String
  48. RQ = CType(HttpWebRequest.Create(url), HttpWebRequest)
  49. RQ.Method = "POST"
  50. RQ.CookieContainer = CC
  51. RQ.UserAgent = "Mozilla/4.0 (Windows NT 8.0; rv:44.0) Gecko/11100101 Firefox/41.0"
  52. If referer <> "" Then
  53. RQ.Referer = referer
  54. End If
  55. Dim byteArr() As Byte = Encoding.Default.GetBytes(post)
  56. RQ.ContentLength = byteArr.Length
  57. Dim dataStream As Stream = RQ.GetRequestStream()
  58. dataStream.Write(byteArr, 0, byteArr.Length)
  59. RP = CType(RQ.GetResponse(), HttpWebResponse)
  60. Return New StreamReader(RP.GetResponseStream()).ReadToEnd()
  61. End Function
  62. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement