Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60603

Re: Cracking hashes with Python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <wishingforsam@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'position,': 0.05; 'subject:Python': 0.06; 'sys': 0.07; '#print': 0.09; 'width': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '1):': 0.16; 'basestring):': 0.16; 'characters:': 0.16; 'dictionary.': 0.16; 'dig': 0.16; 'guessing': 0.16; 'improper': 0.16; 'md5': 0.16; 'missing?': 0.16; 'skips': 0.16; 'string:': 0.16; 'sys.exit(1)': 0.16; 'skip:= 10': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '&lt;': 0.19; 'australian': 0.19; 'skip:f 30': 0.19; 'solution.': 0.20; '8bit%:5': 0.22; 'input': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'char': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; '&gt;': 0.26; 'shown': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'tim': 0.29; "doesn't": 0.30; '8bit%:3': 0.30; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'getting': 0.31; 'url:wiki': 0.31; '"")': 0.31; '&quot;': 0.31; 'apparently': 0.31; 'post.': 0.31; 'skip:= 20': 0.31; 'url:wikipedia': 0.31; 'anyone': 0.31; 'skip:c 30': 0.32; 'url:python': 0.33; '(i.e.': 0.33; 'problem': 0.35; 'subject:with': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'passwords': 0.36; 'skip:f 40': 0.36; 'url:listinfo': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'half': 0.37; 'too': 0.37; 'skip:o 20': 0.38; 'skip:& 10': 0.38; '8bit%:4': 0.38; 'nov': 0.38; 'tired': 0.38; 'issue': 0.38; 'pm,': 0.38; 'either': 0.39; '8bit%:6': 0.40; 'url:mail': 0.40; 'how': 0.40; 'skip:c 50': 0.60; 'up,': 0.60; 'tell': 0.60; 'length': 0.61; 'matter': 0.61; 'more': 0.64; 'brain': 0.68; 'obvious': 0.74; 'day': 0.76; 'working,': 0.84; 'lazy': 0.91; 'to:none': 0.92; 'hands': 0.96; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=f7rx4Ut0JDJikN+gdMa8TR+mt+YKlxnUsbAO/Tck5EA=; b=fDAF6Fm5kQkrdH9v8TZvqUrfcOXzv4/W2J2nMEw3eeOWbKBxnllwROdb+dVMK9Lwgt 2mcNJA9ZTUndW4XziKs+7BslIirKq516s5+2CSThc6n5gXmtde0qs25TLuQZuod9oOvx alJN26hu7sLYn3nBtI6HhmCjbi6TC2ERGut7bKVeYxVSyQR2NgVUeeOUbkGuuzSPpZd8 tcuEf/uYEfCsuVvj7gFje58l42ZBx5AnoDOYPQ8mL7ANapYrbfSduIh1Ab86lY/o1yW+ rETvXCWRyD+8Zdnuu7TxHmNdqbfPV+szuzaz1TRXbFc94Xr5++bdyI+Tr1TexuWocaVX RVLg==
MIME-Version 1.0
X-Received by 10.180.208.4 with SMTP id ma4mr22224149wic.43.1385556041281; Wed, 27 Nov 2013 04:40:41 -0800 (PST)
In-Reply-To <CAPTjJmqRmJTbM0j43kJtY2zYwwJ4asQ6Bi2x2HeGDiDbvHRoSg@mail.gmail.com>
References <0a4ae59b-fff8-40dd-b264-823ea596ad82@googlegroups.com> <52940dbe$0$11089$c3e8da3@news.astraweb.com> <mailman.3215.1385438789.18130.python-list@python.org> <2a8225b8-da33-4db4-b83b-dcbd8a619f6c@googlegroups.com> <l72oj3$ghd$2@dont-email.me> <CAMp65DW=T3ed9V5SMUqT5AbFT2mhx+AFkvp0vqFw5_aJsY4neA@mail.gmail.com> <l73gf4$o45$1@ger.gmane.org> <CAPTjJmpcF==ZSKTr5_0wukhqWm2iNv31LpF0pL_dzbwWOCc-og@mail.gmail.com> <CAN8CLg=s3TvPx2+AAyOWswLwgg9acsE12GCH4j+wC+9ATh7gAg@mail.gmail.com> <CAPTjJmqRmJTbM0j43kJtY2zYwwJ4asQ6Bi2x2HeGDiDbvHRoSg@mail.gmail.com>
Date Wed, 27 Nov 2013 12:40:41 +0000
Subject Re: Cracking hashes with Python
From "TheRandomPast ." <wishingforsam@gmail.com>
Cc python-list@python.org
Content-Type multipart/alternative; boundary=001a11c387e0a8367004ec27e7bb
X-Mailman-Approved-At Wed, 27 Nov 2013 14:24:34 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3296.1385558675.18130.python-list@python.org> (permalink)
Lines 164
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385558675 news.xs4all.nl 15950 [2001:888:2000:d::a6]:33208
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60603

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

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.

This is my code;

import md5
import sys

characters=range(48,57)+range(65,90)+range(97,122)

def chklength(hash):
    if len(hash) != 32:
        print '[-] Improper length for md5 hash.'
        sys.exit(1)

def checkPassword(password):
    #print password
    m = md5.new(password)
    if (m.hexdigest() == hash):
        print "match [" + password + "]"
        sys.exit()

def recurse(width, position, baseString):
    for char in characters:
        if (position < width - 1):
            recurse(width, position + 1, baseString + "%c" % char)
        checkPassword(baseString + "%c" % char)
        print "Target Hash [" + hash+ " string: "+ baseString

def brute_force():
    maxChars = 32
    for baseWidth in range(1, maxChars + 1):
        print "checking passwords width [" + `baseWidth` + "]"
        recurse(baseWidth, 0, "")

def dictionary():
    for line in File.readlines():
        checkPassword(line.strip('\n'))
hash =raw_input("Input MD5 hash:")
option=raw_input("Choose method:1=Brute Force; 0=Dictionary")
if(option==1):
    chklength()
    brute_force()
else:
    if(option==0):
        File=open("C:\dictionary.txt")
        chklength()
        dictionary()
    else:
        print "Wrong method!"

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.

Can anyone point out an obvious error that I am missing?


On Wed, Nov 27, 2013 at 2:58 AM, Chris Angelico <rosuav@gmail.com> wrote:

> On Wed, Nov 27, 2013 at 1:55 PM, Tim Delaney
> <timothy.c.delaney@gmail.com> wrote:
> > Before I go look it up, I'm guessing that the etymology of "stumped" is
> > actually coming from the problem of a plough getting stuck on a stump
> (i.e.
> > can't progress any further). Not much of an issue anymore since the
> > invention of the stump-jump plough:
> > https://en.wikipedia.org/wiki/Stump-jump_plough
> >
>
> Australian inventiveness! We were too lazy to dig out the stumps
> before ploughing, so we came up with a solution.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Cracking hashes with Python TheRandomPast <wishingforsam@gmail.com> - 2013-11-25 15:32 -0800
  Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-26 10:47 +1100
    Re: Cracking hashes with Python TheRandomPast <wishingforsam@gmail.com> - 2013-11-25 16:01 -0800
      Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-26 11:19 +1100
  Re: Cracking hashes with Python Steven D'Aprano <steve@pearwood.info> - 2013-11-26 02:55 +0000
    RE: Cracking hashes with Python Frank Cui <ycui@outlook.com> - 2013-11-25 23:46 -0300
      Re: Cracking hashes with Python TheRandomPast <wishingforsam@gmail.com> - 2013-11-26 02:30 -0800
        Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-26 21:39 +1100
        Re: Cracking hashes with Python "TheRandomPast ." <wishingforsam@gmail.com> - 2013-11-26 11:46 +0000
        Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-26 23:48 +1100
        Re: Cracking hashes with Python Robert Kern <robert.kern@gmail.com> - 2013-11-26 13:00 +0000
        Re: Cracking hashes with Python "TheRandomPast ." <wishingforsam@gmail.com> - 2013-11-26 14:18 +0000
          Re: Cracking hashes with Python Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-26 18:33 +0000
        Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-27 01:46 +1100
        Re: Cracking hashes with Python "TheRandomPast ." <wishingforsam@gmail.com> - 2013-11-26 15:13 +0000
        Re: Cracking hashes with Python Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-26 18:17 +0000
          Re: Cracking hashes with Python "TheRandomPast ." <wishingforsam@gmail.com> - 2013-11-26 23:06 +0000
          Re: Cracking hashes with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-27 01:04 +0000
          Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-27 13:28 +1100
          Re: Cracking hashes with Python Tim Delaney <timothy.c.delaney@gmail.com> - 2013-11-27 13:55 +1100
          Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-27 13:58 +1100
          Re: Cracking hashes with Python "TheRandomPast ." <wishingforsam@gmail.com> - 2013-11-27 12:40 +0000
            Re: Cracking hashes with Python Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-27 21:18 +0000
          Re: Cracking hashes with Python Chris Angelico <rosuav@gmail.com> - 2013-11-28 00:27 +1100
          Re: Cracking hashes with Python MRAB <python@mrabarnett.plus.com> - 2013-11-27 17:44 +0000

csiph-web