useParallel::ForkManager;
$pm = new Parallel::ForkManager($MAX_PROCESSES);foreach $data (@all_data){# Forks and returns the pid for the child:my $pid = $pm->start andnext;# do some work with $data in the child process ...
$pm->finish;# Terminates the child process}
寫了一個 Parallel 的 MD5 Bruteforce Cracker
#!/usr/bin/perluse5.012;use warnings;# MD5 Hash Bruteforce Kit# original version by Iman Karim (iman.karim@smail.inf.fh-bonn-rhein-sieg.de)# http://home.inf.fh-rhein-sieg.de/~ikarim2s/# modified by xatier (xatierlike @gmail.com)# Date : 10/15 2012# This Cracker is by far not the fastest! only used to find "lost" passwords ;)# run on my ubuntu server :Pmy $ver ="02";useDigest::MD5qw(md5_hex);useTime::HiResqw(gettimeofday);useParallel::ForkManager;# for parallel crackingour $MAX_PROCESS_NUMBER =25;# charsetmy $alpha ="";
$alpha .="abcdefghijklmnopqrstuvwxyz"if($ARGV[0]=~"a");
$alpha .="ABCDEFGHIJKLMNOPQRSTUVWXYZ"if($ARGV[0]=~"A");
$alpha .="1234567890"if($ARGV[0]=~"d");
$alpha .="~!@#\$%^&*()_+`-=[]\\{}|;':\",./<>?"if($ARGV[0]=~"x");
usage()if($alpha eq""or $ARGV[3]eq"");if(length($ARGV[3])!=32){die"Sorry but it seems that the MD5 is not valid!\n";};
say "Selected charset for attack => '$alpha'";
say "Going to Crack '$ARGV[3]'";
say "length from $ARGV[1] to $ARGV[2]...";
say "Press Enter to continue...";my $key =<>;system("mv key.txt key.txt.old");# go!for(my $t = $ARGV[1]; $t <= $ARGV[2]; $t++){
crack ($t);}sub usage { say<<EOF; Charset can be: [aAdx] a = {'a','b','c',...} A = {'A','B','C',...} d = {'1','2','3',...} x = {'!','\"',' ',...} EXAMPLES: ./md5crack.pl ad 13 900150983cd24fb0d6963f7d28e17f72 all lowercase Alphas and all digits length from 1 and 3 characters. ------------------------------ ./md5crack.pl aA 33 900150983cd24fb0d6963f7d28e17f7; all lowercase Alphas and all uppercase Alphas; exactly 3 characters. ------------------------------ ./md5crack.pl aAdx 110 900150983cd24fb0d6963f7d28e17f7; nearly every characte; length from 1 to 10 character;EOFdie"Quitting...\n";}sub crack {my $CharSet =shift;my @RawString =();my @testdata =();my @realbuf =();my $BUFSIZ = $MAX_PROCESS_NUMBER;my $data_BUFSIZ =100;my $data_count =0;my $real_count =0;push @RawString,0for(0.. $CharSet -1);do{for(my $i =0; $i < $CharSet; $i++){if($RawString[$i]>length($alpha)-1){if($i == $CharSet-1){
crack_parallel([@realbuf]);
say "Bruteforcing done with $CharSet Chars. No Results.";return;}
$RawString[$i+1]++;
$RawString[$i]=0;}}my $ret ="";
$ret .=substr($alpha,$RawString[$_],1)for(0..$CharSet-1);if($data_count < $data_BUFSIZ){push @testdata, $ret;
$data_count++;}if($data_count == $data_BUFSIZ){push @realbuf,[@testdata];
@testdata =();
$data_count =0;
$real_count++;}if($real_count == $BUFSIZ){
crack_parallel([@realbuf]);
@realbuf =();
$real_count =0;}
$RawString[0]++;}while($RawString[$CharSet-1]<length($alpha));}sub crack_parallel {my $realbuf_ref =shift;my $pm = new Parallel::ForkManager($MAX_PROCESS_NUMBER);
$pm->run_on_finish (sub{my($pid, $exit_code, $ident, $exit_signal, $core_dump, $ref)= @_;if(defined $ref){
say "$ref->[0] ==> $ref->[1]";open F,">","key.txt";
say F "$ref->[0] ==> $ref->[1]";close F;
$@ ="";# shut up, error message!die"\n**** Password Cracked! ";}});formy $r (@$realbuf_ref){# paralleize the cracking md5s
$pm->start andnext;formy $text (@$r){my $hash = md5_hex($text);
say "$ARGV[3] != $hash ($text)";if($ARGV[3]eq $hash){
$pm->finish(0,[$text, $hash]);}}
$pm->finish(0);}
$pm->wait_all_children;}
At least for the people who send me mail about a new language that they're
designing, the general advice is: do it to learn about how to write a compiler.
At the same time, much of it seems to have to do with recreating things we or
others had already done; it seems rather derivative intellectually; is there a
dearth of really new ideas?
C is peculiar in a lot of ways, but it, like many other successful things, has
a certain unity of approach that stems from development in a small group.
C was already implemented on several quite different machines and OSs, Unix was already being distributed on the PDP-11, but the portability of the whole
system was new.
C++ and Java, say, are presumably growing faster than plain C, but I bet C will
still be around.
For infrastructure technology, C will be hard to displace.
I can't recall any difficulty in making the C language definition completely
open - any discussion on the matter tended to mention languages whose inventors
tried to keep tight control, and consequent ill fate.
I'm just an observer of Java, and where Microsoft wants to go with C# is too
early to tell.
I'm not a person who particularly had heros when growing up.
I've done a reasonable amount of travelling, which I enjoyed, but not for too
long at a time.
Obviously, the person who had most influence on my career was Ken Thompson.
Over the past several years, I've been more in a managerial role.
The kind of programming that C provides will probably remain similar absolutely
or slowly decline in usage, but relatively, JavaScript or its variants, or XML,
will continue to become more central.
UNIX is basically a simple operating system, but you have to be a genius to
understand the simplicity.
Dennis Ritchie
When I read commentary about suggestions for where C should go, I often think
back and give thanks that it wasn't developed under the advice of a worldwide
crowd.
$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C)2007 Free Software Foundation, Inc.
更新步驟
$ brew install bash
$ /usr/local/bin/bash --version
GNU bash, version 4.2.37(2)-release (i386-apple-darwin12.2.0)
Copyright (C)2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
# 在最後加上裝好的 bash 新版
sudo vim /private/etc/shells
/usr/local/bin/bash
# 換過來
chsh -s /usr/local/bin/bash
$ echo $SHELL
/usr/local/bin/bash
$ echo $BASH_VERSION
4.2.37(2)-release