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


Groups > comp.lang.python > #60520

Re: Cracking hashes with Python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'represents': 0.05; 'subject:Python': 0.06; 'error:': 0.07; 'fixes': 0.07; 'assuming': 0.09; 'bytes,': 0.09; 'terminated': 0.09; 'throws': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug': 0.12; 'itself.': 0.14; 'better?': 0.16; 'collections': 0.16; 'did.': 0.16; 'display,': 0.16; 'hashes': 0.16; 'iterable,': 0.16; 'losing': 0.16; 'meanwhile,': 0.16; 'patches': 0.16; 'phase,': 0.16; 'programmer,': 0.16; 'sys.exit(0)': 0.16; 'sys.exit(1)': 0.16; 'typeerror:': 0.16; 'version;': 0.16; 'whitespace.': 0.16; 'all.': 0.16; 'wrote:': 0.18; '(not': 0.18; 'code.': 0.18; 'wed,': 0.18; 'trying': 0.19; 'things.': 0.19; 'value.': 0.19; 'thanks.': 0.20; 'help.': 0.21; 'code,': 0.22; '(in': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'adds': 0.24; "aren't": 0.24; 'unicode': 0.24; 'fairly': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'query': 0.26; 'somewhere': 0.26; 'supported': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; '(this': 0.29; 'am,': 0.29; 'character': 0.29; 'words': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'work.': 0.31; '(which': 0.31; 'code': 0.31; 'getting': 0.31; 'comments': 0.31; 'easier': 0.31; 'posting': 0.31; 'that.': 0.31; 'ball': 0.31; 'bunch': 0.31; 'file': 0.32; 'stuff': 0.32; 'option': 0.32; "we're": 0.32; 'run': 0.32; 'up.': 0.33; 'url:python': 0.33; 'running': 0.33; 'skip:& 30': 0.33; 'maybe': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'board': 0.35; 'except': 0.35; 'case,': 0.35; 'good.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'method': 0.36; 'thanks': 0.36; "i'll": 0.36; 'url:org': 0.36; 'being': 0.38; 'skip:o 20': 0.38; 'sometimes': 0.38; 'skip:& 10': 0.38; 'nov': 0.38; 'version,': 0.38; 'list,': 0.38; 'pm,': 0.38; 'that,': 0.38; 'anything': 0.39; 'functional': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'hope': 0.61; 'new': 0.61; 'course': 0.61; 'simply': 0.61; "you're": 0.61; 'you.': 0.62; "you've": 0.63; 'teaching': 0.64; 'charset:windows-1252': 0.65; 'life': 0.66; 'side': 0.67; 'between': 0.67; 'hang': 0.67; '26,': 0.68; 'to,': 0.72; '3.4': 0.84; 'clearer': 0.84; "it'd": 0.84; 'studying': 0.84; '1:18': 0.91; 'to:none': 0.92; 'differences': 0.93; '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=gVBSYmz58cwd5MZ+eulEivos5S15FjlwTr1DMqTeFJk=; b=yN2EHOEvU6ZJHa7jiwhe0ekm/ODqHxoIJcuprLprWC+2K+arb8uhvVyTMpsXO9sm+z bjepom4CJe4gu5Wjmp+h8apPci07BFoTutCR/zMw/lHmVwBARUL/DT4TwcV9ohaxO6wb MlfP4mJLw03iZVfRRG8Lgxs8SdFiAJAaCYiodw1RYS9pcKYIbUpJoAhyIVHZdHC73I2a p2VAiTapDTISDpQMIfz/5TNZaflNvK8STrjgAr0BIJ1WgxU7kJO8N07vj0mHwbcrCeIc ylXXIIRCEwE9AwGtZxxws2jOh+S4wM2kVYyczzCIBYtf6TH3o46nBpgytTmRJkka7HYI wI5Q==
MIME-Version 1.0
X-Received by 10.180.77.74 with SMTP id q10mr18531375wiw.65.1385478823792; Tue, 26 Nov 2013 07:13:43 -0800 (PST)
In-Reply-To <CAPTjJmqy+k-bNNMmH9bfwyX+q8C=6JWFTSb=34jrLWvtgK6m=w@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> <l72616$82k$1@ger.gmane.org> <CAMp65DUjvuprx1H2apoV6yPyGpZL=S=5jsjTAv6M=1gOMYffkw@mail.gmail.com> <CAPTjJmqy+k-bNNMmH9bfwyX+q8C=6JWFTSb=34jrLWvtgK6m=w@mail.gmail.com>
Date Tue, 26 Nov 2013 15:13:43 +0000
Subject Re: Cracking hashes with Python
From "TheRandomPast ." <wishingforsam@gmail.com>
Cc python-list@python.org
Content-Type multipart/alternative; boundary=f46d043bdf6a22de8f04ec15ed2c
X-Mailman-Approved-At Tue, 26 Nov 2013 16:19:56 +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.3245.1385479197.18130.python-list@python.org> (permalink)
Lines 194
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385479197 news.xs4all.nl 15961 [2001:888:2000:d::a6]:48653
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60520

Show key headers only | View raw


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

Thanks. I'll take that on board and let you know how I get on.

Thanks for all your help.


On Tue, Nov 26, 2013 at 2:46 PM, Chris Angelico <rosuav@gmail.com> wrote:

> On Wed, Nov 27, 2013 at 1:18 AM, TheRandomPast .
> <wishingforsam@gmail.com> wrote:
> > This is my code. I hope it looks better? I'm sorry if it doesn't. I'm
> trying
> > to get the hang of posting by email :)
>
> There are no BBCode tags here, so [code] doesn't help you at all.
> Other than that, looks good. Though if you're going to annotate your
> code, please mark your comments with a hash; that way, we can simply
> copy and paste your code and run it, which is a huge help. (In this
> case, I can see what's going on without running it, but that's not
> always true. Sometimes my crystal ball is faulty.)
>
> > wordlist = open('C:/dictionary.txt')
> > try:
> >     words = wordlist
> > except(IOError):
> >     print "[-] Error: Check your  path.\n"
> >     sys.exit(1)
>
> This now is functional but completely useless. You can drop this whole
> block of code.
>
> > words = open('C:/dictionary.txt')
> > print "\n",len(words),"words loaded…" (This line now throws up an error
> > where it wasn't before: TypeError: object of type 'file' has no len()
>
> The problem is that you've left out the readlines() call, so you now
> aren't looking at a list, you're looking at the file object itself.
> But take heart! A file object is iterable, so as long as you don't
> mind losing this line of status display, it'll all work.
>
> > for word in words:
> >     hash = hashlib.md5(word[:-1])
> >     value = hash.hexdigest()
>
> This is all very well, but you actually don't do anything with the
> hash and the value. Tip: This would be a good place to stash them all
> somewhere so you can look them up quickly.
>
> Side point: You're currently assuming that each word you get is
> terminated by exactly a single newline. It'd be clearer to, instead of
> slicing off the last character with the smiley [:-1] (not sure what
> that represents - maybe he has a pen lid sticking out of his mouth?),
> try stripping off whitespace. Strings have a method that'll do that
> for you.
>
> > if hashes == value:
> >     print "[+] Password is:"+word,"\n"
> >     sys.exit(0)
>
> This is where you'd look up in what you've stashed, except that at no
> point before this do you query the user for the hash to look up.
>
> I recommend you think in terms of an initialization phase, and then a
> loop in which you ask the user for input. That would be the most
> normal way to do things. As it is, there's no loop, so having an
> "exit" option is actually fairly useless.
>
> By the way, are you also learning about Python 3, or are you
> exclusively studying Python 2? Python 2 is now a dead end; no new
> features are being added to it, and it's to be supported with some bug
> fixes for a while, and then security patches only after that;
> meanwhile, Python 3 just keeps on getting better. We're now able to
> play with a beta of 3.4 that adds a bunch of fun stuff above 3.3
> (which added a veritable ton of awesomeness over 3.2), and there are
> features slated for 3.5 after that. Even if your course is teaching
> only the old version, it'd be good for you, as a programmer, to
> explore the differences in the new version; the sooner you get your
> head around the difference between Unicode strings and collections of
> bytes, the easier your life will be, and Py3 makes that distinction a
> lot clearer than Py2 did.
>
> 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