nikto icon indicating copy to clipboard operation
nikto copied to clipboard

Feature: autoflush output when '-o -' is used

Open HuntClauss opened this issue 1 year ago • 0 comments

Description

When -o - is used as an output file, in some cases internal buffer stores output and flush it only after end of execution.

Example

#!/usr/bin/env python

from subprocess import Popen, PIPE, DEVNULL

proc = Popen(["nikto", "-h", "https://example.com", "-Format", "csv", "-o", "-"], stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL)

while True:
    line = proc.stdout.readline().decode("utf8")
    if proc.poll() is not None:
        break

    print(line, end="")

This could be changed by setting autoflush(1) when -o - was used or after some flag was provided eg. -Flush or -Autoflush.

Links/Info

One of the potential solutions for this could be this:

https://github.com/sullo/nikto/blob/b25a36b2b92b757b7fbe7badc4dfa2a1ed506759/program/plugins/nikto_core.plugin#L2079-L2083

 my $handle; 
 if (defined $plugin->{report_head}) { 
     $handle = &{ $plugin->{report_head} }($file);
     if ($file eq "-") { $handle->autoflush(1); }
 } 

After discussing what solution would be best I can create PR with it.

HuntClauss avatar Dec 29 '23 21:12 HuntClauss