diff --git a/scripts/bittorrent-discovery.nse b/scripts/bittorrent-discovery.nse index b197a9ec5..06d5303a9 100644 --- a/scripts/bittorrent-discovery.nse +++ b/scripts/bittorrent-discovery.nse @@ -21,10 +21,10 @@ peers as targets. -- @usage -- nmap --script bittorrent-discovery --script-args newtargets,bittorrent-discovery.torrent= -- --- @arg torrent, a string containing the filename of the torrent file --- @arg magnet, a string containing the magnet link of the torrent --- @arg timeout, desired (not actual) timeout for the DHT discovery (default = 30 s) --- @arg include-nodes, boolean selecting whether to show only nodes +-- @args bittorrent-discovery.torrent a string containing the filename of the torrent file +-- @args bittorrent-discovery.magnet a string containing the magnet link of the torrent +-- @args bittorrent-discover.timeout desired (not actual) timeout for the DHT discovery (default = 30s) +-- @args bittorrent-discover.include-nodes boolean selecting whether to show only nodes -- -- @output -- | bittorrent-peers: @@ -59,7 +59,7 @@ prerule = function() end action = function() - local timeout = stdnse.get_script_args(SCRIPT_NAME..".dht_timeout") + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME..".timeout")) local filename = stdnse.get_script_args(SCRIPT_NAME..".torrent") local magnet = stdnse.get_script_args(SCRIPT_NAME..".magnet") local include_nodes = stdnse.get_script_args(SCRIPT_NAME..".include-nodes") diff --git a/scripts/broadcast-bjnp-discover.nse b/scripts/broadcast-bjnp-discover.nse index d26f3109e..17639b601 100644 --- a/scripts/broadcast-bjnp-discover.nse +++ b/scripts/broadcast-bjnp-discover.nse @@ -26,6 +26,8 @@ information for all discovered devices. -- | Description: Canon MG5200 series -- |_ Command: MultiPass 2.1,IVEC -- +-- @args broadcast-bjnp-discover.timeout specifies the amount of seconds to sniff +-- the network interface. (default 30s) author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -39,7 +41,7 @@ local table = require("table") local printer_port = { number = 8611, protocol = "udp"} local scanner_port = { number = 8612, protocol = "udp"} -local arg_timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) prerule = function() if ( nmap.address_family() ~= 'inet' ) then @@ -169,4 +171,4 @@ action = function() if ( result ) then return stdnse.format_output(true, result) end -end \ No newline at end of file +end diff --git a/scripts/broadcast-dhcp-discover.nse b/scripts/broadcast-dhcp-discover.nse index 234de1bf4..d2620c423 100644 --- a/scripts/broadcast-dhcp-discover.nse +++ b/scripts/broadcast-dhcp-discover.nse @@ -137,11 +137,8 @@ end action = function() local host, port = "255.255.255.255", 67 - local timeout = stdnse.get_script_args("broadcast-dhcp-discover.timeout") - timeout = tonumber(timeout) or 10 - - -- convert from seconds to ms - timeout = timeout * 1000 + local timeout = stdnse.parse_timespec(stdnse.get_script_args("broadcast-dhcp-discover.timeout")) + timeout = (timeout or 10) * 1000 -- randomizing the MAC could exhaust dhcp servers with small scopes -- if ran multiple times, so we should probably refrain from doing diff --git a/scripts/broadcast-eigrp-discovery.nse b/scripts/broadcast-eigrp-discovery.nse index 631f14dc2..696dfdab5 100644 --- a/scripts/broadcast-eigrp-discovery.nse +++ b/scripts/broadcast-eigrp-discovery.nse @@ -196,11 +196,11 @@ action = function() -- Get script arguments local as = stdnse.get_script_args(SCRIPT_NAME .. ".as") local kparams = stdnse.get_script_args(SCRIPT_NAME .. ".kparams") or "101000" - local timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or 10 + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) local interface = stdnse.get_script_args(SCRIPT_NAME .. ".interface") local output, responses, interfaces, lthreads = {}, {}, {}, {} local result, response, route, eigrp_hello, k - local timeout = timeout * 1000 + local timeout = (timeout or 10) * 1000 -- K params should be of length 6 -- Cisco routers ignore eigrp packets that don't have matching K parameters diff --git a/scripts/broadcast-igmp-discovery.nse b/scripts/broadcast-igmp-discovery.nse index a556b014b..b909485eb 100644 --- a/scripts/broadcast-igmp-discovery.nse +++ b/scripts/broadcast-igmp-discovery.nse @@ -317,10 +317,10 @@ local mgroup_name_identify = function(db, ip) end action = function(host, port) - local timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) or 7 + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) local version = stdnse.get_script_args(SCRIPT_NAME .. ".version") or 2 local interface = stdnse.get_script_args(SCRIPT_NAME .. ".interface") - timeout = timeout * 1000 + timeout = (timeout or 7) * 1000 if version ~= 'all' then version = tonumber(version) end diff --git a/scripts/broadcast-listener.nse b/scripts/broadcast-listener.nse index 4b4fe2df3..cda4afc68 100644 --- a/scripts/broadcast-listener.nse +++ b/scripts/broadcast-listener.nse @@ -137,7 +137,7 @@ sniffInterface = function(iface, Decoders, decodertab) local timeout = stdnse.parse_timespec(stdnse.get_script_args("broadcast-listener.timeout")) -- default to 30 seconds, if nothing else was set - timeout = timeout and (timeout * 1000) or (30 * 1000) + timeout = (timeout or 30) * 1000 -- We want all packets that aren't explicitly for us sock:pcap_open(iface.name, 1500, true, ("!host %s"):format(iface.address)) diff --git a/scripts/broadcast-pc-anywhere.nse b/scripts/broadcast-pc-anywhere.nse index 72028a132..490a34e2c 100644 --- a/scripts/broadcast-pc-anywhere.nse +++ b/scripts/broadcast-pc-anywhere.nse @@ -16,12 +16,14 @@ Sends a special broadcast probe to discover PC-Anywhere hosts running on a LAN. -- | broadcast-pc-anywhere: -- |_ 10.0.200.113 - WIN2K3SRV-1 -- +-- @args broadcast-pc-anywhere.timeout specifies the amount of seconds to sniff +-- the network interface. (default varies according to timing. -T3 = 5s) author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" categories = { "broadcast", "safe" } -local TIMEOUT = tonumber(stdnse.get_script_args("broadcast-pc-anywhere.timeout")) +local TIMEOUT = stdnse.parse_timespec(stdnse.get_script_args("broadcast-pc-anywhere.timeout")) prerule = function() return ( nmap.address_family() == "inet") end diff --git a/scripts/broadcast-pc-duo.nse b/scripts/broadcast-pc-duo.nse index c1cd61c64..1460d5912 100644 --- a/scripts/broadcast-pc-duo.nse +++ b/scripts/broadcast-pc-duo.nse @@ -21,12 +21,14 @@ Discovers PC-DUO remote control hosts and gateways running on a LAN by sending a -- | PC-Duo Hosts -- |_ 10.0.200.113 - WIN2K3SRV-1 -- +-- @args broadcast-pc-duo.timeout specifies the amount of seconds to sniff +-- the network interface. (default varies according to timing. -T3 = 5s) author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" categories = { "broadcast", "safe" } -local TIMEOUT = tonumber(stdnse.get_script_args("broadcast-pc-duo.timeout")) +local TIMEOUT = stdnse.parse_timespec(stdnse.get_script_args("broadcast-pc-duo.timeout")) prerule = function() return ( nmap.address_family() == "inet") end diff --git a/scripts/broadcast-pim-discovery.nse b/scripts/broadcast-pim-discovery.nse index 82472e20a..33137be82 100644 --- a/scripts/broadcast-pim-discovery.nse +++ b/scripts/broadcast-pim-discovery.nse @@ -17,7 +17,7 @@ This works by sending a PIM Hello message to the PIM multicast address -- -- @args broadcast-pim-discovery.timeout Time to wait for responses in seconds. --- Defaults to 5 seconds. +-- Defaults to 5s. -- --@usage -- nmap --script broadcast-pim-discovery @@ -151,9 +151,9 @@ local getInterface = function(destination) end action = function() - local timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) or 5 + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) local responses = {} - timeout = timeout * 1000 + timeout = (timeout or 5) * 1000 local mcast = "224.0.0.13" -- Get the network interface to use diff --git a/scripts/broadcast-ping.nse b/scripts/broadcast-ping.nse index d43072a10..bab481407 100644 --- a/scripts/broadcast-ping.nse +++ b/scripts/broadcast-ping.nse @@ -42,9 +42,9 @@ is 0. The payload is consisted of random bytes. -- nmap -e [--ttl ] [--data-length ] -- --script broadcast-ping [--script-args [broadcast-ping.timeout=],[num-probes=]] -- --- @arg interface string specifying which interface to use for this script --- @arg num_probes number specifying how many ICMP probes should be sent --- @arg timeout number specifying how long to wait for response in miliseconds +-- @args broadcast-ping.interface string specifying which interface to use for this script (default all interfaces) +-- @args broadcast-ping.num_probes number specifying how many ICMP probes should be sent (default 1) +-- @args broadcast-ping.timeout number specifying how long to wait for response in milliseconds (default 3000) -- -- @output -- | broadcast-ping: @@ -139,8 +139,7 @@ end local broadcast_if = function(if_table,icmp_responders) local condvar = nmap.condvar(icmp_responders) - local num_probes = stdnse.get_script_args(SCRIPT_NAME .. ".num-probes") - if not num_probes then num_probes = 1 end + local num_probes = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".num-probes")) or 1 local timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") if not timeout then timeout = 3000 end diff --git a/scripts/broadcast-rip-discover.nse b/scripts/broadcast-rip-discover.nse index 3023bd2a9..19718d968 100644 --- a/scripts/broadcast-rip-discover.nse +++ b/scripts/broadcast-rip-discover.nse @@ -31,8 +31,8 @@ from all devices responding to the request. -- | ip netmask nexthop metric -- |_ 0.0.0.0 0.0.0.0 10.0.200.1 1 -- --- @args broadcast-rip-discover.timeout sets the timeout in seconds to wait for --- a response. +-- @args broadcast-rip-discover.timeout timespec defining how long to wait for +-- a response. (default 5s) -- -- Version 0.1 @@ -147,8 +147,8 @@ RIPv2 = { action = function() - local timeout = stdnse.get_script_args('broadcast-rip-discover.timeout') - timeout = (timeout and tonumber(timeout) * 1000) or 5000 + local timeout = stdnse.parse_timespec(stdnse.get_script_args('broadcast-rip-discover.timeout')) + timeout = (timeout or 5) * 1000 local socket = nmap.new_socket("udp") socket:set_timeout(timeout) diff --git a/scripts/broadcast-xdmcp-discover.nse b/scripts/broadcast-xdmcp-discover.nse index 7e805b677..43f1e7cc5 100644 --- a/scripts/broadcast-xdmcp-discover.nse +++ b/scripts/broadcast-xdmcp-discover.nse @@ -18,7 +18,7 @@ are marked using the keyword Willing in the result. -- | broadcast-xdmcp-discover: -- |_ 192.168.2.162 - Willing -- --- @arg broadcast-xdmcp-discover.timeout socket timeout in seconds (default: 5) +-- @args broadcast-xdmcp-discover.timeout socket timeout (default: 5s) author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -27,7 +27,7 @@ categories = {"broadcast", "safe"} prerule = function() return true end -local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) action = function() diff --git a/scripts/eap-info.nse b/scripts/eap-info.nse index ec8ab1f4b..c96592ee5 100644 --- a/scripts/eap-info.nse +++ b/scripts/eap-info.nse @@ -24,10 +24,10 @@ anonymous identity if no argument is passed. -- | false EAP-TLS -- |_ false EAP-MSCHAP-V2 -- --- @args identity Identity to use for the first step of the authentication methods (if omitted "anonymous" will be used). --- @args scan Table of authentication methods to test, e.g. { 4, 13, 25 } for MD5, TLS and PEAP. Default: TLS, TTLS, PEAP, MSCHAP. --- @args interface Network interface to use for the scan, overrides "-e". --- @args timeout Maximum time allowed for the scan, in seconds. Methods not tested because of timeout will be listed as "unknown". +-- @args eap-info.identity Identity to use for the first step of the authentication methods (if omitted "anonymous" will be used). +-- @args eap-info.scan Table of authentication methods to test, e.g. { 4, 13, 25 } for MD5, TLS and PEAP. Default: TLS, TTLS, PEAP, MSCHAP. +-- @args eap-info.interface Network interface to use for the scan, overrides "-e". +-- @args eap-info.timeout Maximum time allowed for the scan (default 10s). Methods not tested because of timeout will be listed as "unknown". author = "Riccardo Cecolin" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -53,7 +53,7 @@ action = function() local arg_interface = stdnse.get_script_args(SCRIPT_NAME .. ".interface") local arg_identity = stdnse.get_script_args(SCRIPT_NAME .. ".identity") local arg_scan = stdnse.get_script_args(SCRIPT_NAME .. ".scan") - local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") + local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) local iface -- trying with provided interface name @@ -75,10 +75,7 @@ action = function() end stdnse.print_debug(1, "iface: %s", iface.device) - local timeout = 10 * 1000 - if arg_timeout then - timeout = arg_timeout * 1000 - end + local timeout = (arg_timeout or 10) * 1000 stdnse.print_debug(2, "timeout: %s", timeout) diff --git a/scripts/ftp-brute.nse b/scripts/ftp-brute.nse index 8cf75f8c3..c42d1b875 100644 --- a/scripts/ftp-brute.nse +++ b/scripts/ftp-brute.nse @@ -27,9 +27,9 @@ Based on old ftp-brute.nse script by Diman Todorov, Vlatko Kosturjak and Ron Bow -- | Statistics -- |_ Performed 510 guesses in 610 seconds, average tps: 0 -- --- @args timeout the amount of seconds to wait for a response on the socket. +-- @args ftp-brute.timeout the amount of time to wait for a response on the socket. -- Lowering this value may result in a higher throughput for servers --- having a delayed response on incorrect login attempts. (default: 5) +-- having a delayed response on incorrect login attempts. (default: 5s) author = "Aleksandar Nikolic" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -37,7 +37,8 @@ categories = {"intrusive", "brute"} portrule = shortport.port_or_service(21, "ftp") -local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or 5 +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = (arg_timeout or 5) * 1000 Driver = { @@ -53,7 +54,7 @@ Driver = { connect = function( self ) self.socket = nmap.new_socket() local status, err = self.socket:connect(self.host, self.port) - self.socket:set_timeout(tonumber(arg_timeout) * 1000) + self.socket:set_timeout(arg_timeout) if(not(status)) then return false, brute.Error:new( "Couldn't connect to host: " .. err ) end diff --git a/scripts/gpsd-info.nse b/scripts/gpsd-info.nse index f378c64dc..723267b58 100644 --- a/scripts/gpsd-info.nse +++ b/scripts/gpsd-info.nse @@ -20,6 +20,7 @@ Retrieves GPS time, coordinates and speed from the GPSD network daemon. -- | Coordinates: 59.321685,17.886493 -- |_ Speed: - knots -- +-- @args gpsd-info.timeout timespec defining how long to wait for data (default 10s) author = "Patrik Karlsson" @@ -29,7 +30,8 @@ categories = {"discovery", "safe"} portrule = shortport.port_or_service(2947, "gpsd-ng", "tcp") -local arg_timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) or 10 +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = arg_timeout or 10 local function updateData(gpsinfo, entry) for k, v in pairs(gpsinfo) do diff --git a/scripts/ipv6-ra-flood.nse b/scripts/ipv6-ra-flood.nse index 65f375397..35eff0579 100644 --- a/scripts/ipv6-ra-flood.nse +++ b/scripts/ipv6-ra-flood.nse @@ -27,7 +27,7 @@ Additional documents: https://tools.ietf.org/rfc/rfc6104.txt --- -- @args ipv6-ra-flood.interface defines interface we should broadcast on --- @args ipv6-ra-flood.timeout runs the script until the timeout (in seconds) is reached (default: 30s). If timeout is zero, the script will run forever. +-- @args ipv6-ra-flood.timeout runs the script until the timeout is reached (default: 30s). If timeout is zero, the script will run forever. -- -- @usage -- nmap -6 --script ipv6-ra-flood.nse @@ -131,7 +131,8 @@ local function broadcast_on_interface(iface) -- packet counter local counter = 0 - local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME..".timeout") or "30s") + local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME..".timeout")) + arg_timeout = arg_timeout or 30 local dnet = nmap.new_dnet() diff --git a/scripts/llmnr-resolve.nse b/scripts/llmnr-resolve.nse index 3a45999eb..a4e54d22c 100644 --- a/scripts/llmnr-resolve.nse +++ b/scripts/llmnr-resolve.nse @@ -24,8 +24,7 @@ For more information, see: --- --@args llmnr-resolve.hostname Hostname to resolve. -- ---@args llmnr-resolve.timeout Max time to wait for a response. Defaults to --- 3 seconds. +--@args llmnr-resolve.timeout Max time to wait for a response. (default 3s) -- --@usage -- nmap --script llmnr-resolve --script-args 'llmnr-resolve.hostname=examplename' -e wlan0 @@ -164,9 +163,9 @@ end action = function() - local timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) or 3 + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) + timeout = (timeout or 3) * 1000 local hostname = stdnse.get_script_args(SCRIPT_NAME .. ".hostname") - timeout = timeout * 1000 local result, output = {}, {} local mcast = "224.0.0.252" local mport = 5355 diff --git a/scripts/lltd-discovery.nse b/scripts/lltd-discovery.nse index 8086d7b6b..8a8a898fe 100644 --- a/scripts/lltd-discovery.nse +++ b/scripts/lltd-discovery.nse @@ -21,7 +21,8 @@ http://www.microsoft.com/whdc/connect/Rally/LLTD-spec.mspx -- @usage -- nmap -e --script lltd-discovery -- --- @arg interface, a string specifying which interface to do lltd discovery on. If not specified, all ethernet interfaces are tried. +-- @args lltd-discovery.interface string specifying which interface to do lltd discovery on. If not specified, all ethernet interfaces are tried. +-- @args lltd-discover.timeout timespec specifying how long to listen for replies (default 30s) -- -- @output -- | lltd-discovery: @@ -258,12 +259,9 @@ end action = function() - local timeout = stdnse.get_script_args(SCRIPT_NAME..".timeout") - if timeout then - timeout = tonumber(timeout) - else - timeout = 30 - end + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME..".timeout")) + timeout = timeout or 30 + --get interface script-args, if any local interface_arg = stdnse.get_script_args(SCRIPT_NAME .. ".interface") local interface_opt = nmap.get_interface() diff --git a/scripts/mmouse-brute.nse b/scripts/mmouse-brute.nse index a6fea30f2..4f048b77b 100644 --- a/scripts/mmouse-brute.nse +++ b/scripts/mmouse-brute.nse @@ -15,7 +15,7 @@ http://mobilemouse.com/ --- -- @usage --- nmap --script mobilemouse-brute -p 51010 +-- nmap --script mmouse-brute -p 51010 -- -- @output -- PORT STATE SERVICE @@ -26,6 +26,7 @@ http://mobilemouse.com/ -- | Statistics -- |_ Performed 1199 guesses in 23 seconds, average tps: 47 -- +-- @args mmouse-brute.timeout socket timeout (milliseconds) for connecting to Mobile Mouse (default 5000) author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" diff --git a/scripts/mrinfo.nse b/scripts/mrinfo.nse index e2414b337..080703e0c 100644 --- a/scripts/mrinfo.nse +++ b/scripts/mrinfo.nse @@ -25,8 +25,8 @@ Cisco IOS. -- @args mrinfo.target Host to which the request is sent. If not set, the -- request will be sent to 224.0.0.1. -- --- @args mrinfo.timeout Time to wait for responses in seconds. --- Defaults to 5 seconds. +-- @args mrinfo.timeout Time to wait for responses. +-- Defaults to 5s. -- --@usage -- nmap --script mrinfo @@ -242,11 +242,11 @@ local getInterface = function(target) end action = function() - local timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) or 5 + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) + timeout = (timeout or 5) * 1000 local target = stdnse.get_script_args(SCRIPT_NAME .. ".target") or "224.0.0.1" local responses = {} local interface, result - timeout = timeout * 1000 interface = nmap.get_interface() if interface then diff --git a/scripts/mtrace.nse b/scripts/mtrace.nse index f385326aa..a28753a91 100644 --- a/scripts/mtrace.nse +++ b/scripts/mtrace.nse @@ -33,8 +33,8 @@ This is similar to the mtrace utility provided in Cisco IOS. --@args mtrace.firsthop Host to which the query is sent. If not set, the -- query will be sent to 224.0.0.2. -- ---@args mtrace.timeout Time to wait for responses in seconds. --- Defaults to 7 seconds. +--@args mtrace.timeout Time to wait for responses. +-- Defaults to 7s. -- --@usage -- nmap --script mtrace --script-args 'mtrace.fromip=172.16.45.4' @@ -324,9 +324,9 @@ action = function() local toip = stdnse.get_script_args(SCRIPT_NAME .. ".toip") local group = stdnse.get_script_args(SCRIPT_NAME .. ".group") or "0.0.0.0" local firsthop = stdnse.get_script_args(SCRIPT_NAME .. ".firsthop") or "224.0.0.2" - local timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) or 7 + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) local responses = {} - timeout = timeout * 1000 + timeout = (timeout or 7) * 1000 -- Source address from which to traceroute if not fromip then diff --git a/scripts/mysql-brute.nse b/scripts/mysql-brute.nse index 18a1c7cb1..656e57a8f 100644 --- a/scripts/mysql-brute.nse +++ b/scripts/mysql-brute.nse @@ -20,6 +20,8 @@ Performs password guessing against MySQL. -- | mysql-brute: -- | Accounts -- | root:root - Valid credentials +-- +-- @args mysql-brute.timeout socket timeout for connecting to MySQL (default 5s) author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -34,7 +36,8 @@ categories = {"intrusive", "brute"} portrule = shortport.port_or_service(3306, "mysql") -local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or 5 +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = (arg_timeout or 5) * 1000 Driver = { @@ -50,7 +53,7 @@ Driver = { connect = function( self ) self.socket = nmap.new_socket() local status, err = self.socket:connect(self.host, self.port) - self.socket:set_timeout(tonumber(arg_timeout) * 1000) + self.socket:set_timeout(arg_timeout) if(not(status)) then return false, brute.Error:new( "Couldn't connect to host: " .. err ) end diff --git a/scripts/mysql-enum.nse b/scripts/mysql-enum.nse index 3071ab65f..d02380c2b 100644 --- a/scripts/mysql-enum.nse +++ b/scripts/mysql-enum.nse @@ -35,6 +35,8 @@ http://seclists.org/fulldisclosure/2012/Dec/9 -- | test_mysql: - Valid credentials -- | Statistics -- |_ Performed 11 guesses in 1 seconds, average tps: 11 +-- +-- @args mysql-enum.timeout socket timeout for connecting to MySQL (default 5s) author = "Aleksandar Nikolic" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -42,7 +44,8 @@ categories = {"intrusive", "brute"} portrule = shortport.port_or_service(3306, "mysql") -local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or 5 +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = (arg_timeout or 5) * 1000 Driver = { @@ -58,7 +61,7 @@ Driver = { connect = function( self ) self.socket = nmap.new_socket() local status, err = self.socket:connect(self.host, self.port) - self.socket:set_timeout(tonumber(arg_timeout) * 1000) + self.socket:set_timeout(arg_timeout) if(not(status)) then return false, brute.Error:new( "Couldn't connect to host: " .. err ) end diff --git a/scripts/mysql-vuln-cve2012-2122.nse b/scripts/mysql-vuln-cve2012-2122.nse index e0b484cad..444d3ba19 100644 --- a/scripts/mysql-vuln-cve2012-2122.nse +++ b/scripts/mysql-vuln-cve2012-2122.nse @@ -64,9 +64,9 @@ Interesting post about this vuln: -- | http://seclists.org/oss-sec/2012/q2/493 -- |_ http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-2122 -- --- @args mysql-cve2012-2122.user MySQL username. Default: root. --- @args mysql-cve2012-2122.iterations Connection retries. Default: 1500. --- @args mysql-cve2012-2122.socket_timeout Socket timeout. Default: 5000. +-- @args mysql-vuln-cve2012-2122.user MySQL username. Default: root. +-- @args mysql-vuln-cve2012-2122.iterations Connection retries. Default: 1500. +-- @args mysql-vuln-cve2012-2122.socket_timeout Socket timeout (milliseconds). Default: 5000. --- local mysql = require "mysql" diff --git a/scripts/nessus-xmlrpc-brute.nse b/scripts/nessus-xmlrpc-brute.nse index 9b0747b88..43cd9c666 100644 --- a/scripts/nessus-xmlrpc-brute.nse +++ b/scripts/nessus-xmlrpc-brute.nse @@ -20,6 +20,7 @@ Performs brute force password auditing against a Nessus vulnerability scanning d -- |_ Performed 1933 guesses in 26 seconds, average tps: 73 -- -- @args nessus-xmlrpc-brute.threads sets the number of threads. +-- @args nessus-xmlrpc-brute.timeout socket timeout (milliseconds) for connecting to Nessus (default 5000) author = "Patrik Karlsson" diff --git a/scripts/pcanywhere-brute.nse b/scripts/pcanywhere-brute.nse index ca43e6b63..2285d010c 100644 --- a/scripts/pcanywhere-brute.nse +++ b/scripts/pcanywhere-brute.nse @@ -28,6 +28,8 @@ some time until server becomes available again. -- | administrator:administrator - Valid credentials -- | Statistics -- |_ Performed 2 guesses in 55 seconds, average tps: 0 +-- +-- @args pcanywhere-brute.timeout socket timeout for connecting to PCAnywhere (default 10s) author = "Aleksandar Nikolic" @@ -37,7 +39,8 @@ categories = {"intrusive", "brute"} portrule = shortport.port_or_service(5631, "pcanywheredata") -local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or 10 +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = (arg_timeout or 10) * 1000 -- implements simple xor based encryption which the server expects local function encrypt(data) @@ -78,7 +81,7 @@ Driver = { -- variable "retry" signifies if we need to wait or this is just not pcAnywhere server while not status do status, err = self.socket:connect(self.host, self.port) - self.socket:set_timeout(tonumber(arg_timeout) * 1000) + self.socket:set_timeout(arg_timeout) if(not(status)) then return false, brute.Error:new( "Couldn't connect to host: " .. err ) end diff --git a/scripts/rexec-brute.nse b/scripts/rexec-brute.nse index df6505717..9e4e6f19a 100644 --- a/scripts/rexec-brute.nse +++ b/scripts/rexec-brute.nse @@ -21,7 +21,7 @@ Performs brute force password auditing against the classic UNIX rexec (remote ex -- | Statistics -- |_ Performed 16 guesses in 7 seconds, average tps: 2 -- --- @args rexec-brute.timeout number +-- @args rexec-brute.timeout socket timeout for connecting to rexec (default 10s) -- Version 0.1 -- Created 11/02/2011 - v0.1 - created by Patrik Karlsson @@ -85,16 +85,14 @@ Driver = { } +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = (arg_timeout or 10) * 1000 action = function(host, port) local options = { - timeout = stdnse.get_script_args("rexec-brute.timeout") + timeout = arg_timeout } - options.timeout = options.timeout and - tonumber(options.timeout) * 1000 or - 10000 - local engine = brute.Engine:new(Driver, host, port, options) engine.options.script_name = SCRIPT_NAME local status, result = engine:start() diff --git a/scripts/rlogin-brute.nse b/scripts/rlogin-brute.nse index 485fa7d0d..5b6c3c921 100644 --- a/scripts/rlogin-brute.nse +++ b/scripts/rlogin-brute.nse @@ -22,7 +22,7 @@ Performs brute force password auditing against the classic UNIX rlogin (remote l -- | Statistics -- |_ Performed 4 guesses in 5 seconds, average tps: 0 -- --- @args rlogin-brute.timeout number +-- @args rlogin-brute.timeout socket timeout for connecting to rlogin (default 10s) -- Version 0.1 -- Created 11/02/2011 - v0.1 - created by Patrik Karlsson @@ -138,6 +138,9 @@ Driver = { end, } +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +arg_timeout = (arg_timeout or 10) * 1000 + action = function(host, port) if ( not(nmap.is_privileged()) ) then @@ -145,13 +148,9 @@ action = function(host, port) end local options = { - timeout = stdnse.get_script_args("rlogin-brute.timeout") + timeout = arg_timeout } - options.timeout = options.timeout and - tonumber(options.timeout) * 1000 or - 10000 - local engine = brute.Engine:new(Driver, host, port, options) engine.options.script_name = SCRIPT_NAME local status, result = engine:start() diff --git a/scripts/sip-call-spoof.nse b/scripts/sip-call-spoof.nse index 10e32a681..dda0117fb 100644 --- a/scripts/sip-call-spoof.nse +++ b/scripts/sip-call-spoof.nse @@ -26,7 +26,7 @@ Timeout (408) or Hang up (200). --@args sip-call-spoof.src Source address to spoof. -- --@args sip-call-spoof.timeout Time to wait for a response. Defaults to --- 5 seconds. +-- 5s -- -- @usage -- nmap --script=sip-call-spoof -sU -p 5060 @@ -133,15 +133,11 @@ action = function(host, port) local from = stdnse.get_script_args(SCRIPT_NAME .. ".from") or "Home" local src = stdnse.get_script_args(SCRIPT_NAME .. ".src") local extension = stdnse.get_script_args(SCRIPT_NAME .. ".extension") or 100 - local timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) + local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) -- Default timeout value = 5 seconds. - if timeout then - timeout = timeout * 1000 - else - timeout = 5000 - end - + timeout = (timeout or 5) * 1000 + session = sip.Session:new(host, port) status = session:connect() if not status then diff --git a/scripts/targets-ipv6-multicast-mld.nse b/scripts/targets-ipv6-multicast-mld.nse index a5d25de9b..097ce9cd2 100644 --- a/scripts/targets-ipv6-multicast-mld.nse +++ b/scripts/targets-ipv6-multicast-mld.nse @@ -22,8 +22,8 @@ Attempts to discover available IPv6 hosts on the LAN by sending an MLD (multicas -- | -- |_ Use --script-args=newtargets to add the results as targets -- --- @args targets-ipv6-multicast-mld.timeout timeout in seconds to wait for --- responses (default: 10) +-- @args targets-ipv6-multicast-mld.timeout timeout to wait for +-- responses (default: 10s) -- author = "niteesh" @@ -31,7 +31,7 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html" categories = {"discovery","broadcast"} -local arg_timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME .. '.timeout')) +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. '.timeout')) prerule = function() if ( not(nmap.is_privileged()) ) then diff --git a/scripts/targets-sniffer.nse b/scripts/targets-sniffer.nse index 7f8aaebf4..fc336af28 100644 --- a/scripts/targets-sniffer.nse +++ b/scripts/targets-sniffer.nse @@ -79,9 +79,8 @@ action = function() local sock = nmap.new_socket() local packet_counter = 0 local ip_counter = 0 - local DEFAULT_TIMEOUT_SEC = 10 -- Default timeout value in seconds if the timeout argument is not specified - local timeoutstr = stdnse.get_script_args("targets-sniffer.timeout") or tostring(DEFAULT_TIMEOUT_SEC) - local timeout = (stdnse.parse_timespec(timeoutstr) * 1000) + local timeout = stdnse.parse_timespec(stdnse.get_script_args("targets-sniffer.timeout")) + timeout = (timeout or 10) * 1000 local interface = stdnse.get_script_args("targets-sniffer.iface") or nmap.get_interface() interface_info = nmap.get_interface_info(interface) diff --git a/scripts/url-snarf.nse b/scripts/url-snarf.nse index 4e4fc661c..68b2632be 100644 --- a/scripts/url-snarf.nse +++ b/scripts/url-snarf.nse @@ -24,10 +24,11 @@ ctrl+break is issued, by setting the timeout to 0. -- | url-snarf: -- |_ Sniffed 169 URLs in 5 seconds -- --- @arg timeout runs the script until the timeout (in seconds) is reached. +-- @args url-snarf.timeout runs the script until the timeout is reached. -- a timeout of 0s can be used to run until ctrl+break. (default: 30s) --- @arg nostdout doesn't write any output to stdout while running --- @arg outfile filename to which all discovered URLs are written +-- @args url-snarf.nostdout doesn't write any output to stdout while running +-- @args url-snarf.outfile filename to which all discovered URLs are written +-- @args url-snarf.interface interface on which to sniff (overrides -e) -- author = "Patrik Karlsson" @@ -85,7 +86,8 @@ local function get_url(data) return u end -local arg_timeout = tonumber(stdnse.get_script_args(SCRIPT_NAME..".timeout")) or 30 +local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME..".timeout")) +arg_timeout = arg_timeout or 30 local arg_nostdout= stdnse.get_script_args(SCRIPT_NAME..".nostdout") local arg_outfile = stdnse.get_script_args(SCRIPT_NAME..".outfile")