1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-29 02:49:01 +00:00

Reindent some scripts. Whitespace only.

https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
dmiller
2014-01-31 16:37:27 +00:00
parent 32936167c2
commit 078aa688c9
50 changed files with 2573 additions and 2573 deletions

View File

@@ -33,79 +33,79 @@ local last_len = 0
-- split the output in 50 character length lines
local function buildOutput(output, w)
local nl
local nl
if w:len() == 0 then
return nil
end
if w:len() == 0 then
return nil
end
-- check for duplicates
for i,v in ipairs(output) do
if w == v or w == v:sub(2, v:len()) then
return nil
end
end
-- check for duplicates
for i,v in ipairs(output) do
if w == v or w == v:sub(2, v:len()) then
return nil
end
end
-- format lines
if last_len == 0 or last_len + w:len() <= 50 then
last_len = last_len + w:len()
nl = ''
else
last_len = 0
nl = '\n'
end
-- format lines
if last_len == 0 or last_len + w:len() <= 50 then
last_len = last_len + w:len()
nl = ''
else
last_len = 0
nl = '\n'
end
output = output .. (nl .. w)
output = output .. (nl .. w)
end
-- parse all disallowed entries in body and add them to a strbuf
local function parse_robots(body, output)
for line in body:gmatch("[^\r\n]+") do
for w in line:gmatch('[Dd]isallow:%s*(.*)') do
w = w:gsub("%s*#.*", "")
buildOutput(output, w)
end
end
for line in body:gmatch("[^\r\n]+") do
for w in line:gmatch('[Dd]isallow:%s*(.*)') do
w = w:gsub("%s*#.*", "")
buildOutput(output, w)
end
end
return #output
return #output
end
action = function(host, port)
local dis_count, noun
local answer = http.get(host, port, "/robots.txt" )
local dis_count, noun
local answer = http.get(host, port, "/robots.txt" )
if answer.status ~= 200 then
return nil
end
if answer.status ~= 200 then
return nil
end
local v_level = nmap.verbosity() + (nmap.debugging()*2)
local output = strbuf.new()
local detail = 15
local v_level = nmap.verbosity() + (nmap.debugging()*2)
local output = strbuf.new()
local detail = 15
dis_count = parse_robots(answer.body, output)
dis_count = parse_robots(answer.body, output)
if dis_count == 0 then
return
end
if dis_count == 0 then
return
end
-- verbose/debug mode, print 50 entries
if v_level > 1 and v_level < 5 then
detail = 40
-- double debug mode, print everything
elseif v_level >= 5 then
detail = dis_count
end
-- verbose/debug mode, print 50 entries
if v_level > 1 and v_level < 5 then
detail = 40
-- double debug mode, print everything
elseif v_level >= 5 then
detail = dis_count
end
-- check we have enough entries
if detail > dis_count then
detail = dis_count
end
-- check we have enough entries
if detail > dis_count then
detail = dis_count
end
noun = dis_count == 1 and "entry " or "entries "
noun = dis_count == 1 and "entry " or "entries "
local shown = (detail == 0 or detail == dis_count)
and "\n" or '(' .. detail .. ' shown)\n'
local shown = (detail == 0 or detail == dis_count)
and "\n" or '(' .. detail .. ' shown)\n'
return dis_count .. " disallowed " .. noun ..
shown .. table.concat(output, ' ', 1, detail)
return dis_count .. " disallowed " .. noun ..
shown .. table.concat(output, ' ', 1, detail)
end