mirror of
https://github.com/nmap/nmap.git
synced 2025-12-18 13:39:02 +00:00
Handle servers which offer ciphers we didn't request
Code from David.
This commit is contained in:
@@ -282,6 +282,17 @@ local function merge_recursive(chunks, cmp)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- https://bugzilla.mozilla.org/show_bug.cgi?id=946147
|
||||||
|
local function remove_high_byte_ciphers(t)
|
||||||
|
local output = {}
|
||||||
|
for i, v in ipairs(t) do
|
||||||
|
if tls.CIPHERS[v] <= 255 then
|
||||||
|
output[#output+1] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
local function find_ciphers_group(host, port, protocol, group)
|
local function find_ciphers_group(host, port, protocol, group)
|
||||||
local name, protocol_worked, record, results
|
local name, protocol_worked, record, results
|
||||||
results = {}
|
results = {}
|
||||||
@@ -330,12 +341,22 @@ local function find_ciphers_group(host, port, protocol, group)
|
|||||||
protocol_worked = true
|
protocol_worked = true
|
||||||
name = record["body"][1]["cipher"]
|
name = record["body"][1]["cipher"]
|
||||||
stdnse.debug2("Cipher %s chosen.", name)
|
stdnse.debug2("Cipher %s chosen.", name)
|
||||||
remove(group, name)
|
if not remove(group, name) then
|
||||||
|
stdnse.debug1("%s: chose cipher %s that was not offered.", t.protocol, name)
|
||||||
|
stdnse.debug1("%s: removing high-byte ciphers and trying again.", t.protocol)
|
||||||
|
local size_before = #group
|
||||||
|
group = remove_high_byte_ciphers(group)
|
||||||
|
stdnse.debug1("%s: removed %d high-byte ciphers.", t.protocol, size_before - #group)
|
||||||
|
if #group == size_before then
|
||||||
|
-- No changes... Server just doesn't like our offered ciphers.
|
||||||
|
break
|
||||||
|
end
|
||||||
|
else
|
||||||
-- Add cipher to the list of accepted ciphers.
|
-- Add cipher to the list of accepted ciphers.
|
||||||
table.insert(results, name)
|
table.insert(results, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return results, protocol_worked
|
return results, protocol_worked
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user