mirror of
https://github.com/nmap/nmap.git
synced 2026-01-05 22:19:03 +00:00
Re-indent some libs and scripts, change 4 to 2-space indent
Mostly found with:
for i in nselib/*.lua scripts/*.nse; do
echo $(perl -lne 'BEGIN{$a=$p=0}next unless $_;/^(\s*)/;' \
-e '$l=length$1;next if$l==$p;$a+=(abs($l-$p)-$a)/$.;' \
-e '$p=$l;END{print$a}' $i) $i
done | sort -nr
And indented with: https://gist.github.com/bonsaiviking/8845871
whois-ip.nse was particularly mangled (probably my fault due to using
vim's built-in indentation script, but it could be structured better)
This commit is contained in:
@@ -49,36 +49,36 @@ categories = {"default", "discovery", "safe"}
|
||||
|
||||
-- helper function
|
||||
local follow_redirects = function(host, port, path, n)
|
||||
local pattern = "^[hH][tT][tT][pP]/1.[01] 30[12]"
|
||||
local response = http.get(host, port, path)
|
||||
local pattern = "^[hH][tT][tT][pP]/1.[01] 30[12]"
|
||||
local response = http.get(host, port, path)
|
||||
|
||||
while (response['status-line'] or ""):match(pattern) and n > 0 do
|
||||
n = n - 1
|
||||
local loc = response.header['location']
|
||||
response = http.get_url(loc)
|
||||
end
|
||||
while (response['status-line'] or ""):match(pattern) and n > 0 do
|
||||
n = n - 1
|
||||
local loc = response.header['location']
|
||||
response = http.get_url(loc)
|
||||
end
|
||||
|
||||
return response
|
||||
return response
|
||||
end
|
||||
|
||||
portrule = shortport.http
|
||||
|
||||
action = function(host, port)
|
||||
local response, loc, generator
|
||||
local path = stdnse.get_script_args('http-generator.path') or '/'
|
||||
local redirects = tonumber(stdnse.get_script_args('http-generator.redirects')) or 3
|
||||
local response, loc, generator
|
||||
local path = stdnse.get_script_args('http-generator.path') or '/'
|
||||
local redirects = tonumber(stdnse.get_script_args('http-generator.redirects')) or 3
|
||||
|
||||
-- Worst case: <meta name=Generator content="Microsoft Word 11">
|
||||
local pattern = '<meta name="?generator"? content="([^\"]*)" ?/?>'
|
||||
-- Worst case: <meta name=Generator content="Microsoft Word 11">
|
||||
local pattern = '<meta name="?generator"? content="([^\"]*)" ?/?>'
|
||||
|
||||
-- make pattern case-insensitive
|
||||
pattern = pattern:gsub("%a", function (c)
|
||||
return string.format("[%s%s]", string.lower(c),
|
||||
string.upper(c))
|
||||
end)
|
||||
-- make pattern case-insensitive
|
||||
pattern = pattern:gsub("%a", function (c)
|
||||
return string.format("[%s%s]", string.lower(c),
|
||||
string.upper(c))
|
||||
end)
|
||||
|
||||
response = follow_redirects(host, port, path, redirects)
|
||||
if ( response and response.body ) then
|
||||
return response.body:match(pattern)
|
||||
end
|
||||
response = follow_redirects(host, port, path, redirects)
|
||||
if ( response and response.body ) then
|
||||
return response.body:match(pattern)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user