From f6fbb29481e68a644edb497506b4c62e7412fe24 Mon Sep 17 00:00:00 2001 From: nnposter Date: Sun, 27 Dec 2020 00:38:53 +0000 Subject: [PATCH] Improve output formatting - EHLO output no longer has a trailing separator - Strings "214" and "250" are now removed only from the line beginning --- scripts/smtp-commands.nse | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/smtp-commands.nse b/scripts/smtp-commands.nse index 4b1b6d435..abf5854ed 100644 --- a/scripts/smtp-commands.nse +++ b/scripts/smtp-commands.nse @@ -93,19 +93,19 @@ function go(host, port) return status, response end - response = string.gsub(response, "250[%-%s]+", "") -- 250 or 250- - response = string.gsub(response, "\r\n", "\n") -- normalize CR LF - response = string.gsub(response, "\n\r", "\n") -- normalize LF CR - response = string.gsub(response, "^\n+(.-)\n+$", "%1") - response = string.gsub(response, "\n", ", ") -- LF to comma - response = string.gsub(response, "%s+", " ") -- get rid of extra spaces + response = response:gsub("\r", "") -- switch to simple LF line termination + :gsub("^%s*(.-)%s*$", "%1") -- trim leading and trailing whitespace + :gsub("%f[^\0\n]250[-%s]+", "") -- remove line prefix 250 or 250- + :gsub("\n", ", ") -- LF to comma + :gsub("%s+", " ") -- get rid of extra spaces table.insert(result,response) status, response = smtp.help(socket) if status then - response = string.gsub(response, "214[%-%s]+", "") -- 214 - response = string.gsub(response, "^%s+(.-)%s+$", "%1") - response = string.gsub(response, "%s+", " ") -- get rid of extra spaces + response = response:gsub("\r", "") -- switch to simple LF line termination + :gsub("^%s*(.-)%s*$", "%1") -- trim leading and trailing whitespace + :gsub("%f[^\0\n]214[-%s]+", "") -- remove line prefix 214 or 214- + :gsub("%s+", " ") -- get rid of extra spaces table.insert(result,response) smtp.quit(socket) end