| 1 | package P50Tools::AdminFinder; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use common::sense; | ||
| 5 | use Moose; | ||
| 6 | use HTTP::Request; | ||
| 7 | use LWP::UserAgent; | ||
| 8 | |||
| 9 | { | ||
| 10 | no strict "vars"; | ||
| 11 | $VERSION = '0.2'; | ||
| 12 | } | ||
| 13 | |||
| 14 | =head1 | ||
| 15 | For more information go to L<P50Tools>. | ||
| 16 | =cut | ||
| 17 | |||
| 18 | our @string; | ||
| 19 | |||
| 20 | has 'target' => (is => 'rw', isa => 'Str'); | ||
| 21 | has 'string_list' => (is => 'rw', isa => 'Str', default => 'nada'); | ||
| 22 | has 'output' => (is => 'rw', isa => 'Str', default => 'output.txt'); | ||
| 23 | |||
| 24 | sub scan{ | ||
| 25 | my $self = shift; | ||
| 26 | my $s1 = $self->target; | ||
| 27 | |||
| 28 | unless ($self->string_list eq 'nada') { open IN, $self->string_list or die "Cannot open data: $!"; @string = <IN>;} | ||
| 29 | if ($self->string_list eq 'nada') {@string = <DATA>;} | ||
| 30 | open OUT,">". $self->output or die "Cannot cerate data: $!"; | ||
| 31 | foreach (@string){ | ||
| 32 | |||
| 33 | $s1 .= "/" if ($s1 !~ m~(.+)/~gi); | ||
| 34 | $s1 = "http://" . $s1 if ($s1 !~ /^http:/); | ||
| 35 | $s1 .= $_; | ||
| 36 | |||
| 37 | |||
| 38 | my $req=HTTP::Request->new(GET=>$s1); | ||
| 39 | my $ua=LWP::UserAgent->new(); | ||
| 40 | $ua->timeout(20); | ||
| 41 | my $response = $ua->request($req); | ||
| 42 | if ($response->is_success) { | ||
| 43 | |||
| 44 | print OUT $s1; | ||
| 45 | |||
| 46 | print "Find a adm page\n"; | ||
| 47 | } | ||
| 48 | else { | ||
| 49 | print "Cannot find adm page\n"; | ||
| 50 | } | ||
| 51 | |||
| 52 | } | ||
| 53 | close OUT; | ||
| 54 | return $s1; | ||
| 55 | } | ||
| 56 | no Moose; | ||
| 57 | 1; | ||
| 58 | __DATA__ |