1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-04 13:49:03 +00:00

Normalize tab.lua usage so that a call to tab.nextrow comes after (not

before) each group of tab.add, and there is no tab.nextrow before or
after tab.addrow. Also remove manual indenting that was accomplished by
padding the first column with spaces; this is done by
stdnse.format_output now.
This commit is contained in:
david
2010-12-30 21:08:25 +00:00
parent 04210ef88f
commit a9a5869173
6 changed files with 20 additions and 24 deletions

View File

@@ -12,6 +12,8 @@
-- tab.nextrow(t)
-- tab.add(t, 1, 'BBBBBBBBB1')
-- tab.add(t, 2, 'BBB2')
-- tab.nextrow(t)
-- tab.addrow(t, 'C1', 'C2')
-- tab.dump(t)
-- </code>
-- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html

View File

@@ -348,7 +348,6 @@ function parse_records_table(number, data, table, offset)
local answer, st = {}
st, offset = get_answer_record(answer, data, offset)
if st then
tab.nextrow(table)
if answer.domain then
tab.add(table, 1, answer.domain)
end
@@ -358,6 +357,7 @@ function parse_records_table(number, data, table, offset)
if answer.rdata then
tab.add(table, 3, answer.rdata)
end
tab.nextrow(table)
end
number = number - 1
end
@@ -429,8 +429,7 @@ function add_zone_info(response)
local outtab, nhosts = tab.new(), 0
local newhosts_count, status, ret = 0, false
tab.nextrow(outtab)
tab.addrow(outtab, " Domains", "Added Targets")
tab.addrow(outtab, "Domains", "Added Targets")
for rdata in pairs(RR['Node Names']) do
status, ret = target.add(rdata)
if not status then
@@ -442,11 +441,12 @@ function add_zone_info(response)
if newhosts_count == 0 then
return false, ret and ret or "Error: failed to add DNS records."
end
tab.addrow(outtab, " Node Names", newhosts_count)
tab.addrow(outtab, "Node Names", newhosts_count)
nhosts = newhosts_count
tab.nextrow(outtab)
tab.addrow(outtab, " DNS Records", "Added Targets")
tab.addrow(outtab, "DNS Records", "Added Targets")
for rectype in pairs(RR) do
newhosts_count = 0
-- filter Private IPs
@@ -475,7 +475,7 @@ function add_zone_info(response)
end
if newhosts_count ~= 0 then
tab.addrow(outtab, " "..rectype, newhosts_count)
tab.addrow(outtab, rectype, newhosts_count)
nhosts = nhosts + newhosts_count
elseif nhosts == 0 then
-- error: we can't add new targets
@@ -488,7 +488,7 @@ function add_zone_info(response)
return false, "Error: failed to add valid DNS records."
end
return true, tab.dump(outtab) ..
return true, tab.dump(outtab) .. "\n" ..
string.format("Total new targets added to Nmap scan queue: %d.",
nhosts)
end

View File

@@ -395,13 +395,14 @@ local function report(tested, forwarded)
tab.add(output, 1, "PROTOCOL")
tab.add(output, 2, "FORWARDED PORTS")
tab.nextrow(output)
-- script output: one line per protocol
for proto in pairs(tested) do
if #tested[proto] ~= 0 then
tab.nextrow(output)
tab.add(output, 1, proto)
tab.add(output, 2, portrange(forwarded[proto]))
tab.nextrow(output)
end
end

View File

