1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00

Remove unnecessary vars and redistribute declarations

This commit is contained in:
dmiller
2014-11-07 16:39:24 +00:00
parent 111fbe4b41
commit e11a8609a7

View File

@@ -446,14 +446,13 @@ end
-- handle many client ciphers at once), and then call find_ciphers_group on -- handle many client ciphers at once), and then call find_ciphers_group on
-- each chunk. -- each chunk.
local function find_ciphers(host, port, protocol) local function find_ciphers(host, port, protocol)
local name, protocol_worked, results, chunk
local ciphers = in_chunks(sorted_keys(tls.CIPHERS), CHUNK_SIZE) local ciphers = in_chunks(sorted_keys(tls.CIPHERS), CHUNK_SIZE)
results = {} local results = {}
-- Try every cipher. -- Try every cipher.
for _, group in ipairs(ciphers) do for _, group in ipairs(ciphers) do
chunk, protocol_worked = find_ciphers_group(host, port, protocol, group) local chunk, protocol_worked = find_ciphers_group(host, port, protocol, group)
if protocol_worked == nil then return nil end if protocol_worked == nil then return nil end
for _, name in ipairs(chunk) do for _, name in ipairs(chunk) do
table.insert(results, name) table.insert(results, name)
@@ -630,13 +629,12 @@ local function sort_ciphers(host, port, protocol, ciphers)
end end
local function try_protocol(host, port, protocol, upresults) local function try_protocol(host, port, protocol, upresults)
local ciphers, compressors, results
local condvar = nmap.condvar(upresults) local condvar = nmap.condvar(upresults)
results = stdnse.output_table() local results = stdnse.output_table()
-- Find all valid ciphers. -- Find all valid ciphers.
ciphers = find_ciphers(host, port, protocol) local ciphers = find_ciphers(host, port, protocol)
if ciphers == nil then if ciphers == nil then
condvar "signal" condvar "signal"
return nil return nil
@@ -652,6 +650,7 @@ local function try_protocol(host, port, protocol, upresults)
return nil return nil
end end
-- Find all valid compression methods. -- Find all valid compression methods.
local compressors
for _, c in ipairs(in_chunks(ciphers, CHUNK_SIZE)) do for _, c in ipairs(in_chunks(ciphers, CHUNK_SIZE)) do
compressors = find_compressors(host, port, protocol, c) compressors = find_compressors(host, port, protocol, c)
-- I observed a weird interaction between ECDSA ciphers and DEFLATE compression. -- I observed a weird interaction between ECDSA ciphers and DEFLATE compression.
@@ -774,7 +773,6 @@ function sorted_by_key(t)
end end
action = function(host, port) action = function(host, port)
local name, result, results
rankedciphersfilename=stdnse.get_script_args("ssl-enum-ciphers.rankedcipherlist") rankedciphersfilename=stdnse.get_script_args("ssl-enum-ciphers.rankedcipherlist")
if rankedciphersfilename then if rankedciphersfilename then
@@ -785,7 +783,7 @@ action = function(host, port)
filltable(rankedciphersfilename,rankedciphers) filltable(rankedciphersfilename,rankedciphers)
end end
results = {} local results = {}
local condvar = nmap.condvar(results) local condvar = nmap.condvar(results)
local threads = {} local threads = {}
@@ -805,7 +803,7 @@ action = function(host, port)
end end
until next(threads) == nil until next(threads) == nil
if #( stdnse.keys(results) ) == 0 then if not next(results) then
return nil return nil
end end