diff --git a/scripts/acarsd-info.nse b/scripts/acarsd-info.nse index 0e39a93d8..a1493aa5f 100644 --- a/scripts/acarsd-info.nse +++ b/scripts/acarsd-info.nse @@ -56,8 +56,7 @@ action = function(host, port) if not timeout or timeout < 0 then timeout = 10 end -- Set bytes - local bytes = tonumber(nmap.registry.args[SCRIPT_NAME .. '.bytes']) - if not bytes then bytes = 512 else tonumber(bytes) end + local bytes = tonumber(nmap.registry.args[SCRIPT_NAME .. '.bytes']) or 512 -- Connect and retrieve acarsd info in XML format over TCP stdnse.debug1("Connecting to %s:%s [Timeout: %ss]", host.targetname or host.ip, port.number, timeout) diff --git a/scripts/dns-brute.nse b/scripts/dns-brute.nse index 4426c0970..06d8b2372 100644 --- a/scripts/dns-brute.nse +++ b/scripts/dns-brute.nse @@ -184,7 +184,7 @@ action = function(host) nmap.registry.bruteddomains[domainname] = true stdnse.debug1("Starting dns-brute at: "..domainname) - local max_threads = stdnse.get_script_args('dns-brute.threads') and tonumber( stdnse.get_script_args('dns-brute.threads') ) or 5 + local max_threads = tonumber( stdnse.get_script_args('dns-brute.threads') ) or 5 local dosrv = stdnse.get_script_args("dns-brute.srv") or false stdnse.debug1("THREADS: "..max_threads) -- First look for dns-brute.hostlist diff --git a/scripts/drda-brute.nse b/scripts/drda-brute.nse index db72ebc75..e4272f95f 100644 --- a/scripts/drda-brute.nse +++ b/scripts/drda-brute.nse @@ -136,7 +136,7 @@ action = function( host, port ) local usernames, passwords, creds local database = stdnse.get_script_args('drda-brute.dbname') or "SAMPLE" local condvar = nmap.condvar( valid_accounts ) - local max_threads = stdnse.get_script_args('drda-brute.threads') and tonumber( stdnse.get_script_args('drda-brute.threads') ) or 10 + local max_threads = tonumber( stdnse.get_script_args('drda-brute.threads') ) or 10 -- Check if the DB specified is valid if( not(isValidDb(host, port, database)) ) then diff --git a/scripts/http-domino-enum-passwords.nse b/scripts/http-domino-enum-passwords.nse index b3f38fe7a..da6e2fa24 100644 --- a/scripts/http-domino-enum-passwords.nse +++ b/scripts/http-domino-enum-passwords.nse @@ -222,7 +222,7 @@ action = function(host, port) local creds, pos, pager local links, result, hashes,legacyHashes, id_files = {}, {}, {}, {},{} local chunk_size = 30 - local max_fetch = stdnse.get_script_args('domino-enum-passwords.count') and tonumber(stdnse.get_script_args('domino-enum-passwords.count')) or 10 + local max_fetch = tonumber(stdnse.get_script_args('domino-enum-passwords.count')) or 10 local http_response if ( nmap.registry['credentials'] and nmap.registry['credentials']['http'] ) then diff --git a/scripts/irc-sasl-brute.nse b/scripts/irc-sasl-brute.nse index c9d3a4733..b1579c653 100644 --- a/scripts/irc-sasl-brute.nse +++ b/scripts/irc-sasl-brute.nse @@ -195,7 +195,7 @@ action = function(host, port) -- irc servers seem to be restrictive about too many connection attempts -- in a short time thus we need to limit the number of threads local threads = stdnse.get_script_args(("%s.threads"):format(SCRIPT_NAME)) - threads = tonumber(threads) and tonumber(threads) or 2 + threads = tonumber(threads) or 2 engine:setMaxThreads(threads) local status, accounts = engine:start() return accounts diff --git a/scripts/ldap-search.nse b/scripts/ldap-search.nse index 65017045b..717aa087b 100644 --- a/scripts/ldap-search.nse +++ b/scripts/ldap-search.nse @@ -116,7 +116,7 @@ function action(host,port) local saveFile = stdnse.get_script_args('ldap.savesearch') local accounts local objCount = 0 - local maxObjects = stdnse.get_script_args('ldap.maxobjects') and tonumber(stdnse.get_script_args('ldap.maxobjects')) or 20 + local maxObjects = tonumber(stdnse.get_script_args('ldap.maxobjects')) or 20 -- In order to discover what protocol to use (SSL/TCP) we need to send a few bytes to the server -- An anonymous bind should do it diff --git a/scripts/ms-sql-hasdbaccess.nse b/scripts/ms-sql-hasdbaccess.nse index 9da6d1c6c..f4f7aeb8b 100644 --- a/scripts/ms-sql-hasdbaccess.nse +++ b/scripts/ms-sql-hasdbaccess.nse @@ -87,8 +87,7 @@ local function process_instance( instance ) local output = {} local exclude_dbs = { "'master'", "'tempdb'", "'model'", "'msdb'" } - local RS_LIMIT = stdnse.get_script_args( {'mssql-hasdbaccess.limit', 'ms-sql-hasdbaccess.limit' } ) - and tonumber(stdnse.get_script_args( {'mssql-hasdbaccess.limit', 'ms-sql-hasdbaccess.limit' } )) or 5 + local RS_LIMIT = tonumber(stdnse.get_script_args( {'mssql-hasdbaccess.limit', 'ms-sql-hasdbaccess.limit' } )) or 5 if ( RS_LIMIT <= 0 ) then limit = "" diff --git a/scripts/ms-sql-tables.nse b/scripts/ms-sql-tables.nse index f48645d33..be2e26482 100644 --- a/scripts/ms-sql-tables.nse +++ b/scripts/ms-sql-tables.nse @@ -112,10 +112,8 @@ local function process_instance( instance ) local done_dbs = {} local db_limit, tbl_limit - local DB_COUNT = stdnse.get_script_args( {'ms-sql-tables.maxdb', 'mssql-tables.maxdb'} ) - and tonumber( stdnse.get_script_args( {'ms-sql-tables.maxdb', 'mssql-tables.maxdb'} ) ) or 5 - local TABLE_COUNT = stdnse.get_script_args( {'ms-sql-tables.maxtables', 'mssql-tables.maxtables' } ) - and tonumber( stdnse.get_script_args( {'ms-sql-tables.maxtables', 'mssql-tables.maxtables' } ) ) or 2 + local DB_COUNT = tonumber( stdnse.get_script_args( {'ms-sql-tables.maxdb', 'mssql-tables.maxdb'} ) ) or 5 + local TABLE_COUNT = tonumber( stdnse.get_script_args( {'ms-sql-tables.maxtables', 'mssql-tables.maxtables' } ) ) or 2 local keywords_filter = "" if ( DB_COUNT <= 0 ) then @@ -129,9 +127,10 @@ local function process_instance( instance ) tbl_limit = string.format( "TOP %d", TABLE_COUNT ) end + local keywords_arg = stdnse.get_script_args( {'ms-sql-tables.keywords', 'mssql-tables.keywords' } ) -- Build the keyword filter - if ( stdnse.get_script_args( {'ms-sql-tables.keywords', 'mssql-tables.keywords' } ) ) then - local keywords = stdnse.get_script_args( {'ms-sql-tables.keywords', 'mssql-tables.keywords' } ) + if keywords_arg then + local keywords = keywords_arg local tmp_tbl = {} if( type(keywords) == 'string' ) then @@ -207,8 +206,8 @@ local function process_instance( instance ) local pos = 1 local restrict_tbl = {} - if ( stdnse.get_script_args( {'ms-sql-tables.keywords', 'mssql-tables.keywords' } ) ) then - local tmp = stdnse.get_script_args( {'ms-sql-tables.keywords', 'mssql-tables.keywords' } ) + if keywords_arg then + local tmp = keywords_arg if ( type(tmp) == 'table' ) then tmp = stdnse.strjoin(',', tmp) end