1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use a more straightforward return style in script rules. Instead of

if cond then
		return true
	else
		return false
	end

just do

	return cond
This commit is contained in:
david
2008-11-18 16:59:09 +00:00
parent f4b970f889
commit 85deff9ede
16 changed files with 21 additions and 127 deletions

View File

@@ -30,16 +30,10 @@ portrule = function(host, port)
local auth_port = { number=113, protocol="tcp" } local auth_port = { number=113, protocol="tcp" }
local identd = nmap.get_port_state(host, auth_port) local identd = nmap.get_port_state(host, auth_port)
if return identd ~= nil
identd ~= nil
and identd.state == "open" and identd.state == "open"
and port.protocol == "tcp" and port.protocol == "tcp"
and port.state == "open" and port.state == "open"
then
return true
else
return false
end
end end
action = function(host, port) action = function(host, port)

View File

@@ -26,7 +26,7 @@ local stdnse = require "stdnse"
--- ---
-- Script is executed for any TCP port. -- Script is executed for any TCP port.
portrule = function( host, port ) portrule = function( host, port )
return (port.protocol == "tcp" and true) or false return port.protocol == "tcp"
end end

View File

@@ -1,4 +1,3 @@
description = [[ description = [[
Checks a DNS server for the predictable-TXID DNS recursion Checks a DNS server for the predictable-TXID DNS recursion
vulnerability. Predictable TXID values can make a DNS server vulnerable to vulnerability. Predictable TXID values can make a DNS server vulnerable to

View File

@@ -108,19 +108,12 @@ end
portrule = function(host, port) portrule = function(host, port)
local extra = port.version.extrainfo local extra = port.version.extrainfo
if return (port.number == 3306 or port.service == "mysql")
(port.number == 3306
or port.service == "mysql")
and port.protocol == "tcp" and port.protocol == "tcp"
and port.state == "open" and port.state == "open"
and not (extra ~= nil and not (extra ~= nil
and (extra:match("[Uu]nauthorized") and (extra:match("[Uu]nauthorized")
or extra:match("[Tt]oo many connection"))) or extra:match("[Tt]oo many connection")))
then
return true
end
return false
end end
action = function(host, port) action = function(host, port)

View File

@@ -51,18 +51,12 @@ hostrule = function(host)
local port_u137 = nmap.get_port_state(host, local port_u137 = nmap.get_port_state(host,
{number=137, protocol="udp"}) {number=137, protocol="udp"})
if ( return (port_t135 ~= nil and port_t135.state == "open") or
(port_t135 ~= nil and port_t135.state == "open") or
(port_t139 ~= nil and port_t139.state == "open") or (port_t139 ~= nil and port_t139.state == "open") or
(port_t445 ~= nil and port_t445.state == "open") or (port_t445 ~= nil and port_t445.state == "open") or
(port_u137 ~= nil and (port_u137 ~= nil and
(port_u137.state == "open" or (port_u137.state == "open" or
port_u137.state == "open|filtered"))) port_u137.state == "open|filtered"))
then
return true
else
return false
end
end end

View File

@@ -42,15 +42,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
local VULNERABLE = 1 local VULNERABLE = 1

View File

@@ -53,15 +53,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
action = function(host) action = function(host)

View File

@@ -52,15 +52,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
---Attempts to enumerate the sessions on a remote system using MSRPC calls. This will likely fail ---Attempts to enumerate the sessions on a remote system using MSRPC calls. This will likely fail

View File

@@ -72,15 +72,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
---Attempts to enumerate the shares on a remote system using MSRPC calls. This will likely fail ---Attempts to enumerate the shares on a remote system using MSRPC calls. This will likely fail

View File

@@ -124,15 +124,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
---Attempt to enumerate users through SAMR methods. See the file description for more information. ---Attempt to enumerate users through SAMR methods. See the file description for more information.

View File

@@ -31,15 +31,7 @@ require 'stdnse'
--- Check whether or not this script should be run. --- Check whether or not this script should be run.
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
--- Converts numbered Windows version strings (<code>"Windows 5.0"</code>, <code>"Windows 5.1"</code>) to names (<code>"Windows 2000"</code>, <code>"Windows XP"</code>). --- Converts numbered Windows version strings (<code>"Windows 5.0"</code>, <code>"Windows 5.1"</code>) to names (<code>"Windows 2000"</code>, <code>"Windows XP"</code>).

View File

@@ -60,15 +60,7 @@ require 'smb'
-- Check whether or not this script should be run. -- Check whether or not this script should be run.
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end

View File

@@ -39,15 +39,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
action = function(host) action = function(host)

View File

@@ -55,15 +55,7 @@ require 'smb'
require 'stdnse' require 'stdnse'
hostrule = function(host) hostrule = function(host)
return smb.get_port(host) ~= nil
local port = smb.get_port(host)
if(port == nil) then
return false
else
return true
end
end end
---Retrieves the requested value from the registry. ---Retrieves the requested value from the registry.

View File

@@ -17,21 +17,10 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"malware"} categories = {"malware"}
portrule = function(host, port) portrule = function(host, port)
if return port.service == "smtp" and
( port.number ~= 25 port.number ~= 25 and port.number ~= 465 and port.number ~= 587
and
port.number ~= 465
and
port.number ~= 587
and
port.service == "smtp" )
and port.protocol == "tcp" and port.protocol == "tcp"
and port.state == "open" and port.state == "open"
then
return true
else
return false
end
end end
action = function() action = function()

View File

@@ -17,14 +17,11 @@ categories = {"discovery"}
-- okay, we're interested only in hosts that are on our ethernet lan -- okay, we're interested only in hosts that are on our ethernet lan
hostrule = function(host, port) hostrule = function(host, port)
if host.directly_connected == true and return host.directly_connected == true and
host.mac_addr ~= nil and host.mac_addr ~= nil and
host.mac_addr_src ~= nil and host.mac_addr_src ~= nil and
host.interface ~= nil and host.interface ~= nil and
nmap.get_interface_link(host.interface) == 'ethernet' then nmap.get_interface_link(host.interface) == 'ethernet'
return true
end
return false
end end
--[[ --[[