mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +00:00
Use binary strings, not hex strings, as keys in ssl-known-key.
This commit is contained in:
@@ -44,16 +44,6 @@ categories = {"safe", "discovery", "vuln", "default"}
|
|||||||
local FINGERPRINT_FILE = "ssl-fingerprints"
|
local FINGERPRINT_FILE = "ssl-fingerprints"
|
||||||
|
|
||||||
local get_fingerprints = function(path)
|
local get_fingerprints = function(path)
|
||||||
local pretty = function(key)
|
|
||||||
local s = key:sub(1, 2)
|
|
||||||
|
|
||||||
for i = 3, 40, 2 do
|
|
||||||
s = s .. ":" .. key:sub(i, i + 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
return s:upper()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check registry for cached fingerprints.
|
-- Check registry for cached fingerprints.
|
||||||
if nmap.registry.ssl_fingerprints then
|
if nmap.registry.ssl_fingerprints then
|
||||||
stdnse.print_debug(2, "Using cached SSL fingerprints.")
|
stdnse.print_debug(2, "Using cached SSL fingerprints.")
|
||||||
@@ -88,12 +78,16 @@ local get_fingerprints = function(path)
|
|||||||
section = line
|
section = line
|
||||||
elseif section ~= nil then
|
elseif section ~= nil then
|
||||||
-- Add fingerprint to section.
|
-- Add fingerprint to section.
|
||||||
line = pretty(line)
|
local fingerprint = bin.pack("H", line)
|
||||||
stdnse.print_debug(4, "Added key %s to database.", line)
|
if #fingerprint == 20 then
|
||||||
fingerprints[line] = section
|
fingerprints[fingerprint] = section
|
||||||
|
stdnse.print_debug(4, "Added key %s to database.", line)
|
||||||
|
else
|
||||||
|
stdnse.print_debug(0, "Cannot parse presumed fingerprint %q in section %q.", line, section)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- Key found outside of section.
|
-- Key found outside of section.
|
||||||
stdnse.print_debug(1, "Key %s is not in a section.", pretty(line))
|
stdnse.print_debug(1, "Key %s is not in a section.", line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -128,8 +122,7 @@ action = function(host, port)
|
|||||||
local fingerprint_fmt = stdnse.tohex(fingerprint, {separator=" ", group=4})
|
local fingerprint_fmt = stdnse.tohex(fingerprint, {separator=" ", group=4})
|
||||||
|
|
||||||
-- Check SSL fingerprint against database.
|
-- Check SSL fingerprint against database.
|
||||||
local key = stdnse.tohex(fingerprint, {separator=":", group=2}):upper()
|
local section = fingerprints[fingerprint]
|
||||||
local section = fingerprints[key]
|
|
||||||
if not section then
|
if not section then
|
||||||
stdnse.print_debug(2, "%s was not in the database.", fingerprint_fmt)
|
stdnse.print_debug(2, "%s was not in the database.", fingerprint_fmt)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user