trewq343

Visual Basic vBulletin Login Module

May 31st, 2011
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Text
  2. Imports System.Net
  3. Imports System.Security.Cryptography
  4. Imports System.IO
  5. Module vbloginsystem
  6.  
  7.     Public Function Login(ByVal Username As String, ByVal Password As String)
  8.  
  9.         Password = MD5(Password)
  10.         Dim valid As Boolean = False
  11.         Dim data As String = "vb_login_username=" & Username & "&vb_login_password=&s=&do=login&vb_login_md5password=" & Password & "&vb_login_md5password_utf=" & Password
  12.  
  13.         Try
  14.             Dim request As HttpWebRequest = WebRequest.Create("http://brutalcheaters.net/login.php?do=login")
  15.             request.Method = WebRequestMethods.Http.Post
  16.             request.ContentType = "application/x-www-form-urlencoded"
  17.             request.UserAgent = "-- vBulletin Vaidation  --"
  18.  
  19.  
  20.  
  21.             request.ContentLength = data.Length
  22.  
  23.             Dim rStream As New StreamWriter(request.GetRequestStream)
  24.  
  25.             rStream.Write(data)
  26.             rStream.Flush()
  27.             rStream.Close()
  28.  
  29.             Dim response As HttpWebResponse = request.GetResponse
  30.             Dim resReader As New StreamReader(response.GetResponseStream)
  31.  
  32.             Dim str As String = resReader.ReadToEnd
  33.  
  34.  
  35.             If str.Contains("Thank you for logging in") Then
  36.                 valid = True
  37.                 Form1.Label6.Text = "Login Successful!"
  38.                 MsgBox("Thank you for logging in, " & Form1.TextBox1.Text)
  39.             Else
  40.                 MsgBox("Login Failed!")
  41.             End If
  42.  
  43.  
  44.             response.Close()
  45.  
  46.         Catch ex As Exception
  47.             MessageBox.Show(ex.Message, "Error login.php Login!", MessageBoxButtons.OK, MessageBoxIcon.Error)
  48.  
  49.         End Try
  50.  
  51.         Return valid
  52.  
  53.     End Function
  54.  
  55.     Public Function MD5(ByVal number As String) As String
  56.  
  57.         Dim ASCIIenc As New ASCIIEncoding
  58.         Dim strReturn As String = String.Empty
  59.  
  60.         Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(number)
  61.         Dim Md5Hash As New MD5CryptoServiceProvider
  62.         Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
  63.  
  64.         For Each b As Byte In ByteHash
  65.             strReturn &= b.ToString("x2")
  66.         Next
  67.  
  68.         Return strReturn
  69.  
  70.     End Function
  71. End Module
Advertisement
Add Comment
Please, Sign In to add comment