diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index 4c645ddff..f114f9f38 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -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; +} diff --git a/scripts/showHTMLTitle.nse b/scripts/showHTMLTitle.nse index f4d074c20..b2ea51860 100644 --- a/scripts/showHTMLTitle.nse +++ b/scripts/showHTMLTitle.nse @@ -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