forked from Shadow-Network/perl-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory spider.pl
More file actions
33 lines (29 loc) · 756 Bytes
/
Directory spider.pl
File metadata and controls
33 lines (29 loc) · 756 Bytes
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
#!/usr/bin/perl
use strict;
use LWP::Simple qw($ua get);
$ua = LWP::UserAgent->new;
$ua->agent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.9');
my @found;
&usage unless @ARGV==3;
my $url = $ARGV[0];
my $dirlist = $ARGV[1];
my $results = $ARGV[2];
open(ifile, "<$dirlist") || die "Couldn't open file\n";
my @dirs =<ifile>;
close("ifile");
&search;
sub usage{
print "Usage:\n";
print "DirSpider.pl <url> <file of directories> <result file>\n";
print "DirSpider.pl http://www.google.com dirs.txt found.txt\n";
exit;
}
sub search{
foreach my $dir(@dirs){
print "$url/$dir";
my $response = $ua->get("$url/$dir");
if($response->status_line !~ m/^404/){
push(@found,"$url/$dir");
}
}
}