Created
January 7, 2010 10:46
-
-
Save hryk/271156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Digest::SHA1 qw/sha1_hex/; | |
use Digest::MD5 qw(md5 md5_hex md5_base64); | |
use Data::Dumper; | |
my @ascii = map {pack 'C', $_} ord('a')..ord('z'); | |
push @ascii, ('-', '_'); | |
push @ascii, (0..9); | |
for my $length (0..10) { | |
print "length is $length\n"; | |
my $nestfor = sub { nestfor(\@ascii, $_[0], $_[1]); }; | |
# seed. | |
my $subref = sub { | |
my $h = shift; | |
my $url = "http://vulnerability.jp/$h.html"; | |
if (sha1_hex($url) eq 'e5877ebe3560be14d35c6eb96ffa38fee97078f0') { | |
print "Answer is $url\n"; | |
exit; | |
} | |
}; | |
# wrap. | |
if ($length != 0) { | |
$subref = gen($subref) for 1..$length; | |
} | |
# Run. | |
$nestfor->($subref, ''); | |
} | |
sub gen { | |
my $s = shift; | |
return sub {nestfor(\@ascii,$s,shift)}; | |
} | |
sub nestfor { | |
my $ary = shift; | |
my $sub = shift; | |
my $bind = shift || ''; | |
$sub->("$bind$_") for @$ary; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment