1 Attachment(s)
An Advanced auth system based on Hardware Identification
First of all, what is a HWID?
Quote:
Short for Hardware Identification, a security measure used by Microsoft upon the activation of the Windows operating system. As part of the Product Activation system, a unique HWID number is generated when the operating system is first installed. The HWID identifies the hardware components that the system is utilizing, and this number is communicated to Microsoft. Every 10 days and at every reboot the operating system will generate another HWID number and compare it to the original to make sure that the operating system is still running on the same device. If the two HWID numbers differ too much then the operating system will shut down until Microsoft reactivates the product.
The theory behind HWID is to ensure that the operating system is not being used on any device other than the one for which it was purchased and registered. However, problems can arise when users start replacing or adding hardware components -- such as motherboards, sound cards, CD-R drives, Ethernet adapters -- because these will generate new HWIDs, and if there are too many differences from the original installation number the system will register that the operating system has been installed on a different device than the original and subsequently shut itself down. The only way to resolve the issue is to telephone Microsoft and explain the new hardware in order to obtain a new code.
Add Modules:
- vBulletin
- vbloginsystem
- httpworker
All the imports:
Code:
Imports System.Security.Cryptography
Impcrts System.IO
Imports System.Net.Mail
Imports System.Text
Imports System.Web
Imports System.Management
Imports System.Net
Imports System
Imports System.Collections.Generic Imports System.Linq Imports DevComponents.UI Imports System.Data.SqlClient Imports System.Web.Services.Description Imports System.Configuration Imports System.Xml.Serialization Imports System.Net.CookieContainer Imports System.Net.Sockets Imports System.Data.OleDb
Imports System.Reflection
Yes, I know there are many items to quote import
Next, this procedure calls to retrieve the user of the application hardware ID and recieves and and send an email.
Code:
Public Class Form1
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Declare Function GetAnyncKeySync Lib "user32" (ByVal vKey As Long) As Integer Dim mail As New MailMessage() Dim SmtpServer
Public cpuInfo As String = String.Empty
Public hwid As String = cpuInfo
Dim strUser As String, strPass As String
Dim objSendMail As New Message
Dim strEmailAddress As String
Dim MyC As Integer
Dim MyY As Integer
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim strConnString, strSQL As String
Dim whole_file As String
Dim username() As String
Dim i As Integer
Dim txt As String
This allows the program to decrypt and read MD5 Hash encryptions
and tells the user if they are connected to the internet
Code:
Private Sub Forml_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Network.IsAvailable Then
lblConnectStatus.Text = ("Internet Status: Online")
Else
lblConnectStatus.Text = ("Internet Status: Offline") End If
strUser = ComboBoxExl.Text
Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim f As FileStream = New FileStream(TextBoxXl.Text, FileMode.Open, FileAccess.Read, FileShare.Read, 8192) f = New FileStream(TextBoxXl.Text, FileMode.Open, FileAccess.Read, FileShare.Read, 8192) md5.ComputeHash(f)
Dim ObjFSO As Object = CreateObject("Scripting.FileSystemObject") Dim objFile = ObjFSO.GetFile(TextBoxXl.Text)
Dim hash As Byte() = MD5.Hash
Dim buff As StringBuilder = New StringBuilder
Dim hashByte As Byte
For Each hashByte In hash
buff.Append(String.Format("{0:X1}", hashByte))
Next
And the rest is pretty easy, i will type this code for you :68:
Code:
Friend Function GetProcessorId() As String
Dim strProcessorId As String = String.Empty
Dim query As New SelectQuery("Win32_processor")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strProcessorId = info("processorId").ToString()
Next
Return strProcessorId
End Function
Friend Function GetMACAddress() As String
Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
Dim MACAddress As String = String.Empty
For Each mo As ManagementObject In moc
If (MACAddress.Equals(String.Empty)) Then
If CBool(mo("IPEnabled")) Then MACAddress = mo("MacAddress").ToString()
mo.Dispose()
End If
MACAddress = MACAddress.Replace(":", String.Empty)
Next
Return MACAddress
End Function
Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String
Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter))
disk.Get()
Return disk("VolumeSerialNumber").ToString()
End Function
Friend Function GetMotherBoardID() As String
Dim strMotherBoardID As String = String.Empty
Dim query As New SelectQuery("Win32_BaseBoard")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strMotherBoardID = info("SerialNumber").ToString()
Next
Return strMotherBoardID
End Function
Public Function GetHDId() As String
Dim tmpStr2 As String = ""
Dim myScop As New Management.ManagementScope("\\" & Environment.MachineName & "\root\cimv2")
Dim oQuer As New Management.SelectQuery("SELECT * FROM WIN32_DiskDrive")
Dim oResult As New Management.ManagementObjectSearcher(myScop, oQuer)
Dim oIte As Management.ManagementObject
Dim oPropert As Management.PropertyData
For Each oIte In oResult.Get()
For Each oPropert In oIte.Properties
If Not oPropert.Value Is Nothing AndAlso oPropert.Name = "Signature" Then
tmpStr2 = oPropert.Value.ToString
Exit For
End If
Next
Next
Return tmpStr2
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
Timer1.Enabled = True
TextBox1.Text = hwid
Dim cpuInfo As String = String.Empty
Dim mc As New ManagementClass("win32_processor")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo As ManagementObject In moc
If cpuInfo = "" Then
cpuInfo = mo.Properties("processorID").Value.ToString()
Exit For
End If
Next
TextBox1.Text = cpuInfo & ComboBoxEx1.Text
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient
SmtpServer.Credentials = New Net.NetworkCredential("youremail", "emailspassword")
SmtpServer.Port = 'THE PORT GOES HERE NO QUOTES OR PARENTHESIS'
SmtpServer.Host = "HOST GOES HERE"
SmtpServer.EnableSsl = True
mail.To.Add("email that receives info")
mail.From = New MailAddress("emailgoeshere")
mail.Subject = "HWID"
mail.Body = TextBox1.Text & ComboBoxEx1.Text
SmtpServer.Send(mail)
Dim wc3 As New System.Net.WebClient
Dim http3 As String = wc3.DownloadString("URL TO DATABASE.TXT OR PHP")
If http3.Contains(cpuInfo) Then
Else
MsgBox("Locked Due To Hardware ID Change", MsgBoxStyle.Information, "Check")
End If
If Login(ComboBoxEx1.Text, TextBoxX1.Text) Then
Me.Hide()
Form2.Show()
Timer1.Enabled = True
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If MessageBox.Show("Do you want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
End
Else
End If
End Sub
IMAGES:
[Only registered and activated users can see links. Click Here To Register...]
Modules
vbulletin Module Source
Code:
Imports System.Security.Cryptography
Imports System.Text
Imports System.Net
Imports System.IO
Module vbloginsystem
Public Function Login(ByVal Username As String, ByVal Password As String)
Password = MD5(Password)
Dim valid As Boolean = False
Dim data As String = "vb_login_username=" & Username & "&vb_login_password=&s=&do=login&vb_login_md5password=" & Password & "&vb_login_md5password_utf=" & Password
Try
Dim request As HttpWebRequest = WebRequest.Create("url/login.php?do=login")
request.Method = WebRequestMethods.Http.Post
request.ContentType = "application/x-www-form-urlencoded"
request.UserAgent = "-- vBulletin Vaidation --"
request.ContentLength = data.Length
Dim rStream As New StreamWriter(request.GetRequestStream)
rStream.Write(data)
rStream.Flush()
rStream.Close()
Dim response As HttpWebResponse = request.GetResponse
Dim resReader As New StreamReader(response.GetResponseStream)
Dim str As String = resReader.ReadToEnd
If str.Contains("Thank you for logging in") Then
valid = True
Else
valid = False
MsgBox("Incorrect Username/Passowrd")
End If
response.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error FORUM NAME Login!", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return valid
End Function
Public Function MD5(ByVal number As String) As String
Dim ASCIIenc As New ASCIIEncoding
Dim strReturn As String = String.Empty
Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(number)
Dim Md5Hash As New MD5CryptoServiceProvider
Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
For Each b As Byte In ByteHash
strReturn &= b.ToString("x2")
Next
Return strReturn
End Function
End Module
vbulletin module 2 Source
Code:
Public Class vBulletin
Inherits Forum
Dim vBulletinForum As New vBulletin("url/login.php?do=login", "username", "pass")
Public Sub New(ByVal url As String, ByVal username As String, _
ByVal password As String)
MyBase.New(url, url & "url/login.php?do=login", username, "vbseo_loggedin", "yes")
MyBase.logindata = "vb_login_username=" + username + "&vb_login_password=" + password + _
"&cookieuser=1&s=&securitytoken=guest&do=login&vb_login_md5password=" + Md5String(password) + _
"&vb_login_md5password_utf=" + Md5String(password)
End Sub
Public Overrides Function isLoggedIn(ByVal cookies As System.Net.CookieContainer) As Boolean
If Not IsNothing(cookies.GetCookies(New Uri(url)).Item(defaultCookieName)) Then
If cookies.GetCookies(New Uri(url)).Item(defaultCookieName).Value.Contains(defaultCookieSearch) Then
Return True
End If
End If
Return False
End Function
Private Function Md5String(ByVal v As String) As String
Dim myProv As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim b As Byte() = System.Text.Encoding.ASCII.GetBytes(v)
b = myProv.ComputeHash(b)
Dim str As String = ""
Dim i As Integer
For i = 0 To b.Length - 1
str = (str & b(i).ToString("x2").ToLower)
Next i
Return str
End Function
End Class
httpworker module source
Code:
Imports System.Net
Imports System.Text
Imports System.IO.Compression
Public Class HTTPWorker
Public Shared cookies As CookieContainer
Private data As Byte()
Public Function login(ByVal forumInstance As Forum) As Boolean
Dim request As HttpWebRequest
Dim response As HttpWebResponse
Dim stream As IO.Stream
cookies = New CookieContainer
Try
request = WebRequest.Create(forumInstance.loginUrl)
setConnectionParameters(request)
data = Encoding.ASCII.GetBytes(forumInstance.logindata)
request.ContentLength = data.Length
stream = request.GetRequestStream()
stream.Write(data, 0, data.Length)
stream.Flush()
stream.Close()
response = request.GetResponse()
If forumInstance.isLoggedIn(cookies) Then
Return True
End If
Catch ex As Exception
'do something with the exception
End Try
Return False
End Function
Public Sub setConnectionParameters(ByRef request As HttpWebRequest)
With request
.Method = "POST"
.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.ContentType = "application/x-www-form-urlencoded"
.Proxy = Nothing
.CookieContainer = cookies
.KeepAlive = True
.ServicePoint.Expect100Continue = False
.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5; FBI-version/0.07"
'.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate") if you want to speed up the steam reading (most boards support this)
End With
End Sub
'this function not implemented, it is added to show how to link the cookies from the login
Public Sub navTo()
'Dim request As HttpWebRequest
'request.CookieContainer = cookies
'etcetc: you could set idletime, speed if you simultaniously want to fire requests, headers, method (get/post), etc
End Sub
'Note: to read the result in login()
'--If you want to read the result (using compression techniques to speed it up--
'Dim responseStream As IO.Stream = response.GetResponseStream()
'If (response.ContentEncoding.ToLower().Contains("gzip")) Then
' responseStream = New GZipStream(responseStream, CompressionMode.Decompress)
'ElseIf (response.ContentEncoding.ToLower().Contains("deflate")) Then
' responseStream = New DeflateStream(responseStream, CompressionMode.Decompress)
'End If
'Dim streamReader As IO.StreamReader = New IO.StreamReader(responseStream, Encoding.Default)
'Dim result As String = streamReader.ReadToEnd().Trim()
'streamReader.Close()
'--
End Class