| 1 | package P50Tools::SQLiScan; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use Moose; | ||
| 6 | use HTTP::Request; | ||
| 7 | use LWP::UserAgent; | ||
| 8 | |||
| 9 | { | ||
| 10 | no strict "vars"; | ||
| 11 | $VERSION = '0.1'; | ||
| 12 | } | ||
| 13 | |||
| 14 | has 'target_list' => (is => 'rw', isa => 'Str'); | ||
| 15 | has 'output' => (is => 'rw', isa => 'Str', default => 'output.txt'); | ||
| 16 | |||
| 17 | sub scan{ | ||
| 18 | my $self = shift; | ||
| 19 | |||
| 20 | open IN, $self->target_list or die "Cannot open data: $!"; | ||
| 21 | |||
| 22 | foreach (<IN>){ | ||
| 23 | |||
| 24 | |||
| 25 | $_ = "http://" . $_ if ($_ !~ /^http:/); | ||
| 26 | $_ .= "'"; | ||
| 27 | my $req=HTTP::Request->new(GET=>$_); | ||
| 28 | my $ua=LWP::UserAgent->new(); | ||
| 29 | $ua->timeout(20); | ||
| 30 | my $response = $ua->request($req); | ||
| 31 | if ($response->is_success){ | ||
| 32 | if($response->content =~ /You have an error in your SQL syntax/ || | ||
| 33 | $response->content =~ /MySQL server version/ || | ||
| 34 | $response->content =~ /Syntax error converting the nvarchar value/ || | ||
| 35 | $response->content =~ /Unclosed/ || | ||
| 36 | $response->content =~ /SQL Server error/ || | ||
| 37 | $response->content =~ /JET/) { | ||
| 38 | open OUT,">". $self->output or die "Cannot create data: $!\n"; | ||
| 39 | print "Find a vulnerability\n"; | ||
| 40 | print OUT $_; | ||
| 41 | close OUT; | ||
| 42 | |||
| 43 | } | ||
| 44 | } | ||
| 45 | else { | ||
| 46 | print "Cannot find a vulnerability\n"; | ||
| 47 | } | ||
| 48 | return $_; | ||
| 49 | } | ||
| 50 | close IN; | ||
| 51 | |||
| 52 | } | ||
| 53 | no Moose; | ||
| 54 | 1; | ||
| 55 | |||
| 56 | __END__ |