MD5 brute-force cracking program (Python)

Source: Internet
Author: User

Yesterday, an MD5 brute force cracking tool was installed in Python due to a hand mark.

 

In the duration, the method for calculating the n times of the string is optimized, and version 0.2 is implemented.

 

Then I found that the generated sequence had some problems, so I switched back to v0.1 and then improved it. Low efficiency.

 

The maximum latency of the single-object string on my Intel Core Duo t6670 is 5 W string/sec

 

It is really sad that I wanted to use multiple programming threads to discover Python fake multi-programming.

 

Okay. The next generation will give you the desired ones:

 

#! /Usr/bin/ENV python <br/> #-*-coding: UTF-8-*-<br/> "" <br/> MD5 checker <br/> Version: 0.3 beta <br/> speed: 5 w/s <br/> author: zagfai <br/> time: 2011.4.9 <br/> the MIT license <br/> copyright (c) 2011 Foshan University zagfai <br/> permission is hereby granted, free of charge, to any person obtaining a copy <br/> of this software and associated documentation files (the "software"), to deal <br/> in th E software without restriction, including without limitation the Rights <br/> to use, copy, modify, merge, publish, distriense, sublicense, and/or conditions <br/> copies of the software, and to permit persons to whom the software is <br/> furnished to do so, subject to the following conditions: <br/> the above copyright notice and this permission notice shall be encoded in <br/> All copies or substantial P Ortions of the software. <br/> the software is provided "as is", without warranty of any kind, express or <br/> implied, including but not limited to the warranties of merchantability, <br/> fitness for a particle purpose and noninfringement. in no event shall the <br/> authors or copyright holders be liable for any claim, damages or other <br/> liability, whether in an action of contract, tort or ot Herwise, arising from, <br/> out of or in connection with the software or the use or other dealings in <br/> the software. </P> <p> http://www.opensource.org/licenses/mit-license.php </P> <p> "" <br/> Import OS <br/> Import sys <br/> Import MD5 <br/> import time <br/> Import string <br/> Import threading <br/> isotimeformat = '% Y/% m/% d/% x' <br/> class passwordtraveler (): <br/> "" <br/> use to make a travel from 0 T O unlimited. </P> <p> next (): <br/> return next password from pw_str to the next. <br/> This function takes the next follow this: <br/> 0 ~ 9 then ~ Z then ~ Z </P> <p> value (): <br/> return the value of this password </P> <p> set (start_string ): <br/> set the startup positon </P> <p >__ fix (): <br/> not for public use, only make the string in format we use. <br/> you can modify this if you want to enlarge the searching or enclose. <br/> "" <br/> pw_str = '0' </P> <p> def _ init _ (self, start_up = none ): <br/> If (start_up! = None): <br/> self. pw_str = start_up </P> <p> def next (Self): <br/> low_chr = CHR (ord (self. pw_str [0]) + 1) <br/> self. pw_str = STR (low_chr) + self. pw_str [1:] <br/> self. _ fix (0, Len (self. pw_str), ord (low_chr) </P> <p> def value (Self): <br/> return self. pw_str <br/> def set (self, new_str): <br/> self. pw_str = new_str </P> <p> def _ fix (self, POs, length, chr_ I): </P> <p> # print POs, length, chr_ I <br/> # print "string :" + Self. pw_str <br/> If (chr_ I = 58): <br/> If (Pos = length-1): <br/> self. pw_str = self. pw_str [: length-1] + 'A' <br/> return <br/> self. pw_str = self. pw_str [: POS] + 'A' + self. pw_str [POS + 1: length] </P> <p> Elif (chr_ I = 91): <br/> If (Pos = length-1 ): <br/> self. pw_str = self. pw_str [: length-1] + 'A' <br/> return <br/> self. pw_str = self. pw_str [: POS] + 'A' + self. pw_str [POS + 1: length] </P> <p> Elif (chr_ I = 123): <Br/> If (Pos = length-1): <br/> self. pw_str = self. pw_str [: length-1] + '00' <br/> return <br/> self. pw_str = self. pw_str [: POS] + '0' + STR (CHR (ord (self. pw_str [POS + 1]) + 1) + self. pw_str [POS + 2: length] <br/> self. _ fix (Pos + 1, length, ord (self. pw_str [POS + 1]) <br/> pass <br/> class Loger (): <br/> "" <br/> use to log the calculations. <br/> "" <br/>__ Path = "log.txt" <br/> def _ init _ (self, Path = none): <br/> I F (path! = None): <br/> self. _ Path = path <br/> def A (self, St): <br/> try: <br/> fp = open (self. _ path, "A") <br/> FP. write ('[' + time. strftime (isotimeformat, time. localtime () + ']' + st + '/N') <br/> FP. close () <br/> handle T (ioerror): <br/> Print "Write result error. "<br/> pass <br/> class config (): <br/>" "<br/> config modifier. <br/> "" <br/> lT = "" <br/> loaded = 0 <br/> def _ init _ (Self ): <br/> pass <br/> lT = "" <br/> self. L () <br/> def L (Self): <br/> # Read config. INI <br/> try: <br/> fp = open ("config. ini ") <br/> self. lt = FP. read () <br/> # For I in XT: <br/> # lt. append (I [:-1]. split ("->") <br/> # print lt <br/> FP. close () <br/> self. loaded = 1 <br/> handle T (ioerror): <br/> LG. A ("Config load error. ") </P> <p> def W (self, St): <br/> try: <br/> fp = open (" config. ini "," W ") <br/> FP. write (ST) <br/> FP. close () <br/> handle T (ioerror): <br/> LG. A ("Write config error. ") </P> <p> def at (Self): <br/> return self. lt </P> <p> class Checker (threading. thread ): <br/>__ result = [] <br/>__ endp = none <br/>__ ck_str = none </P> <p> def _ init _ (self, begin_str): <br/> threading. thread. _ init _ (Self) <br/> self. _ ck_str = begin_str <br/> self. _ result = [] <br/> self. _ endp = none </P> <p> def run (Self): <br/> TT = time. time () </P> <p> X = passwordtraveler (self. _ ck_str) <br/> for I in xrange (once_check): <br/> md5_str = md5.new (X. value ()). hexdigest () <br/> for CIP in CT: <br/> If (CIP = md5_str): <br/> self. _ result. append (X. value () + 'for' + CIP) <br/> X. next () <br/> self. _ endp = x. value () <br/> LG. A (self. getname () + "start at" + self. _ ck_str + "to" + X. value () + "in" + STR (time. time ()-TT) + "secs") </P> <p> def get_result (Self): <br/> return self. _ result, self. _ endp <br/> def readin (): <br/> # Read ciphertext <br/> try: <br/> fp = open ("ciphertext ") <br/> XT = FP. readlines () <br/> for I in XT: <br/> CT. append (I [:-1]) <br/> # print CT <br/> FP. close () <br/> handle T (ioerror): <br/> LG. A ("input file error. ") <br/> def saved (list): <br/> try: <br/> fp = open (" result.txt "," A ") <br/> FP. writelines (list [0]) <br/> FP. write ('/N') <br/> FP. close () <br/> handle T (ioerror): <br/> LG. A ("Write result error. ") <br/> Ct = [] <br/> lg = Loger () <br/> CG = config () <br/> once_check = 100000 #242234 968936 726702 <br/> def main (): <br/> readin () <br/> If Len (sys. argv) <2: <br/> starter = '0' <br/> If (CG. loaded = 1): <br/> starter = CG. at () <br/> else: <br/> starter = sys. argv [1] <br/> LG. A ("start at:" + starter) </P> <p> while 1: <br/> CK = Checker (starter) <br/> CK. start () <br/> while CK. isalive (): <br/> continue <br/> If (LEN (CK. get_result () [0])> 0): <br/> saved (CK. get_result () <br/> starter = ck. get_result () [1] <br/> CG. W (starter) </P> <p> If _ name _ = "_ main _": <br/> main () 

I have already done a good job of this kind.

 

However, you need to upload at least one file to start the operation:

CiphertextFile (text, but not end with txt). This text is used to import the object's MD5 password. Each line is 32 bits, and each password is 1 line.

 

Passwordtraveler () is the object of the character string. Use. Next () to convert it to the next string to be modified.

Loger () is a type of log

Config () is used to retrieve and merge the configuration file so that the next time the cursor is retained

Checker () is not to be mentioned anymore. It is to be used to compile logs.

 

This brute-force cracking program downloads 0 ~ 9, ~ Z and ~ Z. If you need to modify it, please understand the number of _ fix () mails in passwordtraveler () and then modify it.

 

Modify once_check = XXXXX.

 

Modify md5_str = md5.new (X. Value (). hexdigest ()

 

Basically. Have your nice time .~ 0.0

 

 

If you do not set config for the first operation, the system will remember the load error. Then, the config. ini will be generated.

 

If you need more help, please visit me. Address: me {at} zagfai.info

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.