Current time: 01-08-2010, 07:06 AM | Shoutbox Hello There, Guest! (LoginRegister)


Post Reply  Post Thread 
[Perl] MD5 Brute forcer
Author Message
Langy
Administrator
*******


Posts: 8.460
Group: Administrators
Joined: Sep 2007
Status: Offline
Reputation: 10
Post: #1
[Perl] MD5 Brute forcer

Code:
#!/usr/bin/perl

# use strict; Sorry next time i'll use it ;)
# MD5 Hash Bruteforce Kit
# by Iman Karim (iman.karim@smail.inf.fh-bonn-rhein-sieg.de)
# URL : http://home.inf.fh-rhein-sieg.de/~ikarim2s/
# Date : 11.02.2007
# Info[0] : This Cracker is by far not the fastest! But it helped me alot to find "lost" passwords ;)
# Info[1] : Written under Kubuntu Linux (Throw away Windows!)
# Info[2] : If you can code a bit perl, you can modify it to crack sha etc too...
# Greets to: Invisible!

$ver = "01";

$dbgtmr = "1"; #Intervall of showing the current speed + lastpassword in seconds.



if ($dbgtmr<=0){ die "Set dbgtmr to a value >=1 !\n";};
use Digest::MD5 qw(md5_hex);
use Time::HiRes qw(gettimeofday);

