-
Notifications
You must be signed in to change notification settings - Fork 6
/
web_dir.pl
52 lines (41 loc) · 1.29 KB
/
web_dir.pl
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
#!/usr/bin/perl
# vim:ft=perl
# HTTP Directory Brute Force Scanner
# (C) 2014 Adam Ziaja <[email protected]> http://adamziaja.com
use v5.10;
use strict;
use warnings;
use Set::CrossProduct; # cpan> install Set::CrossProduct
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
if ( $#ARGV < 2 ) {
print "You must have at least 3 parameters (URL, min, max).\n";
print "perl $0 http://google.com 2 8\n";
exit 1;
}
my $target = $ARGV[0];
my $min = $ARGV[1]; # min 2
if ( $min < 2 ) {
$min = 2;
}
my $max = $ARGV[2];
my $set = [qw( a b c d e f g h i j k l m n o p q r s t u v w x y z )];
foreach my $length ( $min .. $max ) {
my $cross = Set::CrossProduct->new( [ ($set) x $length ] );
while ( my $tuple = $cross->get ) {
my $string = join '', @$tuple;
my $url = $target . '/' . $string;
my $req = HTTP::Request->new( GET => $url );
my $resp = $ua->request($req);
if ( $resp->is_success ) {
print "$url\n";
my $message = $resp->decoded_content;
#print "Received reply: $message\n";
}
#else {
# print "$url\n";
# print "HTTP GET error code: ", $resp->code, "\n";
# print "HTTP GET error message: ", $resp->message, "\n";
#}
}
}