[go: nahoru, domu]

Skip to content

Commit

Permalink
Explicitly load first conf file found, not last
Browse files Browse the repository at this point in the history
  • Loading branch information
sullo committed Feb 27, 2019
1 parent 6d1c07d commit f7ca6a4
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions program/nikto.pl
Original file line number Diff line number Diff line change
Expand Up @@ -233,33 +233,42 @@ sub config_init {
if (defined $optcfg{'config'}) { $VARIABLES{'configfile'} = $optcfg{'config'}; }
}

# Read the config files in order
# Read the config files in appropriate order
my ($error, $home);
my $config_exists = 0;
$error = load_config("$VARIABLES{'configfile'}");
$config_exists = 1 if ($error eq "");

# Guess home directory -- to support Windows
foreach my $var (split(/ /, "HOME USERPROFILE")) {
$home = $ENV{$var} if ($ENV{$var});
if (!$config_exists) {
foreach my $var (split(/ /, "HOME USERPROFILE")) {
$home = $ENV{$var} if ($ENV{$var});
}
$error = load_config("$home/nikto.conf");
$config_exists = 1 if ($error eq "");
}
$error = load_config("$home/nikto.conf");
$config_exists = 1 if ($error eq "");

# Guess Nikto current directory
my $NIKTODIR = $0;
chomp($NIKTODIR);
$NIKTODIR =~ s#[\\/]nikto.pl$##;
$error = load_config("$NIKTODIR/nikto.conf");
$config_exists = 1 if ($error eq "");

$error = load_config("nikto.conf");
$config_exists = 1 if ($error eq "");
if ($config_exists) {
$error = load_config("$NIKTODIR/nikto.conf");
$config_exists = 1 if ($error eq "");
}

$error = load_config("$NIKTODIR/nikto.conf.default");
$config_exists = 1 if ($error eq "");
if (!$config_exists) {
$error = load_config("nikto.conf");
$config_exists = 1 if ($error eq "");
}

if (!$config_exists) {
$error = load_config("$NIKTODIR/nikto.conf.default");
$config_exists = 1 if ($error eq "");
}

if ($config_exists == 0) {
if (!$config_exists) {
die "- Could not find a valid nikto config file.\n";
}

Expand Down

0 comments on commit f7ca6a4

Please sign in to comment.