diff --git a/scripts/auth-owners.nse b/scripts/auth-owners.nse index 0a69ae673..5ff85d213 100644 --- a/scripts/auth-owners.nse +++ b/scripts/auth-owners.nse @@ -30,16 +30,10 @@ portrule = function(host, port) local auth_port = { number=113, protocol="tcp" } local identd = nmap.get_port_state(host, auth_port) - if - identd ~= nil + return identd ~= nil and identd.state == "open" and port.protocol == "tcp" and port.state == "open" - then - return true - else - return false - end end action = function(host, port) diff --git a/scripts/banner.nse b/scripts/banner.nse index 00e2f946b..86dad06fd 100644 --- a/scripts/banner.nse +++ b/scripts/banner.nse @@ -26,7 +26,7 @@ local stdnse = require "stdnse" --- -- Script is executed for any TCP port. portrule = function( host, port ) - return (port.protocol == "tcp" and true) or false + return port.protocol == "tcp" end diff --git a/scripts/dns-random-txid.nse b/scripts/dns-random-txid.nse index db3c55819..24c5fd064 100644 --- a/scripts/dns-random-txid.nse +++ b/scripts/dns-random-txid.nse @@ -1,4 +1,3 @@ - description = [[ Checks a DNS server for the predictable-TXID DNS recursion vulnerability. Predictable TXID values can make a DNS server vulnerable to diff --git a/scripts/mysql-info.nse b/scripts/mysql-info.nse index 39ef91620..75bcd6b78 100644 --- a/scripts/mysql-info.nse +++ b/scripts/mysql-info.nse @@ -108,19 +108,12 @@ end portrule = function(host, port) local extra = port.version.extrainfo - if - (port.number == 3306 - or port.service == "mysql") + return (port.number == 3306 or port.service == "mysql") and port.protocol == "tcp" and port.state == "open" and not (extra ~= nil and (extra:match("[Uu]nauthorized") or extra:match("[Tt]oo many connection"))) - then - return true - end - - return false end action = function(host, port) diff --git a/scripts/nbstat.nse b/scripts/nbstat.nse index 2d404cd79..11f883bca 100644 --- a/scripts/nbstat.nse +++ b/scripts/nbstat.nse @@ -51,18 +51,12 @@ hostrule = function(host) local port_u137 = nmap.get_port_state(host, {number=137, protocol="udp"}) - if ( - (port_t135 ~= nil and port_t135.state == "open") or + return (port_t135 ~= nil and port_t135.state == "open") or (port_t139 ~= nil and port_t139.state == "open") or (port_t445 ~= nil and port_t445.state == "open") or (port_u137 ~= nil and (port_u137.state == "open" or - port_u137.state == "open|filtered"))) - then - return true - else - return false - end + port_u137.state == "open|filtered")) end diff --git a/scripts/smb-check-vulns.nse b/scripts/smb-check-vulns.nse index 2abbae72c..7193839fd 100644 --- a/scripts/smb-check-vulns.nse +++ b/scripts/smb-check-vulns.nse @@ -42,15 +42,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end local VULNERABLE = 1 diff --git a/scripts/smb-enum-domains.nse b/scripts/smb-enum-domains.nse index ba93e1fdc..beb4be32f 100644 --- a/scripts/smb-enum-domains.nse +++ b/scripts/smb-enum-domains.nse @@ -53,15 +53,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end action = function(host) diff --git a/scripts/smb-enum-sessions.nse b/scripts/smb-enum-sessions.nse index 09ee080ce..6277983da 100644 --- a/scripts/smb-enum-sessions.nse +++ b/scripts/smb-enum-sessions.nse @@ -52,15 +52,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end ---Attempts to enumerate the sessions on a remote system using MSRPC calls. This will likely fail diff --git a/scripts/smb-enum-shares.nse b/scripts/smb-enum-shares.nse index 4b50db444..4e9cdb532 100644 --- a/scripts/smb-enum-shares.nse +++ b/scripts/smb-enum-shares.nse @@ -72,15 +72,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end ---Attempts to enumerate the shares on a remote system using MSRPC calls. This will likely fail diff --git a/scripts/smb-enum-users.nse b/scripts/smb-enum-users.nse index 1ab8511e7..6b667afac 100644 --- a/scripts/smb-enum-users.nse +++ b/scripts/smb-enum-users.nse @@ -124,15 +124,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end ---Attempt to enumerate users through SAMR methods. See the file description for more information. diff --git a/scripts/smb-os-discovery.nse b/scripts/smb-os-discovery.nse index 03032954e..6bbc77a90 100644 --- a/scripts/smb-os-discovery.nse +++ b/scripts/smb-os-discovery.nse @@ -31,15 +31,7 @@ require 'stdnse' --- Check whether or not this script should be run. hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end --- Converts numbered Windows version strings ("Windows 5.0", "Windows 5.1") to names ("Windows 2000", "Windows XP"). diff --git a/scripts/smb-security-mode.nse b/scripts/smb-security-mode.nse index c50ac2a02..8eb6fc88e 100644 --- a/scripts/smb-security-mode.nse +++ b/scripts/smb-security-mode.nse @@ -60,15 +60,7 @@ require 'smb' -- Check whether or not this script should be run. hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end diff --git a/scripts/smb-server-stats.nse b/scripts/smb-server-stats.nse index 767298657..f767fa487 100644 --- a/scripts/smb-server-stats.nse +++ b/scripts/smb-server-stats.nse @@ -39,15 +39,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end action = function(host) diff --git a/scripts/smb-system-info.nse b/scripts/smb-system-info.nse index 183f38ede..adb98f612 100644 --- a/scripts/smb-system-info.nse +++ b/scripts/smb-system-info.nse @@ -55,15 +55,7 @@ require 'smb' require 'stdnse' hostrule = function(host) - - local port = smb.get_port(host) - - if(port == nil) then - return false - else - return true - end - + return smb.get_port(host) ~= nil end ---Retrieves the requested value from the registry. diff --git a/scripts/smtp-strangeport.nse b/scripts/smtp-strangeport.nse index ca8123dd3..24d135007 100644 --- a/scripts/smtp-strangeport.nse +++ b/scripts/smtp-strangeport.nse @@ -17,21 +17,10 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html" categories = {"malware"} portrule = function(host, port) - if - ( port.number ~= 25 - and - port.number ~= 465 - and - port.number ~= 587 - and - port.service == "smtp" ) + return port.service == "smtp" and + port.number ~= 25 and port.number ~= 465 and port.number ~= 587 and port.protocol == "tcp" and port.state == "open" - then - return true - else - return false - end end action = function() diff --git a/scripts/sniffer-detect.nse b/scripts/sniffer-detect.nse index 72985aa08..a44a8f184 100644 --- a/scripts/sniffer-detect.nse +++ b/scripts/sniffer-detect.nse @@ -17,14 +17,11 @@ categories = {"discovery"} -- okay, we're interested only in hosts that are on our ethernet lan hostrule = function(host, port) - if host.directly_connected == true and - host.mac_addr ~= nil and - host.mac_addr_src ~= nil and - host.interface ~= nil and - nmap.get_interface_link(host.interface) == 'ethernet' then - return true - end - return false + return host.directly_connected == true and + host.mac_addr ~= nil and + host.mac_addr_src ~= nil and + host.interface ~= nil and + nmap.get_interface_link(host.interface) == 'ethernet' end --[[