Jump to content
io.kent

Login Folosind HttpWebRequest [Source Code]

Recommended Posts

Posted

mod de autentificare folosind HttpWebrequest....

Textboxs

Textbox1 for UserName

Textbox2 For Password (put the PasswordChar to systemDefault)

Button for Login

Our Imports :

Imports System.Net 
Imports System.Text
Imports System.IO

In the Public Class Form Add This Code

Dim logincookie As CookieContainer 

Click the Button and Add this Code :

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
Dim postData As String = "http%3A%2F%2Feliteguys.org%2Fforum%2Fmember.php?action=login&username=" + TextBox1.Text & "&password=" + TextBox2.Text & "&submit=Login&action=do_login&url="
Dim tempcookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postreq As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://eliteguys.org/member.php?&action=login"), HttpWebRequest)
postreq.Method = "POST"
postreq.KeepAlive = True
postreq.CookieContainer = tempcookies
postreq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729"
postreq.ContentType = "application/x-www-form-urlencoded"
postreq.Referer = "http://eliteguys.org/member.php?&action=login"
postreq.ContentLength = byteData.Length
Dim postreqstream As Stream = postreq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postreq.GetResponse, HttpWebResponse)
tempcookies.Add(postresponse.Cookies)
logincookie = tempcookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
If thepage.Contains("You have entered an invalid username/password combination.") = True Then
MsgBox("Incorrect Username/password combination", 0, "Login error!")
Else
MsgBox("Logged in", 0, "Success!")
End If
End Sub
End Class

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...