Advertisement
Guest User

VB.NET - vBulletin Login Module

a guest
May 18th, 2012
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  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://yoursite.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. MsgBox("Login Successful!", vbOKOnly + vbExclamation, "Message")
  38. Else
  39. MsgBox("Login Failed!, Please try again.", vbOKOnly + vbExclamation, "Message")
  40. End If
  41.  
  42.  
  43. response.Close()
  44.  
  45. Catch ex As Exception
  46. MessageBox.Show(ex.Message, "Error login.php Login!", MessageBoxButtons.OK, MessageBoxIcon.Error)
  47.  
  48. End Try
  49.  
  50. Return valid
  51.  
  52. End Function
  53.  
  54. Public Function MD5(ByVal number As String) As String
  55.  
  56. Dim ASCIIenc As New ASCIIEncoding
  57. Dim strReturn As String = String.Empty
  58.  
  59. Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(number)
  60. Dim Md5Hash As New MD5CryptoServiceProvider
  61. Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
  62.  
  63. For Each b As Byte In ByteHash
  64. strReturn &= b.ToString("x2")
  65. Next
  66.  
  67. Return strReturn
  68.  
  69. End Function
  70. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement