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


Groups > comp.lang.python > #60560

Re: Cracking hashes with Python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'algorithm': 0.04; 'position,': 0.05; 'subject:Python': 0.06; 'sys': 0.07; 'string': 0.09; '#print': 0.09; 'width': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'def': 0.12; '&gt;&gt;': 0.16; '1):': 0.16; 'basestring):': 0.16; 'bit.': 0.16; 'characters:': 0.16; 'hashes': 0.16; 'hashlib': 0.16; 'improper': 0.16; 'md5': 0.16; 'string:': 0.16; 'sys.exit(1)': 0.16; 'values:': 0.16; '\xa0def': 0.16; 'skip:= 10': 0.16; 'wrote:': 0.18; '&lt;': 0.19; 'skip:f 30': 0.19; 'working.': 0.19; '8bit%:5': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '"you': 0.24; 'char': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; '8bit%:3': 0.30; 'converting': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; '"")': 0.31; '&quot;': 0.31; 'skip:= 20': 0.31; 'anyone': 0.31; 'skip:c 30': 0.32; 'url:python': 0.33; 'trouble': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'passwords': 0.36; 'skip:s 60': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'nov': 0.38; 'skip:. 20': 0.38; 'pm,': 0.38; 'rather': 0.38; '8bit%:6': 0.40; 'url:mail': 0.40; 'algorithms': 0.60; 'skip:c 50': 0.60; 'length': 0.61; 'email addr:gmail.com': 0.63; 'here': 0.66; '26,': 0.68; 'topic,': 0.81; 'url:gif': 0.82; 'url:images': 0.83; 'cryptography': 0.91; 'works!': 0.91; 'to:none': 0.92; '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=txM2uAVRd4Kz3k8L0j7X94RjOTtxecaFnxBCxUYt9LI=; b=hUSPNIbg1FdT/auHO9r4ReDD+nZc0xDQjxwloiO7Hl2FrdVBp8X3iKLKii9FbekXbh lxAVvcRUt1lT7N0Jp31ElaLaDfsx2KXLJc179tVY3N5bwqNe4lm72aWOpLQzfXjLY6ax 3pSL/LGTHtD0PhkQ58x6sgGILtSIxzkvqk7gyyOTjYZEj4g2BNinHzr43TdfAIRSEZkw Z8LqyQMS/sEOfOTNRtAlH4Xj4RNYbhkYbyGToPh8yLEmaHfM0qpnOySoeSlhqbdo4RxC IOh6guCZ5wQdmJ0FDqh2yuwLhxaOf71tzue6UCEg2ZJSCEDnoLXUUGiMbB2L81IYcxOn SaxQ==
MIME-Version 1.0
X-Received by 10.180.198.170 with SMTP id jd10mr20082450wic.65.1385507175511; Tue, 26 Nov 2013 15:06:15 -0800 (PST)
In-Reply-To <l72oj3$ghd$2@dont-email.me>
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>
Date Tue, 26 Nov 2013 23:06:15 +0000
Subject Re: Cracking hashes with Python
From "TheRandomPast ." <wishingforsam@gmail.com>
Cc python-list@python.org
Content-Type multipart/alternative; boundary=047d7b62509e07c1cc04ec1c8720
X-Mailman-Approved-At Wed, 27 Nov 2013 01:44:43 +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.3267.1385513084.18130.python-list@python.org> (permalink)
Lines 164
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385513084 news.xs4all.nl 15946 [2001:888:2000:d::a6]:54650
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60560

Show key headers only | View raw


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

This is my code

import md5
import sys

def chklength(hashes):
    if len(hashes) != 32:
        print '[-] Improper length for md5 hash.'
        sys.exit(1)
characters=range(48,57)+range(65,90)+range(97,122)
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=input("Choose method:1=Brute Force; 0=Dictionary")
if(option==1):
    chklength()
    brute_force()
else:
    if(option==0):
        File=open("dict.txt")
        chklength()
        dictionary()
    else:
        print "You picked wrong!"

IT WORKS! ...(Almost) My chklength isn't working. Can anyone see why not?
I'm stumped.


On Tue, Nov 26, 2013 at 6:17 PM, Denis McMahon <denismfmcmahon@gmail.com>wrote:

> On Tue, 26 Nov 2013 02:30:03 -0800, TheRandomPast wrote:
>
> >>    for value in values:
> >         print value
>
> ..........^^^^^^^^^^^
>
> so change this to:
>           crackMD5Hash( value )
>
> >> import hashlib
> >> def crackMD5Hash():
>
> Nah ....
>
> def crackMD5Hash( hash ):
>         print "cracking hash:", hash
>         some code goes here ...
>         print "original string was:", result
>
> Algorithms for cracking md5 hashes is not a python topic, but rather a
> cryptography topic. When you find an algorithm to use, then if you have
> trouble converting it into code we may be able to help with that bit.
>
> --
> Denis McMahon, denismfmcmahon@gmail.com
> --
> 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