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

stdnse.print_debug -> stdnse.debug1

$ sed -i 's/stdnse.print_debug("%s \([^"]*\)", SCRIPT_NAME/stdnse.debug1("\1"/' *.nse
This commit is contained in:
batrick
2014-08-01 21:35:56 +00:00
parent c94d5970ff
commit 2a8c81c4f6
19 changed files with 69 additions and 69 deletions

View File

@@ -45,7 +45,7 @@ local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME ..
prerule = function()
if ( nmap.address_family() ~= 'inet' ) then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end
return true

View File

@@ -57,7 +57,7 @@ prerule = function()
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end
return true

View File

@@ -43,7 +43,7 @@ prerule = function()
end
if nmap.address_family() ~= 'inet6' then
stdnse.print_debug("%s is IPv6 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv6 compatible only.")
return false
end
return true

View File

@@ -70,7 +70,7 @@ prerule = function()
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end

View File

@@ -73,7 +73,7 @@ categories = {"discovery", "safe"}
-- We want to run against a specific host if UDP/67 is open
function portrule(host, port)
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end

View File

@@ -729,7 +729,7 @@ local function initial_ttl(host)
nmap.registry['firewalk']['traceroutefail'] = true
if nmap.verbosity() > 0 then
stdnse.print_debug("%s requires unavailable traceroute information.", SCRIPT_NAME)
stdnse.debug1("requires unavailable traceroute information.")
end
return nil

View File

