From d2d5a7839952eac9c439262889eae4c0b12950ff Mon Sep 17 00:00:00 2001 From: dmiller Date: Sun, 29 Nov 2015 16:34:33 +0000 Subject: [PATCH] Avoid error output on non-HTTP and non-XMLRPC services. Closes #244 --- scripts/xmlrpc-methods.nse | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/xmlrpc-methods.nse b/scripts/xmlrpc-methods.nse index 75fcfc785..3bc7755bd 100644 --- a/scripts/xmlrpc-methods.nse +++ b/scripts/xmlrpc-methods.nse @@ -68,6 +68,10 @@ action = function(host, port) local url = stdnse.get_script_args(SCRIPT_NAME .. ".url") or "/" local data = ' system.listMethods ' local response = http.post(host, port, url, {header = {["Content-Type"] = "application/x-www-form-urlencoded"}}, nil, data ) + if not (response and response.status and response.body) then + stdnse.debug1("HTTP POST failed") + return nil + end local output = stdnse.output_table() local parser = slaxml.parser:new() @@ -75,7 +79,7 @@ action = function(host, port) __tostring = set_80_columns } - if response and response.status == 200 and response.body:find("system.listMethods", nil, true) then + if response.status == 200 and response.body:find("system.listMethods", nil, true) then parser._call = {startElement = function(name) parser._call.text = name == "string" and function(content) output["Supported Methods"] = output["Supported Methods"] or {} table.insert(output["Supported Methods"], content) end end,