mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +00:00
o [NSE] Do not print an empty line if there are no remaining characters.
This patch was contributed by Chris Woodbury.
This commit is contained in:
parent
950e435921
commit
47345ac696
1 changed files with 19 additions and 15 deletions
|
|
@ -86,26 +86,30 @@ function print_hex(str)
|
|||
end
|
||||
|
||||
-- Prints out the final, partial line
|
||||
local line = math.floor((#str/16)) + 1
|
||||
io.write(string.format("%08x ", (line - 1) * 16))
|
||||
if (#str % 16 ~= 0) then
|
||||
local line = math.floor((#str/16)) + 1
|
||||
io.write(string.format("%08x ", (line - 1) * 16))
|
||||
|
||||
for char=1, #str % 16, 1 do
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
io.write(string.format("%02x ", ch))
|
||||
end
|
||||
io.write(string.rep(" ", 16 - (#str % 16)));
|
||||
io.write(" ")
|
||||
|
||||
for char=1, #str % 16, 1 do
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
if ch < 0x20 or ch > 0x7f then
|
||||
ch = string.byte(".", 1)
|
||||
for char=1, #str % 16, 1 do
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
io.write(string.format("%02x ", ch))
|
||||
end
|
||||
io.write(string.format("%c", ch))
|
||||
io.write(string.rep(" ", 16 - (#str % 16)));
|
||||
io.write(" ")
|
||||
|
||||
for char=1, #str % 16, 1 do
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
if ch < 0x20 or ch > 0x7f then
|
||||
ch = string.byte(".", 1)
|
||||
end
|
||||
io.write(string.format("%c", ch))
|
||||
end
|
||||
|
||||
io.write("\n")
|
||||
end
|
||||
|
||||
-- Print out the length
|
||||
io.write(string.format("\n Length: %d [0x%x]\n", #str, #str))
|
||||
io.write(string.format(" Length: %d [0x%x]\n", #str, #str))
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue