Index: comm.lua =================================================================== --- comm.lua (revision 21580) +++ comm.lua (working copy) @@ -86,7 +86,7 @@ get_banner = function(host, port, opts) opts = initopts(opts) opts.recv_before = true - local socket, nothing, correct, banner = tryssl(host, port, "", opts) + local socket, nothing, correct, banner = tryssl(host, port, "", opts, opts) if socket then socket:close() return true, banner @@ -185,7 +185,7 @@ -- @return response The response received for the payload -- @return early_resp If opt recv_before is true, returns the value -- of the first receive (before sending data) -local function opencon(host, port, protocol, data, opts) +local function opencon(host, port, protocol, data, opts, eopts) local sd = nmap.new_socket() -- check for connect_timeout or timeout option @@ -215,10 +215,10 @@ end local response, early_resp; - if opts and opts.recv_before then status, early_resp = sd:receive() end + if opts and opts.recv_before then status, early_resp = read(sd, eopts) end if #data > 0 then sd:send(data) - status, response = sd:receive() + status, response = read(sd, opts) else if not opts and opts.recv_before then nsedebug.print_debug("Using comm.tryssl without first data payload and recv_first." .. @@ -246,17 +246,18 @@ -- @param port The port table -- @param data The first data payload of the connection -- @param opts Options, such as timeout +-- @param eopts Options, for early receive -- @return sd The socket descriptor -- @return response The response received for the payload -- @return correctOpt Correct option for connection guess -- @return earlyResp If opt recv_before is true, returns the value -- of the first receive (before sending data) -function tryssl(host, port, data, opts) +function tryssl(host, port, data, opts, eopts) local opt1, opt2 = bestoption(port) local best = opt1 - local sd, response, early_resp = opencon(host, port, opt1, data, opts) + local sd, response, early_resp = opencon(host, port, opt1, data, opts, eopts) if not sd then - sd, response, early_resp = opencon(host, port, opt2, data, opts) + sd, response, early_resp = opencon(host, port, opt2, data, opts, eopts) best = opt2 end if not sd then best = "none" end