1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Give datafiles.lua the ability to parse nmap-mac-prefixes, and use it in

nbstat.nse to look up the MAC vendor string.
This commit is contained in:
david
2010-02-26 00:27:30 +00:00
parent 1f7e90a0af
commit 84a388aeb9
3 changed files with 48 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
--- Read and parse some of Nmap's data files: <code>nmap-protocols</code>,
-- <code>nmap-rpc</code>, and <code>nmap-services</code>.
-- <code>nmap-rpc</code>, <code>nmap-services</code>, and
-- <code>nmap-mac-prefixes</code>.
--
-- The functions in this module return values appropriate for use with exception
-- handling via <code>nmap.new_try</code>. On success, they return true and
@@ -23,7 +24,8 @@ local common_files = {
["nmap-protocols"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)" ) ) end] = "^%s*([^%s#]+)%s+%d+" },
["nmap-services"] = { ["tcp"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)/tcp" ) ) end] = "^%s*([^%s#]+)%s+%d+/tcp" },
["udp"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)/udp" ) ) end] = "^%s*([^%s#]+)%s+%d+/udp" }
}
},
["nmap-mac-prefixes"] = { [ "^%s*(%w+)%s+[^#]+" ] = "^%s*%w+%s+([^#]+)" }
}
@@ -90,6 +92,23 @@ parse_services = function(protocol)
end
---
-- Read and parse <code>nmap-mac-prefixes</code>.
--
-- On success, return true and a table mapping 3 byte MAC prefixes to manufacturer names.
-- @return Status (true or false).
-- @return Table (if status is true) or error string (if status is false).
-- @see parse_file
parse_mac_prefixes = function()
local status, mac_prefixes_table = parse_file("nmap-mac-prefixes")
if not status then
return false, "Error parsing nmap-mac-prefixes"
end
return true, mac_prefixes_table
end
---
-- Read and parse a generic data file. The other parse functions are
-- defined in terms of this one.