Skip to content

Commit

Permalink
Fixes for #837
Browse files Browse the repository at this point in the history
- Exit 0 on successful program completion
- Eplicitly set exit code in all cases
  • Loading branch information
sullo committed Jul 30, 2024
1 parent 66592bf commit 6f9108f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
8 changes: 1 addition & 7 deletions program/nikto.pl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@
$COUNTERS{'total_targets'} = $COUNTERS{'hosts_completed'} = 0;
load_plugins();

my $is_failure = 0;

# Parse the supplied list of targets
my @MARKS = set_targets($CLI{'host'}, $CLI{'ports'}, $CLI{'ssl'}, $CLI{'root'});

Expand Down Expand Up @@ -186,10 +184,6 @@
run_hooks($mark, "recon");
run_hooks($mark, "scan");

if ($mark->{'total_errors'} > 0 || $mark->{'total_vulns'} > 0) {
$is_failure = 1;
}

$mark->{'end_time'} = time();
$mark->{'elapsed'} = $mark->{'end_time'} - $mark->{'start_time'};
if (!$mark->{'terminate'}) {
Expand Down Expand Up @@ -223,7 +217,7 @@

nprint("T:" . localtime() . ": Ending", "d");

exit $is_failure;
exit 0;

#################################################################################
# Load config files in order
Expand Down
18 changes: 8 additions & 10 deletions program/plugins/nikto_core.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ sub general_config {
nprint("- ***** TLS/SSL support not available (see docs for SSL install) *****");
if ($CLI{'ssl'} || ($CLI{'host'} =~ /^https/i)) {
nprint("- ERROR: -ssl was specified but TLS/SSL is not available.");
exit;
exit 1;
}
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ sub safe_quit {
report_summary($mark);
report_close($mark);
$NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'oterm'}) if ($^O !~ /MSWin32/);
exit(1);
exit 1;
}

###############################################################################
Expand Down Expand Up @@ -1125,7 +1125,7 @@ sub resolve {
{
if ($CLI{'skiplookup'}) {
nprint("+ ERROR: -nolookup set, but given name\n");
exit;
exit 1;
}

if ($LW2::LW2_CAN_IPv6) { # IPv4/v6 resolve
Expand Down Expand Up @@ -1183,7 +1183,7 @@ sub resolve {
"+ ERROR: IPv4 scanning mode requested but only IPv6 addresses found ($ipcache)"
);
}
exit;
exit 1;
}

if ($ipcache != "") {
Expand All @@ -1194,7 +1194,7 @@ sub resolve {
&& $ip !~ /^$LW2::IPv6_re$/) {
nprint("+ ERROR: Invalid IP: $ip\n\n",
"", ($mark->{'hostname'}, $mark->{'ip'}, $mark->{'displayname'}));
exit;
exit 1;
}

$name = $ident;
Expand Down Expand Up @@ -2843,7 +2843,7 @@ sub version {
# Check dependencies
check_modules();

exit;
exit 0;
}

#######################################################################
Expand Down Expand Up @@ -2938,8 +2938,6 @@ sub send_updates {

#######################################################################
sub usage {
my $is_failure = shift;

print "
Options:
-ask+ Whether to ask about submitting updates
Expand Down Expand Up @@ -3039,7 +3037,7 @@ sub usage {

check_modules();

exit $is_failure;
exit 0;
}

#######################################################################
Expand Down Expand Up @@ -3190,7 +3188,7 @@ sub list_plugins {
}
}

exit(0);
exit 0;
}

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions program/plugins/nikto_fileops.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ sub save_createdir {
}
elsif (-f $savedir) {
nprint("+ ERROR: Directory from -Savedir is a file.");
exit;
exit 1;
}

# create?
Expand All @@ -146,7 +146,7 @@ sub save_createdir {
if (!-d $savedir) {
nprint("+ ERROR: Unable to create -Save directory '$savedir'",
"", ($mark->{'hostname'}, $mark->{'ip'}, $mark->{'displayname'}));
exit;
exit 1;
}
}
return $savedir;
Expand Down

0 comments on commit 6f9108f

Please sign in to comment.