<div dir="ltr">Hi, <div><br></div><div>So apparently when I've been staring at code all day and tired my brain doesn't tell my hands to type half of what I want it to. I apologise for my last post. </div><div><br></div>
<div>This is my code;</div><div><br></div><div><div>import md5</div><div>import sys</div><div><br></div><div>characters=range(48,57)+range(65,90)+range(97,122)</div><div><br></div><div>def chklength(hash):</div><div> if len(hash) != 32:</div>
<div> print '[-] Improper length for md5 hash.'</div><div> sys.exit(1)</div><div><br></div><div>def checkPassword(password):</div><div> #print password</div><div> m = md5.new(password)</div><div>
if (m.hexdigest() == hash):</div><div> print "match [" + password + "]"</div><div> sys.exit()</div><div> </div><div>def recurse(width, position, baseString):</div><div> for char in characters:</div>
<div> if (position < width - 1):</div><div> recurse(width, position + 1, baseString + "%c" % char)</div><div> checkPassword(baseString + "%c" % char)</div><div> print "Target Hash [" + hash+ " string: "+ baseString </div>
<div><br></div><div>def brute_force():</div><div> maxChars = 32</div><div> for baseWidth in range(1, maxChars + 1):</div><div> print "checking passwords width [" + `baseWidth` + "]" </div>
<div> recurse(baseWidth, 0, "")</div><div><br></div><div>def dictionary():</div><div> for line in File.readlines():</div><div> checkPassword(line.strip('\n'))</div><div>hash =raw_input("Input MD5 hash:")</div>
<div>option=raw_input("Choose method:1=Brute Force; 0=Dictionary")</div><div>if(option==1):</div><div> chklength()</div><div> brute_force()</div><div>else:</div><div> if(option==0):</div><div> File=open("C:\dictionary.txt")</div>
<div> chklength()</div><div> dictionary()</div><div> else:</div><div> print "Wrong method!"</div></div><div><br></div><div>And dictionary is working, as is the brute force however the issue I have having is with my chklength() as no matter how many characters I input it skips the !=32 and goes straight to asking the user to chose either Brute Force or Dictionary. I want an error to be shown if the hash is less than or more than 32 characters but at present this chklength() doesn't work as I thought it would.</div>
<div><br></div><div>Can anyone point out an obvious error that I am missing? </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 27, 2013 at 2:58 AM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, Nov 27, 2013 at 1:55 PM, Tim Delaney<br>
<<a href="mailto:timothy.c.delaney@gmail.com">timothy.c.delaney@gmail.com</a>> wrote:<br>
> Before I go look it up, I'm guessing that the etymology of "stumped" is<br>
> actually coming from the problem of a plough getting stuck on a stump (i.e.<br>
> can't progress any further). Not much of an issue anymore since the<br>
> invention of the stump-jump plough:<br>
> <a href="https://en.wikipedia.org/wiki/Stump-jump_plough" target="_blank">https://en.wikipedia.org/wiki/Stump-jump_plough</a><br>
><br>
<br>
</div>Australian inventiveness! We were too lazy to dig out the stumps<br>
before ploughing, so we came up with a solution.<br>
<br>
ChrisA<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>