r00t-err0r

MD5 Hash Bruteforce Kit

Dec 17th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.09 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # use strict; Sorry next time i'll use it ;)
  4. # MD5 Hash Bruteforce Kit
  5. # by Iman Karim ([email protected])
  6. # URL : http://home.inf.fh-rhein-sieg.de/~ikarim2s/
  7. # Date : 11.02.2007
  8. # Info[0] : This Cracker is by far not the fastest! But it helped me alot to find "lost" passwords ;)
  9. # Info[1] : Written under Kubuntu Linux (Throw away Windows!)
  10. # Info[2] : If you can code a bit perl, you can modify it to crack sha etc too...
  11. # Greets to: Invisible!
  12.  
  13. $ver = "01";
  14.  
  15. $dbgtmr = "1"; #Intervall of showing the current speed + lastpassword in seconds.
  16.  
  17.  
  18.  
  19. if ($dbgtmr<=0){ die "Set dbgtmr to a value >=1 !\n";};
  20. use Digest::MD5 qw(md5_hex);
  21. use Time::HiRes qw(gettimeofday);
  22.  
  23. if ($ARGV[0]=~"a") {
  24. $alpha = "abcdefghijklmnopqrstuvwxyz";}
  25. if ($ARGV[0]=~"A") {
  26. $alpha = $alpha. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";}
  27. if ($ARGV[0]=~"d") {
  28. $alpha = $alpha."1234567890";}
  29.  
  30. if ($ARGV[0]=~"x") {
  31.  
  32. $alpha = $alpha. "!\"\$%&/()=?-.:\\*'-_:.;,";}
  33.  
  34. if ($alpha eq "" or $ARGV[3] eq "") {usage();};
  35. if (length($ARGV[3]) != 32) { die "Sorry but it seems that the MD5 is not valid!\n";};
  36.  
  37. print "Selected charset for attack: '$alpha\'\n";
  38. print "Going to Crack '$ARGV[3]'...\n";
  39.  
  40. for (my $t=$ARGV[1];$t<=$ARGV[2];$t++){
  41. crack ($t);
  42. }
  43.  
  44. sub usage{
  45. print "\n\nMD5 Hash Bruteforce Kit v_$ver\n";
  46. print "by Iman Karim (iman.karim\@smail.inf.fh-bonn-rhein-sieg.de)\n";
  47. print "http:\/\/home.inf.fh-rhein-sieg.de\/~ikarim2s\/\n\n";
  48. print "USAGE\n";
  49.  
  50. print "./md5crack <charset> <mincount> <maxcount> <yourMD5>\n";
  51. print " Charset can be: [aAdx]\n";
  52. print " a = {'a','b','c',...}\n";
  53. print " A = {'A','B','C',...}\n";
  54. print " d = {'1','2','3',...}\n";
  55. print " x = {'!','\"',' ',...}\n";
  56. print "EXAMPLE FOR CRACKING A MD5 HASH\n";
  57. print "./md5crack.pl ad 1 3 900150983cd24fb0d6963f7d28e17f72\n";
  58. print " This example tries to crack the given MD5 with all lowercase Alphas and all digits.\n";
  59. print " MD5 Kit only tries combinations with a length from 1 and 3 characters.\n-------\n";
  60. print "./md5crack.pl aA 3 3 900150983cd24fb0d6963f7d28e17f72\n";
  61. print " This example tries to crack the given MD5 with all lowercase Alphas and all uppercase Alphas.\n";
  62. print " MD5 Kit only tries passwords which length is exactly 3 characters.\n-------\n";
  63. print "./md5crack.pl aAdx 1 10 900150983cd24fb0d6963f7d28e17f72\n";
  64. print " This example tries to crack the given MD5 with nearly every character.\n";
  65. print " MD5 Kit only tries combinations with a length from 1 to 10 characters.\n";
  66. die "Quitting...\n";
  67.  
  68. }
  69.  
  70. sub crack{
  71. $CharSet = shift;
  72. @RawString = ();
  73. for (my $i =0;$i<$CharSet;$i++){ $RawString[i] = 0;}
  74.  
  75. $Start = gettimeofday();
  76. do{
  77.   for (my $i =0;$i<$CharSet;$i++){
  78.    if ($RawString[$i] > length($alpha)-1){
  79.     if ($i==$CharSet-1){
  80.     print "Bruteforcing done with $CharSet Chars. No Results.\n";
  81.     $cnt=0;
  82.     return false;
  83.    }
  84.    $RawString[$i+1]++;
  85.    $RawString[$i]=0;
  86.    }
  87.   }
  88.  
  89. ###################################################
  90.  
  91.    $ret = "";
  92.    for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
  93.    $hash = md5_hex($ret);
  94.    $cnt++;
  95.    $Stop = gettimeofday();
  96.    if ($Stop-$Start>$dbgtmr){
  97.     $cnt = int($cnt/$dbgtmr);
  98.     print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  99.     $cnt=0;
  100.     $Start = gettimeofday();
  101.    }
  102.             print "$ARGV[3] != $hash ($ret)\n";
  103.    if ($ARGV[3] eq $hash){
  104.     die "\n**** Password Cracked! => $ret\n";
  105.    }
  106.  
  107. ###################################################
  108.  
  109.   #checkhash($CharSet)."\n";
  110.  
  111.   $RawString[0]++;
  112. }while($RawString[$CharSet-1]<length($alpha));
  113. }
  114.  
  115. sub checkhash{
  116. $CharSet = shift;
  117. $ret = "";
  118. for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
  119. $hash = md5_hex($ret);
  120. $cnt++;
  121. $Stop = gettimeofday();
  122. if ($Stop-$Start>$dbgtmr){
  123.   $cnt = int($cnt/$dbgtmr);
  124.   print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  125.   $cnt=0;
  126.   $Start = gettimeofday();
  127. }
  128.  
  129. if ($ARGV[3] eq $hash){
  130.   die "\n**** Password Cracked! => $ret\n";
  131. }
  132.  
  133.  
  134.  
  135.  
  136. }
Advertisement
Add Comment
Please, Sign In to add comment