From c622a1518ed39d57ef39eaefa44bf343b337c9a0 Mon Sep 17 00:00:00 2001 From: jah Date: Tue, 3 Feb 2009 02:43:24 +0000 Subject: [PATCH] Pass "ssl" as the third paramater to connect() in pop3.lua capabilities() and smtp-commands.nse if version detection set the port service_tunnel to "ssl". --- nselib/pop3.lua | 3 ++- scripts/smtp-commands.nse | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nselib/pop3.lua b/nselib/pop3.lua index 33cd4d3c6..fce2f7f33 100644 --- a/nselib/pop3.lua +++ b/nselib/pop3.lua @@ -149,7 +149,8 @@ function capabilities(host, port) local socket = nmap.new_socket() local capas = {} socket:set_timeout(10000) - if not socket:connect(host.ip, port.number) then return nil, "Could Not Connect" end + local proto = (port.version and port.version.service_tunnel == "ssl" and "ssl") or "tcp" + if not socket:connect(host.ip, port.number, proto) then return nil, "Could Not Connect" end status, line = socket:receive_lines(1) if not stat(line) then return nil, "No Response" end diff --git a/scripts/smtp-commands.nse b/scripts/smtp-commands.nse index a3311f2f6..3440d87d3 100644 --- a/scripts/smtp-commands.nse +++ b/scripts/smtp-commands.nse @@ -71,10 +71,11 @@ action = function(host, port) local try = nmap.new_try(catch) - local attempt = try(socket:connect(host.ip, port.number, port.protocol)) + local proto = (port.version and port.version.service_tunnel == "ssl" and "ssl") or port.protocol + local attempt = try(socket:connect(host.ip, port.number, proto)) if attempt then if nmap.verbosity() >= 2 or nmap.debugging() >= 1 then -- only tell you it fails if you are debugging or verbose X 2 - return "Problem connecting to " .. host.ip .. " on port " .. port.number .. " using protocol " .. port.protocol + return ("Problem connecting to %s on port %d using protocol %s%s"):format(host.ip, port.number, port.protocol, (proto == "ssl" and " (ssl)") or "") else return -- if you aren't debugging, just return with nothing end