source: trunk/plugins/nikto_httpoptions.plugin @ 70

Revision 70, 3.6 KB checked in by deity, 5 years ago (diff)

Fix for ticket #38 and new dynamic database api

  • Property svn:keywords set to Id
Line 
1#VERSION,2.04
2# $Id$
3
4###############################################################################
5#  Copyright (C) 2006 CIRT, Inc.
6#
7#  This program is free software; you can redistribute it and/or
8#  modify it under the terms of the GNU General Public License
9#  as published by the Free Software Foundation; version 2
10#  of the License only.
11#
12#  This program is distributed in the hope that it will be useful,
13#  but WITHOUT ANY WARRANTY; without even the implied warranty of
14#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#  GNU General Public License for more details.
16#
17#  You should have received a copy of the GNU General Public License
18#  along with this program; if not, write to the Free Software
19#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20###############################################################################
21
22###############################################################################
23# PURPOSE
24# HTTP options check
25###############################################################################
26
27# This just gets the HTTP options & checks 'em out.
28# See RFC 2626 for more info...
29
30sub nikto_httpoptions
31{
32   # test for both OPTIONS / and OPTIONS * as they may give different results
33   (my $RES, $CONTENT) = fetch("*", "OPTIONS");
34   my $aoptions = "$result{allow}, ";
35   my $poptions = "$result{public}, ";
36   my ($allow_methods, $public_methods, $txt);
37   my $dbarray;
38
39   $dbarray=initialise_db("db_httpoptions");
40
41   ($RES, $CONTENT) = fetch("/", "OPTIONS");
42   $aoptions .= $result{allow};
43   $poptions .= $result{public};
44
45   foreach my $o (split(/,[ ]?/, $aoptions)) { $allow_methods .= ", $o" unless ($allow_methods =~ /\b$o\b/ || $o eq ''); }
46   $allow_methods =~ s/^[ ]?, //;
47   foreach my $o (split(/,[ ]?/, $poptions)) { $public_methods .= ", $o" unless ($public_methods =~ /\b$o\b/ || $o eq ''); }
48   $public_methods =~ s/^[ ]?, //;
49
50   # proxy can impose it's methods... should actually check this not just warn
51   if ($CLI{useproxy} ne "") { $txt = "(May be proxy's methods, not server's)"; }
52
53   if ($allow_methods ne "")
54   {
55      $TARGETS{$CURRENT_HOST_ID}{positives}{999990} = 1;
56      $TESTS{999990}{message}                       = "Allowed HTTP Methods: $allow_methods $txt";
57      $TESTS{999990}{osvdb}                         = 0;
58      $TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
59      nprint("- $TESTS{999990}{message}");
60      foreach my $m (split /,? /, $allow_methods) { eval_methods($m, "Allow", $dbarray); }
61   }
62
63   if ($public_methods ne "")
64   {
65      $TESTS{999985}{message}                       = "Public HTTP Methods: $public_methods $txt";
66      $TESTS{999985}{osvdb}                         = 0;
67      $TARGETS{$CURRENT_HOST_ID}{positives}{999985} = 1;
68      $TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
69      nprint("- $TESTS{999985}{message}");
70      foreach my $m (split /,? /, $public_methods) { eval_methods($m, "Public", $dbarray); }
71   }
72 
73   # Now release memory for the dbarray
74   undef @$dbarray;
75   return;
76}
77
78sub eval_methods
79{
80   my $method = $_[0] || return;
81   my $type = $_[1];
82   my $dbarray = $_[2];
83   $method = uc($method);
84
85   # Now search database for the method.
86   foreach my $item (@$dbarray)
87   {
88      if ($item->{method} eq $method)
89      {
90         $TESTS{$item->{nikto_id}}{message} = $item->{message};
91         $TESTS{$item->{nikto_id}}{message} =~ s/\@TYPE\@/$type/;
92         $TESTS{$item->{nikto_id}}{osvdb} = $item->{osvdb};
93         nprint("+ OSVDB-$item->{osvdb}: $TESTS{$item->{nikto_id}}{message}");
94         $TARGETS{$CURRENT_HOST_ID}{positives}{$item->{nikto_id}} = 1;
95         $TARGETS{$CURRENT_HOST_ID}{total_vulns}++;
96      }
97   }
98}
99
1001;
Note: See TracBrowser for help on using the repository browser.