ก็เลยเอา code แนวๆ brute md5 ที่เคยเขียนไว้มาลงไว้ใน blog หน่อย
#!/usr/bin/perl -w
# Copyright (c) 2011 by windows98SE
#
# This software is open source, licensed under the GNU General Public
# License, version 2.
# Basically, this means that you're allowed to modify and distribute
# this software. However, if you distribute modified versions, you MUST
# also distribute the source code.
# See http://www.gnu.org/licenses/gpl.html for the full license.
use Digest::MD5 qw(md5_hex);
my $debug = 1;
my $debug_report = 5000000;#or 1000000, 99999999999999999 (if you don't want report)
my $start_time = time();
my $end_time;
my $file = 'crackme.txt';
my $cracked_out_file = 'cracked.txt';
my %hashlist = readFile($file);
print "[+] uncracked ".scalar(keys(%hashlist))." hash loaded\n";
my %passlist = (
#name => aaa-nnn,
'1 basic' => '000000-999999',
'2 basic' => '0000000-9999999',
'3 basic' => '00000000-99999999',
'4 mobile 081' => '0810000000-0819999999',
'5 mobile 085' => '0850000000-0859999999',
'6 mobile 086' => '0860000000-0869999999',
'7 mobile 089' => '0890000000-0899999999',
'8 mobile 080' => '0800000000-0809999999',
'9 bkk_tel' => '0200000000-0299999999',
'10 az_4' => 'aaaa-zzzz',
'11 az_5' => 'aaaaa-zzzzz',
'12 az_6' => 'aaaaaa-zzzzzz',
'13 az_7' => 'aaaaaaa-zzzzzzz',
'14 az_8' => 'aaaaaaaa-zzzzzzzz',
);
foreach my $list (sort keys %passlist){
my ($start, $stop) = split(/\-/,$passlist{$list});
print "[+] start crack mode $list : $start - $stop\n";
&crack_md5hash_list($start, $stop);
}
print "Time taken was ", time_format(time()-$start_time), "\n";
sub crack_md5hash_list {
my $count = 1;
my $start = $_[0];
my $stop = $_[1];
foreach my $tmp ($start..$stop){
if($count%$debug_report==0 && $debug){print "[-] $tmp : uncracked = ".scalar(keys(%hashlist))." ea. ".time_format(time()-$start_time)."\n";}
my $md5tmp = md5_hex($tmp);
if($hashlist{$md5tmp}){
print "[!] cracked ==> $md5tmp : $tmp (", time_format(time()-$start_time), ")\n";
delete($hashlist{$md5tmp});
open OUTFILE, ">> $cracked_out_file" or die "Can't open $cracked_out_file : $!";
print OUTFILE "$md5tmp:$tmp\n";
close OUTFILE;
if(scalar(keys(%hashlist)) == 0){
print "[+] cracked done\n";
$end_time = time();
print "[+] Time taken was ", time_format(time()-$start_time), "\n";
exit;
}
}
$count++;
}
}
sub time_format{
my $return;
my $time = $_[0];
return '<1s' if($time < 1);
my $sec = int($time%60);
my $min = int($time/60);
my $hr = int($time/(60*60));
$return .= "${hr}H:" if($hr);
$return .= "${min}m:" if($min);
$return .= "${sec}s" if($sec);
return $return;
}
sub readFile{
my %var;
my $file = $_[0];
open F, "<", "$file" or die "[+] Can't open $file : $!";
while(<F>){
my @lines = split (/\r?\n/, $_);
foreach my $line (@lines){
$line =~ s/[^\x20-\x7F]//ig;
$line =~ s/\r|\n//g;
next if ($line =~ /^#/ig);
next if (length($line) == 0);
$var{$line} = 1;
}
}
close F;
return(%var);
}
No comments:
Post a Comment