Skip to content

Commit

Permalink
This update is focused on headers!
Browse files Browse the repository at this point in the history
- add db_headers_suggested
- report missing suggested headers (set in db_headers_suggested)
- db_headers renamed to db_headers_common
  • Loading branch information
Sullo committed Nov 1, 2024
1 parent badb856 commit 40c5f75
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions program/databases/db_headers_common
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"bfcache-opt-in"
"cache-control"
"cf-cache-status"
"cf-edge-cache"
"cf-ray"
"cf-request-id"
"commerce-server-software"
Expand Down
14 changes: 12 additions & 2 deletions program/plugins/nikto_core.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ sub set_targets {

###############################################################################
sub load_databases {
my @dbs = qw/db_parked_strings db_404_strings db_outdated db_variables/;
my @dbs = qw/db_parked_strings db_404_strings db_outdated db_variables db_headers_suggested/;
my $prefix = $_[0] || '';

# Only load the right databases if -Userdbs is set
Expand Down Expand Up @@ -1391,6 +1391,15 @@ sub load_databases {
}
}

# db_headers_suggested
elsif ($file =~ /u?db_headers_suggested/) {
foreach my $l (@file) {
my @T = parse_csv($l);
next if $T[0] eq '';
$VARIABLES->{'SUGGESTED_HEADERS'}->{$T[0]} = $T[1];
}
}

# db_404_strings
elsif ($file =~ /u?db_404_strings/) {
foreach my $l (@file) {
Expand Down Expand Up @@ -3027,7 +3036,8 @@ sub usage {

#######################################################################
sub init_db {
my $dbname = $_[0];
my $dbname = shift;
return if $dbname eq "";
my $filename = "$CONFIGFILE{'DBDIR'}/" . $dbname;
my (@dbarray, @headers);
my $hashref = {};
Expand Down
21 changes: 18 additions & 3 deletions program/plugins/nikto_headers.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# PURPOSE:
# General HTTP headers checks
###############################################################################
use vars qw/$HEADERSDB %HEADERSSUG/;
use vars qw/$HEADERSDB/;

sub nikto_headers_init {
my $id = {
Expand All @@ -43,7 +43,6 @@ sub nikto_headers_init {

sub nikto_headers_load {
$HEADERSDB = init_db("db_headers_common");
$HEADERSSUG = init_db("db_headers_suggested")
}

sub nikto_headers_postfetch {
Expand Down Expand Up @@ -739,6 +738,22 @@ sub nikto_headers {

#######################################################################
# Missing suggested headers
print "called once\n";
($res, $content, $errors, $request, $result) =
nfetch($mark, '/', "GET", "", , , "headers: Suggested Headers Test", "1.1");

while (my ($header, $ref) = each %{ $VARIABLES->{'SUGGESTED_HEADERS'} }) {
if (!exists $result->{$header}) {
add_vulnerability(
$mark,
$request->{'whisker'}{'uri'} . ": Suggested security header missing: " . $header,
"013587",
$ref,
"GET",
"/",
$request,
$result
);
}
}
}
1;

0 comments on commit 40c5f75

Please sign in to comment.