script/check.pl

filter: Statementstmt 46.6% 21 / 45 Branchbran 12.5% 1 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 47.4% 28 / 59 CC 1 SCAR 0.0
CC
1
Cov
42%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/HTML/Form/XSS/Result.pm ↑ Summary
1 #!/usr/bin/env perl
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use lib qw(lib ../lib);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use HTML::Form::XSS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use WWW::Mechanize;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶if(scalar(@ARGV) != 1){ #check command line args
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @ARGV != 1) 1 0 1
9 1 print "Usage: $0 <URL with form>\n";
10 1 exit(1);
11 }
12 0 my $url = $ARGV[0];
13 0 my $mech = WWW::Mechanize->new();
14 0 $mech->get($url);
15 0 my @forms = $mech->forms();
16 0 foreach my $form (@forms){
17 0 print "Found form:\n";
18 0 print $form->dump();
19 0 print "Test it (y/n)?";
20 0 my $answer = <STDIN>;
21 0 chomp $answer;
22 0 ▶ if($answer ne "y"){
Branch: 1 branch
BranchTrueFalseTotal
if ($answer ne "y") 0 0 0
23 0 next;
24 }
25 0 my $checker = HTML::Form::XSS->new($mech, config => '../root/config.xml');
26 0 my @results = $checker->do_audit($form);
27 0 my $vuln = 0;
28 0 foreach my $result (@results){
29 0 ▶ if($result->vulnerable()){
Branch: 1 branch
BranchTrueFalseTotal
if ($result->vulnerable) 0 0 0
30 0 $vuln = 1;
31 0 my $example = $result->example();
32 0 print "Example of vulnerable URL: $example\n";
33 0 last;
34 }
35 }
36 0 ▶ if(!$vuln){
Branch: 1 branch
BranchTrueFalseTotal
unless ($vuln) 0 0 0
37 0 print "Form not vulnerable :-)\n";
38 }
39 }
40 0 exit();
« lib/HTML/Form/XSS/Result.pm ↑ Summary