if ($ARGV[0]=~"a") {
$alpha = "abcdefghijklmnopqrstuvwxyz";}
if ($ARGV[0]=~"A") {
$alpha = $alpha. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";}
if ($ARGV[0]=~"d") {
$alpha = $alpha."1234567890";}

if ($ARGV[0]=~"x") {

$alpha = $alpha. "!\"\$%&/()=?-.:\\*'-_:.;,";}

if ($alpha eq "" or $ARGV[3] eq "") {usage();};
if (length($ARGV[3]) != 32) { die "Sorry but it seems that the MD5 is not valid!\n";};

print "Selected charset for attack: '$alpha\'\n";
print "Going to Crack '$ARGV[3]'...\n";

for (my $t=$ARGV[1];$t<=$ARGV[2];$t++){
crack ($t);
}

sub usage{
print "\n\nMD5 Hash Bruteforce Kit v_$ver\n";
print "by Iman Karim (iman.karim\@smail.inf.fh-bonn-rhein-sieg.de)\n";
print "http:\/\/home.inf.fh-rhein-sieg.de\/~ikarim2s\/\n\n";
print "USAGE\n";

print "./md5crack <charset> <mincount> <maxcount> <yourMD5>\n";
print " Charset can be: [aAdx]\n";
print " a = {'a','b','c',...}\n";
print " A = {'A','B','C',...}\n";
print " d = {'1','2','3',...}\n";
print " x = {'!','\"',' ',...}\n";
print "EXAMPLE FOR CRACKING A MD5 HASH\n";
print "./md5crack.pl ad 1 3 900150983cd24fb0d6963f7d28e17f72\n";
print " This example tries to crack the given MD5 with all lowercase Alphas and all digits.\n";
print " MD5 Kit only tries combinations with a length from 1 and 3 characters.\n-------\n";
print "./md5crack.pl aA 3 3 900150983cd24fb0d6963f7d28e17f72\n";
print " This example tries to crack the given MD5 with all lowercase Alphas and all uppercase Alphas.\n";
print " MD5 Kit only tries passwords which length is exactly 3 characters.\n-------\n";
print "./md5crack.pl aAdx 1 10 900150983cd24fb0d6963f7d28e17f72\n";
print " This example tries to crack the given MD5 with nearly every character.\n";
print " MD5 Kit only tries combinations with a length from 1 to 10 characters.\n";
die "Quitting...\n";

}

sub crack{
$CharSet = shift;
@RawString = ();
for (my $i =0;$i<$CharSet;$i++){ $RawString[i] = 0;}

$Start = gettimeofday();
do{
  for (my $i =0;$i<$CharSet;$i++){
   if ($RawString[$i] > length($alpha)-1){
    if ($i==$CharSet-1){
    print "Bruteforcing done with $CharSet Chars. No Results.\n";
    $cnt=0;
    return false;
   }
   $RawString[$i+1]++;
   $RawString[$i]=0;
   }
  }

###################################################

   $ret = "";
   for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
   $hash = md5_hex($ret);
   $cnt++;
   $Stop = gettimeofday();
   if ($Stop-$Start>$dbgtmr){
    $cnt = int($cnt/$dbgtmr);
    print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
    $cnt=0;
    $Start = gettimeofday();
   }
            print "$ARGV[3] != $hash ($ret)\n";
   if ($ARGV[3] eq $hash){
    die "\n**** Password Cracked! => $ret\n";
   }

###################################################

  #checkhash($CharSet)."\n";

  $RawString[0]++;
}while($RawString[$CharSet-1]<length($alpha));
}

sub checkhash{
$CharSet = shift;
$ret = "";
for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
$hash = md5_hex($ret);
$cnt++;
$Stop = gettimeofday();
if ($Stop-$Start>$dbgtmr){
  $cnt = int($cnt/$dbgtmr);
  print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  $cnt=0;
  $Start = gettimeofday();
}

if ($ARGV[3] eq $hash){
  die "\n**** Password Cracked! => $ret\n";
}




}


"There is no patch for human stupidity" - K. D. M.

This post was last modified: 08-11-2008 04:44 PM by Langy.

Firefox Linux Ubuntu
Browser e O.S.: 
24-06-2008 02:38 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Langy
Administrator
*******


Posts: 8.460
Group: Administrators
Joined: Sep 2007
Status: Offline
Reputation: 10
Post: #2
RE: [Perl] MD5 Brute forcer

Code:
#MD5 Cracker (GUI Version)
#d3hydr8[at]gmail[dot]com
#http://www.darkc0de.com

from Tkinter import *
import tkFileDialog, md5

class Application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.create_widget()
    def create_widget(self):
        
        self.lbl = Label(self, text = "ENTER MD5: ")
        self.lbl.grid(row = 2, column = 0, sticky = E)
        
        self.pw_ent = Entry(self, width = 32)
        self.pw_ent.grid(row = 2, column = 1, sticky = E)
        
        self.submit_bttn = Button(self, text = "Choose Wordlist", command = self.loadwords)
        self.submit_bttn.grid(row = 5, column = 1, sticky = W)
        
        self.txtbox = Text(self, width = 55, height = 8, font=('Georgia', 8), bg = "#CCC", wrap = WORD)
        self.txtbox.grid(row = 7, column = 0, columnspan = 2, sticky = W)

        self.bttn1 = Button(self, text = "Crack", font=('courier', 10, 'bold'), command = self.crack)
        self.bttn1.grid(row = 9, columnspan = 2, sticky = "WE")
    
        self.clear = Button(self, text="Clear", font=('Georgia', 8), command = self.clear)
        self.clear.grid(row = 10, column = 1,sticky= E)
        
    def loadwords(self):
        global wordlist
        file = tkFileDialog.askopenfile(parent=root,mode='r',title='Choose a file')
        wordlist = file.readlines()
        self.txtbox.insert(END, "Loaded: "+str(len(wordlist))+" words")
        
    def crack(self):
        pw = self.pw_ent.get()
        if len(pw) == 32:
            self.txtbox.insert(END, "\nCracking: "+pw)
            for word in wordlist:
                hash = md5.new(word.replace("\n","")).hexdigest()
                if pw == hash:
                    self.txtbox.insert(END, "\n\nCracked: "+word)
                    break
            self.txtbox.insert(END, "\nComplete")
        else:
            self.txtbox.insert(END, "\nImproper MD5 Length: "+str(len(pw)))
            
    def clear(self):
        self.pw_ent.delete(0, END)
           self.txtbox.delete(0.0, END)
        wordlist = []
        
root = Tk()
root.title("MD5 Cracker")
root.geometry("350x200")
app = Application(root)
root.mainloop()


"There is no patch for human stupidity" - K. D. M.
Firefox Linux Ubuntu
Browser e O.S.: 
08-11-2008 04:28 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Perl] RFI Scanner Langy 5 71.260 20-05-2010 08:55 AM
Last Post: tms
  [Perl] FTP Scanner Langy 1 5.135 11-03-2010 03:08 AM
Last Post: nidou

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites