1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00

Fix format string argument mismatches

Cases where the format string does not contain any placeholders, but
values are given anyway. Cases where string.format is used without any
placeholders or arguments.
This commit is contained in:
dmiller
2015-09-18 12:40:32 +00:00
parent a954950b5a
commit 9840973b60
17 changed files with 25 additions and 27 deletions

View File

@@ -201,7 +201,7 @@ local function get_quoted_string(s, offset, crlf)
c = s:sub(i, i) c = s:sub(i, i)
if c == "" then if c == "" then
-- No character following. -- No character following.
error(string.format("\\ escape at end of input while parsing quoted-string.")) error("\\ escape at end of input while parsing quoted-string.")
end end
-- Only CHAR may follow a backslash. -- Only CHAR may follow a backslash.
if c:byte(1) > 127 then if c:byte(1) > 127 then
@@ -2543,13 +2543,13 @@ function identify_404(host, port)
if(clean_body ~= clean_body2) then if(clean_body ~= clean_body2) then
stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response.") stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response.")
stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.")
return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response.") return false, "Two known 404 pages returned valid and different pages; unable to identify valid response."
end end
if(clean_body ~= clean_body3) then if(clean_body ~= clean_body3) then
stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).")
stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.")
return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") return false, "Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder)."
end end
return true, 200, clean_body return true, 200, clean_body

View File

@@ -170,7 +170,7 @@ JDWPReplyPacket = {
if flags == 0x80 then if flags == 0x80 then
return true, JDWPReplyPacket:new(length,id,error_code,data) return true, JDWPReplyPacket:new(length,id,error_code,data)
end end
stdnse.debug2("JDWP error parsing reply. Wrong reply packet flag. Raw data: ", stdnse.tohex(reply_packet)) stdnse.debug2("JDWP error parsing reply. Wrong reply packet flag. Raw data: %s", stdnse.tohex(reply_packet))
return false, "JDWP error parsing reply." return false, "JDWP error parsing reply."
end end

View File

@@ -1659,7 +1659,7 @@ function samr_querydisplayinfo(smbstate, domain_handle, index, count)
return false, result return false, result
end end
stdnse.debug3("MSRPC: QueryDisplayInfo() returned successfully", i) stdnse.debug3("MSRPC: QueryDisplayInfo() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -4313,7 +4313,7 @@ function service_create(host, servicename, path)
end end
-- Create the service -- Create the service
stdnse.debug2("Creating the service", servicename) stdnse.debug2("Creating the service")
status, create_result = svcctl_createservicew(smbstate, open_result['handle'], servicename, servicename, path) status, create_result = svcctl_createservicew(smbstate, open_result['handle'], servicename, servicename, path)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)

View File

@@ -374,8 +374,7 @@ Comm = {
local tmp local tmp
status, tmp = self:GetAdditionalBytes( data, pos, HEADER_LEN - ( data:len() - pos ) ) status, tmp = self:GetAdditionalBytes( data, pos, HEADER_LEN - ( data:len() - pos ) )
if not status then if not status then
stdnse.debug4( stdnse.debug4("Comm.DecodeHeader: failed to call GetAdditionalBytes")
string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes"))
return -1, nil return -1, nil
end end
data = data .. tmp data = data .. tmp
@@ -394,8 +393,7 @@ Comm = {
if header.verifier.length - 8 > 0 then if header.verifier.length - 8 > 0 then
status, data = self:GetAdditionalBytes( data, pos, header.verifier.length - 8 ) status, data = self:GetAdditionalBytes( data, pos, header.verifier.length - 8 )
if not status then if not status then
stdnse.debug4( stdnse.debug4("Comm.DecodeHeader: failed to call GetAdditionalBytes")
string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes"))
return -1, nil return -1, nil
end end
pos, header.verifier.data = bin.unpack("A" .. header.verifier.length - 8, data, pos ) pos, header.verifier.data = bin.unpack("A" .. header.verifier.length - 8, data, pos )

View File

@@ -135,7 +135,7 @@ action = function(host, port)
end end
if ( not status ) then if ( not status ) then
stdnse.debug1("Login failed", response) stdnse.debug1("Login failed")
stdnse.debug3("Login error: %s", response) stdnse.debug3("Login error: %s", response)
return return
end end

View File

@@ -176,7 +176,7 @@ Directory traversal vulnerability in AFP Server in Apple Mac OS X before
status, response = afp_helper:Login(nil, nil) status, response = afp_helper:Login(nil, nil)
end end
if ( not(status) ) then if ( not(status) ) then
stdnse.debug1("Login failed", response) stdnse.debug1("Login failed")
stdnse.debug3("Login error: %s", response) stdnse.debug3("Login error: %s", response)
return return
end end

View File

@@ -73,7 +73,7 @@ action = function(host, port)
end end
if ( not status ) then if ( not status ) then
stdnse.debug1("Login failed", response) stdnse.debug1("Login failed")
stdnse.debug3("Login error: %s", response) stdnse.debug3("Login error: %s", response)
return return
end end

View File

@@ -324,7 +324,7 @@ action = function (host, port)
return stdnse.format_output(false, string.format("Failed to submit the form to path %q", path)) return stdnse.format_output(false, string.format("Failed to submit the form to path %q", path))
end end
if success then if success then
return stdnse.format_output(false, string.format("Failed to recognize failed authentication. See http-form-brute.onsuccess and http-form-brute.onfailure")) return stdnse.format_output(false, "Failed to recognize failed authentication. See http-form-brute.onsuccess and http-form-brute.onfailure")
end end
local engine = brute.Engine:new(Driver, host, port, options) local engine = brute.Engine:new(Driver, host, port, options)

View File

@@ -98,7 +98,7 @@ local function check_vuln(host, port)
stdnse.debug1("HTTP GET %s", evil_uri) stdnse.debug1("HTTP GET %s", evil_uri)
local response = http.get(host, port, evil_uri) local response = http.get(host, port, evil_uri)
if response.body and response.status==200 and response.body:match("root:") then if response.body and response.status==200 and response.body:match("root:") then
stdnse.debug1("Pattern 'root:' found.", response.body) stdnse.debug1("Pattern 'root:' found.")
return true return true
end end
return false return false

View File

@@ -152,7 +152,7 @@ servers to remote users who send carefully crafted requests.]],
end end
-- TEST 3: The external website test. This does not mean that you can reach a LAN ip, but this is a relevant issue anyway. -- TEST 3: The external website test. This does not mean that you can reach a LAN ip, but this is a relevant issue anyway.
local external = http.get(host,port, ("@scanme.nmap.org"):format(prefix)) local external = http.get(host,port, ("%s@scanme.nmap.org"):format(prefix))
if ( external.status == 200 and string.match(external.body,"Go ahead and ScanMe") ) then if ( external.status == 200 and string.match(external.body,"Go ahead and ScanMe") ) then
vuln.extra_info = "Proxy allows requests to external websites" vuln.extra_info = "Proxy allows requests to external websites"
end end

View File

@@ -125,7 +125,7 @@ local function get_version(path, typeof, host, port)
if versioncheck.body then if versioncheck.body then
version = versioncheck.body:match(pattern) version = versioncheck.body:match(pattern)
end end
stdnse.debug1("Version found:", version) stdnse.debug1("Version found: %s", version)
return version return version
end end

View File

@@ -61,7 +61,7 @@ prerule = function()
end end
if not stdnse.get_script_args(SCRIPT_NAME .. ".interface") and not nmap.get_interface() then if not stdnse.get_script_args(SCRIPT_NAME .. ".interface") and not nmap.get_interface() then
stdnse.debug1("No interface was selected, aborting...", SCRIPT_NAME) stdnse.debug1("No interface was selected, aborting...")
return false return false
end end

View File

@@ -81,7 +81,7 @@ local function test_credentials( instance, helper, username, password )
if ( loginErrorCode == mssql.LoginErrorType.PasswordMustChange ) then passwordIsGood = true end if ( loginErrorCode == mssql.LoginErrorType.PasswordMustChange ) then passwordIsGood = true end
if ( loginErrorCode == mssql.LoginErrorType.AccountLockedOut ) then if ( loginErrorCode == mssql.LoginErrorType.AccountLockedOut ) then
stdnse.debug1("Account %s locked out on %s", username, instance:GetName() ) stdnse.debug1("Account %s locked out on %s", username, instance:GetName() )
table.insert( instance.ms_sql_empty, string.format("'sa' account is locked out.", result ) ) table.insert( instance.ms_sql_empty, "'sa' account is locked out." )
end end
if ( mssql.LoginErrorMessage[ loginErrorCode ] == nil ) then if ( mssql.LoginErrorMessage[ loginErrorCode ] == nil ) then
stdnse.debug2("Attemping login to %s: Unknown login error number: %s", instance:GetName(), loginErrorCode ) stdnse.debug2("Attemping login to %s: Unknown login error number: %s", instance:GetName(), loginErrorCode )

View File

@@ -605,7 +605,7 @@ action = function(host)
udp_ports[generated_ports[2]] = true udp_ports[generated_ports[2]] = true
udp_ports[generated_ports[4]] = true udp_ports[generated_ports[4]] = true
table.insert(response, string.format("Checking for Conficker.C or higher...")) table.insert(response, "Checking for Conficker.C or higher...")
-- Check the TCP ports -- Check the TCP ports
for port in pairs(tcp_ports) do for port in pairs(tcp_ports) do

View File

@@ -115,7 +115,7 @@ action = function(host, port)
local url_iter = urlIterator(f) local url_iter = urlIterator(f)
if ( not(url_iter) ) then if ( not(url_iter) ) then
return stdnse.format_output(false, ("Could not open the URL dictionary: "):format(f)) return stdnse.format_output(false, ("Could not open the URL dictionary: %s"):format(f))
end end
local threads = {} local threads = {}

View File

@@ -84,13 +84,13 @@ action = function(host)
if(#data.groups > 0) then if(#data.groups > 0) then
table.insert(piece, string.format("Groups: %s", stdnse.strjoin(", ", data.groups))) table.insert(piece, string.format("Groups: %s", stdnse.strjoin(", ", data.groups)))
else else
table.insert(piece, string.format("Groups: n/a")) table.insert(piece, "Groups: n/a")
end end
if(#data.users > 0) then if(#data.users > 0) then
table.insert(piece, string.format("Users: %s", stdnse.strjoin(", ", data.users))) table.insert(piece, string.format("Users: %s", stdnse.strjoin(", ", data.users)))
else else
table.insert(piece, string.format("Users: n/a")) table.insert(piece, "Users: n/a")
end end
-- Floor data.max_password_age, if possible -- Floor data.max_password_age, if possible
@@ -111,7 +111,7 @@ action = function(host)
if(data.lockout_threshold) then if(data.lockout_threshold) then
table.insert(piece, string.format("Account lockout: %s attempts in %s minutes will lock out the account for %s minutes", data.lockout_threshold, data.lockout_window or "unlimited", data.lockout_duration or "unlimited")) table.insert(piece, string.format("Account lockout: %s attempts in %s minutes will lock out the account for %s minutes", data.lockout_threshold, data.lockout_window or "unlimited", data.lockout_duration or "unlimited"))
else else
table.insert(piece, string.format("Account lockout disabled")) table.insert(piece, "Account lockout disabled")
end end
table.insert(response, piece) table.insert(response, piece)

View File

@@ -948,7 +948,7 @@ local function get_config(host, config)
enabled = false enabled = false
mod.disabled_message = {} mod.disabled_message = {}
table.insert(mod.disabled_message, string.format("Configuration error: Required argument(s) ('%s') weren't given.", stdnse.strjoin("', '", missing_args))) table.insert(mod.disabled_message, string.format("Configuration error: Required argument(s) ('%s') weren't given.", stdnse.strjoin("', '", missing_args)))
table.insert(mod.disabled_message, string.format("Please add --script-args=[arg]=[value] to your commandline to run this module")) table.insert(mod.disabled_message, "Please add --script-args=[arg]=[value] to your commandline to run this module")
if(#missing_args == 1) then if(#missing_args == 1) then
table.insert(mod.disabled_message, string.format("For example: --script-args=%s=123", missing_args[1])) table.insert(mod.disabled_message, string.format("For example: --script-args=%s=123", missing_args[1]))
else else
@@ -1188,7 +1188,7 @@ local function create_service(host, config)
cleanup(host, config) cleanup(host, config)
if(string.find(err, "MARKED_FOR_DELETE")) then if(string.find(err, "MARKED_FOR_DELETE")) then
return false, string.format("Service is stuck in 'being deleted' phase on remote machine; try setting script-args=randomseed=abc for now", err) return false, "Service is stuck in 'being deleted' phase on remote machine; try setting script-args=randomseed=abc for now"
else else
return false, string.format("Couldn't create the service on the remote machine: %s", err) return false, string.format("Couldn't create the service on the remote machine: %s", err)
end end
@@ -1278,7 +1278,7 @@ local function get_output_file(host, config)
stdnse.debug1("Error in remote service: output file was never created!") stdnse.debug1("Error in remote service: output file was never created!")
cleanup(host, config) cleanup(host, config)
return false, string.format("Error in remote service: output file was never created") return false, "Error in remote service: output file was never created"
end end
stdnse.debug1("Output file %s doesn't exist yet, waiting for %d more seconds", config.output_file, i) stdnse.debug1("Output file %s doesn't exist yet, waiting for %d more seconds", config.output_file, i)