Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net
- Public Class Login
- Dim saltz As String = "MaK9d"
- Dim urlz As String
- Dim usernamez As String
- Dim usergroupz As String
- Dim isverfifiedz As Boolean
- Sub New(ByVal URL As String)
- urlz = URL
- End Sub
- #Region "Properties"
- Public Property URL() As String
- Get
- Return urlz
- End Get
- Set(ByVal value As String)
- urlz = value
- End Set
- End Property
- Public Property isValidated() As Boolean
- Get
- Return isverfifiedz
- End Get
- Set(ByVal value As Boolean)
- isverfifiedz = value
- End Set
- End Property
- Public WriteOnly Property Salt() As String
- Set(ByVal value As String)
- saltz = value
- End Set
- End Property
- Public ReadOnly Property Username() As String
- Get
- Return usernamez
- End Get
- End Property
- Public ReadOnly Property Usergroup() As String
- Get
- Return usergroupz
- End Get
- End Property
- #End Region
- Public Function PingServer() As Boolean
- Try
- Dim wc As New WebClient()
- If wc.DownloadString(urlz + "?act=test") = "ForumConnect by Oscar" Then
- Return True
- Else
- Return False
- End If
- Catch ex As Exception
- End Try
- End Function
- Public Function Verify(ByVal Username As String, ByVal Password As String) As Boolean
- Try
- Dim rID As String = genRid()
- Dim sha1rid As String = sha1(rID + sha1(saltz))
- Dim wc As New WebClient()
- Dim sr As New StreamReader(wc.OpenRead(urlz & "?user=" & Username & "&pass=" & Password & "&rid=" & rID))
- Dim result As String = base64_decode(sr.ReadLine())
- If result.Split(":"c)(0) = "False" Then
- Return False
- ElseIf result.Split(":"c)(0) = "True" Then
- If result.Split(":"c)(3) = sha1(rID + sha1(saltz)) Then
- usernamez = result.Split(":"c)(2)
- usergroupz = result.Split(":"c)(1)
- isverfifiedz = True
- Return True
- Else
- Return False
- End If
- Else
- Return False
- End If
- Catch
- Return False
- End Try
- End Function
- Private Function base64_decode(ByVal str As String) As String
- Try
- Dim byt As Byte() = System.Convert.FromBase64String(str)
- Return System.Text.Encoding.ASCII.GetString(byt)
- Catch
- Return Nothing
- End Try
- End Function
- Private Function base64_encode(ByVal str As String) As String
- Try
- Dim b64byt As Byte() = System.Text.Encoding.ASCII.GetBytes(str)
- Return System.Convert.ToBase64String(b64byt)
- Catch
- Return Nothing
- End Try
- End Function
- Private Function genRid() As String
- Dim rnd As New Random()
- Return sha1(rnd.Next().ToString())
- End Function
- Private Function sha1(ByVal Value As String) As String
- Dim x As New System.Security.Cryptography.SHA1CryptoServiceProvider()
- Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(Value)
- data = x.ComputeHash(data)
- Dim ret As String = ""
- For i As Integer = 0 To data.Length - 1
- ret += data(i).ToString("x2").ToLower()
- Next
- Return ret
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement