Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Net
  3.  
  4. Public Class Login
  5. Dim saltz As String = "MaK9d"
  6. Dim urlz As String
  7. Dim usernamez As String
  8. Dim usergroupz As String
  9. Dim isverfifiedz As Boolean
  10.  
  11. Sub New(ByVal URL As String)
  12. urlz = URL
  13. End Sub
  14. #Region "Properties"
  15. Public Property URL() As String
  16. Get
  17. Return urlz
  18. End Get
  19. Set(ByVal value As String)
  20. urlz = value
  21. End Set
  22. End Property
  23.  
  24. Public Property isValidated() As Boolean
  25. Get
  26. Return isverfifiedz
  27. End Get
  28. Set(ByVal value As Boolean)
  29. isverfifiedz = value
  30. End Set
  31. End Property
  32.  
  33. Public WriteOnly Property Salt() As String
  34. Set(ByVal value As String)
  35. saltz = value
  36. End Set
  37. End Property
  38.  
  39. Public ReadOnly Property Username() As String
  40. Get
  41. Return usernamez
  42. End Get
  43. End Property
  44.  
  45. Public ReadOnly Property Usergroup() As String
  46. Get
  47. Return usergroupz
  48. End Get
  49. End Property
  50. #End Region
  51.  
  52. Public Function PingServer() As Boolean
  53. Try
  54. Dim wc As New WebClient()
  55. If wc.DownloadString(urlz + "?act=test") = "ForumConnect by Oscar" Then
  56. Return True
  57. Else
  58. Return False
  59. End If
  60. Catch ex As Exception
  61.  
  62. End Try
  63. End Function
  64.  
  65. Public Function Verify(ByVal Username As String, ByVal Password As String) As Boolean
  66. Try
  67. Dim rID As String = genRid()
  68. Dim sha1rid As String = sha1(rID + sha1(saltz))
  69. Dim wc As New WebClient()
  70.  
  71. Dim sr As New StreamReader(wc.OpenRead(urlz & "?user=" & Username & "&pass=" & Password & "&rid=" & rID))
  72. Dim result As String = base64_decode(sr.ReadLine())
  73.  
  74. If result.Split(":"c)(0) = "False" Then
  75. Return False
  76. ElseIf result.Split(":"c)(0) = "True" Then
  77. If result.Split(":"c)(3) = sha1(rID + sha1(saltz)) Then
  78. usernamez = result.Split(":"c)(2)
  79. usergroupz = result.Split(":"c)(1)
  80. isverfifiedz = True
  81. Return True
  82. Else
  83. Return False
  84. End If
  85. Else
  86. Return False
  87. End If
  88. Catch
  89. Return False
  90. End Try
  91. End Function
  92.  
  93. Private Function base64_decode(ByVal str As String) As String
  94. Try
  95. Dim byt As Byte() = System.Convert.FromBase64String(str)
  96. Return System.Text.Encoding.ASCII.GetString(byt)
  97. Catch
  98. Return Nothing
  99. End Try
  100. End Function
  101.  
  102. Private Function base64_encode(ByVal str As String) As String
  103. Try
  104. Dim b64byt As Byte() = System.Text.Encoding.ASCII.GetBytes(str)
  105. Return System.Convert.ToBase64String(b64byt)
  106. Catch
  107. Return Nothing
  108. End Try
  109.  
  110. End Function
  111.  
  112.  
  113. Private Function genRid() As String
  114. Dim rnd As New Random()
  115. Return sha1(rnd.Next().ToString())
  116. End Function
  117.  
  118.  
  119. Private Function sha1(ByVal Value As String) As String
  120. Dim x As New System.Security.Cryptography.SHA1CryptoServiceProvider()
  121. Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(Value)
  122. data = x.ComputeHash(data)
  123. Dim ret As String = ""
  124. For i As Integer = 0 To data.Length - 1
  125. ret += data(i).ToString("x2").ToLower()
  126. Next
  127. Return ret
  128. End Function
  129.  
  130. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement