mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 14:11:29 +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:
@@ -56,7 +56,7 @@ request_types_str[8] = "DHCPINFORM"
|
||||
local function read_ip(data, pos, length)
|
||||
if(length ~= 4) then
|
||||
if((length % 4) ~= 0) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for an ip address (%d)", length)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for an ip address (%d)", length)
|
||||
pos = pos + length
|
||||
|
||||
return pos, nil
|
||||
@@ -98,7 +98,7 @@ end
|
||||
--@return The value of the field, or nil if the field length was wrong.
|
||||
local function read_1_byte(data, pos, length)
|
||||
if(length ~= 1) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 1)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 1)
|
||||
pos = pos + length
|
||||
return pos, nil
|
||||
end
|
||||
@@ -118,7 +118,7 @@ local function read_message_type(data, pos, length)
|
||||
|
||||
pos, value = read_1_byte(data, pos, length)
|
||||
if(value == nil) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Couldn't read the 1-byte message type")
|
||||
stdnse.debug1("dhcp-discover: Couldn't read the 1-byte message type")
|
||||
return pos, nil
|
||||
end
|
||||
|
||||
@@ -138,7 +138,7 @@ local function read_boolean(data, pos, length)
|
||||
pos, result = read_1_byte(data, pos, length)
|
||||
|
||||
if(result == nil) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Couldn't read the 1-byte boolean")
|
||||
stdnse.debug1("dhcp-discover: Couldn't read the 1-byte boolean")
|
||||
return pos, nil
|
||||
elseif(result == 0) then
|
||||
return pos, "false"
|
||||
@@ -156,7 +156,7 @@ end
|
||||
--@return The value of the field, or nil if the field length was wrong.
|
||||
local function read_2_bytes(data, pos, length)
|
||||
if(length ~= 2) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 2)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 2)
|
||||
pos = pos + length
|
||||
return pos, nil
|
||||
end
|
||||
@@ -174,7 +174,7 @@ end
|
||||
--@return The value of the field, or nil if the field length was wrong.
|
||||
local function read_2_bytes_list(data, pos, length)
|
||||
if((length % 2) ~= 0) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 2)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 2)
|
||||
pos = pos + length
|
||||
|
||||
return pos, nil
|
||||
@@ -200,7 +200,7 @@ end
|
||||
--@return The value of the field, or nil if the field length was wrong.
|
||||
local function read_4_bytes(data, pos, length)
|
||||
if(length ~= 4) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 4)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 4)
|
||||
pos = pos + length
|
||||
return pos, nil
|
||||
end
|
||||
@@ -218,7 +218,7 @@ end
|
||||
local function read_time(data, pos, length)
|
||||
local result
|
||||
if(length ~= 4) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 4)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 4)
|
||||
pos = pos + length
|
||||
return pos, nil
|
||||
end
|
||||
@@ -254,7 +254,7 @@ end
|
||||
--@return The value of the field, or nil if the field length was wrong.
|
||||
local function read_static_route(data, pos, length)
|
||||
if((length % 8) ~= 0) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8)
|
||||
pos = pos + length
|
||||
|
||||
return pos, nil
|
||||
@@ -281,7 +281,7 @@ end
|
||||
--@return The value of the field, or nil if the field length was wrong.
|
||||
local function read_policy_filter(data, pos, length)
|
||||
if((length % 8) ~= 0) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8)
|
||||
stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8)
|
||||
pos = pos + length
|
||||
|
||||
return pos, nil
|
||||
@@ -536,22 +536,22 @@ function dhcp_parse(data, transaction_id)
|
||||
-- Verify we got a valid code (if we didn't, we're probably in big trouble)
|
||||
local value
|
||||
if(action == nil) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Unknown option: %d", option)
|
||||
stdnse.debug1("dhcp-discover: Unknown option: %d", option)
|
||||
pos = pos + length
|
||||
else
|
||||
-- Call the function to parse the option, and insert the result into our results table
|
||||
|
||||
stdnse.print_debug(2, "dhcp-discover: Attempting to parse %s", action['name'])
|
||||
stdnse.debug2("dhcp-discover: Attempting to parse %s", action['name'])
|
||||
pos, value = action['func'](data, pos, length)
|
||||
|
||||
if(nmap.verbosity() == 0 and action.default == false) then
|
||||
stdnse.print_debug(1, "dhcp-discover: Server returned unrequested option (%s => %s)", action['name'], value)
|
||||
stdnse.debug1("dhcp-discover: Server returned unrequested option (%s => %s)", action['name'], value)
|
||||
|
||||
else
|
||||
if(value) then
|
||||
table.insert(result['options'], {name=action['name'], value=value})
|
||||
else
|
||||
stdnse.print_debug(1, "dhcp-discover: Couldn't determine value for %s", action['name']);
|
||||
stdnse.debug1("dhcp-discover: Couldn't determine value for %s", action['name']);
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -566,7 +566,7 @@ function dhcp_parse(data, transaction_id)
|
||||
elseif(value == 3) then
|
||||
data = data .. result['file'] .. result['sname']
|
||||
else
|
||||
stdnse.print_debug(1, "dhcp-discover: Warning: 'Option Overload' gave an unsupported value: %d", value)
|
||||
stdnse.debug1("dhcp-discover: Warning: 'Option Overload' gave an unsupported value: %d", value)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -624,7 +624,7 @@ function make_request(target, request_type, ip_address, mac_address, options, re
|
||||
-- Generate the packet
|
||||
local status, packet = dhcp_build(request_type, bin.pack(">I", ipOps.todword(ip_address)), mac_address, options, request_options, overrides, lease_time, transaction_id)
|
||||
if(not(status)) then
|
||||
stdnse.print_debug(1, "dhcp: Couldn't build packet: " .. packet)
|
||||
stdnse.debug1("dhcp: Couldn't build packet: " .. packet)
|
||||
return false, "Couldn't build packet: " .. packet
|
||||
end
|
||||
|
||||
@@ -635,7 +635,7 @@ function make_request(target, request_type, ip_address, mac_address, options, re
|
||||
-- Send the packet and get the response
|
||||
local status, response = dhcp_send(socket, target, packet)
|
||||
if(not(status)) then
|
||||
stdnse.print_debug(1, "dhcp: Couldn't send packet: " .. response)
|
||||
stdnse.debug1("dhcp: Couldn't send packet: " .. response)
|
||||
return false, "Couldn't send packet: " .. response
|
||||
end
|
||||
|
||||
@@ -643,14 +643,14 @@ function make_request(target, request_type, ip_address, mac_address, options, re
|
||||
socket:close()
|
||||
|
||||
if ( not(status) ) then
|
||||
stdnse.print_debug(1, "dhcp: Couldn't receive packet: " .. response)
|
||||
stdnse.debug1("dhcp: Couldn't receive packet: " .. response)
|
||||
return false, "Couldn't receive packet: " .. response
|
||||
end
|
||||
|
||||
-- Parse the response
|
||||
local status, parsed = dhcp_parse(response, transaction_id)
|
||||
if(not(status)) then
|
||||
stdnse.print_debug(1, "dhcp: Couldn't parse response: " .. parsed)
|
||||
stdnse.debug1("dhcp: Couldn't parse response: " .. parsed)
|
||||
return false, "Couldn't parse response: " .. parsed
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user