1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-06 06:29:03 +00:00

Patch to make require errors silent and removed evil workarounds.

Added new stdnse function stdnse.print_verbose (similar to print_debug).
This commit is contained in:
batrick
2011-05-04 21:06:53 +00:00
parent 7da53c5147
commit 7f66646636
16 changed files with 103 additions and 158 deletions

View File

@@ -77,8 +77,6 @@ require('stdnse')
require('packet')
require('tab')
-----= scan parameters defaults =-----
-- number of retries for unanswered probes
@@ -399,24 +397,13 @@ end
--- host rule, check for requirements before to launch the script
hostrule = function(host)
-- firewalk requires privileges to run
if not nmap.is_privileged() then
if not nmap.registry['firewalk'] then
nmap.registry['firewalk'] = {}
nmap.registry[SCRIPT_NAME] = nmap.registry[SCRIPT_NAME] or {};
if not nmap.registry[SCRIPT_NAME].rootfail then
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME);
end
if nmap.registry['firewalk']['rootfail'] then
return false
end
nmap.registry['firewalk']['rootfail'] = true
if nmap.verbosity() > 0 then
stdnse.print_debug("%s not running for lack of privileges.", SCRIPT_NAME)
end
return false
nmap.registry[SCRIPT_NAME].rootfail = true;
return nil;
end
if nmap.address_family() ~= 'inet' then

View File

@@ -37,6 +37,7 @@ require "http"
require "stdnse"
require "datafiles"
require "nsedebug"
require "openssl"
portrule = shortport.http
@@ -55,12 +56,6 @@ action = function(host, port)
return
end
if not pcall(require,'openssl') then
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return
end
if(nmap.registry.args['favicon.root']) then
root = nmap.registry.args['favicon.root']
end

View File

@@ -186,19 +186,15 @@ local setreg = function(host, port)
end
hostrule = function(host)
if not nmap.is_privileged() then
if not nmap.registry['ipidseq'] then
nmap.registry['ipidseq'] = {}
end
if nmap.registry['ipidseq']['rootfail'] then
return false
end
nmap.registry['ipidseq']['rootfail'] = true
if nmap.verbosity() > 0 then
stdnse.print_debug("%s not running for lack of privileges.", SCRIPT_NAME)
end
return false
end
if not nmap.is_privileged() then
nmap.registry[SCRIPT_NAME] = nmap.registry[SCRIPT_NAME] or {};
if not nmap.registry[SCRIPT_NAME].rootfail then
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME);
end
nmap.registry[SCRIPT_NAME].rootfail = true;
return nil;
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
return false

View File

@@ -17,22 +17,13 @@ require 'shortport'
require 'stdnse'
require 'mysql'
require 'unpwdb'
require 'openssl'
-- Version 0.3
-- Created 01/15/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- Revised 01/23/2010 - v0.2 - revised by Patrik Karlsson, changed username, password loop, added credential storage for other mysql scripts, added timelimit
-- Revised 01/23/2010 - v0.3 - revised by Patrik Karlsson, fixed bug showing account passwords detected twice
-- ripped from ssh-hostkey.nse
-- openssl is required for this script
if not pcall(require,"openssl") then
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
portrule = shortport.port_or_service(3306, "mysql")
action = function( host, port )

View File

@@ -27,20 +27,10 @@ categories = {"discovery", "intrusive"}
require 'shortport'
require 'stdnse'
require 'mysql'
require 'openssl'
dependencies = {"mysql-brute", "mysql-empty-password"}
-- ripped from ssh-hostkey.nse
-- openssl is required for this script
if not pcall(require,"openssl") then
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
-- Version 0.1
-- Created 01/23/2010 - v0.1 - created by Patrik Karlsson

View File

@@ -30,22 +30,13 @@ categories = {"discovery", "intrusive"}
require 'shortport'
require 'stdnse'
require 'mysql'
require 'openssl'
dependencies = {"mysql-brute", "mysql-empty-password"}
-- Version 0.1
-- Created 01/23/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- ripped from ssh-hostkey.nse
-- openssl is required for this script
if not pcall(require,"openssl") then
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
portrule = shortport.port_or_service(3306, "mysql")
action = function( host, port )

View File

