mirror of
https://github.com/nmap/nmap.git
synced 2026-01-04 21:59:02 +00:00
Updated to Lua 5.1.3 (Bug fix release)
Updated stdnse to include tobinary, toocal, and tohex functions. Minor optimizations to listop.lua
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
-- See nmaps COPYING for licence
|
||||
module(..., package.seeall)
|
||||
module(... or "stdnse", package.seeall)
|
||||
|
||||
print_debug = function(...)
|
||||
local verbosity = 1;
|
||||
@@ -104,3 +104,39 @@ make_buffer = function(sd, sep)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
do
|
||||
local t = {
|
||||
["0"] = "0000",
|
||||
["1"] = "0001",
|
||||
["2"] = "0010",
|
||||
["3"] = "0011",
|
||||
["4"] = "0100",
|
||||
["5"] = "0101",
|
||||
["6"] = "0110",
|
||||
["7"] = "0111",
|
||||
["8"] = "1000",
|
||||
["9"] = "1001",
|
||||
a = "1010",
|
||||
b = "1011",
|
||||
c = "1100",
|
||||
d = "1101",
|
||||
e = "1110",
|
||||
f = "1111"
|
||||
};
|
||||
|
||||
function tobinary(n)
|
||||
assert(tonumber(n), "number expected");
|
||||
return (("%x"):format(n):gsub("%w", t):gsub("^0*", ""));
|
||||
end
|
||||
end
|
||||
|
||||
function tooctal(n)
|
||||
assert(tonumber(n), "number expected");
|
||||
return ("%o"):format(n)
|
||||
end
|
||||
|
||||
function tohex(n)
|
||||
assert(tonumber(n), "number expected");
|
||||
return ("%x"):format(n);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user