mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Add an nmap.have_ssl NSE function and use it in the script showHTMLTitle.nse to
avoid doing an SSL probe if SSL is not available.
This commit is contained in:
@@ -38,6 +38,7 @@ static int l_set_port_state(lua_State* l, Target* target, Port* port);
|
||||
static int l_set_port_version(lua_State* l, Target* target, Port* port);
|
||||
static int l_get_verbosity(lua_State *);
|
||||
static int l_get_debugging(lua_State *);
|
||||
static int l_get_have_ssl(lua_State *l);
|
||||
|
||||
int l_clock_ms(lua_State* l);
|
||||
|
||||
@@ -57,6 +58,7 @@ int set_nmaplib(lua_State* l) {
|
||||
{"new_try", l_exc_newtry},
|
||||
{"verbosity", l_get_verbosity},
|
||||
{"debugging", l_get_debugging},
|
||||
{"have_ssl", l_get_have_ssl},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -510,3 +512,11 @@ static int l_get_debugging(lua_State *l)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_get_have_ssl(lua_State *l) {
|
||||
#if HAVE_OPENSSL
|
||||
lua_pushboolean(l, true);
|
||||
#else
|
||||
lua_pushboolean(l, false);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,19 @@ license = "See nmaps COPYING for licence"
|
||||
|
||||
categories = {"demo", "safe"}
|
||||
|
||||
require "shortport"
|
||||
require "stdnse"
|
||||
|
||||
portrule = shortport.service({'http', 'https'})
|
||||
portrule = function(host, port)
|
||||
if not (port.service == 'http' or port.service == 'https') then
|
||||
return false
|
||||
end
|
||||
-- Don't bother running on SSL ports if we don't have SSL.
|
||||
if (port.service == 'https' or port.version.service_tunnel == 'ssl')
|
||||
and not nmap.have_ssl() then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
local socket, request, result, status, s, title, protocol
|
||||
|
||||
Reference in New Issue
Block a user