1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

o [NSE] Oops, there was a vulnerability in one of our 437 NSE scripts.

If you ran the (fortunately non-default) http-domino-enum-passwords
  script with the (fortunately also non-default)
  domino-enum-passwords.idpath parameter against a malicious server,
  it could cause an arbitrarily named file to to be written to the
  client system.  Thanks to Trustwave researcher Piotr Duszynski for
  discovering and reporting the problem.  We've fixed that script, and
  also updated several other scripts to use a new
  stdnse.filename_escape function for extra safety.  This breaks our
  record of never having a vulnerability in the 16 years that Nmap has
  existed, but that's still a fairly good run. [David, Fyodor]
This commit is contained in:
fyodor
2013-07-29 06:19:24 +00:00
parent 93accf0619
commit f79a11aeeb
10 changed files with 56 additions and 25 deletions

View File

@@ -53,7 +53,7 @@ local target = require "target"
local HOSTMAP_BING_SERVER = "www.ip2hosts.com"
local HOSTMAP_DEFAULT_PROVIDER = "ALL"
local filename_escape, write_file
local write_file
hostrule = function(host)
return not ipOps.isPrivate(host.ip)
@@ -99,7 +99,7 @@ action = function(host)
output_tab.hosts = hostnames
--write to file
if filename_prefix then
local filename = filename_prefix .. filename_escape(host.targetname or host.ip)
local filename = filename_prefix .. stdnse.filename_escape(host.targetname or host.ip)
hostnames_str = stdnse.strjoin("\n", hostnames)
local status, err = write_file(filename, hostnames_str)
if status then
@@ -112,13 +112,6 @@ action = function(host)
return output_tab
end
-- Escape some potentially unsafe characters in a string meant to be a filename.
function filename_escape(s)
return string.gsub(s, "[%z/=]", function(c)
return string.format("=%02X", string.byte(c))
end)
end
function write_file(filename, contents)
local f, err = io.open(filename, "w")
if not f then