@@ -56,7 +56,7 @@ ftp_helper = {
local status, _ = testsock:connect(host.ip, helperport)
testsock:close()
if not status then
stdnse.print_debug("%s Unable to connect to %s helper port.", SCRIPT_NAME, helperport)
stdnse.debug1("Unable to connect to %s helper port.", helperport)
return false
end
return true
@@ -111,14 +111,14 @@ ftp_helper = {
if isIp4 then
if not p:ip_parse() then
-- An error happened
stdnse.print_debug("%s Couldn't parse IPv4 sniffed packet.", SCRIPT_NAME)
stdnse.debug1("Couldn't parse IPv4 sniffed packet.")
sniffer:pcap_close()
return false
end
else
if not p:ip6_parse() then
-- An error happened
stdnse.print_debug("%s Couldn't parse IPv6 sniffed packet.", SCRIPT_NAME)
stdnse.debug1("Couldn't parse IPv6 sniffed packet.")
sniffer:pcap_close()
return false
end
@@ -168,7 +168,7 @@ ftp_helper = {
local status, _ = socket:connect(host.ip, helperport)
if not status then
-- Problem connecting to helper port
stdnse.print_debug("%s Problem connecting to helper port %s.", SCRIPT_NAME, tostring(helperport))
stdnse.debug1("Problem connecting to helper port %s.", tostring(helperport))
return
end
@@ -203,7 +203,7 @@ hostrule = function(host)
end
if helper and not helpers[helper] then
stdnse.print_debug("%s %s helper not supported at the moment.", SCRIPT_NAME, helper)
stdnse.debug1("%s helper not supported at the moment.", helper)
return false
end
@@ -221,7 +221,7 @@ action = function(host, port)
testsock:set_timeout(1000)
local status, _ = testsock:connect(host.ip, targetport)
if status then
stdnse.print_debug("%s %s target port already open.", SCRIPT_NAME, targetport)
stdnse.debug1("%s target port already open.", targetport)
return nil
end
testsock:close()
@@ -231,10 +231,10 @@ action = function(host, port)
local port = nmap.get_ports(host, nil, "tcp", "filtered") or nmap.get_ports(host, nil, "tcp", "closed")
if port then
targetport = port.number
stdnse.print_debug("%s %s chosen as target port.", SCRIPT_NAME, targetport)
stdnse.debug1("%s chosen as target port.", targetport)
else
-- No closed or filtered ports to check on.
stdnse.print_debug("%s Target port not specified and no closed or filtered port found.", SCRIPT_NAME)
stdnse.debug1("Target port not specified and no closed or filtered port found.")
return
end
end
@@ -250,13 +250,13 @@ action = function(host, port)
for i, helper in pairs(helpers) do
if helper.should_run(host, helperport) then
helpername = i
stdnse.print_debug("%s %s chosen as helper.", SCRIPT_NAME, helpername)
stdnse.debug1("%s chosen as helper.", helpername)
helper.attack(host, helperport, targetport)
break
end
end
if not helpername then
stdnse.print_debug("%s no suitable helper found.", SCRIPT_NAME)
stdnse.debug1("no suitable helper found.")
return nil
end
end

View File

@@ -71,26 +71,26 @@ bigip = {
for _, response in pairs(responses) do
if response.header['x-cnection'] then
stdnse.print_debug("%s BigIP detected through X-Cnection header.", SCRIPT_NAME)
stdnse.debug1("BigIP detected through X-Cnection header.")
bigip.detected = true
return
end
if response.header.server == 'BigIP' then --
stdnse.print_debug("%s BigIP detected through Server header.", SCRIPT_NAME)
stdnse.debug1("BigIP detected through Server header.")
bigip.detected = true
return
end
for _, cookie in pairs(response.cookies) do --
if string.find(cookie.name, "BIGipServer") then
stdnse.print_debug("%s BigIP detected through cookies.", SCRIPT_NAME)
stdnse.debug1("BigIP detected through cookies.")
bigip.detected = true
return
end
-- Application Security Manager module
if string.match(cookie.name, 'TS%w+') and string.len(cookie.name) <= 8 then
stdnse.print_debug("%s F5 ASM detected through cookies.", SCRIPT_NAME)
stdnse.debug1("F5 ASM detected through cookies.")
bigip.detected = true
return
end
@@ -110,13 +110,13 @@ webknight = {
match = function(responses)
for name, response in pairs(responses) do
if response.header.server and string.find(response.header.server, 'WebKnight/') then --
stdnse.print_debug("%s WebKnight detected through Server Header.", SCRIPT_NAME)
stdnse.debug1("WebKnight detected through Server Header.")
webknight.version = string.sub(response.header.server, 11)
webknight.detected = true
return
end
if response.status == 999 then
if not webknight.detected then stdnse.print_debug("%s WebKnight detected through 999 response status code.", SCRIPT_NAME) end
if not webknight.detected then stdnse.debug1("WebKnight detected through 999 response status code.") end
webknight.detected = true
end
end
@@ -140,7 +140,7 @@ isaserver = {
for _, response in pairs(responses) do
for _, reason in pairs(isaserver.reason) do --
if http.response_contains(response, reason, true) then -- TODO Replace with something more performant
stdnse.print_debug("%s ISA Server detected through response reason.", SCRIPT_NAME)
stdnse.debug1("ISA Server detected through response reason.")
isaserver.detected = true
return
end
@@ -163,13 +163,13 @@ airlock = {
-- TODO Check if version detection is possible
-- based on the difference in cookies name
if cookie.name == "AL_LB" and string.sub(cookie.value, 1, 4) == '$xc/' then
stdnse.print_debug("%s Airlock detected through AL_LB cookies.", SCRIPT_NAME)
stdnse.debug1("Airlock detected through AL_LB cookies.")
airlock.detected = true
return
end
if cookie.name == "AL_SESS" and (string.sub(cookie.value, 1, 5) == 'AAABL'
or string.sub(cookie.value, 1, 5) == 'LgEAA' )then
stdnse.print_debug("%s Airlock detected through AL_SESS cookies.", SCRIPT_NAME)
stdnse.debug1("Airlock detected through AL_SESS cookies.")
airlock.detected = true
return
end
@@ -190,7 +190,7 @@ barracuda = {
for _, response in pairs(responses) do
for _, cookie in pairs(response.cookies) do
if cookie.name == "barra_counter_session" then
stdnse.print_debug("%s Barracuda detected through cookies.", SCRIPT_NAME)
stdnse.debug1("Barracuda detected through cookies.")
barracuda.detected = true
return
end
@@ -212,7 +212,7 @@ denyall = {
for _, cookie in pairs(response.cookies) do
-- TODO Check accuracy
if cookie.name == "sessioncookie" then
stdnse.print_debug("%s Denyall detected through cookies.", SCRIPT_NAME)
stdnse.debug1("Denyall detected through cookies.")
denyall.detected = true
return
end
@@ -234,14 +234,14 @@ f5trafficshield = {
-- TODO Check for version detection possibility
-- based on the cookie name / server header presence
if response.header.server == "F5-TrafficShield" then
stdnse.print_debug("%s F5 Traffic Shield detected through Server header.", SCRIPT_NAME)
stdnse.debug1("F5 Traffic Shield detected through Server header.")
f5trafficshield.detected = true
return
end
for _, cookie in pairs(response.cookies) do
if cookie.name == "ASINFO" then
stdnse.print_debug("%s F5 Traffic Shield detected through cookies.", SCRIPT_NAME)
stdnse.debug1("F5 Traffic Shield detected through cookies.")
f5trafficshield.detected = true
return
end
@@ -262,7 +262,7 @@ teros = {
for _, response in pairs(responses) do
for _, cookie in pairs(response.cookies) do
if cookie.name == "st8id" or cookie.name == "st8_wat" or cookie.name == "st8_wlf" then
stdnse.print_debug("%s Teros / CAF detected through cookies.", SCRIPT_NAME)
stdnse.debug1("Teros / CAF detected through cookies.")
teros.detected = true
return
end
@@ -282,13 +282,13 @@ binarysec = {
match = function(responses)
for _, response in pairs(responses) do
if response.header.server and string.find(response.header.server, 'BinarySEC/') then --
stdnse.print_debug("%s BinarySec detected through Server Header.", SCRIPT_NAME)
stdnse.debug1("BinarySec detected through Server Header.")
binarysec.version = string.sub(response.header.server, 11)
binarysec.detected = true
return
end
if response.header['x-binarysec-via'] or response.header['x-binarysec-nocache']then
if not binarysec.detected then stdnse.print_debug("%s BinarySec detected through header.", SCRIPT_NAME) end
if not binarysec.detected then stdnse.debug1("BinarySec detected through header.") end
binarysec.detected = true
end
end
@@ -306,13 +306,13 @@ profense = {
match = function(responses)
for _, response in pairs(responses) do
if response.header.server == 'Profense' then
stdnse.print_debug("%s Profense detected through Server header.", SCRIPT_NAME)
stdnse.debug1("Profense detected through Server header.")
profense.detected = true
return
end
for _, cookie in pairs(response.cookies) do
if cookie.name == "PLBSID" then
stdnse.print_debug("%s Profense detected through cookies.", SCRIPT_NAME)
stdnse.debug1("Profense detected through cookies.")
profense.detected = true
return
end
@@ -335,27 +335,27 @@ netscaler = {
-- TODO Check for other version detection possibilities
-- based on fingerprint difference
if response.header.via and string.find(response.header.via, 'NS%-CACHE') then --
stdnse.print_debug("%s Citrix Netscaler detected through Via Header.", SCRIPT_NAME)
stdnse.debug1("Citrix Netscaler detected through Via Header.")
netscaler.version = string.sub(response.header.via, 10, 12)
netscaler.detected = true
return
end
if response.header.cneonction == "close" or response.header.nncoection == "close" then
if not netscaler.detected then stdnse.print_debug("%s Netscaler detected through Cneonction/nnCoection header.", SCRIPT_NAME) end
if not netscaler.detected then stdnse.debug1("Netscaler detected through Cneonction/nnCoection header.") end
netscaler.detected = true
end
-- TODO Does X-CLIENT-IP apply to Citrix Application Firewall too ?
if response.header['x-client-ip'] then
if not netscaler.detected then stdnse.print_debug("%s Netscaler detected through X-CLIENT-IP header.", SCRIPT_NAME) end
if not netscaler.detected then stdnse.debug1("Netscaler detected through X-CLIENT-IP header.") end
netscaler.detected = true
end
for _, cookie in pairs(response.cookies) do
if cookie.name == "ns_af" or cookie.name == "citrix_ns_id" or
string.find(cookie.name, "NSC_") then
if not netscaler.detected then stdnse.print_debug("%s Netscaler detected through cookies.", SCRIPT_NAME) end
if not netscaler.detected then stdnse.debug1("Netscaler detected through cookies.") end
netscaler.detected = true
end
end
@@ -374,7 +374,7 @@ dotdefender = {
match = function(responses)
for _, response in pairs(responses) do
if response.header['X-dotdefender-denied'] == "1" then
stdnse.print_debug("%s dotDefender detected through X-dotDefender-denied header.", SCRIPT_NAME)
stdnse.debug1("dotDefender detected through X-dotDefender-denied header.")
dotdefender.detected = true
return
end
@@ -393,7 +393,7 @@ ibmdatapower = {
match = function(responses)
for _, response in pairs(responses) do
if response.header['x-backside-transport'] then
stdnse.print_debug("%s IBM DataPower detected through X-Backside-Transport header.", SCRIPT_NAME)
stdnse.debug1("IBM DataPower detected through X-Backside-Transport header.")
ibmdatapower.detected = true
return
end
@@ -412,13 +412,13 @@ cloudflare = {
match = function(responses)
for _, response in pairs(responses) do
if response.header.server == 'cloudflare-nginx' then
stdnse.print_debug("%s Cloudflare detected through Server header.", SCRIPT_NAME)
stdnse.debug1("Cloudflare detected through Server header.")
cloudflare.detected = true
return
end
for _, cookie in pairs(response.cookies) do
if cookie.name == "__cfduid" then
stdnse.print_debug("%s Cloudflare detected through cookies.", SCRIPT_NAME)
stdnse.debug1("Cloudflare detected through cookies.")
cloudflare.detected = true
return
end
@@ -439,7 +439,7 @@ incapsula = {
for _, response in pairs(responses) do
for _, cookie in pairs(response.cookies) do
if string.find(cookie.name, 'incap_ses') or string.find(cookie.name, 'visid_incap') then
stdnse.print_debug("%s Incapsula WAF detected through cookies.", SCRIPT_NAME)
stdnse.debug1("Incapsula WAF detected through cookies.")
incapsula.detected = true
return
end
@@ -459,7 +459,7 @@ uspses = {
match = function(responses)
for _, response in pairs(responses) do
if response.header.server == 'Secure Entry Server' then
stdnse.print_debug("%s USP-SES detected through Server header.", SCRIPT_NAME)
stdnse.debug1("USP-SES detected through Server header.")
uspses.detected = true
return
end
@@ -478,7 +478,7 @@ ciscoacexml = {
match = function(responses)
for _, response in pairs(responses) do
if response.header.server == 'ACE XML Gateway' then
stdnse.print_debug("%s Cisco ACE XML Gateway detected through Server header.", SCRIPT_NAME)
stdnse.debug1("Cisco ACE XML Gateway detected through Server header.")
ciscoacexml.detected = true
return
end
@@ -499,7 +499,7 @@ modsecurity = {
match = function(responses)
for _, response in pairs(responses) do
if response.header.server and string.find(response.header.server, 'mod_security/') then
stdnse.print_debug("%s Modsecurity detected through Server Header.", SCRIPT_NAME)
stdnse.debug1("Modsecurity detected through Server Header.")
local pos = string.find(response.header.server, 'mod_security/')
modsecurity.version = string.sub(response.header.server, pos + 13, pos + 18)
modsecurity.detected = true
@@ -507,7 +507,7 @@ modsecurity = {
end
if response.header.server and string.find(response.header.server, 'Mod_Security') then
stdnse.print_debug("%s Modsecurity detected through Server Header.", SCRIPT_NAME)
stdnse.debug1("Modsecurity detected through Server Header.")
modsecurity.version = string.sub(response.header.server, 13, -9)
modsecurity.detected = true
return
@@ -516,7 +516,7 @@ modsecurity = {
-- The default SecServerSignature value is "NOYB" <= TODO For older versions, so we could
-- probably do some version detection out of it.
if response.header.server == 'NOYB' then
stdnse.print_debug("%s modsecurity detected through Server header.", SCRIPT_NAME)
stdnse.debug1("modsecurity detected through Server header.")
modsecurity.detected = true
end
end
@@ -539,7 +539,7 @@ naxsi = {
local response2 = http.get(host, port, root .. "?a=[[[]]]][[[]") -- This should trigger the score based rules
if response.status ~= response2.status then
stdnse.print_debug("%s Naxsi detected through intensive scan.", SCRIPT_NAME)
stdnse.debug1("Naxsi detected through intensive scan.")
naxsi.detected = true
end
return
@@ -635,7 +635,7 @@ local send_requests = function(host, port, root)
-- send all requests
local pipeline_responses = http.pipeline_go(host, port, all)
if not pipeline_responses then
stdnse.print_debug("%s No response from pipelined requests", SCRIPT_NAME)
stdnse.debug1("No response from pipelined requests")
return nil
end

View File

@@ -39,13 +39,13 @@ hostrule = function(host)
stdnse.print_debug( "%s not running: Error in Hostrule: %s.", SCRIPT_NAME, err )
return false
elseif is_private then
stdnse.print_debug("%s not running: Private IP address of target: %s", SCRIPT_NAME, host.ip)
stdnse.debug1("not running: Private IP address of target: %s", host.ip)
return false
end
local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey")
if not (type(api_key)=="string") then
stdnse.print_debug("%s not running: No IPInfoDB API key specified.", SCRIPT_NAME)
stdnse.debug1("not running: No IPInfoDB API key specified.")
return false
end

View File

@@ -191,7 +191,7 @@ hostrule = function(host)
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end
if not host.interface then

View File

@@ -44,7 +44,7 @@ math.randomseed(os.time())
prerule = function()
if nmap.address_family() ~= "inet6" then
stdnse.print_debug("%s is IPv6 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv6 compatible only.")
return false
end
@@ -181,7 +181,7 @@ local function broadcast_on_interface(iface)
end
if counter > 0 then
stdnse.print_debug("%s generated %d packets in %d seconds.", SCRIPT_NAME, counter, stop - start)
stdnse.debug1("generated %d packets in %d seconds.", counter, stop - start)
end
end

View File

@@ -112,7 +112,7 @@ local llmnrListen = function(interface, timeout, result)
-- Message == Response bit
-- and 1 Question (hostname we requested) and
if (bit.rshift(flags, 15) == 1) and questions == 0x01 then
stdnse.print_debug("%s got response from %s", SCRIPT_NAME, p.ip_src)
stdnse.debug1("got response from %s", p.ip_src)
-- Skip header's 12 bytes
-- extract host length
local index, qlen = bin.unpack(">C", llmnr, 13)
@@ -131,7 +131,7 @@ local llmnrListen = function(interface, timeout, result)
response.address = ipOps.fromdword(response.address)
table.insert(result, response)
else
stdnse.print_debug("%s skipped llmnr response.", SCRIPT_NAME)
stdnse.debug1("skipped llmnr response.")
end
end
end
@@ -172,7 +172,7 @@ action = function()
-- Check if a valid hostname was provided
if not hostname or #hostname == 0 then
stdnse.print_debug("%s no hostname was provided.", SCRIPT_NAME)
stdnse.debug1("no hostname was provided.")
return
end

View File

@@ -56,7 +56,7 @@ prerule = function()
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end

View File

@@ -278,7 +278,7 @@ hostrule = function(host)
end
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end
if not (host.interface and host.interface_mtu) then

View File

@@ -374,7 +374,7 @@ hostrule = function(host)
local numopen, numclosed = NUMOPEN, NUMCLOSED
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end
if not host.interface then

View File

@@ -87,7 +87,7 @@ local isRPC = function(host, port)
data = rpcConn:EncodePacket(xid)
status, err = rpcConn:SendPacket(data)
if not status then
stdnse.print_debug("%s SendPacket(): %s", SCRIPT_NAME, err)
stdnse.debug1("SendPacket(): %s", err)
return
end
@@ -168,7 +168,7 @@ local rpcGrinder = function(host, port, iterator, result)
status, err = rpcConn:Connect(host, port)
if not status then
stdnse.print_debug("%s Connect(): %s", SCRIPT_NAME, err)
stdnse.debug1("Connect(): %s", err)
condvar "signal";
return
end
@@ -183,14 +183,14 @@ local rpcGrinder = function(host, port, iterator, result)
packet = rpcConn:EncodePacket(xid)
status, err = rpcConn:SendPacket(packet)
if not status then
stdnse.print_debug("%s SendPacket(): %s", SCRIPT_NAME, err)
stdnse.debug1("SendPacket(): %s", err)
condvar "signal";
return
end
status, data = rpcConn:ReceivePacket()
if not status then
stdnse.print_debug("%s ReceivePacket(): %s", SCRIPT_NAME, data)
stdnse.debug1("ReceivePacket(): %s", data)
condvar "signal";
return
end

View File

@@ -23,7 +23,7 @@ categories = {"discovery", "intrusive"}
-- okay, we're interested only in hosts that are on our ethernet lan
hostrule = function(host)
if nmap.address_family() ~= 'inet' then
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
stdnse.debug1("is IPv4 compatible only.")
return false
end
if host.directly_connected == true and

View File

@@ -49,7 +49,7 @@ action = function(host, port)
sha1 = stdnse.tohex(cert.digest(cert, "sha1"))
query = sha1 .. ".certs.googlednstest.com"
stdnse.print_debug("%s %s", SCRIPT_NAME, query)
stdnse.debug1("%s", query)
local status, decoded_response = dns.query(query, { dtype = "TXT" })

View File

@@ -494,14 +494,14 @@ end
function do_query(db, ip)
if type( db ) ~= "string" or not nmap.registry.whois.whoisdb[db] then
stdnse.print_debug("%s %s Error in do_query: %s is not a defined Whois service.", SCRIPT_NAME, ip, db)
stdnse.debug1("%s Error in do_query: %s is not a defined Whois service.", ip, db)
return nil
end
local service = nmap.registry.whois.whoisdb[db]
if type( service.hostname ) ~= "string" or service.hostname == "" then
stdnse.print_debug("%s %s Error in do_query: Invalid hostname for %s.", SCRIPT_NAME, ip, db)
stdnse.debug1("%s Error in do_query: Invalid hostname for %s.", ip, db)
return nil
end