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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 (<code>"Windows 5.0"</code>, <code>"Windows 5.1"</code>) to names (<code>"Windows 2000"</code>, <code>"Windows XP"</code>).
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
--[[
|
||||
|
||||
Reference in New Issue
Block a user