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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user