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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
#VERSION,2.03
#LASTMOD,01.09.2008
###############################################################################
# Copyright (C) 2007 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
# General HTTP headers checks
###############################################################################
sub nikto_headers
{
my @interesting_headers = qw /microsoftofficewebserver ms-author-via dasl dav daap-server/;
#######################################################################
# look for a powered-by header...could require a valid file, maybe not
my %xpb;
foreach
my $f (qw/\/index.php \/junk999.php \/ \/index.php3 \/ \/junk999.php3 \/index.cfm \/junk999.cfm \/index.asp \/junk999.asp \/index.aspx \/junk988.aspx/)
{
(my $RES, $CONTENT) = fetch($f, "GET");
if ($result{'x-powered-by'} ne "") { $xpb{ $result{'x-powered-by'} } = 1; }
}
foreach my $x (sort keys %xpb)
{
# push version to BUILDITEMS so it can be evaluated later
push(@BUILDITEMS, $x);
if (exists($TESTS{999992}{message}))
{
$TESTS{999992}{message} =~ s/Retrieved X\-Powered\-By header\: //;
$TESTS{999992}{message} = "Retrieved X-Powered-By headers: $TESTS{999992}{message} and $x";
} else
{
$TESTS{999992}{message} = "Retrieved X-Powered-By header: $x";
}
$TESTS{999992}{osvdb} = 0;
nprint("+ OSVDB-$TESTS{999992}{osvdb}: $TESTS{999992}{message}");
$TARGETS{$CURRENT_HOST_ID}{positives}{999992} = 1;
$TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
}
#######################################################################
# Servlet-Engine info
if ($result{'servlet-engine'} ne "")
{
my $x = $result{'servlet-engine'};
$x = ~s/\(.*$//;
$x =~ s/\s+//g;
push(@BUILDITEMS, $x);
$TESTS{999991}{message} = "Retrieved servlet-engine headers: $x";
$TESTS{999991}{osvdb} = 0;
nprint("+ OSVDB-$TESTS{999991}{osvdb}: $TESTS{999991}{message}");
$TARGETS{$CURRENT_HOST_ID}{positives}{999991} = 1;
$TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
my @bits = split(/;/, $x);
foreach my $bit (@bits)
{
# nprint("- Retrieved servlet-engine headers : $bit");
# $TARGETS{$CURRENT_HOST_ID}{positives}{999998}=1;
# $TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
push(@BUILDITEMS, $bit);
}
}
#######################################################################
# Content-Location header in IIS
LW2::http_close(\%request); # force-close any old connections
LW2::http_fixup_request(\%request);
LW2::http_reset();
my $wh = $request{'whisker'}{'Host'};
my $h = $request{'Host'};
delete $request{'whisker'}{'Host'};
delete $request{'Host'};
$request{'whisker'}->{'uri'} = "/";
$request{'whisker'}->{'method'} = "GET";
$request{'whisker'}{'version'} = "1.0";
LW2::http_do_request_timeout(\%request, \%result);
if ( ($result{'content-location'} ne "")
&& ($result{'content-location'} =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)
&& ($result{'content-location'} !~ /$TARGETS{$CURRENT_HOST_ID}{ip}/))
{
$TESTS{999989}{message} =
"IIS may reveal its internal IP in the Content-Location header via a request to the root file. The value is \"$result{'content-location'}\".";
$TESTS{999989}{osvdb} = 630;
nprint("+ OSVDB-$TESTS{999989}{osvdb}: $TESTS{999989}{message}");
$TARGETS{$CURRENT_HOST_ID}{positives}{999989} = 1;
$TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
}
LW2::http_close(\%request); # force-close any old connections
LW2::http_fixup_request(\%request);
LW2::http_reset();
$request{'whisker'}->{'uri'} = "/images";
$request{'whisker'}->{'method'} = "GET";
$request{'whisker'}{'version'} = "1.0";
delete $request{'whisker'}{'Host'};
delete $request{'Host'};
if ($CLI{pause} > 0) { sleep $CLI{pause}; }
LW2::http_do_request_timeout(\%request, \%result);
if (($result{'location'} ne "") && ($result{'location'} =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/) && ($result{'location'} !~ /$TARGETS{$CURRENT_HOST_ID}{ip}/))
{
$TESTS{999988}{message} =
"IIS may reveal its internal IP in the Location header via a request to the /images directory. The value is \"$result{'location'}\".";
$TESTS{999988}{osvdb} = 630;
nprint("+ OSVDB-$TESTS{999988}{osvdb}: $TESTS{999988}{message}");
$TARGETS{$CURRENT_HOST_ID}{positives}{999988} = 1;
$TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
}
$request{'whisker'}{'Host'} = $wh;
$request{'Host'} = $h;
#######################################################################
# Location header in WebLogic
LW2::http_close(\%request); # force-close any old connections
LW2::http_fixup_request(\%request);
LW2::http_reset();
$request{'whisker'}->{'uri'} = ".";
$request{'whisker'}->{'method'} = "GET";
$request{'whisker'}{'version'} = "1.0";
if ($CLI{pause} > 0) { sleep $CLI{pause}; }
LW2::http_do_request_timeout(\%request, \%result);
if (($result{'location'} ne "") && ($result{'location'} =~ /http:\/\//))
{
$TESTS{999987}{message} = "WebLogic may reveal its internal IP or hostname in the Location header. The value is \"$result{'location'}\".";
$TESTS{999987}{osvdb} = 5737;
nprint("+ OSVDB-$TESTS{999987}{osvdb}: $TESTS{999987}{message}");
$TARGETS{$CURRENT_HOST_ID}{positives}{999987} = 1;
$TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
}
#######################################################################
# All other interesting headers
foreach my $header (@interesting_headers)
{
if ($result{$header} ne '')
{
my $x = $result{$header};
$x =~ s/\s+.*$//;
push(@BUILDITEMS, $x);
$TESTS{999986}{message} = "Retrieved $header header: $result{$header}";
$TESTS{999986}{osvdb} = 0;
nprint("+ OSVDB-$TESTS{999986}{osvdb}: $TESTS{999986}{message}");
$TARGETS{$CURRENT_HOST_ID}{positives}{999986} = 1;
$TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
}
}
}
1;
|