forked from aequabit/LoginSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.vb
More file actions
112 lines (89 loc) · 4.25 KB
/
Code.vb
File metadata and controls
112 lines (89 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Imports System.Security.Cryptography
Imports System.Text
Public Class Form1
'ENTERED INFORMATION
Dim enteredemail As String
Dim entereduser As String
Dim enteredpw As String
Dim ctoken As String
'HWID Getter
Function GetHWID()
Dim HWID As String = System.Security.Principal.WindowsIdentity.GetCurrent.User.Value
Return HWID
End Function
'CryptoSystem by QuiteCode (DO NOT CHANGE)
Dim DES As New TripleDESCryptoServiceProvider
Dim MD5 As New MD5CryptoServiceProvider
'hash function
Function MD5Hash(value As String) As Byte()
Return MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(value))
End Function
'Encryption
Function Encrypt(input As String, Key As String) As String
DES.Key = MD5Hash(Key)
DES.Mode = CipherMode.ECB
Dim buffer As Byte() = ASCIIEncoding.ASCII.GetBytes(input)
Return Convert.ToBase64String(DES.CreateEncryptor().TransformFinalBlock(buffer, 0, buffer.Length))
End Function
Function Decrypt(encryptedstring As String, Key As String) As String
DES.Key = MD5Hash(Key)
DES.Mode = CipherMode.ECB
Dim buffer As Byte() = Convert.FromBase64String(encryptedstring)
Return ASCIIEncoding.ASCII.GetString(DES.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length))
End Function
'REGISTER FUNCTION
Private Sub btn_reg_Click(sender As Object, e As EventArgs) Handles btn_register.Click
enteredemail = reg_email.Text
entereduser = reg_user.Text
enteredpw = reg_pw.Text
Dim webbrowser1 As New WebBrowser
webbrowser1.Navigate("http://yourdomain.net/register.php?email=" & enteredemail & "&user=" & entereduser & "&pw5=" & Encrypt(enteredpw, "This is Keys") & "&hwid=" & Encrypt(GetHWID(), "This is Keys"))
Do While webbrowser1.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
Loop
If webbrowser1.DocumentText.Contains("1") Then
MessageBox.Show("Diese E-Mail und/oder der Benutzername existiert bereits in unserer Datenbank!", "E-Mail/Benutzername existiert bereits", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf webbrowser1.DocumentText.Contains("FINISHED") Then
MessageBox.Show("Benutzer erfolgreich registriert, Sie können sich nun Anmelden", "Registrierung erfolgreich", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
'LOGIN FUNCTION
Private Sub btn_login_Click(sender As Object, e As EventArgs) Handles btn_login.Click
'Security Token Generator
Dim pool As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Dim count = 0
Dim rnd As New Random
Dim strpos = ""
Dim rndtoken = ""
While count <= 16
strpos = rnd.Next(0, pool.Length)
count = count + 1
End While
rndtoken = pool(strpos)
'MD5 Generator for SecurityToken
Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim bytes() As Byte = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(rndtoken))
Dim s As String = ""
For Each i As Byte In bytes
s &= i.ToString("x2")
Next
ctoken = s
'Web Request
entereduser = login_user.Text
enteredpw = login_pw.Text
Dim webbrowser1 As New WebBrowser
webbrowser1.Navigate("http://yourdomain.net/login.php?username=" & entereduser & "&password=" & Encrypt(enteredpw, "This is Keys") & "&hwid=" & Encrypt(GetHWID, "This is Keys") & "&token=" & rndtoken)
Do While webbrowser1.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
Loop
If webbrowser1.DocumentText.Contains("wronghwid") Then
MsgBox("This PC is not authorized, Account banned.", MsgBoxStyle.Critical, "AntiPiracy")
End If
If webbrowser1.DocumentText.Contains(ctoken) Then
MessageBox.Show("Successfully logged in.")
Form2.Show()
Else
MessageBox.Show("The entered login details are invalid, please try again!")
End If
End Sub
End Class