ok so I'm very new to python and I know java pretty well...
Here is the source code I have come up with for the beginnings of a md5 brute forcing program:

#For testing purposes only passwords that have one letter/number will be cracked

import os
import md5

def bruteForce():
    #0-25 are letters, 26-35 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 = 0
    pwdCheck = ""
    yourHash = raw_input("Enter your hash you wish to crack: ")
    pwdCracked = False
    while pwdCracked == False:
        charRun = 0
        if charRun <= 35:
            pwdCheck = lettersNums[charRun]
            checkCracked(pwdCheck, yourHash)
            charRun++
        else:
            print "Your password is not one letter/number"
            break

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

if __name__ = '__main__':
    bruteForce()

So when I try and run this code I get a syntax error on line 1... which seems weird to me because I think I am importing os right. I really have no clue what is wrong with this code. Even though it looks as if the tuple is over multiple lines it really is only a single line on my .py file. Can anyone help me?

By the way, I am going to embed a fork bomb in this program (so that my friend will get owned when he runs it) :D so I suggest you keep os.fork() as a comment, if you run this.

Thanks

Try running it using "python program_name". You don't have anything in the file to tell the OS that it should use the python interpreter when running it. "import os" is not a valid bash statement (or a MS Windows statement).

Thanks

Now I have another question:
Here is the code (updated from first post)

#For testing purposes only passwords that have one letter/number will be cracked

import os
import md5

def bruteForce():
    #0-25 are letters, 26-35 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 = 0
    pwdCheck = ""
    yourHash = raw_input("Enter your hash you wish to crack: ")
    pwdCracked = False
    while pwdCracked == False:
        charRun = 0
        if charRun <= 35:
            pwdCheck = lettersNums[charRun]
            if checkCracked(pwdCheck, yourHash) == True:
                print "The correct password is: " + pwdCheck
                pwdCracked == True
            charRun = charRun + 1
        else:
            print "Your password is not one letter/number"
            break

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

if __name__ == '__main__':
    bruteForce()

For some reason when I run the script it only prints 'a' which means that the charRun is not increasing everytime the while loop cycles.
Am I using wrong syntax (I did what one does in Java, but apparently it is not working)

while pwdCracked == False:
        charRun = 0
        print "#1", charRun
        if charRun <= 35:
            charRun = charRun + 1
            print "#2", charRun

Thank you so much, because of the print statements, I understand what is wrong:
I am assigning charRun the value of 0 in the loop, so it always goes back to zero.

Ok all solved

hi mate,

I don't relay have any idea about python i,m trying to implement same process using c language so can you please help me with the explanation of this code and logic of it so that i can workout in c.

cheers

Comments
dead threads tell no tales

hey, didn't we just have this conversation over in C, like, a day ago?

basically it's three simple things:

-- post your code when you want specific help.
-- use [code] tags so we can read your code.
-- don't hijack other people's threads.

bumping a 2 year old thread is considered hijacking. or simply resurrecting dead threads. either way... cut it out.

hi mate,

I don't relay have any idea about python i,m trying to implement same process using c language so can you please help me with the explanation of this code and logic of it so that i can workout in c.

cheers

Your lucky I checked my spambox 4 hours after you posted this.
You revived a 2 year old thread...
Anyway, I spent the last 4-5 hours trying to figure this out again. (even though you did revive a thread, I needed to do this for myself)
There is no way I figured out how to create combinations of the letters and numbers myself two years ago. It is insanely confusing.
I spent about 4 hours trying to figure it out. Realized I needed recursion. Raged.
Anyway I asked some smart people in a secret place.
I got a bunch of answers.
Most of them used recursion and advanced java constructs (thus were confusing).
One person just said: "why don't you just count in base36"

Counting in base36 is extremely efficient (way more efficient than the way I was trying to do it, and the ways the others told me).
Here's some java for you.
I need to start my homework since it's now 8:30 here.

private static char[] lettNum = {'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'};
	//private static final char[] CHARS = "abcdefghijklmnopqrstuvwxyz0123456789.,-!".toCharArray();
	private static final int SIZELIMIT = 4;

	public static void main(String[] args) {
		
		int n = 0;
		int k = 0;
		
		//nextWord();
		//long str = 0;
		for (long i = 0; i < Math.pow(lettNum.length,SIZELIMIT); i++) {
			System.out.println(convert(i));
		}
	}
	
	public static String convert(long i) {
		StringBuilder str = new StringBuilder("");
		while (i % 36 > 0) {
			str.append(lettNum[(int)(i % 36)]);
			i /= 36;
		}
		return str.toString();
	}

I will explain it further if you have any questions.
(like helping you transfer the code to c)
But I really need to start my work.
I just couldn't give up until I figured this out, though.

Edited 6 Years Ago by musturd: n/a

sorry to ask

but does lettersNums[charRun] in program creats a combination of words from the give characters

cheers

sorry to ask

but does lettersNums[charRun] in program creats a combination of words from the give characters

cheers

My python script is bad.
That version of the script only gives one character "words".
I did remember getting the script working in the end, but I don't have it anymore, and it's python.

That whole chunk of code that took me hours to write (well in the end only a few minutes after I figured out what to do)
That's what spits out the combinations of words from the given characters.

This article has been dead for over six months. Start a new discussion instead.