mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
nselib stdnse.print_debug -> stdnse.debug
$ f() { find -name \*.lua -exec /bin/echo sed -i "$1" {} \; ; }
$ f 's/stdnse.print_debug( *\([0-9]*\) *, */stdnse.debug\1(/'
$ f 's/stdnse.print_debug( *"\(.*\))/stdnse.debug1("\1)/'
This commit is contained in:
@@ -293,7 +293,7 @@ SqlServerVersionInfo =
|
||||
elseif versionNumber:match( "^%d+%.%d+%.%d+" ) then
|
||||
major, minor, revision = versionNumber:match( "^(%d+)%.(%d+)%.(%d+)" )
|
||||
else
|
||||
stdnse.print_debug( 1, "%s: SetVersionNumber: versionNumber is not in correct format: %s", "MSSQL", versionNumber or "nil" )
|
||||
stdnse.debug1("%s: SetVersionNumber: versionNumber is not in correct format: %s", "MSSQL", versionNumber or "nil" )
|
||||
end
|
||||
|
||||
self:SetVersion( major, minor, revision, subBuild, source )
|
||||
@@ -534,7 +534,7 @@ SSRP =
|
||||
|
||||
table.insert( instanceStrings, instanceString )
|
||||
until (not firstInstanceEnd)
|
||||
stdnse.print_debug( 2, "%s: SSRP Substrings:\n %s", SSRP.DEBUG_ID, stdnse.strjoin( "\n ", instanceStrings ) )
|
||||
stdnse.debug2("%s: SSRP Substrings:\n %s", SSRP.DEBUG_ID, stdnse.strjoin( "\n ", instanceStrings ) )
|
||||
|
||||
local instances = {}
|
||||
for _, instanceString in ipairs( instanceStrings ) do
|
||||
@@ -556,7 +556,7 @@ SSRP =
|
||||
if status then
|
||||
pipeName = namedpipes.make_pipe_name( host.ip, pipeSubPath )
|
||||
elseif pipeName ~= nil then
|
||||
stdnse.print_debug( 1, "%s: Invalid pipe name:\n%s", SSRP.DEBUG_ID, pipeName )
|
||||
stdnse.debug1("%s: Invalid pipe name:\n%s", SSRP.DEBUG_ID, pipeName )
|
||||
end
|
||||
instance.pipeName = pipeName
|
||||
|
||||
@@ -574,11 +574,11 @@ SSRP =
|
||||
pos, messageType, dataLength = bin.unpack("<CS", responseData, 1)
|
||||
-- extract the response data (i.e. everything after the 3-byte header)
|
||||
responseData = responseData:sub(4)
|
||||
stdnse.print_debug( 2, "%s: SSRP Data: %s", SSRP.DEBUG_ID, responseData )
|
||||
stdnse.debug2("%s: SSRP Data: %s", SSRP.DEBUG_ID, responseData )
|
||||
if ( messageType ~= SSRP.MESSAGE_TYPE.ServerResponse or
|
||||
dataLength ~= responseData:len() ) then
|
||||
|
||||
stdnse.print_debug( 2, "%s: Invalid SSRP response. Type: 0x%02x, Length: %d, Actual length: %d",
|
||||
stdnse.debug2("%s: Invalid SSRP response. Type: 0x%02x, Length: %d, Actual length: %d",
|
||||
SSRP.DEBUG_ID, messageType, dataLength, responseData:len() )
|
||||
else
|
||||
instances = SSRP._ParseSsrpString( host, responseData )
|
||||
@@ -599,7 +599,7 @@ SSRP =
|
||||
port = port or SSRP.PORT
|
||||
|
||||
if ( SCANNED_PORTS_ONLY and nmap.get_port_state( host, port ) == nil ) then
|
||||
stdnse.print_debug( 2, "%s: Discovery disallowed: scanned-ports-only is set and port %d was not scanned", SSRP.DEBUG_ID, port.number )
|
||||
stdnse.debug2("%s: Discovery disallowed: scanned-ports-only is set and port %d was not scanned", SSRP.DEBUG_ID, port.number )
|
||||
return false, "Discovery disallowed: scanned-ports-only"
|
||||
end
|
||||
|
||||
@@ -607,7 +607,7 @@ SSRP =
|
||||
socket:set_timeout(5000)
|
||||
|
||||
if ( port.number ~= SSRP.PORT.number ) then
|
||||
stdnse.print_debug( 1, "%s: DiscoverInstances() called with non-standard port (%d)", SSRP.DEBUG_ID, port.number )
|
||||
stdnse.debug1("%s: DiscoverInstances() called with non-standard port (%d)", SSRP.DEBUG_ID, port.number )
|
||||
end
|
||||
|
||||
local status, err = socket:connect( host, port )
|
||||
@@ -644,7 +644,7 @@ SSRP =
|
||||
local instances_all = {}
|
||||
|
||||
if ( port.number ~= SSRP.PORT.number ) then
|
||||
stdnse.print_debug( 1, "%S: DiscoverInstances_Broadcast() called with non-standard port (%d)", SSRP.DEBUG_ID, port.number )
|
||||
stdnse.debug1("%S: DiscoverInstances_Broadcast() called with non-standard port (%d)", SSRP.DEBUG_ID, port.number )
|
||||
end
|
||||
|
||||
local status, err = socket:sendto(host, port, bin.pack( "C", SSRP.MESSAGE_TYPE.ClientBroadcast ))
|
||||
@@ -938,7 +938,7 @@ ColumnData =
|
||||
coldata = coldata .. '-' .. nextdata
|
||||
|
||||
else
|
||||
stdnse.print_debug("Unhandled length (%d) for GUIDTYPE", len)
|
||||
stdnse.debug1("Unhandled length (%d) for GUIDTYPE", len)
|
||||
return pos + len, 'Unsupported Data'
|
||||
end
|
||||
|
||||
@@ -1046,7 +1046,7 @@ ColumnData =
|
||||
elseif ( len == 8 ) then
|
||||
pos, coldata = bin.unpack("<L", data, pos)
|
||||
else
|
||||
stdnse.print_debug("Unhandled length (%d) for DECIMALNTYPE", len)
|
||||
stdnse.debug1("Unhandled length (%d) for DECIMALNTYPE", len)
|
||||
return pos + len, 'Unsupported Data'
|
||||
end
|
||||
|
||||
@@ -1444,7 +1444,7 @@ Token =
|
||||
local ttype
|
||||
pos, ttype = bin.unpack("C", data, pos)
|
||||
if ( not(Token.Parse[ttype]) ) then
|
||||
stdnse.print_debug( 1, "%s: No parser for token type 0x%X", "MSSQL", ttype )
|
||||
stdnse.debug1("%s: No parser for token type 0x%X", "MSSQL", ttype )
|
||||
return -1, ("No parser for token type: 0x%X"):format( ttype )
|
||||
end
|
||||
|
||||
@@ -1636,32 +1636,32 @@ PreLoginPacket =
|
||||
end
|
||||
expectedOptionLength = OPTION_LENGTH_SERVER[ optionType ]
|
||||
if ( not expectedOptionLength ) then
|
||||
stdnse.print_debug( 2, "%s: Unrecognized pre-login option type: %s", "MSSQL", optionType )
|
||||
stdnse.debug2("%s: Unrecognized pre-login option type: %s", "MSSQL", optionType )
|
||||
expectedOptionLength = -1
|
||||
end
|
||||
|
||||
pos, optionPos, optionLength = bin.unpack(">SS", bytes, pos)
|
||||
if not (optionPos and optionLength) then
|
||||
stdnse.print_debug( 2, "%s: Could not unpack optionPos and optionLength.", "MSSQL" )
|
||||
stdnse.debug2("%s: Could not unpack optionPos and optionLength.", "MSSQL" )
|
||||
return false, "Invalid pre-login response"
|
||||
end
|
||||
|
||||
optionPos = optionPos + 1 -- convert from 0-based index to 1-based index
|
||||
if ( (optionPos + optionLength) > (#bytes + 1) ) then
|
||||
stdnse.print_debug( 2, "%s: Pre-login response: pos+len for option type %s is beyond end of data.", "MSSQL", optionType )
|
||||
stdnse.print_debug( 2, "%s: (optionPos: %s) (optionLength: %s)", "MSSQL", optionPos, optionLength )
|
||||
stdnse.debug2("%s: Pre-login response: pos+len for option type %s is beyond end of data.", "MSSQL", optionType )
|
||||
stdnse.debug2("%s: (optionPos: %s) (optionLength: %s)", "MSSQL", optionPos, optionLength )
|
||||
return false, "Invalid pre-login response"
|
||||
end
|
||||
|
||||
|
||||
if ( optionLength ~= expectedOptionLength and expectedOptionLength ~= -1 ) then
|
||||
stdnse.print_debug( 2, "%s: Option data is incorrect size in pre-login response. ", "MSSQL" )
|
||||
stdnse.print_debug( 2, "%s: (optionType: %s) (optionLength: %s)", "MSSQL", optionType, optionLength )
|
||||
stdnse.debug2("%s: Option data is incorrect size in pre-login response. ", "MSSQL" )
|
||||
stdnse.debug2("%s: (optionType: %s) (optionLength: %s)", "MSSQL", optionType, optionLength )
|
||||
return false, "Invalid pre-login response"
|
||||
end
|
||||
optionData = bytes:sub( optionPos, optionPos + optionLength - 1 )
|
||||
if #optionData ~= optionLength then
|
||||
stdnse.print_debug( 2, "%s: Could not read sufficient bytes from version data.", "MSSQL" )
|
||||
stdnse.debug2("%s: Could not read sufficient bytes from version data.", "MSSQL" )
|
||||
return false, "Invalid pre-login response"
|
||||
end
|
||||
|
||||
@@ -1961,14 +1961,14 @@ TDSStream = {
|
||||
end
|
||||
|
||||
local status, result, connectionType, errorMessage
|
||||
stdnse.print_debug( 3, "%s: Connection preferences for %s: %s",
|
||||
stdnse.debug3("%s: Connection preferences for %s: %s",
|
||||
"MSSQL", instanceInfo:GetName(), stdnse.strjoin( ", ", connectionPreference ) )
|
||||
|
||||
for _, connectionType in ipairs( connectionPreference ) do
|
||||
if connectionType == "TCP" then
|
||||
|
||||
if not ( instanceInfo.port ) then
|
||||
stdnse.print_debug( 3, "%s: Cannot connect to %s via TCP because port table is not set.",
|
||||
stdnse.debug3("%s: Cannot connect to %s via TCP because port table is not set.",
|
||||
"MSSQL", instanceInfo:GetName() )
|
||||
result = "No TCP port for this instance"
|
||||
else
|
||||
@@ -1979,7 +1979,7 @@ TDSStream = {
|
||||
elseif connectionType == "Named Pipes" or connectionType == "NP" then
|
||||
|
||||
if not ( instanceInfo.pipeName ) then
|
||||
stdnse.print_debug( 3, "%s: Cannot connect to %s via named pipes because pipe name is not set.",
|
||||
stdnse.debug3("%s: Cannot connect to %s via named pipes because pipe name is not set.",
|
||||
"MSSQL", instanceInfo:GetName() )
|
||||
result = "No named pipe for this instance"
|
||||
else
|
||||
@@ -1988,7 +1988,7 @@ TDSStream = {
|
||||
end
|
||||
|
||||
else
|
||||
stdnse.print_debug( 1, "%s: Unknown connection preference: %s", "MSSQL", connectionType )
|
||||
stdnse.debug1("%s: Unknown connection preference: %s", "MSSQL", connectionType )
|
||||
return false, ("ERROR: Unknown connection preference: %s"):format(connectionType)
|
||||
end
|
||||
|
||||
@@ -2023,7 +2023,7 @@ TDSStream = {
|
||||
if ( self._socket ) then return false, "Already connected via TCP" end
|
||||
|
||||
if ( SCANNED_PORTS_ONLY and smb.get_port( host ) == nil ) then
|
||||
stdnse.print_debug( 2, "%s: Connection disallowed: scanned-ports-only is set and no SMB port is available", "MSSQL" )
|
||||
stdnse.debug2("%s: Connection disallowed: scanned-ports-only is set and no SMB port is available", "MSSQL" )
|
||||
return false, "Connection disallowed: scanned-ports-only"
|
||||
end
|
||||
|
||||
@@ -2050,7 +2050,7 @@ TDSStream = {
|
||||
if ( self._pipe ) then return false, "Already connected via named pipes" end
|
||||
|
||||
if ( SCANNED_PORTS_ONLY and nmap.get_port_state( host, port ) == nil ) then
|
||||
stdnse.print_debug( 2, "%s: Connection disallowed: scanned-ports-only is set and port %d was not scanned", "MSSQL", port.number )
|
||||
stdnse.debug2("%s: Connection disallowed: scanned-ports-only is set and port %d was not scanned", "MSSQL", port.number )
|
||||
return false, "Connection disallowed: scanned-ports-only"
|
||||
end
|
||||
|
||||
@@ -2075,7 +2075,7 @@ TDSStream = {
|
||||
|
||||
if ( not(status) ) then
|
||||
self._socket = nil
|
||||
stdnse.print_debug( 2, "%s: Socket connection failed on %s:%s", "MSSQL", host.ip, port.number )
|
||||
stdnse.debug2("%s: Socket connection failed on %s:%s", "MSSQL", host.ip, port.number )
|
||||
return false, "Socket connection failed"
|
||||
end
|
||||
self._name = string.format( "%s:%s", host.ip, port.number )
|
||||
@@ -2191,7 +2191,7 @@ TDSStream = {
|
||||
|
||||
-- TDS packet validity check: packet at least as long as the TDS header
|
||||
if ( readBuffer:len() < 8 ) then
|
||||
stdnse.print_debug( 2, "%s: Receiving (%s): packet is invalid length", "MSSQL", self._name )
|
||||
stdnse.debug2("%s: Receiving (%s): packet is invalid length", "MSSQL", self._name )
|
||||
return false, "Server returned invalid packet"
|
||||
end
|
||||
|
||||
@@ -2201,7 +2201,7 @@ TDSStream = {
|
||||
|
||||
-- TDS packet validity check: packet type is Response (0x4)
|
||||
if ( packetType ~= PacketType.Response ) then
|
||||
stdnse.print_debug( 2, "%s: Receiving (%s): Expected type 0x4 (response), but received type 0x%x",
|
||||
stdnse.debug2("%s: Receiving (%s): Expected type 0x4 (response), but received type 0x%x",
|
||||
"MSSQL", self._name, packetType )
|
||||
return false, "Server returned invalid packet"
|
||||
end
|
||||
@@ -2228,7 +2228,7 @@ TDSStream = {
|
||||
|
||||
-- TDS packet validity check: packet length matches length from header
|
||||
if ( packetLength ~= (thisPacketData:len() + 8) ) then
|
||||
stdnse.print_debug( 2, "%s: Receiving (%s): Header reports length %d, actual length is %d",
|
||||
stdnse.debug2("%s: Receiving (%s): Header reports length %d, actual length is %d",
|
||||
"MSSQL", self._name, packetLength, thisPacketData:len() )
|
||||
return false, "Server returned invalid packet"
|
||||
end
|
||||
@@ -2490,7 +2490,7 @@ Helper =
|
||||
Helper.AddOrMergeInstance( instance )
|
||||
table.insert( instances_host, instance )
|
||||
else
|
||||
stdnse.print_debug( 3, "DiscoverBySmb \n pipe: %s\n result: %s", pipeSubPath, tostring( result ) )
|
||||
stdnse.debug3("DiscoverBySmb \n pipe: %s\n result: %s", pipeSubPath, tostring( result ) )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2853,7 +2853,7 @@ Helper =
|
||||
status, response = tdsStream:ConnectEx( instanceInfo )
|
||||
|
||||
if ( not status ) then
|
||||
stdnse.print_debug( 2, "%s: Connection to %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" )
|
||||
stdnse.debug2("%s: Connection to %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" )
|
||||
return false, "Connect failed"
|
||||
end
|
||||
|
||||
@@ -2873,12 +2873,12 @@ Helper =
|
||||
if status then
|
||||
version = preLoginResponse.versionInfo
|
||||
else
|
||||
stdnse.print_debug( 2, "%s: Parsing of pre-login packet from %s failed: %s",
|
||||
stdnse.debug2("%s: Parsing of pre-login packet from %s failed: %s",
|
||||
"MSSQL", instanceInfo:GetName(), preLoginResponse or "" )
|
||||
return false, "Parsing failed"
|
||||
end
|
||||
else
|
||||
stdnse.print_debug( 2, "%s: Receive for %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" )
|
||||
stdnse.debug2("%s: Receive for %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" )
|
||||
return false, "Receive failed"
|
||||
end
|
||||
|
||||
@@ -2925,7 +2925,7 @@ Helper =
|
||||
end
|
||||
|
||||
if ( not Helper.WasDiscoveryPerformed( host ) ) then
|
||||
stdnse.print_debug( 2, "%s: Discovery has not been performed prior to GetTargetInstances() call. Performing discovery now.", "MSSQL" )
|
||||
stdnse.debug2("%s: Discovery has not been performed prior to GetTargetInstances() call. Performing discovery now.", "MSSQL" )
|
||||
Helper.Discover( host )
|
||||
end
|
||||
|
||||
@@ -3078,7 +3078,7 @@ Auth = {
|
||||
LmResponse = function( password, nonce )
|
||||
|
||||
if ( not(HAVE_SSL) ) then
|
||||
stdnse.print_debug("ERROR: Nmap is missing OpenSSL")
|
||||
stdnse.debug1("ERROR: Nmap is missing OpenSSL")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user