@@ -30,7 +30,6 @@ These access permissions are shown only with NFSv3:
-- | nfs-ls:
-- | Arguments:
-- | maxfiles: 10 (file listing output limited)
-- |
-- | NFS Export: /mnt/nfs/files
-- | NFS Access: Read Lookup NoModify NoExtend NoDelete NoExecute
-- |
@@ -38,7 +37,6 @@ These access permissions are shown only with NFSv3:
-- | drwxr-xr-x 1000 100 4096 2010-06-17 12:28 /mnt/nfs/files
-- | drwxr--r-- 1000 1002 4096 2010-05-14 12:58 sources
-- | -rw------- 1000 1002 23606 2010-06-17 12:28 notes
-- |
-- | NFS Export: /home/storage/backup
-- | NFS Access: Read Lookup Modify Extend Delete NoExecute
-- |
@@ -217,17 +215,16 @@ local function report(nfs, table)
time = "CHANGE TIME"
end
tab.nextrow(outtab)
tab.add(outtab, 1, " PERMISSION")
tab.add(outtab, 1, "PERMISSION")
tab.add(outtab, 2, "UID")
tab.add(outtab, 3, "GID")
tab.add(outtab, 4, "SIZE")
tab.add(outtab, 5, time)
tab.add(outtab, 6, "FILENAME")
tab.nextrow(outtab)
for _,f in pairs(table) do
local perm = " " .. f.type .. f.mode
tab.nextrow(outtab)
local perm = f.type .. f.mode
tab.addrow(outtab, perm, f.uid, f.gid,
f.size, f.time, f.filename)
end
@@ -283,7 +280,7 @@ action = function(host, port)
if #access ~= 0 then
table.insert(o, string.format("NFS Access: %s", access[1]))
end
table.insert(o, report(nfs_info, results))
table.insert(o, {report(nfs_info, results)})
end
end

View File

@@ -10,7 +10,6 @@ the version used is NFSv3.
-- @output
-- PORT STATE SERVICE
-- | nfs-statfs:
-- |
-- | Filesystem 1K-blocks Used Available Use% Blocksize
-- | /mnt/nfs/files 5542276 2732012 2528728 52% 4096
-- |_ /mnt/nfs/opensource 5534416 620640 4632644 12% 4096
@@ -72,7 +71,7 @@ end
local function report(nfs, tables)
local outtab, tab_size, tab_avail
local tab_filesys, tab_used, tab_use,
tab_bs, tab_maxfs, tab_linkmax = " Filesystem",
tab_bs, tab_maxfs, tab_linkmax = "Filesystem",
"Used", "Use%", "Blocksize", "Maxfilesize", "Maxlink"
if nfs.human then
@@ -85,22 +84,18 @@ local function report(nfs, tables)
if nfs.version == 2 then
outtab = tab.new()
tab.nextrow(outtab)
tab.addrow(outtab, tab_filesys, tab_size, tab_used,
tab_avail, tab_use, tab_bs)
for _, t in ipairs(tables) do
tab.nextrow(outtab)
tab.addrow(outtab, " "..t.filesystem, t.size,
tab.addrow(outtab, t.filesystem, t.size,
t.used, t.available, t.use, t.bsize)
end
elseif nfs.version == 3 then
outtab = tab.new()
tab.nextrow(outtab)
tab.addrow(outtab, tab_filesys, tab_size, tab_used,
tab_avail, tab_use, tab_maxfs, tab_linkmax)
for _, t in ipairs(tables) do
tab.nextrow(outtab)
tab.addrow(outtab, " "..t.filesystem, t.size, t.used,
tab.addrow(outtab, t.filesystem, t.size, t.used,
t.available, t.use, t.maxfilesize, t.linkmax)
end
end

View File

@@ -238,6 +238,7 @@ local report = function(stats)
tab.add(outtab, 3, "MEAN (us)")
tab.add(outtab, 4, "STDDEV")
tab.add(outtab, 5, "LOSS (%)")
tab.nextrow(outtab)
for _, j in pairs(stats) do
port = tostring(j.port)
@@ -246,12 +247,12 @@ local report = function(stats)
stddev = string.format("%.2f", math.sqrt(j.K / (j.num - 1)))
loss = string.format("%.1f%%", 100 * (1 - j.num / j.sent))
tab.nextrow(outtab)
tab.add(outtab, 1, port)
tab.add(outtab, 2, fam)
tab.add(outtab, 3, mean)
tab.add(outtab, 4, stddev)
tab.add(outtab, 5, loss)
tab.nextrow(outtab)
end
return tab.dump(outtab)