File: nikto_cgi.plugin

package info (click to toggle)
nikto 1%3A2.1.4-2
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 2,276 kB
  • sloc: perl: 4,328; makefile: 11
file content (85 lines) | stat: -rw-r--r-- 3,331 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#VERSION,2.05
# $Id: nikto_cgi.plugin 632 2011-02-19 02:49:31Z sullo $
###############################################################################
#  Copyright (C) 2004 CIRT, Inc.
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; version 2
#  of the License only.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
###############################################################################
# PURPOSE:
# Perform CGI tests
###############################################################################
sub nikto_cgi_init {
    my $id = { name        => "cgi",
               full_name   => "CGI",
               author      => "Sullo",
               description => "Enumerates possible CGI directories.",
               hooks       => { recon => { method => \&nikto_cgi, }, },
               copyright   => "2008 CIRT Inc.",
               };
    return $id;
}

sub nikto_cgi {
    my ($mark) = @_;
    my ($gotvalid, $gotinvalid) = 0;
    my @POSSIBLECGI = ();
    my @CFGCGI = (split(/ /, $VARIABLES{'@CGIDIRS'}));
    my ($res, $content, $possiblecgidir, $found) = "";

    if (defined $CLI{'forcecgi'} && $CLI{'forcecgi'} eq "all")  # all possible CGI dirs to be "true"
    {
        nprint("Using all known CGI directories\n", "d");
        $VARIABLES{'@CGIDIRS'} = join(" ", @CFGCGI);
    }
    elsif (defined $CLI{'forcecgi'} && $CLI{'forcecgi'} eq "none")    # scan no CGI directories
    {
        nprint("Using no CGI directories\n", "d");
        $VARIABLES{'@CGIDIRS'} = "";
    }
    elsif (defined $CLI{'forcecgi'}
           && $CLI{'forcecgi'} =~ /[a-zA-Z0-9]/)                      # scan a specific directory
    {
        nprint("Using CGI dir \'$CLI{'forcecgi'}\'\n", "d");
        $VARIABLES{'@CGIDIRS'} = $CLI{'forcecgi'};
    }
    else    # or normal testing of each dir
    {
        foreach $possiblecgidir (@CFGCGI) {
            return if $mark->{'terminate'};
            ($res, $content) = nfetch($mark, $possiblecgidir, "GET", "", "", "", "cgi dir check");
            nprint("Checked for CGI dir\t$possiblecgidir\tgot:$res", "d");
            if (content_present($res) eq TRUE) {
                $gotvalid++;
                push(@POSSIBLECGI, $possiblecgidir);
            }
        }

        if ($gotvalid eq 0) {
            nprint("+ No CGI Directories found (use '-C all' to force check all possible dirs)");
            $VARIABLES{'@CGIDIRS'} = "";
        }
        elsif ($#CFGCGI eq $#POSSIBLECGI) {
            nprint("+ All CGI directories 'found', use '-C none' to test none");
            $VARIABLES{'@CGIDIRS'} = join(" ", @CFGCGI);
        }
        else {
            $VARIABLES{'@CGIDIRS'} = join(" ", @POSSIBLECGI);
        }
    }    # end !$CLI{'forcecgi'}

    nprint("- Checking for CGI in: $VARIABLES{'@CGIDIRS'}", "v");
}

1;