Brute Force Example 07-22-2013, 10:56 PM
#1
I never got to finishing it, so I figured I would share it. The current code only supports MD5 hashes up to 5 characters long, however making it work for all 6 hash functions I included shouldn't be too difficult.
[code=vbnet]Module Module1
Dim charset As Char() = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray
Dim xss3 As New Stopwatch
Sub Main()
Console.Write("Enter your hash: ")
Dim hash As String = Console.ReadLine()
Console.Write("Enter the hash type (MD5/SHA1/SHA256/SHA384/SHA512/RIPEMD160): ")
Dim type As String = Console.ReadLine()
Select Case type.ToLower
Case "md5"
tryMD5(hash)
End Select
Console.Read()
End Sub
Public Function SHA1(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA1Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function SHA256(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA256Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function SHA384(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA384Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function SHA512(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA512Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function RIPEMD160(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.RIPEMD160Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function MD5(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.MD5CryptoServiceProvider
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Sub tryMD5(ByVal hash As String)
Console.Clear()
xss3.Start()
Dim temp As String
For i = 0 To charset.Length - 1
temp = MD5(charset(i))
Console.Write(vbCr & "Length 1 [" & i + 1 & "/" & charset.Length & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(i) & "! Time taken (h:m
): " & abtemp & ".")
Console.Read()
ElseIf i = charset.Length - 1 Then
Console.WriteLine(vbNewLine & "Not a 1-character string..")
For a = 0 To charset.Length - 1
For b = 0 To charset.Length - 1
temp = MD5(charset(a) & charset(b))
Console.Write(vbCr & "Length 2 [" & (a * charset.Length) + (b + 1) & "/" & Math.Pow(charset.Length, 2) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(a) & charset(b) & "! Time taken (h:m
): " & abtemp & ".")
Console.Read()
ElseIf b = charset.Length - 1 And a = charset.Length - 1 Then
Console.WriteLine(vbNewLine & "Not a 2-character string..")
For c = 0 To charset.Length - 1
For d = 0 To charset.Length - 1
For e = 0 To charset.Length - 1
temp = MD5(charset© & charset(d) & charset(e))
Console.Write(vbCr & "Length 3 [" & (c * Math.Pow(charset.Length, 2)) + (d * charset.Length) + (e + 1) & "/" & Math.Pow(charset.Length, 3) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset© & charset(d) & charset(e) & "! Time taken (h:m
): " & abtemp & ".")
Console.Read()
ElseIf e = charset.Length - 1 And d = charset.Length - 1 And c = charset.Length - 1 Then
Console.WriteLine(vbNewLine & "Not a 3-character string..")
For f = 0 To charset.Length - 1
For g = 0 To charset.Length - 1
For h = 0 To charset.Length - 1
For j = 0 To charset.Length - 1
temp = MD5(charset(f) & charset(g) & charset(h) & charset(j))
Console.Write(vbCr & "Length 4 [" & (f * Math.Pow(charset.Length, 3)) + (g * Math.Pow(charset.Length, 2)) + (h * charset.Length) + (j + 1) & "/" & Math.Pow(charset.Length, 4) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(f) & charset(g) & charset(h) & charset(j) & "! Time taken (h:m
): " & abtemp & ".")
Console.Read()
ElseIf f = charset.Length - 1 And g = charset.Length - 1 And h = charset.Length - 1 And j = charset.Length - 1 Then
For k = 0 To charset.Length - 1
For l = 0 To charset.Length - 1
For m = 0 To charset.Length - 1
For n = 0 To charset.Length - 1
For o = 0 To charset.Length - 1
temp = MD5(charset(k) & charset(l) & charset(m) & charset(n) & charset(o))
Console.Write(vbCr & "Length 4 [" & (k * Math.Pow(charset.Length, 4)) + (l * Math.Pow(charset.Length, 3)) + (m * Math.Pow(charset.Length, 2)) + (n * charset.Length) + (o + 1) & "/" & Math.Pow(charset.Length, 5) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(f) & charset(g) & charset(h) & charset(j) & "! Time taken (h:m
): " & abtemp & ".")
Console.Read()
End If
Next
Next
Next
Next
Next
End If
Next
Next
Next
Next
End If
Next
Next
Next
End If
Next
Next
End If
Next
End Sub
End Module[/code]
Here's a paste link so it's easier to see: http://hastebin.com/keyegicabo.vbs
[code=vbnet]Module Module1
Dim charset As Char() = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray
Dim xss3 As New Stopwatch
Sub Main()
Console.Write("Enter your hash: ")
Dim hash As String = Console.ReadLine()
Console.Write("Enter the hash type (MD5/SHA1/SHA256/SHA384/SHA512/RIPEMD160): ")
Dim type As String = Console.ReadLine()
Select Case type.ToLower
Case "md5"
tryMD5(hash)
End Select
Console.Read()
End Sub
Public Function SHA1(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA1Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function SHA256(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA256Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function SHA384(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA384Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function SHA512(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.SHA512Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function RIPEMD160(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.RIPEMD160Managed
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Function MD5(ByVal Input As String)
Dim enc As New Text.UTF8Encoding
Dim i As Byte() = enc.GetBytes(Input)
Dim s As New Security.Cryptography.MD5CryptoServiceProvider
Dim b As Byte() = s.ComputeHash(i)
Dim retString As String = ""
For Each x As Byte In b
retString &= x.ToString("x2")
Next
Return retString
End Function
Public Sub tryMD5(ByVal hash As String)
Console.Clear()
xss3.Start()
Dim temp As String
For i = 0 To charset.Length - 1
temp = MD5(charset(i))
Console.Write(vbCr & "Length 1 [" & i + 1 & "/" & charset.Length & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(i) & "! Time taken (h:m
![Confused Confused](https://sinister.ly/images/smilies/set/confused.png)
Console.Read()
ElseIf i = charset.Length - 1 Then
Console.WriteLine(vbNewLine & "Not a 1-character string..")
For a = 0 To charset.Length - 1
For b = 0 To charset.Length - 1
temp = MD5(charset(a) & charset(b))
Console.Write(vbCr & "Length 2 [" & (a * charset.Length) + (b + 1) & "/" & Math.Pow(charset.Length, 2) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(a) & charset(b) & "! Time taken (h:m
![Confused Confused](https://sinister.ly/images/smilies/set/confused.png)
Console.Read()
ElseIf b = charset.Length - 1 And a = charset.Length - 1 Then
Console.WriteLine(vbNewLine & "Not a 2-character string..")
For c = 0 To charset.Length - 1
For d = 0 To charset.Length - 1
For e = 0 To charset.Length - 1
temp = MD5(charset© & charset(d) & charset(e))
Console.Write(vbCr & "Length 3 [" & (c * Math.Pow(charset.Length, 2)) + (d * charset.Length) + (e + 1) & "/" & Math.Pow(charset.Length, 3) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset© & charset(d) & charset(e) & "! Time taken (h:m
![Confused Confused](https://sinister.ly/images/smilies/set/confused.png)
Console.Read()
ElseIf e = charset.Length - 1 And d = charset.Length - 1 And c = charset.Length - 1 Then
Console.WriteLine(vbNewLine & "Not a 3-character string..")
For f = 0 To charset.Length - 1
For g = 0 To charset.Length - 1
For h = 0 To charset.Length - 1
For j = 0 To charset.Length - 1
temp = MD5(charset(f) & charset(g) & charset(h) & charset(j))
Console.Write(vbCr & "Length 4 [" & (f * Math.Pow(charset.Length, 3)) + (g * Math.Pow(charset.Length, 2)) + (h * charset.Length) + (j + 1) & "/" & Math.Pow(charset.Length, 4) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(f) & charset(g) & charset(h) & charset(j) & "! Time taken (h:m
![Confused Confused](https://sinister.ly/images/smilies/set/confused.png)
Console.Read()
ElseIf f = charset.Length - 1 And g = charset.Length - 1 And h = charset.Length - 1 And j = charset.Length - 1 Then
For k = 0 To charset.Length - 1
For l = 0 To charset.Length - 1
For m = 0 To charset.Length - 1
For n = 0 To charset.Length - 1
For o = 0 To charset.Length - 1
temp = MD5(charset(k) & charset(l) & charset(m) & charset(n) & charset(o))
Console.Write(vbCr & "Length 4 [" & (k * Math.Pow(charset.Length, 4)) + (l * Math.Pow(charset.Length, 3)) + (m * Math.Pow(charset.Length, 2)) + (n * charset.Length) + (o + 1) & "/" & Math.Pow(charset.Length, 5) & "]")
If temp = hash.ToLower Then
xss3.Stop()
Dim abtemp As String = xss3.Elapsed.Duration.ToString
Console.WriteLine(vbNewLine & "Your hash is equal to " & charset(f) & charset(g) & charset(h) & charset(j) & "! Time taken (h:m
![Confused Confused](https://sinister.ly/images/smilies/set/confused.png)
Console.Read()
End If
Next
Next
Next
Next
Next
End If
Next
Next
Next
Next
End If
Next
Next
Next
End If
Next
Next
End If
Next
End Sub
End Module[/code]
Here's a paste link so it's easier to see: http://hastebin.com/keyegicabo.vbs
![[Image: CDUAq9d.png]](http://i.imgur.com/CDUAq9d.png)