@@ -38,23 +38,13 @@ categories = {"discovery", "intrusive"}
require 'shortport'
require 'stdnse'
require 'mysql'
require 'openssl'
dependencies = {"mysql-brute", "mysql-empty-password"}
-- Version 0.1
-- Created 01/23/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- ripped from ssh-hostkey.nse
-- openssl is required for this script
if not pcall(require,"openssl") then
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
portrule = shortport.port_or_service(3306, "mysql")
action = function( host, port )

View File

@@ -37,15 +37,8 @@ categories = {"intrusive", "auth"}
require 'shortport'
require 'brute'
if pcall(require,"openssl") then
require("tns")
else
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
require 'openssl'
require 'tns'
portrule = shortport.port_or_service(1521, "oracle-tns", "tcp", "open")

View File

@@ -34,15 +34,8 @@ categories = {"intrusive", "auth"}
require 'shortport'
require 'unpwdb'
if pcall(require,"openssl") then
require("tns")
else
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
require 'openssl'
require 'tns'
portrule = shortport.port_or_service(1521, 'oracle-tns' )

View File

@@ -267,19 +267,15 @@ local setreg = function(host, proto, port)
end
hostrule = function(host)
if not nmap.is_privileged() then
if not nmap.registry['pathmtu'] then
nmap.registry['pathmtu'] = {}
end
if nmap.registry['pathmtu']['rootfail'] then
return false
end
nmap.registry['pathmtu']['rootfail'] = true
if nmap.verbosity() > 0 then
stdnse.print_debug("%s not running for lack of privileges.", SCRIPT_NAME)
end
return false
end
if not nmap.is_privileged() then
nmap.registry[SCRIPT_NAME] = nmap.registry[SCRIPT_NAME] or {};
if not nmap.registry[SCRIPT_NAME].rootfail then
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME);
end
nmap.registry[SCRIPT_NAME].rootfail = true;
return nil;
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
return false

View File

@@ -29,6 +29,7 @@ categories = {"intrusive", "auth"}
require 'shortport'
require 'stdnse'
require 'unpwdb'
require 'openssl'
-- Version 0.3
-- Created 01/15/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
@@ -36,18 +37,6 @@ require 'unpwdb'
-- Revised 03/04/2010 - v0.3 - added code from ssh-hostkey.nse to check for SSL support
-- - added support for trusted authentication method
-- ripped from ssh-hostkey.nse
-- openssl is required for this script
if pcall(require,"openssl") then
require("pgsql")
else
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
portrule = shortport.port_or_service(5432, "postgresql")
--- Connect a socket to the server with or without SSL

View File

@@ -364,21 +364,17 @@ local setreg = function(host, ports)
end
hostrule = function(host)
if not nmap.is_privileged() then
nmap.registry[SCRIPT_NAME] = nmap.registry[SCRIPT_NAME] or {};
if not nmap.registry[SCRIPT_NAME].rootfail then
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME);
end
nmap.registry[SCRIPT_NAME].rootfail = true;
return nil;
end
local numopen, numclosed = NUMOPEN, NUMCLOSED
if not nmap.is_privileged() then
if not nmap.registry['qscan'] then
nmap.registry['qscan'] = {}
end
if nmap.registry['qscan']['rootfail'] then
return false
end
nmap.registry['qscan']['rootfail'] = true
if nmap.verbosity() > 0 then
stdnse.print_debug("%s not running for lack of privileges.", SCRIPT_NAME)
end
return false
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
return false

View File

@@ -56,18 +56,9 @@ categories = {"safe","default","discovery"}
require("shortport")
require("stdnse")
-- openssl is required for this script
if pcall(require,"openssl") then
require("ssh1")
require("ssh2")
else
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
require("openssl")
require("ssh1")
require("ssh2")
portrule = shortport.port_or_service(22, "ssh")

View File

@@ -57,15 +57,7 @@ categories = {"safe", "discovery"}
require "shortport"
require "stdnse"
if pcall(require,"openssl") then
require("ssh2")
else
portrule = function() return false end
action = function() end
stdnse.print_debug( 3, "Skipping %s script because OpenSSL is missing.",
SCRIPT_NAME)
return;
end
require "openssl"
portrule = shortport.port_or_service(22, "ssh")