Use the new get_script_args() function to parse script arguments and clean some whitespaces.

This commit is contained in:
djalal 2010-08-17 01:58:47 +00:00
parent e52e6935d6
commit 9849be68a9
4 changed files with 54 additions and 49 deletions

View file

@ -80,6 +80,7 @@ author = "Patrik Karlsson, Djalal Harouni"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery", "safe"}
require 'stdnse'
require 'shortport'
require 'rpc'
require 'tab'
@ -239,13 +240,15 @@ action = function(host, port)
{
host = host,
port = port,
version = nmap.registry.args['nfs.version'] or nil,
maxfiles = tonumber(nmap.registry.args['nfs-ls.maxfiles']) or 10,
time = nmap.registry.args['nfs-ls.time'] or "",
human = nmap.registry.args['nfs-ls.human'] or nil,
--recurs = tonumber(nmap.registry.args['nfs-ls.recurs']) or 1,
}
nfs_info.version, nfs_info.maxfiles, nfs_info.time,
nfs_info.human = stdnse.get_script_args('nfs.version',
'nfs-ls.maxfiles','nfs-ls.time','nfs-ls.human')
nfs_info.maxfiles = tonumber(nfs_info.maxfiles) or 10
if nfs_info.time == "a" or nfs_info.time == "A" then
nfs_info.time = "atime"
elseif nfs_info.time == "c" or nfs_info.time == "C" then

View file

@ -26,6 +26,7 @@ author = "Patrik Karlsson"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery", "safe"}
require("stdnse")
require("shortport")
require("rpc")
@ -33,21 +34,21 @@ portrule = shortport.port_or_service(111, "rpcbind", {"tcp", "udp"} )
action = function(host, port)
local status, mounts, proto
local result = {}
status, mounts = rpc.Helper.ShowMounts( host, port )
local status, mounts, proto
local result = {}
status, mounts = rpc.Helper.ShowMounts( host, port )
if not status or mounts == nil then
return stdnse.format_output(false, mounts)
end
if not status or mounts == nil then
return stdnse.format_output(false, mounts)
end
for _, v in ipairs( mounts ) do
local entry = v.name
entry = entry .. " " .. stdnse.strjoin(" ", v)
table.insert( result, entry )
end
return stdnse.format_output( true, result )
for _, v in ipairs( mounts ) do
local entry = v.name
entry = entry .. " " .. stdnse.strjoin(" ", v)
table.insert( result, entry )
end
return stdnse.format_output( true, result )
end

View file

@ -31,6 +31,7 @@ author = "Patrik Karlsson, Djalal Harouni"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery", "safe"}
require("stdnse")
require("shortport")
require("rpc")
require("tab")
@ -143,29 +144,29 @@ local function nfs_filesystem_info(nfs, mount, filesystem)
status, res = table_fsstat(nfs, mount, res)
if status then
for k, v in pairs(res) do
results[k] = v
results[k] = v
end
end
if nfs_comm.version == 3 then
status, res = nfsobj:FsInfo(nfs_comm, fhandle)
if status then
status, res = table_fsinfo(nfs, res)
if status then
for k, v in pairs(res) do
results[k] = v
end
end
status, res = table_fsinfo(nfs, res)
if status then
for k, v in pairs(res) do
results[k] = v
end
end
end
status, res = nfsobj:PathConf(nfs_comm, fhandle)
if status then
status, res = table_pathconf(nfs, res)
if status then
for k, v in pairs(res) do
results[k] = v
end
end
if status then
for k, v in pairs(res) do
results[k] = v
end
end
end
end
@ -187,8 +188,8 @@ action = function(host, port)
{
host = host,
port = port,
human = nmap.registry.args['nfs-statfs.human'] or nil,
}
nfs_info.human = stdnse.get_script_args('nfs-statfs.human')
status, mounts = rpc.Helper.ShowMounts( host, port )
if (not(status)) then
@ -204,5 +205,5 @@ action = function(host, port)
end
table.insert(o, report(nfs_info, fs_info))
return stdnse.format_output(true, o)
return stdnse.format_output(true, o)
end

View file

@ -28,20 +28,20 @@ portrule = shortport.port_or_service(111, "rpcbind", {"tcp", "udp"} )
action = function(host, port)
local result = {}
local status, rpcinfo = rpc.Helper.RpcInfo( host, port )
if ( not(status) ) then
return stdnse.format_output(false, rpcinfo)
end
for progid, v in pairs(rpcinfo) do
for proto, v2 in pairs(v) do
table.insert( result, ("%-7d %-10s %5d/%s %s"):format(progid, stdnse.strjoin(",", v2.version), v2.port, proto, rpc.Util.ProgNumberToName(progid) or "") )
end
end
table.sort(result)
return stdnse.format_output( true, result )
local result = {}
local status, rpcinfo = rpc.Helper.RpcInfo( host, port )
if ( not(status) ) then
return stdnse.format_output(false, rpcinfo)
end
for progid, v in pairs(rpcinfo) do
for proto, v2 in pairs(v) do
table.insert( result, ("%-7d %-10s %5d/%s %s"):format(progid, stdnse.strjoin(",", v2.version), v2.port, proto, rpc.Util.ProgNumberToName(progid) or "") )
end
end
table.sort(result)
return stdnse.format_output( true, result )
end