MLWALK3R

MD5 Cracker "Perl"

Mar 10th, 2012
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.47 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  $ver = "01";
  3.  $dbgtmr = "1"; #Intervall of showing the current speed + lastpassword in seconds.
  4.  
  5.  if ($dbgtmr<=0){ die "Set dbgtmr to a value >=1 !\n";};
  6.  use Digest::MD5 qw(md5_hex);
  7.  use Time::HiRes qw(gettimeofday);
  8.  
  9.  if ($ARGV[0]=~"a") {
  10.  $alpha = "abcdefghijklmnopqrstuvwxyz";}
  11.  if ($ARGV[0]=~"A") {
  12.  $alpha = $alpha. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";}
  13.  if ($ARGV[0]=~"d") {
  14.  $alpha = $alpha."1234567890";}
  15.  if ($ARGV[0]=~"x") {
  16.  $alpha = $alpha. "!\"\$%&/()=?-.:\\*'-_:.;,";}
  17.  
  18.  if ($alpha eq "" or $ARGV[3] eq "") {usage();};
  19.  if (length($ARGV[3]) != 32) { die "Sorry but it seems that the MD5 is not valid!\n";};
  20.  
  21.  print "Selected charset for attack: '$alpha\'\n";
  22.  print "Going to Crack '$ARGV[3]'...\n";
  23.  
  24.  for (my $t=$ARGV[1];$t<=$ARGV[2];$t++){
  25.  crack ($t);
  26.  }
  27.  
  28.  sub usage{
  29.  print "\n\nMD5 Hash Bruteforce Kit v_$ver\n";
  30.  print "by unix_chro alias backtrack (311733@yahoo.com)\n";
  31.  print "Member in staff leader:elite-members,ubuntu-hackers\n\n";
  32.  print "USAGE\n";
  33.  print "./md5crack <charset> <mincount> <maxcount> <yourMD5>\n";
  34.  print " Charset can be: [aAdx]\n";
  35.  print " a = {'a','b','c',...}\n";
  36.  print " A = {'A','B','C',...}\n";
  37.  print " d = {'1','2','3',...}\n";
  38.  print " x = {'!','\"',' ',...}\n";
  39.  print "EXAMPLE FOR CRACKING A MD5 HASH\n";
  40.  print "./md5crack.pl ad 1 3 900150983cd24fb0d6963f7d28e17f72\n";
  41.  print " This example tries to crack the given MD5 with all lowercase Alphas and all digits.\n";
  42.  print " MD5 Kit only tries combinations with a length from 1 and 3 characters.\n-------\n";
  43.  print "./md5crack.pl aA 3 3 900150983cd24fb0d6963f7d28e17f72\n";
  44.  print " This example tries to crack the given MD5 with all lowercase Alphas and all uppercase Alphas.\n";
  45.  print " MD5 Kit only tries passwords which length is exactly 3 characters.\n-------\n";
  46.  print "./md5crack.pl aAdx 1 10 900150983cd24fb0d6963f7d28e17f72\n";
  47.  print " This example tries to crack the given MD5 with nearly every character.\n";
  48.  print " MD5 Kit only tries combinations with a length from 1 to 10 characters.\n";
  49.  die "Quitting...\n";
  50.  }
  51.  
  52.  sub crack{
  53.  $CharSet = shift;
  54.  @RawString = ();
  55.  for (my $i =0;$i<$CharSet;$i++){ $RawString[i] = 0;}
  56.  $Start = gettimeofday();
  57.  do{
  58.  for (my $i =0;$i<$CharSet;$i++){
  59.  if ($RawString[$i] > length($alpha)-1){
  60.  if ($i==$CharSet-1){
  61.  print "Bruteforcing done with $CharSet Chars. No Results.\n";
  62.  $cnt=0;
  63.  return false;
  64.  }
  65.  $RawString[$i+1]++;
  66.  $RawString[$i]=0;
  67.  }
  68.  }
  69.  ################################################## #
  70.  $ret = "";
  71.  for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
  72.  $hash = md5_hex($ret);
  73.  $cnt++;
  74.  $Stop = gettimeofday();
  75.  if ($Stop-$Start>$dbgtmr){
  76.  $cnt = int($cnt/$dbgtmr);
  77.  print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  78.  $cnt=0;
  79.  $Start = gettimeofday();
  80.  }
  81.  print "$ARGV[3] != $hash ($ret)\n";
  82.  if ($ARGV[3] eq $hash){
  83.  die "\n**** Password Cracked! => $ret\n";
  84.  }
  85.  ################################################## #
  86.  #checkhash($CharSet)."\n";
  87.  
  88.  $RawString[0]++;
  89.  }while($RawString[$CharSet-1]<length($alpha));
  90.  }
  91.  
  92.  sub checkhash{
  93.  $CharSet = shift;
  94.  $ret = "";
  95.  for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
  96.  $hash = md5_hex($ret);
  97.  $cnt++;
  98.  $Stop = gettimeofday();
  99.  if ($Stop-$Start>$dbgtmr){
  100.  $cnt = int($cnt/$dbgtmr);
  101.  print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  102.  $cnt=0;
  103.  $Start = gettimeofday();
  104.  }
  105.  
  106.  if ($ARGV[3] eq $hash){
  107.  die "\n**** Password Cracked! => $ret\n";
  108.  }
  109.  
  110.  }
Add Comment
Please, Sign In to add comment