From 9865904e040946d6619497d57a57cc82c19616f5 Mon Sep 17 00:00:00 2001 From: Jeff Odegard <42775175+JeffOdegard@users.noreply.github.com> Date: Mon, 21 Jan 2019 17:03:12 -0700 Subject: [PATCH] Nmap filetype not found for .nmap files The file type for Normal output .nmap files were not being correctly detected and were producing an error on import. --- exec/parse_nmap.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exec/parse_nmap.php b/exec/parse_nmap.php index 7040468..2b37dfd 100644 --- a/exec/parse_nmap.php +++ b/exec/parse_nmap.php @@ -22,6 +22,7 @@ * - Nov 7, 2016 - Added d parameter documentation * - Dec 7, 2016 - Added check for "Interesting ports on {IP}" line * - Jan 30, 2017 - Updated to use parse_config.ini file, and added populating new targets with shortened os software string if available. + * - Jan 21, 2019 - fixed filetype check for .nmap and .gnmap files. */ $cmd = getopt("f:", ['debug::', 'help::']); @@ -94,7 +95,13 @@ foreach ($lines as $line_num => $line) { $line = trim($line, "\t\n\r"); # chomp would be nice... $matches = []; if (!isset($filetype)) { - if (preg_match('/Starting|\-oN/', $line)) { + if (preg_match('/\.nmap/', $cmd['f'])) { + $filetype = "text"; + } + elseif (preg_match('/\.gnmap/', $cmd['f'])) { + $filetype = "grep"; + } + elseif (preg_match('/Starting|\-oN/', $line)) { $filetype = "text"; } elseif (preg_match('/\-oG/', $line)) {