ProgrammerNazaryman

[Perl] Md5 Cracker

Mar 22nd, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6.08 KB | None | 0 0
  1. PERL Md5 Cracjer
  2.  
  3. #!/usr/bin/perl
  4.  
  5. # * md5crack.pl
  6. # *Usage:
  7. # *./md5crack <charset> <mincount> <maxcount> <yourMD5>
  8. # *nUm/b0
  9.  
  10.  
  11. $ver = "01";
  12. $dbgtmr = "1"; #Intervall of showing the current speed + lastpassword in seconds.
  13.  
  14. if ($dbgtmr<=0){ die "Set dbgtmr to a value >=1 !\n";};
  15. use Digest::MD5 qw(md5_hex);
  16. use Time::HiRes qw(gettimeofday);
  17.  
  18. if ($ARGV[0]=~"a") {
  19. $alpha = "abcdefghijklmnopqrstuvwxyz";}
  20. if ($ARGV[0]=~"A") {
  21. $alpha = $alpha. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";}
  22. if ($ARGV[0]=~"d") {
  23. $alpha = $alpha."1234567890";}
  24. if ($ARGV[0]=~"x") {
  25. $alpha = $alpha. "!\"\$%&/()=?-.:\\*'-_:.;,";}
  26.  
  27. if ($alpha eq "" or $ARGV[3] eq "") {usage();};
  28. if (length($ARGV[3]) != 32) { die "Sorry but it seems that the MD5 is not valid!\n";};
  29.  
  30. print "Selected charset for attack: '$alpha\'\n";
  31. print "Going to Crack '$ARGV[3]'...\n";
  32.  
  33. for (my $t=$ARGV[1];$t<=$ARGV[2];$t++){
  34. crack ($t);
  35. }
  36.  
  37. sub usage{
  38. print "\n\nMD5 Hash Bruteforce Kit v_$ver\n";
  39. print "by unix_chro alias backtrack ([email protected])\n";
  40. print "Member in staff leader:elite-members,ubuntu-hackers\n\n";
  41. print "USAGE\n";
  42. print "./md5crack <charset> <mincount> <maxcount> <yourMD5>\n";
  43. print " Charset can be: [aAdx]\n";
  44. print " a = {'a','b','c',...}\n";
  45. print " A = {'A','B','C',...}\n";
  46. print " d = {'1','2','3',...}\n";
  47. print " x = {'!','\"',' ',...}\n";
  48. print "EXAMPLE FOR CRACKING A MD5 HASH\n";
  49. print "./md5crack.pl ad 1 3 900150983cd24fb0d6963f7d28e17f72\n";
  50. print " This example tries to crack the given MD5 with all lowercase Alphas and all digits.\n";
  51. print " MD5 Kit only tries combinations with a length from 1 and 3 characters.\n-------\n";
  52. print "./md5crack.pl aA 3 3 900150983cd24fb0d6963f7d28e17f72\n";
  53. print " This example tries to crack the given MD5 with all lowercase Alphas and all uppercase Alphas.\n";
  54. print " MD5 Kit only tries passwords which length is exactly 3 characters.\n-------\n";
  55. print "./md5crack.pl aAdx 1 10 900150983cd24fb0d6963f7d28e17f72\n";
  56. print " This example tries to crack the given MD5 with nearly every character.\n";
  57. print " MD5 Kit only tries combinations with a length from 1 to 10 characters.\n";
  58. die "Quitting...\n";
  59. }
  60.  
  61. sub crack{
  62. $CharSet = shift;
  63. @RawString = ();
  64. for (my $i =0;$i<$CharSet;$i++){ $RawString[i] = 0;}
  65. $Start = gettimeofday();
  66. do{
  67. for (my $i =0;$i<$CharSet;$i++){
  68. if ($RawString[$i] > length($alpha)-1){
  69. if ($i==$CharSet-1){
  70. print "Bruteforcing done with $CharSet Chars. No Results.\n";
  71. $cnt=0;
  72. return false;
  73. }
  74. $RawString[$i+1]++;
  75. $RawString[$i]=0;
  76. }
  77. }
  78. ################################################## #
  79. $ret = "";
  80. for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
  81. $hash = md5_hex($ret);
  82. $cnt++;
  83. $Stop = gettimeofday();
  84. if ($Stop-$Start>$dbgtmr){
  85. $cnt = int($cnt/$dbgtmr);
  86. print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  87. $cnt=0;
  88. $Start = gettimeofday();
  89. }
  90. print "$ARGV[3] != $hash ($ret)\n";
  91. if ($ARGV[3] eq $hash){
  92. die "\n**** Password Cracked! => $ret\n";
  93. }
  94. ################################################## #
  95. #checkhash($CharSet)."\n";
  96.  
  97. $RawString[0]++;
  98. }while($RawString[$CharSet-1]<length($alpha));
  99. }
  100.  
  101. sub checkhash{
  102. $CharSet = shift;
  103. $ret = "";
  104. for (my $i =0;$i<$CharSet;$i++){ $ret = $ret . substr($alpha,$RawString[$i],1);}
  105. $hash = md5_hex($ret);
  106. $cnt++;
  107. $Stop = gettimeofday();
  108. if ($Stop-$Start>$dbgtmr){
  109. $cnt = int($cnt/$dbgtmr);
  110. print "$cnt hashes\\second.\tLast Pass '$ret\'\n";
  111. $cnt=0;
  112. $Start = gettimeofday();
  113. }
  114.  
  115. if ($ARGV[3] eq $hash){
  116. die "\n**** Password Cracked! => $ret\n";
  117. }
  118.  
  119. }
  120.  
  121.  
  122.  
  123. ╔═══╗──────╔╗╔╗
  124. ║╔═╗║──────║╠╝╚╗
  125. ║║─╚╬═╦══╦═╝╠╗╔╬══╗
  126. ║║─╔╣╔╣║═╣╔╗╠╣║║══╣
  127. ║╚═╝║║║║═╣╚╝║║╚╬══║
  128. ╚═══╩╝╚══╩══╩╩═╩══╝
  129. ╔╗──╔═══╦═══╦════╦╗─╔╗─────╔╗
  130. ║║──║╔═╗║╔═╗║╔╗╔╗║║─║║─────║║
  131. ║║──╚╝╔╝╠╝╔╝╠╝║║╚╣╚═╝╠══╦══╣║╔╦══╦═╗
  132. ║║─╔╦╗╚╗╠╗╚╗║─║║─║╔═╗║╔╗║╔═╣╚╝╣║═╣╔╝
  133. ║╚═╝║╚═╝║╚═╝║─║║─║║─║║╔╗║╚═╣╔╗╣║═╣║
  134. ╚═══╩═══╩═══╝─╚╝─╚╝─╚╩╝╚╩══╩╝╚╩══╩╝
  135. ╔╗─╔╗─────╔╗─────────╔╗─╔╗─────╔╗
  136. ║║─║║─────║║─────────║║─║║────╔╝╚╗
  137. ║╚═╝╠══╦══╣║╔╦══╦═╦══╣╚═╝╠══╦═╩╗╔╝
  138. ║╔═╗║╔╗║╔═╣╚╝╣║═╣╔╣══╣╔═╗║╔╗║══╣║
  139. ║║─║║╔╗║╚═╣╔╗╣║═╣║╠══║║─║║╚╝╠══║╚╗
  140. ╚╝─╚╩╝╚╩══╩╝╚╩══╩╝╚══╩╝─╚╩══╩══╩═╝
  141. ╔══╗──────────╔╗
  142. ║╔╗║──────────║║
  143. ║╚╝╚╦═╦══╦═══╦╣║╔╦══╦═╗
  144. ║╔═╗║╔╣╔╗╠══║╠╣║╠╣╔╗║╔╗╗
  145. ║╚═╝║║║╔╗║║══╣║╚╣║╔╗║║║║
  146. ╚═══╩╝╚╝╚╩═══╩╩═╩╩╝╚╩╝╚╝
  147. ╔╗─╔╗─────╔╗
  148. ║║─║║─────║║
  149. ║╚═╝╠══╦══╣║╔╦╦═╗╔══╗
  150. ║╔═╗║╔╗║╔═╣╚╝╬╣╔╗╣╔╗║
  151. ║║─║║╔╗║╚═╣╔╗╣║║║║╚╝║
  152. ╚╝─╚╩╝╚╩══╩╝╚╩╩╝╚╩═╗║
  153. ─────────────────╔═╝║
  154. ─────────────────╚══╝
  155. ╔═══╗
  156. ║╔═╗║
  157. ║║─╚╬═╦══╦╗╔╗╔╗
  158. ║║─╔╣╔╣║═╣╚╝╚╝║
  159. ║╚═╝║║║║═╬╗╔╗╔╝
  160. ╚═══╩╝╚══╝╚╝╚╝
Add Comment
Please, Sign In to add comment