Skip to content

Commit

Permalink
host_details.lua: add MAC-based host classification
Browse files Browse the repository at this point in the history
This commit adds to host details the classification of a host based
on its MAC address. The classification is performed according to
https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf.
This partially addresses issue #43.
  • Loading branch information
ariava committed Jul 8, 2015
1 parent 0161be0 commit 0d2eeeb
Show file tree
Hide file tree
Showing 3 changed files with 26,695 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/lua/host_details.lua
Expand Up @@ -362,7 +362,7 @@ if((page == "overview") or (page == nil)) then
print("<table class=\"table table-bordered table-striped\">\n")

if(host["ip"] ~= nil) then
print("<tr><th width=35%>(Router) MAC Address</th><td>" .. host["mac"].. "</td><td>")
print("<tr><th width=35%>(Router) MAC Address</th><td>" .. host["mac"].." ("..get_mac_classification(host["mac"]).. ")</td><td>")

if(host["localhost"] == true) then
dump_status = host["dump_host_traffic"]
Expand Down
23 changes: 23 additions & 0 deletions scripts/lua/modules/lua_utils.lua
Expand Up @@ -1505,6 +1505,10 @@ function split(s, delimiter)
return result;
end

function startswith(s, char)
return string.sub(s, 1, string.len(s)) == char
end

function strsplit(inputstr, sep)
if (inputstr == nil or inputstr == "") then return {} end
if sep == nil then
Expand Down Expand Up @@ -1576,3 +1580,22 @@ function makeTopStatsScriptsArray()
end
return(topArray)
end

function get_mac_classification(mac_address)
local file_mac = io.open(fixPath(dirs.installdir.."/third-party/well-known-MAC.txt"))
if (file_mac == nil) then return "" end
local mac_line = file_mac:read("*l")
while (mac_line ~= nil) do
if (not startswith(mac_line, "#") and mac_line ~= "") then
t = split(mac_line, "\t")
if (string.match(mac_address, t[1]..".*") ~= nil) then
file_mac.close()
return split(t[2], " ")[1]
end
end
mac_line = file_mac:read("*l")
end
file_mac.close()
return ""
end

0 comments on commit 0d2eeeb

Please sign in to comment.