diff --git a/nselib/packet.lua b/nselib/packet.lua index d7dfabee7..70928760e 100644 --- a/nselib/packet.lua +++ b/nselib/packet.lua @@ -580,43 +580,3 @@ function Packet:tcp_lookup_link() end return string.format("unknown-%i", self.tcp_opt_mtu) end - ----------------------------------------------------------------------------------------------------------------- - --- UTILS - ---- Convert a byte string to a hex string. --- @param str Byte string. --- @return Hex string. -function bintohex(str) - local b = "" - if not str then -- nil - return "" - end - for c in string.gmatch(str, ".") do - b = string.format('%s%02x',b, string.byte(c)) - end - return b -end - - - ---- Convert a hex string to a byte string. --- --- Only bytes [a-f0-9A-F] from input are interpreted. The rest is --- ignored. The number of interpreted bytes must be even. --- @param str Hex string. --- @return Byte string. --- @usage --- hextobin("20 20 20") --> " " --- hextobin("414243") --> "ABC" --- hextobin("\\41\\42\\43") --> "ABC" --- hextobin(" 41 42 43 ") --> "ABC" -function hextobin(str) - return (string.gsub(str, "%X*(%x%x)%X*", function(a) - return string.char(tonumber(a, 16)); - end)); -end - - - diff --git a/scripts/sniffer-detect.nse b/scripts/sniffer-detect.nse index 2761cda9e..144148556 100644 --- a/scripts/sniffer-detect.nse +++ b/scripts/sniffer-detect.nse @@ -24,16 +24,6 @@ hostrule = function(host, port) nmap.get_interface_link(host.interface) == 'ethernet' end ---[[ -function bintohex(str) - local b = "" - for c in string.gmatch(str, ".") do - b = string.format('%s%02x',b, string.byte(c)) - end - return b -end ---]] - callback = function(packetsz, layer2, layer3) return string.sub(layer2, 0, 12) end