[go: nahoru, domu]

Skip to content

Commit

Permalink
refactor: remove blind backward seek
Browse files Browse the repository at this point in the history
- in case no vulnerabilities were found, seek would remove '['
  • Loading branch information
HuntClauss committed Dec 16, 2023
1 parent a51fd6d commit e9241f1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions program/plugins/nikto_report_json.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ sub json_host_start {
sub json_host_end {
my ($handle, $mark, $file) = @_;

# this is remove the last , that json_item() left, and overwrite with ] to close the host
seek($handle, -1, 2);
print OUT "]";
return;
}
Expand All @@ -82,10 +80,17 @@ sub json_close {

###############################################################################
# print an item
$json_item_count = 0;
sub json_item {
my ($handle, $mark, $item) = @_;
$json_item_count++;

$uri = $item->{'uri'};
my $line = "{";
my $line = "";

if ($json_item_count gt 1) { $line .= ","; }

$line .= "{";
$line .= "\"id\": \"" . $item->{'nikto_id'} . "\",";
if ($item->{'refs'} ne '') { $line .= "\"references\": \"" . $item->{'refs'} . "\","; }
if ($item->{'method'} ne '') { $line .= "\"method\":\"" . $item->{'method'} . "\","; }
Expand All @@ -102,7 +107,7 @@ sub json_item {
$msg =~ s/"/\\"/g;
$msg = JSON::PP->new->encode($msg);
$line .= "\"msg\":$msg";
$line .= "},";
$line .= "}";
print $handle $line;
}

Expand Down

0 comments on commit e9241f1

Please sign in to comment.