My script works perfectly now!!! :)
This is my first script too!!
The problem is that this code sucks. I hate to bash my own code, but it is really inefficient and I am sure that there is a better way to perform the brute force.

Here is the code, but be warned it is very long and annoying:

import os
import md5

def bruteForce():
    #1-26 are letters, 27-36 are nums
    lettersNums = ('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
    charRun = 1
    charRun1 = 0
    charRun2 = 0
    charRun3 = 0
    charRun4 = 0
    charRun5 = 0
    charRun6 = 0
    charRun7 = 0
    charRun8 = 0
    charRun9 = 0
    charRun10 = 0
    charRun11 = 0
    charRun12 = 0
    charRun13 = 0
    charRun14 = 0
    charRun15 = 0
    pwdCheck = ""
    verboseCheck = False
    yourHash = raw_input("Enter your hash you wish to crack: ")
    verbose = raw_input("Enable verbose mode? (y/n): ")
    if verbose == "y":
        verboseCheck = True
    else:
        verboseCheck = False
    pwdCracked = False
    while pwdCracked == False:
        if charRun <= 36:
            pwdCheck = lettersNums[charRun] + lettersNums[charRun1] + lettersNums[charRun2] + lettersNums[charRun3] + lettersNums[charRun4] + lettersNums[charRun5] + lettersNums[charRun6] + lettersNums[charRun7] + lettersNums[charRun9] + lettersNums[charRun10] + lettersNums[charRun11] + lettersNums[charRun12] + lettersNums[charRun13] + lettersNums[charRun14] + lettersNums[charRun15]
            if checkCracked(pwdCheck, yourHash, verboseCheck) == True:
                print "The correct password is: ", pwdCheck
                pwdCracked == True
                break
            charRun = charRun + 1
        elif charRun == 37:
            if charRun1 <= 36:
                charRun1 = charRun1 + 1
                charRun = 1
        if charRun1 == 37:
            if charRun2 <= 36:
                charRun2 = charRun2 + 1
                charRun1 = 1
                charRun = 1
        if charRun2 == 37:
            if charRun3 <= 36:
                charRun3 = charRun3 + 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun3 == 37:
            if charRun4 <= 36:
                charRun4 = charRun4 + 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun4 == 37:
            if charRun5 <= 36:
                charRun5 = charRun5 + 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun5 == 37:
            if charRun6 <= 36:
                charRun6 = charRun6 + 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun6 == 37:
            if charRun7 <= 36:
                charRun7 = charRun7 + 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun7 == 37:
            if charRun8 <= 36:
                charRun8 = charRun3 + 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun8 == 37:
            if charRun9 <= 36:
                charRun9 = charRun3 + 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun9 == 37:
            if charRun10 <= 36:
                charRun10 = charRun3 + 1
                charRun9 = 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun10 == 37:
            if charRun11 <= 36:
                charRun11 = charRun3 + 1
                charRun10 = 1
                charRun9 = 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun11 == 37:
            if charRun12 <= 36:
                charRun12 = charRun3 + 1
                charRun11 = 1
                charRun10 = 1
                charRun9 = 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun12 == 37:
            if charRun13 <= 36:
                charRun13 = charRun3 + 1
                charRun12 = 1
                charRun11 = 1
                charRun10 = 1
                charRun9 = 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun13 == 37:
            if charRun14 <= 36:
                charRun14 = charRun3 + 1
                charRun13 = 1
                charRun12 = 1
                charRun11 = 1
                charRun10 = 1
                charRun9 = 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun14 == 37:
            if charRun15 <= 36:
                charRun15 = charRun3 + 1
                charRun14 = 1
                charRun13 = 1
                charRun12 = 1
                charRun11 = 1
                charRun10 = 1
                charRun9 = 1
                charRun8 = 1
                charRun7 = 1
                charRun6 = 1
                charRun5 = 1
                charRun4 = 1
                charRun3 = 1
                charRun2 = 1
                charRun1 = 1
                charRun = 1
        if charRun15 == 37:
            print "Your password is either more than 16 characters or contains an illegal character"
            break

def checkCracked(pwdCheck2, yourHash2, verbose):
    getHash = md5.new(pwdCheck2).hexdigest()
    if verbose == True:
        print pwdCheck2
    #os.fork()
    if getHash == yourHash2:  
        return True  
    else:  
       return False  

if __name__ == '__main__':
    bruteForce()

Does anyone no a way to make this script run faster i.e. shorten it somehow. Thanks.

Using a list would make your code shorter:

"""
charRun = 1
charRun1 = 0
charRun2 = 0
charRun3 = 0
charRun4 = 0
charRun5 = 0
charRun6 = 0
charRun7 = 0
charRun8 = 0
charRun9 = 0
charRun10 = 0
charRun11 = 0
charRun12 = 0
charRun13 = 0
charRun14 = 0
charRun15 = 0
"""

# the above cries out for a list
charRun = [1] + [0]*15

# test it ...
print charRun     # [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print charRun[0]  # 1
print charRun[5]  # 0  same as charRun5 in your code

"""
if charRun12 == 37:
    if charRun13 <= 36:
        charRun13 = charRun3 + 1
        charRun12 = 1
        charRun11 = 1
        charRun10 = 1
        charRun9 = 1
        charRun8 = 1
        charRun7 = 1
        charRun6 = 1
        charRun5 = 1
        charRun4 = 1
        charRun3 = 1
        charRun2 = 1
        charRun1 = 1
        charRun = 1
"""

# here you do something like
charRun[12] = 37  # for testing only
if charRun[12] == 37:
    if charRun[13] <= 36:
        charRun[13] = charRun[3] + 1
        for k in range(13):
            charRun[k] = 1

# test it ...
print charRun  # [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]

Using a list would make your code shorter:

# here you do something like
charRun[12] = 37  # for testing only
if charRun[12] == 37:
    if charRun[13] <= 36:
        charRun[13] = charRun[3] + 1
        for k in range(13):
            charRun[k] = 1

# test it ...
print charRun  # [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]

I'll try that, thanks
EDIT: IT WORKS!!
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.