Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net
- Imports System.Text
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim html As String = GetResponse("https://instagram.com/accounts/login/", "")
- Dim token As String = html.Substring(html.IndexOf("csrfmiddlewaretoken")).Split(""""c)(2)
- Dim username As String = TextBox1.Text
- Dim password As String = TextBox2.Text
- Dim S_B As New StringBuilder
- S_B.Append("csrfmiddlewaretoken=" & token)
- S_B.Append("&username=" & username)
- S_B.Append("&password=" & password)
- html = GetResponse("https://instagram.com/accounts/login/", S_B.ToString, "https://instagram.com/accounts/login/")
- If html.Contains("""username"":""" & username) Then
- MsgBox("Successfully Logged In", MessageBoxIcon.Information)
- ElseIf html.Contains("Please enter a correct username and password.") Then
- MsgBox("Invalid Username or Password", MessageBoxIcon.Error)
- Else
- MsgBox("Unable Login Error", MessageBoxIcon.Error)
- End If
- End Sub
- Dim CC As New CookieContainer
- Dim RQ As HttpWebRequest
- Dim RP As HttpWebResponse
- Public Function GetResponse(ByVal url As String, ByVal referer As String) As String
- RQ = CType(HttpWebRequest.Create(url), HttpWebRequest)
- RQ.CookieContainer = CC
- If referer <> "" Then
- RQ.Referer = referer
- End If
- RP = CType(RQ.GetResponse(), HttpWebResponse)
- Return New StreamReader(RP.GetResponseStream()).ReadToEnd()
- End Function
- Public Function GetResponse(ByVal url As String, ByVal post As String, ByVal referer As String) As String
- RQ = CType(HttpWebRequest.Create(url), HttpWebRequest)
- RQ.Method = "POST"
- RQ.CookieContainer = CC
- RQ.UserAgent = "Mozilla/4.0 (Windows NT 8.0; rv:44.0) Gecko/11100101 Firefox/41.0"
- If referer <> "" Then
- RQ.Referer = referer
- End If
- Dim byteArr() As Byte = Encoding.Default.GetBytes(post)
- RQ.ContentLength = byteArr.Length
- Dim dataStream As Stream = RQ.GetRequestStream()
- dataStream.Write(byteArr, 0, byteArr.Length)
- RP = CType(RQ.GetResponse(), HttpWebResponse)
- Return New StreamReader(RP.GetResponseStream()).ReadToEnd()
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement