1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31: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:
batrick
2014-08-03 00:56:45 +00:00
parent a809f52d5d
commit ee6622aea4
67 changed files with 1092 additions and 1092 deletions

View File

@@ -415,7 +415,7 @@ Helper = {
local auth = self:getOption(options, "auth") local auth = self:getOption(options, "auth")
if ( not(auth) or not(auth.username) and not(auth.password) ) then if ( not(auth) or not(auth.username) and not(auth.password) ) then
stdnse.print_debug(2, "No authentication information") stdnse.debug2("No authentication information")
return status, result return status, result
end end
@@ -429,9 +429,9 @@ Helper = {
end end
if ( not(scheme) ) then if ( not(scheme) ) then
stdnse.print_debug(2, "Could not find a supported authentication scheme") stdnse.debug2("Could not find a supported authentication scheme")
elseif ( "basic" ~= scheme ) then elseif ( "basic" ~= scheme ) then
stdnse.print_debug(2, "Unsupported authentication scheme: %s", scheme) stdnse.debug2("Unsupported authentication scheme: %s", scheme)
else else
headers = headers or {} headers = headers or {}
headers["Authorization"] = ("Basic %s"):format(base64.enc(auth.username .. ":" .. auth.password)) headers["Authorization"] = ("Basic %s"):format(base64.enc(auth.username .. ":" .. auth.password))

View File

@@ -249,7 +249,7 @@ AMQP = {
-- parse frame header -- parse frame header
local frametype, chnumber, framesize, method local frametype, chnumber, framesize, method
_, frametype, chnumber, framesize, method = bin.unpack(">CSII", tmp) _, frametype, chnumber, framesize, method = bin.unpack(">CSII", tmp)
stdnse.print_debug("frametype: %d, chnumber: %d, framesize: %d, method: %d", frametype, chnumber, framesize, method) stdnse.debug1("frametype: %d, chnumber: %d, framesize: %d, method: %d", frametype, chnumber, framesize, method)
if (frametype ~= 1) then if (frametype ~= 1) then
return false, ("ERROR: AQMP:handshake expected header (1) frame, but was %d"):format(frametype) return false, ("ERROR: AQMP:handshake expected header (1) frame, but was %d"):format(frametype)

View File

@@ -139,7 +139,7 @@ ASN1Decoder = {
if self.decoder[etype] then if self.decoder[etype] then
return self.decoder[etype]( self, encStr, elen, newpos ) return self.decoder[etype]( self, encStr, elen, newpos )
else else
stdnse.print_debug("no decoder for etype: " .. etype) stdnse.debug1("no decoder for etype: " .. etype)
return newpos, nil return newpos, nil
end end
end, end,

View File

@@ -678,15 +678,15 @@ Torrent =
if tracker:match("^http://") then -- http tracker if tracker:match("^http://") then -- http tracker
status, err = self:http_tracker_peers(tracker) status, err = self:http_tracker_peers(tracker)
if not status then if not status then
stdnse.print_debug("Could not get peers from tracker %s, reason: %s",tracker, err) stdnse.debug1("Could not get peers from tracker %s, reason: %s",tracker, err)
end end
elseif tracker:match("^udp://") then -- udp tracker elseif tracker:match("^udp://") then -- udp tracker
status, err = self:udp_tracker_peers(tracker) status, err = self:udp_tracker_peers(tracker)
if not status then if not status then
stdnse.print_debug("Could not get peers from tracker %s, reason: %s",tracker, err) stdnse.debug1("Could not get peers from tracker %s, reason: %s",tracker, err)
end end
else -- unknown tracker else -- unknown tracker
stdnse.print_debug("Unknown tracker protocol for: "..tracker) stdnse.debug1("Unknown tracker protocol for: "..tracker)
end end
--if not status then return false, err end --if not status then return false, err end
end end
@@ -699,10 +699,10 @@ Torrent =
-- The default timeout for this discovery is 30 seconds but it can be -- The default timeout for this discovery is 30 seconds but it can be
-- set through the timeout argument. -- set through the timeout argument.
dht_peers = function(self, timeout) dht_peers = function(self, timeout)
stdnse.print_debug("bittorrent: Starting DHT peers discovery") stdnse.debug1("bittorrent: Starting DHT peers discovery")
if next(self.peers) == nil then if next(self.peers) == nil then
stdnse.print_debug("bittorrent: No peers detected") stdnse.debug1("bittorrent: No peers detected")
return return
end end

View File

@@ -266,7 +266,7 @@ Options = {
end end
if ( not(supported) ) then if ( not(supported) ) then
stdnse.print_debug("ERROR: brute.options.setMode: mode %s not supported", mode) stdnse.debug1("ERROR: brute.options.setMode: mode %s not supported", mode)
return false, "Unsupported mode" return false, "Unsupported mode"
else else
self.mode = mode self.mode = mode
@@ -535,7 +535,7 @@ Engine =
end end
local msg = ( retries ~= self.options.max_retries ) and "Re-trying" or "Trying" local msg = ( retries ~= self.options.max_retries ) and "Re-trying" or "Trying"
stdnse.print_debug(2, "%s %s against %s:%d", msg, c, self.host.ip, self.port.number ) stdnse.debug2("%s %s against %s:%d", msg, c, self.host.ip, self.port.number )
status, response = driver:login( username, password ) status, response = driver:login( username, password )
driver:disconnect() driver:disconnect()
@@ -584,7 +584,7 @@ Engine =
table.insert(self.credstore, response:toString() ) table.insert(self.credstore, response:toString() )
end end
stdnse.print_debug("Discovered account: %s", response:toString()) stdnse.debug1("Discovered account: %s", response:toString())
-- if we're running in passonly mode, and want to continue guessing -- if we're running in passonly mode, and want to continue guessing
-- we will have a problem as the username is always the same. -- we will have a problem as the username is always the same.
@@ -618,7 +618,7 @@ Engine =
interval_start = os.time() interval_start = os.time()
local tps = self.counter / ( os.time() - self.starttime ) local tps = self.counter / ( os.time() - self.starttime )
table.insert(self.tps, tps ) table.insert(self.tps, tps )
stdnse.print_debug(2, "threads=%d,tps=%d", self:activeThreads(), tps ) stdnse.debug2("threads=%d,tps=%d", self:activeThreads(), tps )
end end
-- if delay was specified, do sleep -- if delay was specified, do sleep

View File

@@ -120,7 +120,7 @@ function describe_cluster_name (socket,cnt)
local status,resp = sendcmd(socket,cname,cnt) local status,resp = sendcmd(socket,cname,cnt)
if (not(status)) then if (not(status)) then
stdnse.print_debug(1, "sendcmd"..resp) stdnse.debug1("sendcmd"..resp)
return false, "error in communication" return false, "error in communication"
end end
@@ -144,7 +144,7 @@ function describe_version (socket,cnt)
local status,resp = sendcmd(socket,cname,cnt) local status,resp = sendcmd(socket,cname,cnt)
if (not(status)) then if (not(status)) then
stdnse.print_debug(1, "sendcmd"..resp) stdnse.debug1("sendcmd"..resp)
return false, "error in communication" return false, "error in communication"
end end
@@ -171,20 +171,20 @@ function login (socket,username,password)
local status, err = socket:send(bin.pack(">I",string.len(loginstr))) local status, err = socket:send(bin.pack(">I",string.len(loginstr)))
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(3, "cannot send len "..combo) stdnse.debug3("cannot send len "..combo)
return false, "Failed to connect to server" return false, "Failed to connect to server"
end end
status, err = socket:send(loginstr) status, err = socket:send(loginstr)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(3, "Sent packet for "..combo) stdnse.debug3("Sent packet for "..combo)
return false, err return false, err
end end
local response local response
status, response = socket:receive_bytes(22) status, response = socket:receive_bytes(22)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(3, "Receive packet for "..combo) stdnse.debug3("Receive packet for "..combo)
return false, err return false, err
end end
local _, size = bin.unpack(">I", response, 1) local _, size = bin.unpack(">I", response, 1)
@@ -195,10 +195,10 @@ function login (socket,username,password)
end end
local magic = string.sub(response,18,22) local magic = string.sub(response,18,22)
stdnse.print_debug(3, "packet for "..combo) stdnse.debug3("packet for "..combo)
stdnse.print_debug(3, "packet hex: %s", stdnse.tohex(response) ) stdnse.debug3("packet hex: %s", stdnse.tohex(response) )
stdnse.print_debug(3, "size packet hex: %s", stdnse.tohex(size) ) stdnse.debug3("size packet hex: %s", stdnse.tohex(size) )
stdnse.print_debug(3, "magic packet hex: %s", stdnse.tohex(magic) ) stdnse.debug3("magic packet hex: %s", stdnse.tohex(magic) )
if (magic == LOGINSUCC) then if (magic == LOGINSUCC) then
return true return true

View File

@@ -11874,7 +11874,7 @@ local f = nmap.fetchfile(nikto_db_path) or io.open(nikto_db_path, "r")
if f then if f then
stdnse.print_debug(1, "Found nikto db.") stdnse.debug1("Found nikto db.")
local nikto_db = {} local nikto_db = {}
for l in io.lines(nikto_db_path) do for l in io.lines(nikto_db_path) do

View File

@@ -97,7 +97,7 @@ Decoders = {
end end
local mac = sender.mac:gsub("(..)(..)(..)(..)(..)(..)","%1:%2:%3:%4:%5:%6") local mac = sender.mac:gsub("(..)(..)(..)(..)(..)(..)","%1:%2:%3:%4:%5:%6")
stdnse.print_debug(1, "Decoded ARP: %s, %s, %s", ipOps.fromdword(sender.ip), mac, ipOps.fromdword(target.ip)) stdnse.debug1("Decoded ARP: %s, %s, %s", ipOps.fromdword(sender.ip), mac, ipOps.fromdword(target.ip))
if ( not(self.dups[("%u:%s"):format(sender.ip,sender.mac)]) ) then if ( not(self.dups[("%u:%s"):format(sender.ip,sender.mac)]) ) then
if ( target.ALLOW_NEW_TARGETS ) then target.add(sender.ip) end if ( target.ALLOW_NEW_TARGETS ) then target.add(sender.ip) end
self.dups[("%u:%s"):format(sender.ip,sender.mac)] = true self.dups[("%u:%s"):format(sender.ip,sender.mac)] = true
@@ -328,7 +328,7 @@ Decoders = {
-- is applied to the whole packet+password -- is applied to the whole packet+password
else else
-- Error -- Error
stdnse.print_debug("Unknown OSPF auth type %d", header.auth_type) stdnse.debug1("Unknown OSPF auth type %d", header.auth_type)
return return
end end
@@ -396,7 +396,7 @@ udp = {
local gw = self.getOption(result.options, "Router") or "-" local gw = self.getOption(result.options, "Router") or "-"
local dns = self.getOption(result.options, "Domain Name Server") or "-" local dns = self.getOption(result.options, "Domain Name Server") or "-"
local vendor = self.getOption(result.options, "Class Identifier") or "-" local vendor = self.getOption(result.options, "Class Identifier") or "-"
stdnse.print_debug(1, "Decoded DHCP: %s, %s, %s, %s, %s, %s", p.ip_src, result.yiaddr_str, mask, gw, dns, vendor) stdnse.debug1("Decoded DHCP: %s, %s, %s, %s, %s, %s", p.ip_src, result.yiaddr_str, mask, gw, dns, vendor)
tab.addrow(self.results, p.ip_src, result.yiaddr_str, mask, gw, dns, vendor ) tab.addrow(self.results, p.ip_src, result.yiaddr_str, mask, gw, dns, vendor )
end end
end end
@@ -440,7 +440,7 @@ udp = {
if ( #res == 0 ) then if ( #res == 0 ) then
tab.addrow(res, 'ip', 'query') tab.addrow(res, 'ip', 'query')
end end
stdnse.print_debug(1, 'Decoded Netbios(%s): %s, %s', (isreg and "Registration" or "Query"), ip, name) stdnse.debug1('Decoded Netbios(%s): %s, %s', (isreg and "Registration" or "Query"), ip, name)
if ( not(dup[ip]) or not(dup[ip][name]) ) then if ( not(dup[ip]) or not(dup[ip][name]) ) then
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
@@ -488,7 +488,7 @@ udp = {
ip = ipOps.fromdword(ip) ip = ipOps.fromdword(ip)
src = netbios.name_decode(src) src = netbios.name_decode(src)
dst = netbios.name_decode(dst) dst = netbios.name_decode(dst)
stdnse.print_debug(1, "Decoded BROWSER: %s, %s, %s", ip, src, dst) stdnse.debug1("Decoded BROWSER: %s, %s, %s", ip, src, dst)
local dup_rec = ("%s:%s:%s"):format(ip, src, dst) local dup_rec = ("%s:%s:%s"):format(ip, src, dst)
if ( not(self.dups[dup_rec]) ) then if ( not(self.dups[dup_rec]) ) then
@@ -581,7 +581,7 @@ udp = {
tab.addrow(self.results, 'ip', 'uri', 'loc', 'model') tab.addrow(self.results, 'ip', 'uri', 'loc', 'model')
end end
stdnse.print_debug(1, "Decoded CUPS: %s, %s, %s, %s", p.ip_src, uri, loc, model) stdnse.debug1("Decoded CUPS: %s, %s, %s, %s", p.ip_src, uri, loc, model)
if ( not(self.dups[p.ip_src]) or not(self.dups[p.ip_src][uri]) ) then if ( not(self.dups[p.ip_src]) or not(self.dups[p.ip_src][uri]) ) then
tab.addrow(self.results, p.ip_src, uri, loc, model) tab.addrow(self.results, p.ip_src, uri, loc, model)
self.dups[p.ip_src] = self.dups[p.ip_src] or {} self.dups[p.ip_src] = self.dups[p.ip_src] or {}
@@ -826,7 +826,7 @@ udp = {
self.macbooks[macbook]['model'] = self.macbooks[macbook]['model'] or model self.macbooks[macbook]['model'] = self.macbooks[macbook]['model'] or model
self.macbooks[macbook]['ip'] = self.macbooks[macbook]['ip'] or ip self.macbooks[macbook]['ip'] = self.macbooks[macbook]['ip'] or ip
self.macbooks[macbook]['ipv6'] = self.macbooks[macbook]['ipv6'] or ipv6 self.macbooks[macbook]['ipv6'] = self.macbooks[macbook]['ipv6'] or ipv6
stdnse.print_debug(1, "Decoded MDNS(MacBook): %s, %s, %s, %s", stdnse.debug1("Decoded MDNS(MacBook): %s, %s, %s, %s",
(self.macbooks[macbook]['ip'] or ""), (self.macbooks[macbook]['ipv6'] or ""), (self.macbooks[macbook]['ip'] or ""), (self.macbooks[macbook]['ipv6'] or ""),
self.macbooks[macbook]['model'], self.macbooks[macbook]['macbook']) self.macbooks[macbook]['model'], self.macbooks[macbook]['macbook'])
else else
@@ -839,7 +839,7 @@ udp = {
else else
self.generic[name]['ip'] = p.ip_src self.generic[name]['ip'] = p.ip_src
end end
stdnse.print_debug(1, "Decoded MDNS(Generic): %s, %s", name, p.ip_src) stdnse.debug1("Decoded MDNS(Generic): %s, %s", name, p.ip_src)
end end
end end
end, end,
@@ -899,7 +899,7 @@ udp = {
local name = (( resp.questions and #resp.questions > 0 ) and resp.questions[1].dname ) local name = (( resp.questions and #resp.questions > 0 ) and resp.questions[1].dname )
if ( not(name) ) then return end if ( not(name) ) then return end
stdnse.print_debug(1, "Decoded LLMNR: %s, %s", p.ip_src, name) stdnse.debug1("Decoded LLMNR: %s, %s", p.ip_src, name)
if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then
self.dups[("%s:%s"):format(p.ip_src, name)] = true self.dups[("%s:%s"):format(p.ip_src, name)] = true

View File

@@ -225,7 +225,7 @@ function parse_lines(lines, data_struct)
_, ret[index] = parse_lines( lines, value ) _, ret[index] = parse_lines( lines, value )
else else
-- TEMP -- TEMP
stdnse.print_debug( "Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) stdnse.debug1("Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value))
end end
elseif type(index) == "string" or type(index) == "function" then elseif type(index) == "string" or type(index) == "function" then
if type( value ) == "string" or type( value ) == "function" then if type( value ) == "string" or type( value ) == "function" then
@@ -235,7 +235,7 @@ function parse_lines(lines, data_struct)
end end
else else
-- TEMP -- TEMP
stdnse.print_debug( "Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) stdnse.debug1("Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value))
end end
end end

View File

@@ -56,7 +56,7 @@ request_types_str[8] = "DHCPINFORM"
local function read_ip(data, pos, length) local function read_ip(data, pos, length)
if(length ~= 4) then if(length ~= 4) then
if((length % 4) ~= 0) 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 pos = pos + length
return pos, nil return pos, nil
@@ -98,7 +98,7 @@ end
--@return The value of the field, or nil if the field length was wrong. --@return The value of the field, or nil if the field length was wrong.
local function read_1_byte(data, pos, length) local function read_1_byte(data, pos, length)
if(length ~= 1) then 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 pos = pos + length
return pos, nil return pos, nil
end end
@@ -118,7 +118,7 @@ local function read_message_type(data, pos, length)
pos, value = read_1_byte(data, pos, length) pos, value = read_1_byte(data, pos, length)
if(value == nil) then 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 return pos, nil
end end
@@ -138,7 +138,7 @@ local function read_boolean(data, pos, length)
pos, result = read_1_byte(data, pos, length) pos, result = read_1_byte(data, pos, length)
if(result == nil) then 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 return pos, nil
elseif(result == 0) then elseif(result == 0) then
return pos, "false" return pos, "false"
@@ -156,7 +156,7 @@ end
--@return The value of the field, or nil if the field length was wrong. --@return The value of the field, or nil if the field length was wrong.
local function read_2_bytes(data, pos, length) local function read_2_bytes(data, pos, length)
if(length ~= 2) then 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 pos = pos + length
return pos, nil return pos, nil
end end
@@ -174,7 +174,7 @@ end
--@return The value of the field, or nil if the field length was wrong. --@return The value of the field, or nil if the field length was wrong.
local function read_2_bytes_list(data, pos, length) local function read_2_bytes_list(data, pos, length)
if((length % 2) ~= 0) then 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 pos = pos + length
return pos, nil return pos, nil
@@ -200,7 +200,7 @@ end
--@return The value of the field, or nil if the field length was wrong. --@return The value of the field, or nil if the field length was wrong.
local function read_4_bytes(data, pos, length) local function read_4_bytes(data, pos, length)
if(length ~= 4) then 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 pos = pos + length
return pos, nil return pos, nil
end end
@@ -218,7 +218,7 @@ end
local function read_time(data, pos, length) local function read_time(data, pos, length)
local result local result
if(length ~= 4) then 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 pos = pos + length
return pos, nil return pos, nil
end end
@@ -254,7 +254,7 @@ end
--@return The value of the field, or nil if the field length was wrong. --@return The value of the field, or nil if the field length was wrong.
local function read_static_route(data, pos, length) local function read_static_route(data, pos, length)
if((length % 8) ~= 0) then 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 pos = pos + length
return pos, nil return pos, nil
@@ -281,7 +281,7 @@ end
--@return The value of the field, or nil if the field length was wrong. --@return The value of the field, or nil if the field length was wrong.
local function read_policy_filter(data, pos, length) local function read_policy_filter(data, pos, length)
if((length % 8) ~= 0) then 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 pos = pos + length
return pos, nil 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) -- Verify we got a valid code (if we didn't, we're probably in big trouble)
local value local value
if(action == nil) then 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 pos = pos + length
else else
-- Call the function to parse the option, and insert the result into our results table -- 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) pos, value = action['func'](data, pos, length)
if(nmap.verbosity() == 0 and action.default == false) then 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 else
if(value) then if(value) then
table.insert(result['options'], {name=action['name'], value=value}) table.insert(result['options'], {name=action['name'], value=value})
else 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 end
end end
@@ -566,7 +566,7 @@ function dhcp_parse(data, transaction_id)
elseif(value == 3) then elseif(value == 3) then
data = data .. result['file'] .. result['sname'] data = data .. result['file'] .. result['sname']
else 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 end
end end
@@ -624,7 +624,7 @@ function make_request(target, request_type, ip_address, mac_address, options, re
-- Generate the packet -- 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) 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 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 return false, "Couldn't build packet: " .. packet
end end
@@ -635,7 +635,7 @@ function make_request(target, request_type, ip_address, mac_address, options, re
-- Send the packet and get the response -- Send the packet and get the response
local status, response = dhcp_send(socket, target, packet) local status, response = dhcp_send(socket, target, packet)
if(not(status)) then 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 return false, "Couldn't send packet: " .. response
end end
@@ -643,14 +643,14 @@ function make_request(target, request_type, ip_address, mac_address, options, re
socket:close() socket:close()
if ( not(status) ) then 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 return false, "Couldn't receive packet: " .. response
end end
-- Parse the response -- Parse the response
local status, parsed = dhcp_parse(response, transaction_id) local status, parsed = dhcp_parse(response, transaction_id)
if(not(status)) then 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 return false, "Couldn't parse response: " .. parsed
end end

View File

@@ -126,7 +126,7 @@ DHCP6.Option = {
local pos local pos
pos, opt.duid = bin.unpack(">S", data, pos) pos, opt.duid = bin.unpack(">S", data, pos)
if ( 1 ~= opt.duid ) then if ( 1 ~= opt.duid ) then
stdnse.print_debug("Unexpected DUID type (%d)", opt.duid) stdnse.debug1("Unexpected DUID type (%d)", opt.duid)
return return
end end
pos, opt.hwtype, opt.time, opt.mac = bin.unpack(">SIA" .. (#data - pos - 4 - 2 + 1), data, pos) pos, opt.hwtype, opt.time, opt.mac = bin.unpack(">SIA" .. (#data - pos - 4 - 2 + 1), data, pos)
@@ -501,7 +501,7 @@ DHCP6.Response = {
table.insert(resp.opts, { type = opt.type, resp = opt_parsed, raw = opt.data }) table.insert(resp.opts, { type = opt.type, resp = opt_parsed, raw = opt.data })
end end
else else
stdnse.print_debug(2, "No option decoder for type: %d; len: %d", opt.type, #(opt.data or "")) stdnse.debug2("No option decoder for type: %d; len: %d", opt.type, #(opt.data or ""))
table.insert(resp.opts, { type = opt.type, raw = opt.data }) table.insert(resp.opts, { type = opt.type, raw = opt.data })
end end
end end
@@ -647,7 +647,7 @@ Helper = {
table.insert(result_options, ("%s: %s"):format(topic, str)) table.insert(result_options, ("%s: %s"):format(topic, str))
end end
else else
stdnse.print_debug(2, "No decoder for option type: %d", opt.type) stdnse.debug2("No decoder for option type: %d", opt.type)
end end
end end
table.insert(result, result_options) table.insert(result, result_options)

View File

@@ -284,7 +284,7 @@ local function processResponse( response, dname, dtype, options )
end end
-- nothing worked -- nothing worked
stdnse.print_debug(1, "dns.query() failed to resolve the requested query%s%s", dname and ": " or ".", dname or "") stdnse.debug1("dns.query() failed to resolve the requested query%s%s", dname and ": " or ".", dname or "")
return false, "No Answers" return false, "No Answers"
end end
@@ -397,7 +397,7 @@ function query(dname, options)
return processResponse( response[1].data, dname, dtype, options) return processResponse( response[1].data, dname, dtype, options)
end end
else else
stdnse.print_debug(1, "dns.query() got zero responses attempting to resolve query%s%s", dname and ": " or ".", dname or "") stdnse.debug1("dns.query() got zero responses attempting to resolve query%s%s", dname and ": " or ".", dname or "")
return false, "No Answers" return false, "No Answers"
end end
end end
@@ -453,7 +453,7 @@ answerFetcher[types.TXT] = function(dec, retAll)
if not retAll and dec.answers[1].data then if not retAll and dec.answers[1].data then
return true, string.sub(dec.answers[1].data, 2) return true, string.sub(dec.answers[1].data, 2)
elseif not retAll then elseif not retAll then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") stdnse.debug1("dns.answerFetcher found no records of the required type: TXT")
return false, "No Answers" return false, "No Answers"
else else
for _, v in ipairs(dec.answers) do for _, v in ipairs(dec.answers) do
@@ -465,7 +465,7 @@ answerFetcher[types.TXT] = function(dec, retAll)
end end
end end
if #answers == 0 then if #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") stdnse.debug1("dns.answerFetcher found no records of the required type: TXT")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -487,7 +487,7 @@ answerFetcher[types.A] = function(dec, retAll)
end end
end end
if not retAll or #answers == 0 then if not retAll or #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: A") stdnse.debug1("dns.answerFetcher found no records of the required type: A")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -504,7 +504,7 @@ answerFetcher[types.CNAME] = function(dec, retAll)
if not retAll and dec.answers[1].domain then if not retAll and dec.answers[1].domain then
return true, dec.answers[1].domain return true, dec.answers[1].domain
elseif not retAll then elseif not retAll then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: NS, PTR or CNAME") stdnse.debug1("dns.answerFetcher found no records of the required type: NS, PTR or CNAME")
return false, "No Answers" return false, "No Answers"
else else
for _, v in ipairs(dec.answers) do for _, v in ipairs(dec.answers) do
@@ -512,7 +512,7 @@ answerFetcher[types.CNAME] = function(dec, retAll)
end end
end end
if #answers == 0 then if #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: NS, PTR or CNAME") stdnse.debug1("dns.answerFetcher found no records of the required type: NS, PTR or CNAME")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -532,7 +532,7 @@ answerFetcher[types.MX] = function(dec, retAll)
if not retAll then break end if not retAll then break end
end end
if #mx == 0 then if #mx == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: MX") stdnse.debug1("dns.answerFetcher found no records of the required type: MX")
return false, "No Answers" return false, "No Answers"
end end
for _, add in ipairs(dec.add) do for _, add in ipairs(dec.add) do
@@ -570,7 +570,7 @@ answerFetcher[types.SRV] = function(dec, retAll)
end end
end end
if #answers == 0 then if #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: SRV") stdnse.debug1("dns.answerFetcher found no records of the required type: SRV")
return false, "No Answers" return false, "No Answers"
end end
@@ -590,7 +590,7 @@ answerFetcher[types.NSEC] = function(dec, retAll)
if not retAll then break end if not retAll then break end
end end
if #nsec == 0 then if #nsec == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: NSEC") stdnse.debug1("dns.answerFetcher found no records of the required type: NSEC")
return false, "No Answers" return false, "No Answers"
end end
for _, nsecrec in ipairs(nsec) do for _, nsecrec in ipairs(nsec) do
@@ -633,7 +633,7 @@ answerFetcher[types.AAAA] = function(dec, retAll)
end end
end end
if not retAll or #answers == 0 then if not retAll or #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: AAAA") stdnse.debug1("dns.answerFetcher found no records of the required type: AAAA")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -653,13 +653,13 @@ function findNiceAnswer(dtype, dec, retAll)
if answerFetcher[dtype] then if answerFetcher[dtype] then
return answerFetcher[dtype](dec, retAll) return answerFetcher[dtype](dec, retAll)
else else
stdnse.print_debug(1, "dns.findNiceAnswer() does not have an answerFetcher for dtype %s", tostring(dtype)) stdnse.debug1("dns.findNiceAnswer() does not have an answerFetcher for dtype %s", tostring(dtype))
return false, "Unable to handle response" return false, "Unable to handle response"
end end
elseif (dec.flags.RC3 and dec.flags.RC4) then elseif (dec.flags.RC3 and dec.flags.RC4) then
return false, "No Such Name" return false, "No Such Name"
else else
stdnse.print_debug(1, "dns.findNiceAnswer() found zero answers in a response, but got an unexpected flags.replycode") stdnse.debug1("dns.findNiceAnswer() found zero answers in a response, but got an unexpected flags.replycode")
return false, "No Answers" return false, "No Answers"
end end
end end
@@ -682,7 +682,7 @@ additionalFetcher[types.TXT] = function(dec, retAll)
if not retAll and dec.add[1].data then if not retAll and dec.add[1].data then
return true, string.sub(dec.add[1].data, 2) return true, string.sub(dec.add[1].data, 2)
elseif not retAll then elseif not retAll then
stdnse.print_debug(1, "dns.additionalFetcher found no records of the required type: TXT") stdnse.debug1("dns.additionalFetcher found no records of the required type: TXT")
return false, "No Answers" return false, "No Answers"
else else
for _, v in ipairs(dec.add) do for _, v in ipairs(dec.add) do
@@ -694,7 +694,7 @@ additionalFetcher[types.TXT] = function(dec, retAll)
end end
end end
if #answers == 0 then if #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") stdnse.debug1("dns.answerFetcher found no records of the required type: TXT")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -716,7 +716,7 @@ additionalFetcher[types.A] = function(dec, retAll)
end end
end end
if not retAll or #answers == 0 then if not retAll or #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: A") stdnse.debug1("dns.answerFetcher found no records of the required type: A")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -741,7 +741,7 @@ additionalFetcher[types.SRV] = function(dec, retAll)
end end
end end
if #answers == 0 then if #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: SRV") stdnse.debug1("dns.answerFetcher found no records of the required type: SRV")
return false, "No Answers" return false, "No Answers"
end end
@@ -765,7 +765,7 @@ additionalFetcher[types.AAAA] = function(dec, retAll)
end end
end end
if not retAll or #answers == 0 then if not retAll or #answers == 0 then
stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: AAAA") stdnse.debug1("dns.answerFetcher found no records of the required type: AAAA")
return false, "No Answers" return false, "No Answers"
end end
return true, answers return true, answers
@@ -784,14 +784,14 @@ function findNiceAdditional(dtype, dec, retAll)
if additionalFetcher[dtype] then if additionalFetcher[dtype] then
return additionalFetcher[dtype](dec, retAll) return additionalFetcher[dtype](dec, retAll)
else else
stdnse.print_debug(1, "dns.findNiceAdditional() does not have an additionalFetcher for dtype %s", stdnse.debug1("dns.findNiceAdditional() does not have an additionalFetcher for dtype %s",
(type(dtype) == 'string' and dtype) or type(dtype) or "nil") (type(dtype) == 'string' and dtype) or type(dtype) or "nil")
return false, "Unable to handle response" return false, "Unable to handle response"
end end
elseif (dec.flags.RC3 and dec.flags.RC4) then elseif (dec.flags.RC3 and dec.flags.RC4) then
return false, "No Such Name" return false, "No Such Name"
else else
stdnse.print_debug(1, "dns.findNiceAdditional() found zero answers in a response, but got an unexpected flags.replycode") stdnse.debug1("dns.findNiceAdditional() found zero answers in a response, but got an unexpected flags.replycode")
return false, "No Answers" return false, "No Answers"
end end
end end

View File

@@ -377,7 +377,7 @@ SERVICES = {
if ( not(parts) or err ) then if ( not(parts) or err ) then
-- TODO Should we return failure in the result? -- TODO Should we return failure in the result?
stdnse.print_debug("The dnsbl.httpbl.org provider failed to return a valid address") stdnse.debug1("The dnsbl.httpbl.org provider failed to return a valid address")
return return
end end
@@ -592,7 +592,7 @@ Helper = {
local status, answer = dns.query(query, {dtype=ns_type, retAll=true} ) local status, answer = dns.query(query, {dtype=ns_type, retAll=true} )
answers[name] = { status = status, answer = answer, svc = svc } answers[name] = { status = status, answer = answer, svc = svc }
else else
stdnse.print_debug("Query function returned nothing, skipping '%s'", name) stdnse.debug1("Query function returned nothing, skipping '%s'", name)
end end
condvar "signal" condvar "signal"
@@ -626,7 +626,7 @@ Helper = {
local svc_result = svc:resp_parser(answer) local svc_result = svc:resp_parser(answer)
if ( not(svc_result) ) then if ( not(svc_result) ) then
local resp = ( #answer > 0 and ("UNKNOWN (%s)"):format(answer[1]) or "UNKNOWN" ) local resp = ( #answer > 0 and ("UNKNOWN (%s)"):format(answer[1]) or "UNKNOWN" )
stdnse.print_debug(2, "%s received %s", name, resp) stdnse.debug2("%s received %s", name, resp)
end end
if ( svc_result ) then if ( svc_result ) then

View File

@@ -190,7 +190,7 @@ Comm = {
local condvar = nmap.condvar(svcresponse) local condvar = nmap.condvar(svcresponse)
local status, response = dns.query( svc, { port = port, host = host, dtype="PTR", retPkt=true, retAll=true, multiple=multiple, sendCount=1, timeout=2000} ) local status, response = dns.query( svc, { port = port, host = host, dtype="PTR", retPkt=true, retAll=true, multiple=multiple, sendCount=1, timeout=2000} )
if not status then if not status then
stdnse.print_debug("Failed to query service: %s; Error: %s", svc, response) stdnse.debug1("Failed to query service: %s; Error: %s", svc, response)
return return
end end
svcresponse[svc] = svcresponse[svc] or {} svcresponse[svc] = svcresponse[svc] or {}

View File

@@ -191,11 +191,11 @@ DRDA = {
-- @return err string containing the error message if status is false -- @return err string containing the error message if status is false
addParameter = function( self, param ) addParameter = function( self, param )
if ( not(self.DDM) ) then if ( not(self.DDM) ) then
stdnse.print_debug("drda.DRDA.addParameter: DDM must be set prior to adding parameters") stdnse.debug1("drda.DRDA.addParameter: DDM must be set prior to adding parameters")
return false, "DDM must be set prior to adding parameters" return false, "DDM must be set prior to adding parameters"
end end
if ( not(param) ) then if ( not(param) ) then
stdnse.print_debug("drda.DRDA.addParameter: Param cannot be nil") stdnse.debug1("drda.DRDA.addParameter: Param cannot be nil")
return false, "Param cannot be nil" return false, "Param cannot be nil"
end end
@@ -226,7 +226,7 @@ DRDA = {
-- @return data containing the object instance -- @return data containing the object instance
__tostring = function(self) __tostring = function(self)
if ( not(self.DDM) ) then if ( not(self.DDM) ) then
stdnse.print_debug("drda.DRDA.toString: DDM cannot be nil") stdnse.debug1("drda.DRDA.toString: DDM cannot be nil")
return nil return nil
end end
@@ -258,7 +258,7 @@ DRDA = {
-- first read atleast enough so that we can populate the DDM -- first read atleast enough so that we can populate the DDM
local status, data = db2socket:receive_buf( match.numbytes(DDM_SIZE), true ) local status, data = db2socket:receive_buf( match.numbytes(DDM_SIZE), true )
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("drda.DRDA.receive: %s", data) stdnse.debug1("drda.DRDA.receive: %s", data)
return false, ("Failed to read at least %d bytes from socket"):format(DDM_SIZE) return false, ("Failed to read at least %d bytes from socket"):format(DDM_SIZE)
end end
@@ -607,7 +607,7 @@ Helper = {
if ( packet:getDRDAByCodePoint( CodePoint.RDBNFNRM ) or if ( packet:getDRDAByCodePoint( CodePoint.RDBNFNRM ) or
packet:getDRDAByCodePoint( CodePoint.RDBAFLRM ) ) then packet:getDRDAByCodePoint( CodePoint.RDBAFLRM ) ) then
stdnse.print_debug("drda.Helper.login: ERROR: RDB not found") stdnse.debug1("drda.Helper.login: ERROR: RDB not found")
return false, "ERROR: Database not found" return false, "ERROR: Database not found"
end end
@@ -618,12 +618,12 @@ Helper = {
local param = drda:getParameter( CodePoint.SECMEC ) local param = drda:getParameter( CodePoint.SECMEC )
if ( not(param) ) then if ( not(param) ) then
stdnse.print_debug("drda.Helper.login: ERROR: Response did not contain any valid security mechanisms") stdnse.debug1("drda.Helper.login: ERROR: Response did not contain any valid security mechanisms")
return false, "ERROR: Response did not contain any valid security mechanisms" return false, "ERROR: Response did not contain any valid security mechanisms"
end end
if ( select(2, bin.unpack(">S", param:getData())) ~= SecMec.USER_PASSWORD ) then if ( select(2, bin.unpack(">S", param:getData())) ~= SecMec.USER_PASSWORD ) then
stdnse.print_debug("drda.Helper.login: ERROR: Securite Mechanism not supported") stdnse.debug1("drda.Helper.login: ERROR: Securite Mechanism not supported")
return false, "ERROR: Security mechanism not supported" return false, "ERROR: Security mechanism not supported"
end end
@@ -706,13 +706,13 @@ Comm = {
local status, err = self.socket:send( tostring(packet) ) local status, err = self.socket:send( tostring(packet) )
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("drda.Helper.login: ERROR: DB2Socket error: %s", err ) stdnse.debug1("drda.Helper.login: ERROR: DB2Socket error: %s", err )
return false, ("ERROR: DB2Socket error: %s"):format( err ) return false, ("ERROR: DB2Socket error: %s"):format( err )
end end
status, drda = self:recvDRDA() status, drda = self:recvDRDA()
if( not(status) ) then if( not(status) ) then
stdnse.print_debug("drda.Helper.login: ERROR: DB2Socket error: %s", drda ) stdnse.debug1("drda.Helper.login: ERROR: DB2Socket error: %s", drda )
return false, ("ERROR: DB2Socket error: %s"):format( drda ) return false, ("ERROR: DB2Socket error: %s"):format( drda )
end end
return true, DRDAPacket:new( drda ) return true, DRDAPacket:new( drda )

View File

@@ -181,7 +181,7 @@ local make_eap = function (arg)
arg.header.payload = bin.pack("C",arg.code) .. bin.pack("C",arg.id) .. bin.pack(">S",bin_payload:len() + EAP_HEADER_SIZE).. bin.pack("C",arg.type) .. bin_payload arg.header.payload = bin.pack("C",arg.code) .. bin.pack("C",arg.id) .. bin.pack(">S",bin_payload:len() + EAP_HEADER_SIZE).. bin.pack("C",arg.type) .. bin_payload
local v = make_eapol(arg.header) local v = make_eapol(arg.header)
stdnse.print_debug(2, "make eapol %s", arg.header.src) stdnse.debug2("make eapol %s", arg.header.src)
return v return v
end end
@@ -190,7 +190,7 @@ parse = function (packet)
local tb = {} local tb = {}
local _ local _
stdnse.print_debug(2, "packet size: 0x%x", #packet ) stdnse.debug2("packet size: 0x%x", #packet )
-- parsing ethernet header -- parsing ethernet header
_, tb.mac_src, tb.mac_dst, tb.ether_type = bin.unpack(">A6A6S", packet) _, tb.mac_src, tb.mac_dst, tb.ether_type = bin.unpack(">A6A6S", packet)
@@ -199,12 +199,12 @@ parse = function (packet)
-- parsing eapol header -- parsing eapol header
_, tb.version, tb.type, tb.length = bin.unpack(">CCS", packet, ETHER_HEADER_SIZE + 1) _, tb.version, tb.type, tb.length = bin.unpack(">CCS", packet, ETHER_HEADER_SIZE + 1)
stdnse.print_debug(1, "mac_src: %s, mac_dest: %s, ether_type: 0x%X", stdnse.debug1("mac_src: %s, mac_dest: %s, ether_type: 0x%X",
tb.mac_src_str, tb.mac_dst_str, tb.ether_type) tb.mac_src_str, tb.mac_dst_str, tb.ether_type)
if tb.ether_type ~= ETHER_TYPE_EAPOL_N then return nil, "not an eapol packet" end if tb.ether_type ~= ETHER_TYPE_EAPOL_N then return nil, "not an eapol packet" end
stdnse.print_debug(2, "version: %X, type: %s, length: 0x%X", stdnse.debug2("version: %X, type: %s, length: 0x%X",
tb.version, eapol_str[tb.type] or "unknown", tb.version, eapol_str[tb.type] or "unknown",
tb.length) tb.length)
@@ -215,11 +215,11 @@ parse = function (packet)
_, tb.eap.code, tb.eap.id, tb.eap.length, tb.eap.type = bin.unpack(">CCSC", packet, _, tb.eap.code, tb.eap.id, tb.eap.length, tb.eap.type = bin.unpack(">CCSC", packet,
ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + 1) ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + 1)
stdnse.print_debug(2, "code: %s, id: 0x%X, length: 0x%X, type: %s", stdnse.debug2("code: %s, id: 0x%X, length: 0x%X, type: %s",
code_str[tb.eap.code] or "unknown", code_str[tb.eap.code] or "unknown",
tb.eap.id, tb.eap.length, eap_str[tb.eap.type] or "unknown" ) tb.eap.id, tb.eap.length, eap_str[tb.eap.type] or "unknown" )
if tb.length ~= tb.eap.length then if tb.length ~= tb.eap.length then
stdnse.print_debug(1, "WARNING length mismatch: 0x%X and 0x%X", tb.length, tb.eap.length ) stdnse.debug1("WARNING length mismatch: 0x%X and 0x%X", tb.length, tb.eap.length )
end end
end end
@@ -229,7 +229,7 @@ parse = function (packet)
if tb.length > 5 and tb.eap.type == eap_t.IDENTITY then if tb.length > 5 and tb.eap.type == eap_t.IDENTITY then
_, tb.eap.body.identity = bin.unpack("z", packet, _, tb.eap.body.identity = bin.unpack("z", packet,
ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1) ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1)
stdnse.print_debug(1, "identity: %s", tb.eap.body.identity ) stdnse.debug1("identity: %s", tb.eap.body.identity )
end end
if tb.length > 5 and tb.eap.type == eap_t.MD5 then if tb.length > 5 and tb.eap.type == eap_t.MD5 then
@@ -242,7 +242,7 @@ end
send_identity_response = function (iface, id, identity) send_identity_response = function (iface, id, identity)
if not iface then if not iface then
stdnse.print_debug(1, "no interface given") stdnse.debug1("no interface given")
return return
end end
@@ -258,7 +258,7 @@ end
send_nak_response = function (iface, id, auth) send_nak_response = function (iface, id, auth)
if not iface then if not iface then
stdnse.print_debug(1, "no interface given") stdnse.debug1("no interface given")
return return
end end
@@ -275,7 +275,7 @@ end
send_start = function (iface) send_start = function (iface)
if not iface then if not iface then
stdnse.print_debug(1, "no interface given") stdnse.debug1("no interface given")
return return
end end

View File

@@ -93,11 +93,11 @@ EIGRP = {
-- @return response table Structured eigrp packet. -- @return response table Structured eigrp packet.
parse = function(eigrp_raw) parse = function(eigrp_raw)
if type(eigrp_raw) ~= 'string' then if type(eigrp_raw) ~= 'string' then
stdnse.print_debug("eigrp.lua: parse input should be string.") stdnse.debug1("eigrp.lua: parse input should be string.")
return return
end end
if #eigrp_raw < 20 then if #eigrp_raw < 20 then
stdnse.print_debug("eigrp.lua: raw packet size lower then 20.") stdnse.debug1("eigrp.lua: raw packet size lower then 20.")
return return
end end
local tlv local tlv
@@ -118,7 +118,7 @@ EIGRP = {
index, tlv.length = bin.unpack(">S", eigrp_raw, index) index, tlv.length = bin.unpack(">S", eigrp_raw, index)
if tlv.length == 0x00 then if tlv.length == 0x00 then
-- In case someone wants to DoS us :) -- In case someone wants to DoS us :)
stdnse.print_debug("eigrp.lua: stopped parsing due to null TLV length.") stdnse.debug1("eigrp.lua: stopped parsing due to null TLV length.")
break break
end end
if tlv.type == TLV.PARAM then if tlv.type == TLV.PARAM then
@@ -153,19 +153,19 @@ EIGRP = {
index = index + tlv.length - 8 index = index + tlv.length - 8
elseif tlv.type == TLV.STUB then elseif tlv.type == TLV.STUB then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.TERM then elseif tlv.type == TLV.TERM then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.TIDLIST then elseif tlv.type == TLV.TIDLIST then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.REQ then elseif tlv.type == TLV.REQ then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.INT then elseif tlv.type == TLV.INT then
-- Internal Route -- Internal Route
@@ -215,22 +215,22 @@ EIGRP = {
tlv.dst = dst[1] .. '.' .. dst[2] .. '.' .. dst[3] .. '.' .. dst[4] tlv.dst = dst[1] .. '.' .. dst[2] .. '.' .. dst[3] .. '.' .. dst[4]
elseif tlv.type == TLV.COM then elseif tlv.type == TLV.COM then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.INT6 then elseif tlv.type == TLV.INT6 then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.EXT6 then elseif tlv.type == TLV.EXT6 then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
elseif tlv.type == TLV.COM6 then elseif tlv.type == TLV.COM6 then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
else else
stdnse.print_debug("eigrp.lua: eigrp.lua: TLV type %d unknown.", tlv.type) stdnse.debug1("eigrp.lua: eigrp.lua: TLV type %d unknown.", tlv.type)
index = index + tlv.length - 4 index = index + tlv.length - 4
end end
table.insert(eigrp_packet.tlvs, tlv) table.insert(eigrp_packet.tlvs, tlv)
@@ -244,7 +244,7 @@ EIGRP = {
if type(tlv) == 'table' then if type(tlv) == 'table' then
table.insert(self.tlvs, tlv) table.insert(self.tlvs, tlv)
else else
stdnse.print_debug("eigrp.lua: TLV should be a table, not %s", type(tlv)) stdnse.debug1("eigrp.lua: TLV should be a table, not %s", type(tlv))
end end
end, end,
@@ -332,10 +332,10 @@ EIGRP = {
data = data .. bin.pack(">S", tlv.htime) data = data .. bin.pack(">S", tlv.htime)
elseif tlv.type == TLV.AUTH then elseif tlv.type == TLV.AUTH then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.SEQ then elseif tlv.type == TLV.SEQ then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.SWVER then elseif tlv.type == TLV.SWVER then
data = data .. bin.pack(">S", TLV.SWVER) data = data .. bin.pack(">S", TLV.SWVER)
data = data .. bin.pack(">S", 0x0008) data = data .. bin.pack(">S", 0x0008)
@@ -343,39 +343,39 @@ EIGRP = {
data = data .. bin.pack(">CC", tonumber(tlv.majtlv), tonumber(tlv.mintlv)) data = data .. bin.pack(">CC", tonumber(tlv.majtlv), tonumber(tlv.mintlv))
elseif tlv.type == TLV.MSEQ then elseif tlv.type == TLV.MSEQ then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.STUB then elseif tlv.type == TLV.STUB then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.TERM then elseif tlv.type == TLV.TERM then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.TIDLIST then elseif tlv.type == TLV.TIDLIST then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.REQ then elseif tlv.type == TLV.REQ then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.INT then elseif tlv.type == TLV.INT then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.EXT then elseif tlv.type == TLV.EXT then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.COM then elseif tlv.type == TLV.COM then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.INT6 then elseif tlv.type == TLV.INT6 then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.EXT6 then elseif tlv.type == TLV.EXT6 then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
elseif tlv.type == TLV.COM6 then elseif tlv.type == TLV.COM6 then
-- TODO -- TODO
stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type)
else else
stdnse.print_debug("eigrp.lua: TLV type %d unknown.", tlv.type) stdnse.debug1("eigrp.lua: TLV type %d unknown.", tlv.type)
end end
end end
-- In the end, correct the checksum if not manually set -- In the end, correct the checksum if not manually set

View File

@@ -98,7 +98,7 @@ NMEA = {
return true, e return true, e
else else
local err = ("No parser for prefix: %s"):format(prefix) local err = ("No parser for prefix: %s"):format(prefix)
stdnse.print_debug(2, err) stdnse.debug2("%s", err)
return false, err return false, err
end end

View File

@@ -266,17 +266,17 @@ local function validate_options(options)
for key, value in pairs(options) do for key, value in pairs(options) do
if(key == 'timeout') then if(key == 'timeout') then
if(type(tonumber(value)) ~= 'number') then if(type(tonumber(value)) ~= 'number') then
stdnse.print_debug(1, 'http: options.timeout contains a non-numeric value') stdnse.debug1('http: options.timeout contains a non-numeric value')
bad = true bad = true
end end
elseif(key == 'header') then elseif(key == 'header') then
if(type(value) ~= 'table') then if(type(value) ~= 'table') then
stdnse.print_debug(1, "http: options.header should be a table") stdnse.debug1("http: options.header should be a table")
bad = true bad = true
end end
elseif(key == 'content') then elseif(key == 'content') then
if(type(value) ~= 'string' and type(value) ~= 'table') then if(type(value) ~= 'string' and type(value) ~= 'table') then
stdnse.print_debug(1, "http: options.content should be a string or a table") stdnse.debug1("http: options.content should be a string or a table")
bad = true bad = true
end end
elseif(key == 'cookies') then elseif(key == 'cookies') then
@@ -285,42 +285,42 @@ local function validate_options(options)
for cookie_key, cookie_value in pairs(cookie) do for cookie_key, cookie_value in pairs(cookie) do
if(cookie_key == 'name') then if(cookie_key == 'name') then
if(type(cookie_value) ~= 'string') then if(type(cookie_value) ~= 'string') then
stdnse.print_debug(1, "http: options.cookies[i].name should be a string") stdnse.debug1("http: options.cookies[i].name should be a string")
bad = true bad = true
end end
elseif(cookie_key == 'value') then elseif(cookie_key == 'value') then
if(type(cookie_value) ~= 'string') then if(type(cookie_value) ~= 'string') then
stdnse.print_debug(1, "http: options.cookies[i].value should be a string") stdnse.debug1("http: options.cookies[i].value should be a string")
bad = true bad = true
end end
elseif(cookie_key == 'path') then elseif(cookie_key == 'path') then
if(type(cookie_value) ~= 'string') then if(type(cookie_value) ~= 'string') then
stdnse.print_debug(1, "http: options.cookies[i].path should be a string") stdnse.debug1("http: options.cookies[i].path should be a string")
bad = true bad = true
end end
elseif(cookie_key == 'expires') then elseif(cookie_key == 'expires') then
if(type(cookie_value) ~= 'string') then if(type(cookie_value) ~= 'string') then
stdnse.print_debug(1, "http: options.cookies[i].expires should be a string") stdnse.debug1("http: options.cookies[i].expires should be a string")
bad = true bad = true
end end
else else
stdnse.print_debug(1, "http: Unknown field in cookie table: %s", cookie_key) stdnse.debug1("http: Unknown field in cookie table: %s", cookie_key)
bad = true bad = true
end end
end end
end end
elseif(type(value) ~= 'string') then elseif(type(value) ~= 'string') then
stdnse.print_debug(1, "http: options.cookies should be a table or a string") stdnse.debug1("http: options.cookies should be a table or a string")
bad = true bad = true
end end
elseif(key == 'auth') then elseif(key == 'auth') then
if(type(value) == 'table') then if(type(value) == 'table') then
if(value['username'] == nil or value['password'] == nil) then if(value['username'] == nil or value['password'] == nil) then
stdnse.print_debug(1, "http: options.auth should contain both a 'username' and a 'password' key") stdnse.debug1("http: options.auth should contain both a 'username' and a 'password' key")
bad = true bad = true
end end
else else
stdnse.print_debug(1, "http: options.auth should be a table") stdnse.debug1("http: options.auth should be a table")
bad = true bad = true
end end
elseif (key == 'digestauth') then elseif (key == 'digestauth') then
@@ -328,27 +328,27 @@ local function validate_options(options)
local req_keys = {"username","realm","nonce","digest-uri","response"} local req_keys = {"username","realm","nonce","digest-uri","response"}
for _,k in ipairs(req_keys) do for _,k in ipairs(req_keys) do
if not value[k] then if not value[k] then
stdnse.print_debug(1, "http: options.digestauth missing key: %s",k) stdnse.debug1("http: options.digestauth missing key: %s",k)
bad = true bad = true
break break
end end
end end
else else
bad = true bad = true
stdnse.print_debug(1, "http: options.digestauth should be a table") stdnse.debug1("http: options.digestauth should be a table")
end end
elseif(key == 'bypass_cache' or key == 'no_cache' or key == 'no_cache_body') then elseif(key == 'bypass_cache' or key == 'no_cache' or key == 'no_cache_body') then
if(type(value) ~= 'boolean') then if(type(value) ~= 'boolean') then
stdnse.print_debug(1, "http: options.bypass_cache, options.no_cache, and options.no_cache_body must be boolean values") stdnse.debug1("http: options.bypass_cache, options.no_cache, and options.no_cache_body must be boolean values")
bad = true bad = true
end end
elseif(key == 'redirect_ok') then elseif(key == 'redirect_ok') then
if(type(value)~= 'function' and type(value)~='boolean') then if(type(value)~= 'function' and type(value)~='boolean') then
stdnse.print_debug(1, "http: options.redirect_ok must be a function or boolean") stdnse.debug1("http: options.redirect_ok must be a function or boolean")
bad = true bad = true
end end
else else
stdnse.print_debug(1, "http: Unknown key in the options table: %s", key) stdnse.debug1("http: Unknown key in the options table: %s", key)
end end
end end
@@ -525,7 +525,7 @@ local function recv_chunked(s, partial)
if not line then if not line then
-- this warning message was initially an error but was adapted -- this warning message was initially an error but was adapted
-- to support broken servers, such as the Citrix XML Service -- to support broken servers, such as the Citrix XML Service
stdnse.print_debug(2, "Didn't find CRLF after chunk-data.") stdnse.debug2("Didn't find CRLF after chunk-data.")
elseif not string.match(line, "^\r?\n") then elseif not string.match(line, "^\r?\n") then
return nil, string.format("Didn't find CRLF after chunk-data; got %q.", line) return nil, string.format("Didn't find CRLF after chunk-data; got %q.", line)
end end
@@ -925,7 +925,7 @@ local function check_size (cache)
local size = cache.size; local size = cache.size;
if size > max_size then if size > max_size then
stdnse.print_debug(1, stdnse.debug1(
"Current http cache size (%d bytes) exceeds max size of %d", "Current http cache size (%d bytes) exceeds max size of %d",
size, max_size); size, max_size);
table.sort(cache, function(r1, r2) table.sort(cache, function(r1, r2)
@@ -942,7 +942,7 @@ local function check_size (cache)
end end
cache.size = size; cache.size = size;
end end
stdnse.print_debug(2, "Final http cache size (%d bytes) of max size of %d", stdnse.debug2("Final http cache size (%d bytes) of max size of %d",
size, max_size); size, max_size);
return size; return size;
end end
@@ -1202,7 +1202,7 @@ local function request(host, port, data, options)
if type(port) == 'table' then if type(port) == 'table' then
if port.protocol and port.protocol ~= 'tcp' then if port.protocol and port.protocol ~= 'tcp' then
stdnse.print_debug(1, "http.request() supports the TCP protocol only, your request to %s cannot be completed.", host) stdnse.debug1("http.request() supports the TCP protocol only, your request to %s cannot be completed.", host)
return http_error("Unsupported protocol.") return http_error("Unsupported protocol.")
end end
end end
@@ -1256,7 +1256,7 @@ function generic_request(host, port, method, path, options)
local digest_auth = options and options.auth and options.auth.digest local digest_auth = options and options.auth and options.auth.digest
if digest_auth and not have_ssl then if digest_auth and not have_ssl then
stdnse.print_debug("http: digest auth requires openssl.") stdnse.debug1("http: digest auth requires openssl.")
end end
if digest_auth and have_ssl then if digest_auth and have_ssl then
@@ -1267,7 +1267,7 @@ function generic_request(host, port, method, path, options)
local r = generic_request(host, port, method, path, options_with_auth_removed) local r = generic_request(host, port, method, path, options_with_auth_removed)
local h = r.header['www-authenticate'] local h = r.header['www-authenticate']
if not r.status or (h and not string.find(h:lower(), "digest.-realm")) then if not r.status or (h and not string.find(h:lower(), "digest.-realm")) then
stdnse.print_debug("http: the target doesn't support digest auth or there was an error during request.") stdnse.debug1("http: the target doesn't support digest auth or there was an error during request.")
return http_error("The target doesn't support digest auth or there was an error during request.") return http_error("The target doesn't support digest auth or there was an error during request.")
end end
-- Compute the response hash -- Compute the response hash
@@ -1381,7 +1381,7 @@ function redirect_ok(host, port)
counter = counter - 1 counter = counter - 1
for i, rule in ipairs( rules ) do for i, rule in ipairs( rules ) do
if ( not(rule( url, host, port )) ) then if ( not(rule( url, host, port )) ) then
--stdnse.print_debug("Rule failed: %d", i) --stdnse.debug1("Rule failed: %d", i)
return false return false
end end
end end
@@ -1603,19 +1603,19 @@ end
-- Deprecated pipeline functions -- Deprecated pipeline functions
function pGet( host, port, path, options, ignored, allReqs ) function pGet( host, port, path, options, ignored, allReqs )
stdnse.print_debug(1, "WARNING: pGet() is deprecated. Use pipeline_add() instead.") stdnse.debug1("WARNING: pGet() is deprecated. Use pipeline_add() instead.")
return pipeline_add(path, options, allReqs, 'GET') return pipeline_add(path, options, allReqs, 'GET')
end end
function pHead( host, port, path, options, ignored, allReqs ) function pHead( host, port, path, options, ignored, allReqs )
stdnse.print_debug(1, "WARNING: pHead() is deprecated. Use pipeline_add instead.") stdnse.debug1("WARNING: pHead() is deprecated. Use pipeline_add instead.")
return pipeline_add(path, options, allReqs, 'HEAD') return pipeline_add(path, options, allReqs, 'HEAD')
end end
function addPipeline(host, port, path, options, ignored, allReqs, method) function addPipeline(host, port, path, options, ignored, allReqs, method)
stdnse.print_debug(1, "WARNING: addPipeline() is deprecated! Use pipeline_add instead.") stdnse.debug1("WARNING: addPipeline() is deprecated! Use pipeline_add instead.")
return pipeline_add(path, options, allReqs, method) return pipeline_add(path, options, allReqs, method)
end end
function pipeline(host, port, allReqs) function pipeline(host, port, allReqs)
stdnse.print_debug(1, "WARNING: pipeline() is deprecated. Use pipeline_go() instead.") stdnse.debug1("WARNING: pipeline() is deprecated. Use pipeline_go() instead.")
return pipeline_go(host, port, allReqs) return pipeline_go(host, port, allReqs)
end end
@@ -1678,7 +1678,7 @@ end
-- @return A list of responses, in the same order as the requests were queued. -- @return A list of responses, in the same order as the requests were queued.
-- Each response is a table as described in the module documentation. -- Each response is a table as described in the module documentation.
function pipeline_go(host, port, all_requests) function pipeline_go(host, port, all_requests)
stdnse.print_debug("Total number of pipelined requests: " .. #all_requests) stdnse.debug1("Total number of pipelined requests: " .. #all_requests)
local responses local responses
local response local response
local partial local partial
@@ -1687,7 +1687,7 @@ function pipeline_go(host, port, all_requests)
-- Check for an empty request -- Check for an empty request
if (#all_requests == 0) then if (#all_requests == 0) then
stdnse.print_debug(1, "Warning: empty set of requests passed to http.pipeline()") stdnse.debug1("Warning: empty set of requests passed to http.pipeline()")
return responses return responses
end end
@@ -1713,7 +1713,7 @@ function pipeline_go(host, port, all_requests)
limit = limit > #all_requests and #all_requests or limit limit = limit > #all_requests and #all_requests or limit
local max_pipeline = stdnse.get_script_args("http.max-pipeline") or limit -- how many requests should be pipelined local max_pipeline = stdnse.get_script_args("http.max-pipeline") or limit -- how many requests should be pipelined
local count = 1 local count = 1
stdnse.print_debug(1, "Number of requests allowed by pipeline: " .. limit) stdnse.debug1("Number of requests allowed by pipeline: " .. limit)
while #responses < #all_requests do while #responses < #all_requests do
local j, batch_end local j, batch_end
@@ -1752,7 +1752,7 @@ function pipeline_go(host, port, all_requests)
local req_sent = 0 local req_sent = 0
-- start sending the requests and pipeline them in batches of max_pipeline elements -- start sending the requests and pipeline them in batches of max_pipeline elements
while start <= len do while start <= len do
stdnse.print_debug(2, "HTTP pipeline: number of requests in current batch: %d, already sent: %d, responses from current batch: %d, all responses received: %d",len,start-1,count,#responses) stdnse.debug2("HTTP pipeline: number of requests in current batch: %d, already sent: %d, responses from current batch: %d, all responses received: %d",len,start-1,count,#responses)
local req = {} local req = {}
if max_pipeline == limit then if max_pipeline == limit then
req = requests req = requests
@@ -1772,8 +1772,8 @@ function pipeline_go(host, port, all_requests)
while inner_count < num_req and #responses < #all_requests do while inner_count < num_req and #responses < #all_requests do
response, partial = next_response(socket, all_requests[#responses + 1].method, partial) response, partial = next_response(socket, all_requests[#responses + 1].method, partial)
if not response then if not response then
stdnse.print_debug("HTTP pipeline: there was a problem while receiving responses.") stdnse.debug1("HTTP pipeline: there was a problem while receiving responses.")
stdnse.print_debug(3, "The request was:\n%s",req) stdnse.debug3("The request was:\n%s",req)
fail = true fail = true
break break
end end
@@ -1787,15 +1787,15 @@ function pipeline_go(host, port, all_requests)
socket:close() socket:close()
if count == 0 then if count == 0 then
stdnse.print_debug("Received 0 of %d expected responses.\nGiving up on pipeline.", limit); stdnse.debug1("Received 0 of %d expected responses.\nGiving up on pipeline.", limit);
break break
elseif count < req_sent then elseif count < req_sent then
stdnse.print_debug("Received only %d of %d expected responses.\nDecreasing max pipelined requests to %d.", count, req_sent, count) stdnse.debug1("Received only %d of %d expected responses.\nDecreasing max pipelined requests to %d.", count, req_sent, count)
limit = count limit = count
end end
end end
stdnse.print_debug("Number of received responses: " .. #responses) stdnse.debug1("Number of received responses: " .. #responses)
return responses return responses
end end
@@ -1993,17 +1993,17 @@ function parse_date(s)
tz = "GMT" tz = "GMT"
end end
if not day then if not day then
stdnse.print_debug(1, "http.parse_date: can't parse date \"%s\": unknown format.", s) stdnse.debug1("http.parse_date: can't parse date \"%s\": unknown format.", s)
return nil return nil
end end
-- Look up the numeric code for month. -- Look up the numeric code for month.
month = MONTH_MAP[month_name] month = MONTH_MAP[month_name]
if not month then if not month then
stdnse.print_debug(1, "http.parse_date: unknown month name \"%s\".", month_name) stdnse.debug1("http.parse_date: unknown month name \"%s\".", month_name)
return nil return nil
end end
if tz ~= "GMT" then if tz ~= "GMT" then
stdnse.print_debug(1, "http.parse_date: don't know time zone \"%s\", only \"GMT\".", tz) stdnse.debug1("http.parse_date: don't know time zone \"%s\", only \"GMT\".", tz)
return nil return nil
end end
day = tonumber(day) day = tonumber(day)
@@ -2169,26 +2169,26 @@ function can_use_head(host, port, result_404, path)
local data = head( host, port, path ) local data = head( host, port, path )
if data then if data then
if data.status and data.status == 302 and data.header and data.header.location then if data.status and data.status == 302 and data.header and data.header.location then
stdnse.print_debug(1, "HTTP: Warning: Host returned 302 and not 200 when performing HEAD.") stdnse.debug1("HTTP: Warning: Host returned 302 and not 200 when performing HEAD.")
return false return false
end end
if data.status and data.status == 200 and data.header then if data.status and data.status == 200 and data.header then
-- check that a body wasn't returned -- check that a body wasn't returned
if #data.body > 0 then if #data.body > 0 then
stdnse.print_debug(1, "HTTP: Warning: Host returned data when performing HEAD.") stdnse.debug1("HTTP: Warning: Host returned data when performing HEAD.")
return false return false
end end
stdnse.print_debug(1, "HTTP: Host supports HEAD.") stdnse.debug1("HTTP: Host supports HEAD.")
return true, data return true, data
end end
stdnse.print_debug(1, "HTTP: Didn't receive expected response to HEAD request (got %s).", get_status_string(data)) stdnse.debug1("HTTP: Didn't receive expected response to HEAD request (got %s).", get_status_string(data))
return false return false
end end
stdnse.print_debug(1, "HTTP: HEAD request completely failed.") stdnse.debug1("HTTP: HEAD request completely failed.")
return false return false
end end
@@ -2294,17 +2294,17 @@ function identify_404(host, port)
data = get(host, port, URL_404_1) data = get(host, port, URL_404_1)
if(data == nil) then if(data == nil) then
stdnse.print_debug(1, "HTTP: Failed while testing for 404 status code") stdnse.debug1("HTTP: Failed while testing for 404 status code")
return false, "Failed while testing for 404 error message" return false, "Failed while testing for 404 error message"
end end
if(data.status and data.status == 404) then if(data.status and data.status == 404) then
stdnse.print_debug(1, "HTTP: Host returns proper 404 result.") stdnse.debug1("HTTP: Host returns proper 404 result.")
return true, 404 return true, 404
end end
if(data.status and data.status == 200) then if(data.status and data.status == 200) then
stdnse.print_debug(1, "HTTP: Host returns 200 instead of 404.") stdnse.debug1("HTTP: Host returns 200 instead of 404.")
-- Clean up the body (for example, remove the URI). This makes it easier to validate later -- Clean up the body (for example, remove the URI). This makes it easier to validate later
if(data.body) then if(data.body) then
@@ -2312,7 +2312,7 @@ function identify_404(host, port)
local data2 = get(host, port, URL_404_2) local data2 = get(host, port, URL_404_2)
local data3 = get(host, port, URL_404_3) local data3 = get(host, port, URL_404_3)
if(data2 == nil or data3 == nil) then if(data2 == nil or data3 == nil) then
stdnse.print_debug(1, "HTTP: Failed while testing for extra 404 error messages") stdnse.debug1("HTTP: Failed while testing for extra 404 error messages")
return false, "Failed while testing for extra 404 error messages" return false, "Failed while testing for extra 404 error messages"
end end
@@ -2323,7 +2323,7 @@ function identify_404(host, port)
if(type(data2.status) ~= "number") then if(type(data2.status) ~= "number") then
data2.status = -1 data2.status = -1
end end
stdnse.print_debug(1, "HTTP: HTTP 404 status changed for second request (became %d).", data2.status) stdnse.debug1("HTTP: HTTP 404 status changed for second request (became %d).", data2.status)
return false, string.format("HTTP 404 status changed for second request (became %d).", data2.status) return false, string.format("HTTP 404 status changed for second request (became %d).", data2.status)
end end
@@ -2332,7 +2332,7 @@ function identify_404(host, port)
if(type(data3.status) ~= "number") then if(type(data3.status) ~= "number") then
data3.status = -1 data3.status = -1
end end
stdnse.print_debug(1, "HTTP: HTTP 404 status changed for third request (became %d).", data3.status) stdnse.debug1("HTTP: HTTP 404 status changed for third request (became %d).", data3.status)
return false, string.format("HTTP 404 status changed for third request (became %d).", data3.status) return false, string.format("HTTP 404 status changed for third request (became %d).", data3.status)
end end
@@ -2341,33 +2341,33 @@ function identify_404(host, port)
local clean_body2 = clean_404(data2.body) local clean_body2 = clean_404(data2.body)
local clean_body3 = clean_404(data3.body) local clean_body3 = clean_404(data3.body)
if(clean_body ~= clean_body2) then if(clean_body ~= clean_body2) then
stdnse.print_debug(1, "HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response.") stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response.")
stdnse.print_debug(1, "HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.")
return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response.") return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response.")
end end
if(clean_body ~= clean_body3) then if(clean_body ~= clean_body3) then
stdnse.print_debug(1, "HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).")
stdnse.print_debug(1, "HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.")
return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).")
end end
return true, 200, clean_body return true, 200, clean_body
end end
stdnse.print_debug(1, "HTTP: The 200 response didn't contain a body.") stdnse.debug1("HTTP: The 200 response didn't contain a body.")
return true, 200 return true, 200
end end
-- Loop through any expected error codes -- Loop through any expected error codes
for _,code in pairs(bad_responses) do for _,code in pairs(bad_responses) do
if(data.status and data.status == code) then if(data.status and data.status == code) then
stdnse.print_debug(1, "HTTP: Host returns %s instead of 404 File Not Found.", get_status_string(data)) stdnse.debug1("HTTP: Host returns %s instead of 404 File Not Found.", get_status_string(data))
return true, code return true, code
end end
end end
stdnse.print_debug(1, "Unexpected response returned for 404 check: %s", get_status_string(data)) stdnse.debug1("Unexpected response returned for 404 check: %s", get_status_string(data))
return true, data.status return true, data.status
end end
@@ -2398,17 +2398,17 @@ function page_exists(data, result_404, known_404, page, displayall)
-- If the 404 response is also "200", deal with it (check if the body matches) -- If the 404 response is also "200", deal with it (check if the body matches)
if(#data.body == 0) then if(#data.body == 0) then
-- I observed one server that returned a blank string instead of an error, on some occasions -- I observed one server that returned a blank string instead of an error, on some occasions
stdnse.print_debug(1, "HTTP: Page returned a totally empty body; page likely doesn't exist") stdnse.debug1("HTTP: Page returned a totally empty body; page likely doesn't exist")
return false return false
elseif(clean_404(data.body) ~= known_404) then elseif(clean_404(data.body) ~= known_404) then
stdnse.print_debug(1, "HTTP: Page returned a body that doesn't match known 404 body, therefore it exists (%s)", page) stdnse.debug1("HTTP: Page returned a body that doesn't match known 404 body, therefore it exists (%s)", page)
return true return true
else else
return false return false
end end
else else
-- If 404s return something other than 200, and we got a 200, we're good to go -- If 404s return something other than 200, and we got a 200, we're good to go
stdnse.print_debug(1, "HTTP: Page was '%s', it exists! (%s)", get_status_string(data), page) stdnse.debug1("HTTP: Page was '%s', it exists! (%s)", get_status_string(data), page)
return true return true
end end
else else
@@ -2416,7 +2416,7 @@ function page_exists(data, result_404, known_404, page, displayall)
if(data.status ~= 404 and data.status ~= result_404) then if(data.status ~= 404 and data.status ~= result_404) then
-- If this check succeeded, then the page isn't a standard 404 -- it could be a redirect, authentication request, etc. Unless the user -- If this check succeeded, then the page isn't a standard 404 -- it could be a redirect, authentication request, etc. Unless the user
-- asks for everything (with a script argument), only display 401 Authentication Required here. -- asks for everything (with a script argument), only display 401 Authentication Required here.
stdnse.print_debug(1, "HTTP: Page didn't match the 404 response (%s) (%s)", get_status_string(data), page) stdnse.debug1("HTTP: Page didn't match the 404 response (%s) (%s)", get_status_string(data), page)
if(data.status == 401) then -- "Authentication Required" if(data.status == 401) then -- "Authentication Required"
return true return true
@@ -2431,7 +2431,7 @@ function page_exists(data, result_404, known_404, page, displayall)
end end
end end
else else
stdnse.print_debug(1, "HTTP: HTTP request failed (is the host still up?)") stdnse.debug1("HTTP: HTTP request failed (is the host still up?)")
return false return false
end end
end end

View File

@@ -294,7 +294,7 @@ LinkExtractor = {
if ( self.options.maxdepth and self.options.maxdepth >= 0 ) then if ( self.options.maxdepth and self.options.maxdepth >= 0 ) then
local depth = self:getDepth( url ) local depth = self:getDepth( url )
if ( -1 == depth or depth > self.options.maxdepth ) then if ( -1 == depth or depth > self.options.maxdepth ) then
stdnse.print_debug(3, "%s: Skipping link depth: %d; b_url=%s; url=%s", LIBRARY_NAME, depth, tostring(self.options.base_url), tostring(url)) stdnse.debug3("%s: Skipping link depth: %d; b_url=%s; url=%s", LIBRARY_NAME, depth, tostring(self.options.base_url), tostring(url))
return false return false
end end
end end
@@ -302,7 +302,7 @@ LinkExtractor = {
-- withindomain trumps any whitelisting -- withindomain trumps any whitelisting
if ( self.options.withindomain ) then if ( self.options.withindomain ) then
if ( not(self.options.withindomain(url)) ) then if ( not(self.options.withindomain(url)) ) then
stdnse.print_debug(2, "%s: Link is not within domain: %s", LIBRARY_NAME, tostring(url)) stdnse.debug2("%s: Link is not within domain: %s", LIBRARY_NAME, tostring(url))
return false return false
end end
end end
@@ -310,7 +310,7 @@ LinkExtractor = {
-- withinhost trumps any whitelisting -- withinhost trumps any whitelisting
if ( self.options.withinhost ) then if ( self.options.withinhost ) then
if ( not(self.options.withinhost(url)) ) then if ( not(self.options.withinhost(url)) ) then
stdnse.print_debug(2, "%s: Link is not within host: %s", LIBRARY_NAME, tostring(url)) stdnse.debug2("%s: Link is not within host: %s", LIBRARY_NAME, tostring(url))
return false return false
end end
end end
@@ -319,7 +319,7 @@ LinkExtractor = {
if ( #self.options.blacklist > 0 ) then if ( #self.options.blacklist > 0 ) then
for _, func in ipairs(self.options.blacklist) do for _, func in ipairs(self.options.blacklist) do
if ( func(url) ) then if ( func(url) ) then
stdnse.print_debug(2, "%s: Blacklist match: %s", LIBRARY_NAME, tostring(url)) stdnse.debug2("%s: Blacklist match: %s", LIBRARY_NAME, tostring(url))
valid = false valid = false
break break
end end
@@ -331,7 +331,7 @@ LinkExtractor = {
valid = false valid = false
for _, func in ipairs(self.options.whitelist) do for _, func in ipairs(self.options.whitelist) do
if ( func(url) ) then if ( func(url) ) then
stdnse.print_debug(2, "%s: Whitelist match: %s", LIBRARY_NAME, tostring(url)) stdnse.debug2("%s: Whitelist match: %s", LIBRARY_NAME, tostring(url))
valid = true valid = true
break break
end end
@@ -379,10 +379,10 @@ LinkExtractor = {
local valid = self:validate_link(url) local valid = self:validate_link(url)
if ( valid ) then if ( valid ) then
stdnse.print_debug(3, "%s: Adding link: %s", LIBRARY_NAME, tostring(url)) stdnse.debug3("%s: Adding link: %s", LIBRARY_NAME, tostring(url))
links[tostring(url)] = true links[tostring(url)] = true
elseif ( tostring(url) ) then elseif ( tostring(url) ) then
stdnse.print_debug(3, "%s: Skipping url: %s", LIBRARY_NAME, link) stdnse.debug3("%s: Skipping url: %s", LIBRARY_NAME, link)
end end
end end
end end
@@ -441,11 +441,11 @@ URL = {
self.domain= self.host:match("^[^%.]-%.(.*)") self.domain= self.host:match("^[^%.]-%.(.*)")
return true return true
elseif( self.raw:match("^javascript:") ) then elseif( self.raw:match("^javascript:") ) then
stdnse.print_debug(2, "%s: Skipping javascript url: %s", LIBRARY_NAME, self.raw) stdnse.debug2("%s: Skipping javascript url: %s", LIBRARY_NAME, self.raw)
elseif( self.raw:match("^mailto:") ) then elseif( self.raw:match("^mailto:") ) then
stdnse.print_debug(2, "%s: Skipping mailto link: %s", LIBRARY_NAME, self.raw) stdnse.debug2("%s: Skipping mailto link: %s", LIBRARY_NAME, self.raw)
else else
stdnse.print_debug(2, "%s: WARNING: Failed to parse url: %s", LIBRARY_NAME, self.raw) stdnse.debug2("%s: WARNING: Failed to parse url: %s", LIBRARY_NAME, self.raw)
end end
return false return false
end, end,
@@ -527,7 +527,7 @@ UrlQueue = {
if ( u ) then if ( u ) then
table.insert(self.urls, u) table.insert(self.urls, u)
else else
stdnse.print_debug("ERROR: Invalid URL: %s", url) stdnse.debug1("ERROR: Invalid URL: %s", url)
end end
end end
end, end,
@@ -690,7 +690,7 @@ Crawler = {
end end
end end
stdnse.print_debug(2, "%s: %s", LIBRARY_NAME, o:getLimitations()) stdnse.debug2("%s: %s", LIBRARY_NAME, o:getLimitations())
return o return o
end, end,
@@ -790,16 +790,16 @@ Crawler = {
end end
if ( self.options.maxpagecount ) then if ( self.options.maxpagecount ) then
stdnse.print_debug(2, "%s: Fetching url [%d of %d]: %s", LIBRARY_NAME, count, self.options.maxpagecount, tostring(url)) stdnse.debug2("%s: Fetching url [%d of %d]: %s", LIBRARY_NAME, count, self.options.maxpagecount, tostring(url))
else else
stdnse.print_debug(2, "%s: Fetching url: %s", LIBRARY_NAME, tostring(url)) stdnse.debug2("%s: Fetching url: %s", LIBRARY_NAME, tostring(url))
end end
local scrape = true local scrape = true
if not (self.options.doscraping(url)) then if not (self.options.doscraping(url)) then
stdnse.print_debug(2, "%s: Scraping is not allowed for url: %s", LIBRARY_NAME, tostring(url)) stdnse.debug2("%s: Scraping is not allowed for url: %s", LIBRARY_NAME, tostring(url))
scrape = false scrape = false
end end
@@ -819,10 +819,10 @@ Crawler = {
end end
end end
if is_web_file then if is_web_file then
stdnse.print_debug(2, "%s: Using GET: %s", LIBRARY_NAME, file) stdnse.debug2("%s: Using GET: %s", LIBRARY_NAME, file)
response = http.get(url:getHost(), url:getPort(), url:getFile(), { timeout = self.options.timeout, redirect_ok = self.options.redirect_ok, no_cache = self.options.no_cache } ) response = http.get(url:getHost(), url:getPort(), url:getFile(), { timeout = self.options.timeout, redirect_ok = self.options.redirect_ok, no_cache = self.options.no_cache } )
else else
stdnse.print_debug(2, "%s: Using HEAD: %s", LIBRARY_NAME, file) stdnse.debug2("%s: Using HEAD: %s", LIBRARY_NAME, file)
response = http.head(url:getHost(), url:getPort(), url:getFile()) response = http.head(url:getHost(), url:getPort(), url:getFile())
end end
else else
@@ -854,7 +854,7 @@ Crawler = {
end end
table.insert(response_queue, { true, { url = url, response = response } } ) table.insert(response_queue, { true, { url = url, response = response } } )
while ( PREFETCH_SIZE < #response_queue ) do while ( PREFETCH_SIZE < #response_queue ) do
stdnse.print_debug(2, "%s: Response queue full, waiting ...", LIBRARY_NAME) stdnse.debug2("%s: Response queue full, waiting ...", LIBRARY_NAME)
condvar "wait" condvar "wait"
end end
condvar "signal" condvar "signal"
@@ -866,7 +866,7 @@ Crawler = {
loadScriptArguments = function(self) loadScriptArguments = function(self)
local sn = self.options.scriptname local sn = self.options.scriptname
if ( not(sn) ) then if ( not(sn) ) then
stdnse.print_debug("%s: WARNING: Script argument could not be loaded as scriptname was not set", LIBRARY_NAME) stdnse.debug1("%s: WARNING: Script argument could not be loaded as scriptname was not set", LIBRARY_NAME)
return return
end end

View File

@@ -76,7 +76,7 @@ IAX2 = {
local pos, frame_type = bin.unpack("C", data) local pos, frame_type = bin.unpack("C", data)
if ( bit.band(frame_type, 0x80) == 0 ) then if ( bit.band(frame_type, 0x80) == 0 ) then
print("frame_type", stdnse.tohex(frame_type)) print("frame_type", stdnse.tohex(frame_type))
stdnse.print_debug(2, "Frametype not supported") stdnse.debug2("Frametype not supported")
return return
end end
header.type = IAX2.PacketType.FULL header.type = IAX2.PacketType.FULL

View File

@@ -106,7 +106,7 @@ local function load_fingerprints()
-- Check if fingerprints are cached -- Check if fingerprints are cached
if(nmap.registry.ike_fingerprints ~= nil) then if(nmap.registry.ike_fingerprints ~= nil) then
stdnse.print_debug(1, "ike: Loading cached fingerprints") stdnse.debug1("ike: Loading cached fingerprints")
return nmap.registry.ike_fingerprints return nmap.registry.ike_fingerprints
end end
@@ -115,11 +115,11 @@ local function load_fingerprints()
filename_full = nmap.fetchfile('nselib/data/ike-fingerprints.lua') filename_full = nmap.fetchfile('nselib/data/ike-fingerprints.lua')
-- Load the file -- Load the file
stdnse.print_debug(1, "ike: Loading fingerprints: %s", filename_full) stdnse.debug1("ike: Loading fingerprints: %s", filename_full)
local env = setmetatable({fingerprints = {}}, {__index = _G}); local env = setmetatable({fingerprints = {}}, {__index = _G});
file = loadfile(filename_full, "t", env) file = loadfile(filename_full, "t", env)
if( not(file) ) then if( not(file) ) then
stdnse.print_debug(1, "ike: Couldn't load the file: %s", filename_full) stdnse.debug1("ike: Couldn't load the file: %s", filename_full)
return false, "Couldn't load fingerprint file: " .. filename_full return false, "Couldn't load fingerprint file: " .. filename_full
end end
file() file()
@@ -175,9 +175,9 @@ local function extract_payloads(packet)
-- debug -- debug
if PAYLOADS[np] == 'VID' then if PAYLOADS[np] == 'VID' then
stdnse.print_debug(2, 'IKE: Found IKE Header: %s: %s - %s', np, PAYLOADS[np], payload) stdnse.debug2('IKE: Found IKE Header: %s: %s - %s', np, PAYLOADS[np], payload)
else else
stdnse.print_debug(2, 'IKE: Found IKE Header: %s: %s', np, PAYLOADS[np]) stdnse.debug2('IKE: Found IKE Header: %s: %s', np, PAYLOADS[np])
end end
-- Store payload -- Store payload
@@ -241,7 +241,7 @@ local function lookup(vendor_ids)
local debug_string = '' local debug_string = ''
if row.vendor ~= nil then debug_string = debug_string .. row.vendor .. ' ' end if row.vendor ~= nil then debug_string = debug_string .. row.vendor .. ' ' end
if row.version ~= nil then debug_string = debug_string .. row.version end if row.version ~= nil then debug_string = debug_string .. row.version end
stdnse.print_debug(2, "IKE: Fingerprint: %s matches %s", vendor_id, debug_string) stdnse.debug2("IKE: Fingerprint: %s matches %s", vendor_id, debug_string)
-- Only store the first match -- Only store the first match
if info.vendor == nil then if info.vendor == nil then
@@ -251,7 +251,7 @@ local function lookup(vendor_ids)
elseif row.category == 'attribute' then elseif row.category == 'attribute' then
info.attribs[ #info.attribs + 1] = row info.attribs[ #info.attribs + 1] = row
stdnse.print_debug(2, "IKE: Attribute: %s matches %s", vendor_id, row.text) stdnse.debug2("IKE: Attribute: %s matches %s", vendor_id, row.text)
break break
end end
end end
@@ -280,7 +280,7 @@ local function lookup(vendor_ids)
if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' ' end if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' ' end
if info.vendor.version ~= nil then debug_string = debug_string .. info.vendor.version .. ' ' end if info.vendor.version ~= nil then debug_string = debug_string .. info.vendor.version .. ' ' end
if info.vendor.ostype ~= nil then debug_string = debug_string .. info.vendor.ostype end if info.vendor.ostype ~= nil then debug_string = debug_string .. info.vendor.ostype end
stdnse.print_debug(2, 'IKE: No vendor match, but ordering match found: %s', debug_string) stdnse.debug2('IKE: No vendor match, but ordering match found: %s', debug_string)
return info return info
@@ -292,7 +292,7 @@ local function lookup(vendor_ids)
debug_string = '' debug_string = ''
if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' to ' end if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' to ' end
if row.ostype ~= nil then debug_string = debug_string .. row.ostype end if row.ostype ~= nil then debug_string = debug_string .. row.ostype end
stdnse.print_debug(2, 'IKE: Vendor and ordering match. OS updated: %s', debug_string) stdnse.debug2('IKE: Vendor and ordering match. OS updated: %s', debug_string)
return info return info
@@ -302,7 +302,7 @@ local function lookup(vendor_ids)
debug_string = '' debug_string = ''
if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' vs ' end if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' vs ' end
if row.vendor ~= nil then debug_string = debug_string .. row.vendor end if row.vendor ~= nil then debug_string = debug_string .. row.vendor end
stdnse.print_debug(2, 'IKE: Found an ordering match, but vendors do not match. %s', debug_string) stdnse.debug2('IKE: Found an ordering match, but vendors do not match. %s', debug_string)
end end
end end

View File

@@ -162,7 +162,7 @@ end
--@return The string representing the address. --@return The string representing the address.
fromdword = function( ip ) fromdword = function( ip )
if type( ip ) ~= "number" then if type( ip ) ~= "number" then
stdnse.print_debug(1, "Error in ipOps.todword: Expected IPv4 address.") stdnse.debug1("Error in ipOps.todword: Expected IPv4 address.")
return nil return nil
end end

View File

@@ -267,7 +267,7 @@ IPP = {
end end
if ( not(group) ) then if ( not(group) ) then
stdnse.print_debug(2, "Unexpected tag: %d", tag) stdnse.debug2("Unexpected tag: %d", tag)
return return
end end

View File

@@ -348,7 +348,7 @@ Packet = {
table.insert(resp.records, record) table.insert(resp.records, record)
break break
else else
stdnse.print_debug("ERROR: iscsi.TextResponse: Unknown target record (%s)", k) stdnse.debug1("ERROR: iscsi.TextResponse: Unknown target record (%s)", k)
end end
end end
@@ -669,7 +669,7 @@ Helper = {
end end
if ( resp.status_code ~= 0 ) then if ( resp.status_code ~= 0 ) then
stdnse.print_debug(3, "ERROR: iscsi.Helper.login: Authentication failed (error code: %d)", resp.status_code) stdnse.debug3("ERROR: iscsi.Helper.login: Authentication failed (error code: %d)", resp.status_code)
return false, resp return false, resp
elseif ( auth_method:upper()=="NONE" ) then elseif ( auth_method:upper()=="NONE" ) then
return true, resp return true, resp

View File

@@ -19,7 +19,7 @@
-- <code> -- <code>
-- local status,socket = jdwp.connect(host,port) -- local status,socket = jdwp.connect(host,port)
-- if not status then -- if not status then
-- stdnse.print_debug("error, %s",socket) -- stdnse.debug1("error, %s",socket)
-- end -- end
-- local version_info -- local version_info
-- status, version_info = jdwp.getVersion(socket,0) -- status, version_info = jdwp.getVersion(socket,0)
@@ -176,7 +176,7 @@ JDWPReplyPacket = {
if flags == 0x80 then if flags == 0x80 then
return true, JDWPReplyPacket:new(length,id,error_code,data) return true, JDWPReplyPacket:new(length,id,error_code,data)
end end
stdnse.print_debug(2,"JDWP error parsing reply. Wrong reply packet flag. Raw data: ", stdnse.tohex(reply_packet)) stdnse.debug2("JDWP error parsing reply. Wrong reply packet flag. Raw data: ", stdnse.tohex(reply_packet))
return false, "JDWP error parsing reply." return false, "JDWP error parsing reply."
end end
@@ -194,21 +194,21 @@ function connect(host,port)
socket:set_timeout(10000) socket:set_timeout(10000)
local status, err = socket:connect(host, port) local status, err = socket:connect(host, port)
if not status then if not status then
stdnse.print_debug(2,"JDWP could not connect: %s",err) stdnse.debug2("JDWP could not connect: %s",err)
return status, err return status, err
end end
status, err = socket:send(JDWP_CONSTANTS.handshake) status, err = socket:send(JDWP_CONSTANTS.handshake)
if not status then if not status then
stdnse.print_debug(2,"JDWP could not send handshake: %s",err) stdnse.debug2("JDWP could not send handshake: %s",err)
return status, err return status, err
end end
status, result = socket:receive() status, result = socket:receive()
if not status then if not status then
stdnse.print_debug(2,"JDWP could not receive handshake: %s",result) stdnse.debug2("JDWP could not receive handshake: %s",result)
return status, result return status, result
end end
if result == JDWP_CONSTANTS.handshake then if result == JDWP_CONSTANTS.handshake then
stdnse.print_debug("JDWP handshake successful.") stdnse.debug1("JDWP handshake successful.")
return true, socket return true, socket
end end
return false, "JDWP handshake unsuccessful." return false, "JDWP handshake unsuccessful."
@@ -255,7 +255,7 @@ end
local function extract_string(data,pos) local function extract_string(data,pos)
local string_size local string_size
if pos > #data then if pos > #data then
stdnse.print_debug(2,"JDWP extract_string() position higher than data length, probably incomplete data received.") stdnse.debug2("JDWP extract_string() position higher than data length, probably incomplete data received.")
return pos, nil return pos, nil
end end
pos, string_size = bin.unpack(">I",data,pos) pos, string_size = bin.unpack(">I",data,pos)
@@ -311,7 +311,7 @@ function getVersion(socket,id)
local command = JDWPCommandPacket:new(id,1,1,nil) -- Version Command (1) local command = JDWPCommandPacket:new(id,1,1,nil) -- Version Command (1)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getVersion() error : %s",data) stdnse.debug2("JDWP getVersion() error : %s",data)
return false,data return false,data
end end
-- parse data -- parse data
@@ -348,7 +348,7 @@ function getClassBySignature(socket,id,signature)
local command = JDWPCommandPacket:new(id,1,2,toUTF8(signature)) local command = JDWPCommandPacket:new(id,1,2,toUTF8(signature))
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getClassBySignature() error : %s",data) stdnse.debug2("JDWP getClassBySignature() error : %s",data)
return false,data return false,data
end end
-- parse data -- parse data
@@ -381,7 +381,7 @@ function getAllThreads(socket,id)
local command = JDWPCommandPacket:new(id,1,4,nil) local command = JDWPCommandPacket:new(id,1,4,nil)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getAllThreads() error: %s", data) stdnse.debug2("JDWP getAllThreads() error: %s", data)
return false,data return false,data
end end
-- parse data -- parse data
@@ -407,13 +407,13 @@ function resumeVM(socket,id)
local command = JDWPCommandPacket:new(id,1,9,nil) local command = JDWPCommandPacket:new(id,1,9,nil)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP resumeVM() error: %s", data) stdnse.debug2("JDWP resumeVM() error: %s", data)
return false,data return false,data
end end
-- wait for event notification -- wait for event notification
status, data = receive_all(socket) status, data = receive_all(socket)
if not status then if not status then
stdnse.print_debug(2,"JDWP resumeVM() event notification failed: %s", data) stdnse.debug2("JDWP resumeVM() event notification failed: %s", data)
end end
return true, nil return true, nil
end end
@@ -431,7 +431,7 @@ function createString(socket,id,ascii_string)
local command = JDWPCommandPacket:new(id,1,11,toUTF8(ascii_string)) local command = JDWPCommandPacket:new(id,1,11,toUTF8(ascii_string))
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP createString() error: %s", data) stdnse.debug2("JDWP createString() error: %s", data)
return false,data return false,data
end end
local _,stringID = bin.unpack(">L",data) local _,stringID = bin.unpack(">L",data)
@@ -456,7 +456,7 @@ function getAllClassesWithGeneric(socket,id)
local command = JDWPCommandPacket:new(id,1,20,nil) local command = JDWPCommandPacket:new(id,1,20,nil)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getAllClassesWithGeneric() error: %s", data) stdnse.debug2("JDWP getAllClassesWithGeneric() error: %s", data)
return false,data return false,data
end end
-- parse data -- parse data
@@ -499,7 +499,7 @@ function getSignatureWithGeneric(socket,id,classID)
local command = JDWPCommandPacket:new(id,2,13,bin.pack(">L",classID)) -- Version Command (1) local command = JDWPCommandPacket:new(id,2,13,bin.pack(">L",classID)) -- Version Command (1)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getVersion() error : %s",data) stdnse.debug2("JDWP getVersion() error : %s",data)
return false,data return false,data
end end
local _,signature = extract_string(data,0) local _,signature = extract_string(data,0)
@@ -526,7 +526,7 @@ function getMethodsWithGeneric(socket,id,classID)
local command = JDWPCommandPacket:new(id,2,15,bin.pack(">L",classID)) local command = JDWPCommandPacket:new(id,2,15,bin.pack(">L",classID))
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getMethodsWithGeneric() error : %s",data) stdnse.debug2("JDWP getMethodsWithGeneric() error : %s",data)
return false,data return false,data
end end
-- parse data -- parse data
@@ -579,7 +579,7 @@ function invokeStaticMethod(socket,id,classID,methodID,numberOfArguments,argumen
local command = JDWPCommandPacket:new(id,3,3,params) local command = JDWPCommandPacket:new(id,3,3,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP invokeStaticMethod() error: %s", data) stdnse.debug2("JDWP invokeStaticMethod() error: %s", data)
return false,data return false,data
end end
return true,data return true,data
@@ -610,11 +610,11 @@ function newClassInstance(socket,id,classID,threadID,methodID,numberOfArguments,
local command = JDWPCommandPacket:new(id,3,4,params) local command = JDWPCommandPacket:new(id,3,4,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP newClassInstance() error: %s", data) stdnse.debug2("JDWP newClassInstance() error: %s", data)
return false,data return false,data
end end
-- parse data -- parse data
stdnse.print_debug("newClassInstance data: %s",stdnse.tohex(data)) stdnse.debug1("newClassInstance data: %s",stdnse.tohex(data))
local pos, tag = bin.unpack(">C",data) local pos, tag = bin.unpack(">C",data)
local objectID local objectID
pos, objectID = bin.unpack(">L",data,pos) pos, objectID = bin.unpack(">L",data,pos)
@@ -639,7 +639,7 @@ function newArrayInstance(socket,id,arrayType,length)
local command = JDWPCommandPacket:new(id,4,1,params) local command = JDWPCommandPacket:new(id,4,1,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP newArrayInstance() error: %s", data) stdnse.debug2("JDWP newArrayInstance() error: %s", data)
return false,data return false,data
end end
local pos,_ , tag, arrayID local pos,_ , tag, arrayID
@@ -664,11 +664,11 @@ function getRuntimeType(socket,id,objectID)
local command = JDWPCommandPacket:new(id,9,1,bin.pack(">L",objectID)) local command = JDWPCommandPacket:new(id,9,1,bin.pack(">L",objectID))
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP resumeVM() error: %s", data) stdnse.debug2("JDWP resumeVM() error: %s", data)
return false,data return false,data
end end
local _,tag,runtime_type = bin.unpack(">CL",data) local _,tag,runtime_type = bin.unpack(">CL",data)
stdnse.print_debug("runtime type: %d",runtime_type) stdnse.debug1("runtime type: %d",runtime_type)
return true,runtime_type return true,runtime_type
end end
@@ -698,10 +698,10 @@ function invokeObjectMethod(socket,id,objectID,threadID,classID,methodID,numberO
local command = JDWPCommandPacket:new(id,9,6,params) local command = JDWPCommandPacket:new(id,9,6,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP invokeObjectMethod() error: %s", data) stdnse.debug2("JDWP invokeObjectMethod() error: %s", data)
return false,data return false,data
end end
stdnse.print_debug("invoke obj method data: %s ",stdnse.tohex(data)) stdnse.debug1("invoke obj method data: %s ",stdnse.tohex(data))
return true,data return true,data
end end
@@ -721,7 +721,7 @@ function readString(socket,id,stringID)
local command = JDWPCommandPacket:new(id,10,1,bin.pack(">L",stringID)) local command = JDWPCommandPacket:new(id,10,1,bin.pack(">L",stringID))
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP readString() error: %s", data) stdnse.debug2("JDWP readString() error: %s", data)
return false,data return false,data
end end
local _,result = extract_string(data,0) local _,result = extract_string(data,0)
@@ -746,7 +746,7 @@ function getThreadName(socket,id,threadID)
local command = JDWPCommandPacket:new(id,11,1,params) local command = JDWPCommandPacket:new(id,11,1,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getThreadName() error: %s", data) stdnse.debug2("JDWP getThreadName() error: %s", data)
return false,data return false,data
end end
-- parse data -- parse data
@@ -768,7 +768,7 @@ function suspendThread(socket,id,threadID)
local command = JDWPCommandPacket:new(id,11,2,params) local command = JDWPCommandPacket:new(id,11,2,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP suspendThread() error: %s", data) stdnse.debug2("JDWP suspendThread() error: %s", data)
return false,data return false,data
end end
return true, nil return true, nil
@@ -789,10 +789,10 @@ function threadStatus(socket,id,threadID)
local command = JDWPCommandPacket:new(id,11,4,params) local command = JDWPCommandPacket:new(id,11,4,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP threadStatus() error: %s", data) stdnse.debug2("JDWP threadStatus() error: %s", data)
return false,data return false,data
end end
stdnse.print_debug("threadStatus %s",stdnse.tohex(data)) stdnse.debug1("threadStatus %s",stdnse.tohex(data))
return true, data return true, data
end end
@@ -813,7 +813,7 @@ function setArrayValues(socket,id,objectID,idx,values)
local command = JDWPCommandPacket:new(id,13,3,params) local command = JDWPCommandPacket:new(id,13,3,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP setArrayValues() error: %s", data) stdnse.debug2("JDWP setArrayValues() error: %s", data)
return false,data return false,data
end end
return true, nil return true, nil
@@ -835,7 +835,7 @@ function setThreadSinglestep(socket,id,threadID)
local command = JDWPCommandPacket:new(id,15,1,params) local command = JDWPCommandPacket:new(id,15,1,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP setThreadSinglestep() error: %s", data) stdnse.debug2("JDWP setThreadSinglestep() error: %s", data)
return false,data return false,data
end end
local _, requestID = bin.unpack(">i",data) local _, requestID = bin.unpack(">i",data)
@@ -855,7 +855,7 @@ function clearThreadSinglestep(socket,id,eventID)
local command = JDWPCommandPacket:new(id,15,2,params) local command = JDWPCommandPacket:new(id,15,2,params)
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP clearThreadSinglestep() error: %s", data) stdnse.debug2("JDWP clearThreadSinglestep() error: %s", data)
return false,data return false,data
end end
return true,nil return true,nil
@@ -879,7 +879,7 @@ function getReflectedType(socket,id,classObjectID)
local command = JDWPCommandPacket:new(id,17,1,bin.pack(">L",classObjectID)) local command = JDWPCommandPacket:new(id,17,1,bin.pack(">L",classObjectID))
local status, data = executeCommand(socket,command) local status, data = executeCommand(socket,command)
if not status then if not status then
stdnse.print_debug(2,"JDWP getReflectedType() error: %s", data) stdnse.debug2("JDWP getReflectedType() error: %s", data)
return false,data return false,data
end end
local reflected_type = { local reflected_type = {
@@ -904,7 +904,7 @@ function findMethod(socket,class,methodName,skipFirst)
return false return false
end end
for _, method in ipairs(methods) do -- find first constructor and first defineClass() method for _, method in ipairs(methods) do -- find first constructor and first defineClass() method
stdnse.print_debug(2,"Method name: %s", method.name) stdnse.debug2("Method name: %s", method.name)
if methodID == nil then if methodID == nil then
if string.find(method.name,methodName) then if string.find(method.name,methodName) then
if skipFirst then if skipFirst then
@@ -933,7 +933,7 @@ function injectClass(socket,class_bytes)
-- find byte array class id needed to create new array to load our bytecode into -- find byte array class id needed to create new array to load our bytecode into
status,classes = getAllClassesWithGeneric(socket,0) status,classes = getAllClassesWithGeneric(socket,0)
if not status then if not status then
stdnse.print_debug("getAllClassesWithGeneric failed: %s", classes) stdnse.debug1("getAllClassesWithGeneric failed: %s", classes)
return false return false
end end
local byteArrayID local byteArrayID
@@ -944,10 +944,10 @@ function injectClass(socket,class_bytes)
end end
end end
if byteArrayID == nil then if byteArrayID == nil then
stdnse.print_debug("finding byte array id failed") stdnse.debug1("finding byte array id failed")
return false return false
end end
stdnse.print_debug("Found byte[] id %d",byteArrayID) stdnse.debug1("Found byte[] id %d",byteArrayID)
-- find SecureClassLoader id by signature -- find SecureClassLoader id by signature
status, classes = getClassBySignature(socket,0,"Ljava/security/SecureClassLoader;") status, classes = getClassBySignature(socket,0,"Ljava/security/SecureClassLoader;")
@@ -955,7 +955,7 @@ function injectClass(socket,class_bytes)
return false return false
end end
local secureClassLoader = classes[1].referenceTypeID local secureClassLoader = classes[1].referenceTypeID
stdnse.print_debug("Found SecureClassLoader id %d",secureClassLoader) stdnse.debug1("Found SecureClassLoader id %d",secureClassLoader)
-- find SecureClassLoader() constructor -- find SecureClassLoader() constructor
local constructorMethodID = findMethod(socket,secureClassLoader,"<init>",true) local constructorMethodID = findMethod(socket,secureClassLoader,"<init>",true)
-- find ClassLoader id by signature -- find ClassLoader id by signature
@@ -964,13 +964,13 @@ function injectClass(socket,class_bytes)
return false return false
end end
local classLoader = classes[1].referenceTypeID local classLoader = classes[1].referenceTypeID
stdnse.print_debug("Found ClassLoader id %d",classes[1].referenceTypeID) stdnse.debug1("Found ClassLoader id %d",classes[1].referenceTypeID)
-- find ClassLoader's defineClass() method -- find ClassLoader's defineClass() method
local defineClassMethodID = findMethod(socket,classLoader,"defineClass",false) local defineClassMethodID = findMethod(socket,classLoader,"defineClass",false)
-- find ClassLoader's resolveClass() method -- find ClassLoader's resolveClass() method
local resolveClassMethodID = findMethod(socket,classLoader,"resolveClass",false) local resolveClassMethodID = findMethod(socket,classLoader,"resolveClass",false)
if constructorMethodID == nil or defineClassMethodID == nil or resolveClassMethodID == nil then if constructorMethodID == nil or defineClassMethodID == nil or resolveClassMethodID == nil then
stdnse.print_debug("Either constructor, defineClass or resolveClass method could not be found %s,%s,%s", type(constructorMethodID), type(defineClassMethodID),type(resolveClassMethodID)) stdnse.debug1("Either constructor, defineClass or resolveClass method could not be found %s,%s,%s", type(constructorMethodID), type(defineClassMethodID),type(resolveClassMethodID))
return false return false
end end
@@ -979,18 +979,18 @@ function injectClass(socket,class_bytes)
local arrayID local arrayID
status, arrayID = newArrayInstance(socket,0,byteArrayID,#class_bytes) status, arrayID = newArrayInstance(socket,0,byteArrayID,#class_bytes)
if not status then if not status then
stdnse.print_debug("New array failed: %s", arrayID) stdnse.debug1("New array failed: %s", arrayID)
return false return false
end end
stdnse.print_debug("Created new byte array of length %d",#class_bytes) stdnse.debug1("Created new byte array of length %d",#class_bytes)
-- set array values -- set array values
local temp local temp
status, temp = setArrayValues(socket,0,arrayID,0,class_bytes) status, temp = setArrayValues(socket,0,arrayID,0,class_bytes)
if not status then if not status then
stdnse.print_debug("Set values failed: %s", temp) stdnse.debug1("Set values failed: %s", temp)
return return
end end
stdnse.print_debug("Set array values to injected class bytes") stdnse.debug1("Set array values to injected class bytes")
-- get main thread id -- get main thread id
-- in order to load a new class file, thread must be suspended by an event -- in order to load a new class file, thread must be suspended by an event
@@ -998,58 +998,58 @@ function injectClass(socket,class_bytes)
local threads local threads
status,threads = getAllThreads(socket,0) status,threads = getAllThreads(socket,0)
if not status then if not status then
stdnse.print_debug("get threads failed: %s", threads) stdnse.debug1("get threads failed: %s", threads)
return false return false
end end
local main_thread local main_thread
local eventID local eventID
stdnse.print_debug("Looking for main thread...") stdnse.debug1("Looking for main thread...")
for _,thread in ipairs(threads) do for _,thread in ipairs(threads) do
local thread_name local thread_name
status, thread_name = getThreadName(socket,0,thread) status, thread_name = getThreadName(socket,0,thread)
if not status then if not status then
stdnse.print_debug("getThreadName failed: %s", thread_name) stdnse.debug1("getThreadName failed: %s", thread_name)
return false return false
end end
if thread_name == "main" then if thread_name == "main" then
stdnse.print_debug("Setting singlesteping to main thread.") stdnse.debug1("Setting singlesteping to main thread.")
status, eventID = setThreadSinglestep(socket,0,thread) status, eventID = setThreadSinglestep(socket,0,thread)
main_thread = thread main_thread = thread
break break
end end
end end
if main_thread == nil then if main_thread == nil then
stdnse.print_debug("couldn't find main thread") stdnse.debug1("couldn't find main thread")
return false return false
end end
-- to trigger the singlestep event, VM must be resumed -- to trigger the singlestep event, VM must be resumed
stdnse.print_debug("Resuming VM and waiting for single step event from main thread...") stdnse.debug1("Resuming VM and waiting for single step event from main thread...")
local status, _ = resumeVM(socket,0) local status, _ = resumeVM(socket,0)
-- clear singlestep since we need to run our code in this thread and we don't want it to stop after each instruction -- clear singlestep since we need to run our code in this thread and we don't want it to stop after each instruction
clearThreadSinglestep(socket,0,eventID) clearThreadSinglestep(socket,0,eventID)
stdnse.print_debug("Cleared singlesteping from main thread.") stdnse.debug1("Cleared singlesteping from main thread.")
-- instantiate new class loader -- instantiate new class loader
local class_loader_instance local class_loader_instance
status, class_loader_instance = newClassInstance(socket,0,secureClassLoader,main_thread,constructorMethodID,0,nil) status, class_loader_instance = newClassInstance(socket,0,secureClassLoader,main_thread,constructorMethodID,0,nil)
if not status then if not status then
stdnse.print_debug("newClassInstance failed: %s", class_loader_instance) stdnse.debug1("newClassInstance failed: %s", class_loader_instance)
return false return false
end end
stdnse.print_debug("Created new instance of SecureClassLoader.") stdnse.debug1("Created new instance of SecureClassLoader.")
local injectedClass local injectedClass
-- invoke defineClass with byte array that contains our bytecode -- invoke defineClass with byte array that contains our bytecode
local defineClassArgs = bin.pack(">CLCiCi",0x5b,arrayID,0x49,0,0x49,#class_bytes) -- argument tags taken from http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/types.html#wp9502 local defineClassArgs = bin.pack(">CLCiCi",0x5b,arrayID,0x49,0,0x49,#class_bytes) -- argument tags taken from http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/types.html#wp9502
stdnse.print_debug("Calling secureClassLoader.defineClass(byte[],int,int) ...") stdnse.debug1("Calling secureClassLoader.defineClass(byte[],int,int) ...")
status, injectedClass = invokeObjectMethod(socket,0,class_loader_instance,main_thread,secureClassLoader,defineClassMethodID,3,defineClassArgs) status, injectedClass = invokeObjectMethod(socket,0,class_loader_instance,main_thread,secureClassLoader,defineClassMethodID,3,defineClassArgs)
if not status then if not status then
stdnse.print_debug("invokeObjectMethod failed: %s", injectedClass) stdnse.debug1("invokeObjectMethod failed: %s", injectedClass)
end end
-- resolve (Java's way of saying link) loaded class -- resolve (Java's way of saying link) loaded class
status, _ = invokeObjectMethod(socket,0,class_loader_instance,main_thread,secureClassLoader,resolveClassMethodID,1,injectedClass) -- call with injectedClass which still has a tag status, _ = invokeObjectMethod(socket,0,class_loader_instance,main_thread,secureClassLoader,resolveClassMethodID,1,injectedClass) -- call with injectedClass which still has a tag
if not status then if not status then
stdnse.print_debug("invokeObjectMethod failed:") stdnse.debug1("invokeObjectMethod failed:")
end end
-- extract the injected class' ID -- extract the injected class' ID
local tag,injectedClassID local tag,injectedClassID
@@ -1064,17 +1064,17 @@ function injectClass(socket,class_bytes)
status, _ = invokeObjectMethod(socket,0,injectedClassID,main_thread,runtime_type,getMethodsMethod,0,nil) status, _ = invokeObjectMethod(socket,0,injectedClassID,main_thread,runtime_type,getMethodsMethod,0,nil)
stdnse.print_debug("New class defined. Injected class id : %d",injectedClassID) stdnse.debug1("New class defined. Injected class id : %d",injectedClassID)
local sig, reflected_type local sig, reflected_type
status, sig = getSignatureWithGeneric(socket,0,injectedClassID) status, sig = getSignatureWithGeneric(socket,0,injectedClassID)
stdnse.print_debug("Injected class signature: %s", sig) stdnse.debug1("Injected class signature: %s", sig)
status, reflected_type = getReflectedType(socket,0,injectedClassID) status, reflected_type = getReflectedType(socket,0,injectedClassID)
-- find injected class constructor -- find injected class constructor
local injectedConstructor = findMethod(socket,injectedClassID,"<init>",false) local injectedConstructor = findMethod(socket,injectedClassID,"<init>",false)
if injectedConstructor == nil then if injectedConstructor == nil then
stdnse.print_debug("Couldn't find either evil method or constructor") stdnse.debug1("Couldn't find either evil method or constructor")
return false return false
end end

View File

@@ -182,7 +182,7 @@ end
--Some local shortcuts --Some local shortcuts
local function dbg(str,...) local function dbg(str,...)
stdnse.print_debug("Json:"..str, ...) stdnse.debug1("Json:"..str, ...)
end end
local function d4(str,...) local function d4(str,...)
if nmap.debugging() > 3 then dbg(str, ...) end if nmap.debugging() > 3 then dbg(str, ...) end
@@ -193,7 +193,7 @@ end
--local dbg =stdnse.print_debug --local dbg =stdnse.print_debug
local function dbg_err(str,...) local function dbg_err(str,...)
stdnse.print_debug("json-ERR:"..str, ...) stdnse.debug1("json-ERR:"..str, ...)
end end
-- See section 2.5 for escapes. -- See section 2.5 for escapes.

View File

@@ -225,7 +225,7 @@ end
function searchRequest( socket, params ) function searchRequest( socket, params )
local searchResEntries = { errorMessage="", resultCode = 0} local searchResEntries = { errorMessage="", resultCode = 0}
local catch = function() socket:close() stdnse.print_debug("SearchRequest failed") end local catch = function() socket:close() stdnse.debug1("SearchRequest failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local attributes = params.attributes local attributes = params.attributes
local request = encode(params.baseObject) local request = encode(params.baseObject)
@@ -343,7 +343,7 @@ end
-- @return err string containing error message -- @return err string containing error message
function bindRequest( socket, params ) function bindRequest( socket, params )
local catch = function() socket:close() stdnse.print_debug("bindRequest failed") end local catch = function() socket:close() stdnse.debug1("bindRequest failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local ldapAuth = encode( { _ldaptype = 80, params.password } ) local ldapAuth = encode( { _ldaptype = 80, params.password } )
local bindReq = encode( params.version ) .. encode( params.username ) .. ldapAuth local bindReq = encode( params.version ) .. encode( params.username ) .. ldapAuth
@@ -396,7 +396,7 @@ end
function unbindRequest( socket ) function unbindRequest( socket )
local ldapMsg, packet local ldapMsg, packet
local catch = function() socket:close() stdnse.print_debug("bindRequest failed") end local catch = function() socket:close() stdnse.debug1("bindRequest failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local encoder = asn1.ASN1Encoder:new() local encoder = asn1.ASN1Encoder:new()

View File

@@ -165,7 +165,7 @@ TAP = {
-- @return status true on success, false on failure -- @return status true on success, false on failure
parse = function(self) parse = function(self)
if ( 24 > #self.data ) then if ( 24 > #self.data ) then
stdnse.print_debug("membase: Header packet too short (%d bytes)", #self.data) stdnse.debug1("membase: Header packet too short (%d bytes)", #self.data)
return false, "Packet to short" return false, "Packet to short"
end end
local pos local pos
@@ -286,7 +286,7 @@ Helper = {
local header = TAP.Response.Header:new(data) local header = TAP.Response.Header:new(data)
if ( header.opcode ~= req.header.opcode ) then if ( header.opcode ~= req.header.opcode ) then
stdnse.print_debug("WARNING: Received invalid op code, request contained (%d), response contained (%d)", req.header.opcode, header.opcode) stdnse.debug1("WARNING: Received invalid op code, request contained (%d), response contained (%d)", req.header.opcode, header.opcode)
end end
if ( not(TAP.Response.Decoder[tonumber(header.opcode)]) ) then if ( not(TAP.Response.Decoder[tonumber(header.opcode)]) ) then

View File

@@ -75,12 +75,12 @@ MobileMe = {
if ( response.status == 200 ) then if ( response.status == 200 ) then
local status, resp = json.parse(response.body) local status, resp = json.parse(response.body)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(2, "Failed to parse JSON response from server") stdnse.debug2("Failed to parse JSON response from server")
return false, "Failed to parse JSON response from server" return false, "Failed to parse JSON response from server"
end end
if ( resp.statusCode ~= "200" ) then if ( resp.statusCode ~= "200" ) then
stdnse.print_debug(2, "Failed to send message to server") stdnse.debug2("Failed to send message to server")
return false, "Failed to send message to server" return false, "Failed to send message to server"
end end
end end

View File

@@ -28,7 +28,7 @@ local arg_DB = stdnse.get_script_args("mongodb.db")
-- Some lazy shortcuts -- Some lazy shortcuts
local function dbg(str,...) local function dbg(str,...)
stdnse.print_debug(3, "MngoDb:"..str, ...) stdnse.debug3("MngoDb:"..str, ...)
end end
--local dbg =stdnse.print_debug --local dbg =stdnse.print_debug
@@ -55,7 +55,7 @@ local err =stdnse.print_debug
--module("bson", package.seeall) --module("bson", package.seeall)
--require("bin") --require("bin")
local function dbg_err(str,...) local function dbg_err(str,...)
stdnse.print_debug("Bson-ERR:"..str, ...) stdnse.debug1("Bson-ERR:"..str, ...)
end end
--local err =stdnse.log_error --local err =stdnse.log_error
@@ -558,7 +558,7 @@ function query(socket, data)
--Create an error handler --Create an error handler
local catch = function() local catch = function()
socket:close() socket:close()
stdnse.print_debug("Query failed") stdnse.debug1("Query failed")
end end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)

View File

@@ -234,7 +234,7 @@ function bind(smbstate, interface_uuid, interface_version, transfer_syntax)
local pos, align local pos, align
local result local result
stdnse.print_debug(2, "MSRPC: Sending Bind() request") stdnse.debug2("MSRPC: Sending Bind() request")
-- Use the only transfer_syntax value I know of. -- Use the only transfer_syntax value I know of.
if(transfer_syntax == nil) then if(transfer_syntax == nil) then
@@ -280,7 +280,7 @@ function bind(smbstate, interface_uuid, interface_version, transfer_syntax)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: Received Bind() result") stdnse.debug3("MSRPC: Received Bind() result")
-- Make these easier to access. -- Make these easier to access.
parameters = result['parameters'] parameters = result['parameters']
@@ -402,7 +402,7 @@ function call_function(smbstate, opnum, arguments)
arguments arguments
) )
stdnse.print_debug(3, "MSRPC: Calling function 0x%02x with %d bytes of arguments", #arguments, opnum) stdnse.debug3("MSRPC: Calling function 0x%02x with %d bytes of arguments", #arguments, opnum)
-- Pass the information up to the smb layer -- Pass the information up to the smb layer
status, result = smb.write_file(smbstate, data, 0) status, result = smb.write_file(smbstate, data, 0)
@@ -475,7 +475,7 @@ function call_function(smbstate, opnum, arguments)
result['arguments'] = arguments result['arguments'] = arguments
stdnse.print_debug(3, "MSRPC: Function call successful, %d bytes of returned arguments", #result['arguments']) stdnse.debug3("MSRPC: Function call successful, %d bytes of returned arguments", #result['arguments'])
return true, result return true, result
end end
@@ -493,7 +493,7 @@ function call_lanmanapi(smbstate, opnum, paramdesc, datadesc, data)
data data
) )
stdnse.print_debug(1, "MSRPC: Sending Browser Service request") stdnse.debug1("MSRPC: Sending Browser Service request")
status, result = smb.send_transaction_named_pipe(smbstate, parameters, nil, "\\PIPE\\LANMAN", true) status, result = smb.send_transaction_named_pipe(smbstate, parameters, nil, "\\PIPE\\LANMAN", true)
if(not(status)) then if(not(status)) then
@@ -530,14 +530,14 @@ function rap_netserverenum2(smbstate, domain, server_type, detail_level)
local parameters = result.parameters local parameters = result.parameters
local data = result.data local data = result.data
stdnse.print_debug(1, "MSRPC: Parsing Browser Service response") stdnse.debug1("MSRPC: Parsing Browser Service response")
local pos, status, convert, entry_count, available_entries = bin.unpack("<SSSS", parameters) local pos, status, convert, entry_count, available_entries = bin.unpack("<SSSS", parameters)
if(status ~= 0) then if(status ~= 0) then
return false, string.format("Call to Browser Service failed with status = %d", status) return false, string.format("Call to Browser Service failed with status = %d", status)
end end
stdnse.print_debug(1, "MSRPC: Browser service returned %d entries", entry_count) stdnse.debug1("MSRPC: Browser service returned %d entries", entry_count)
local pos = 1 local pos = 1
@@ -547,7 +547,7 @@ function rap_netserverenum2(smbstate, domain, server_type, detail_level)
local server = {} local server = {}
pos, server.name = bin.unpack("<z", data, pos) pos, server.name = bin.unpack("<z", data, pos)
stdnse.print_debug(1, "MSRPC: Found name: %s", server.name) stdnse.debug1("MSRPC: Found name: %s", server.name)
-- pos needs to be rounded to the next even multiple of 16 -- pos needs to be rounded to the next even multiple of 16
pos = pos + ( 16 - (#server.name % 16) ) - 1 pos = pos + ( 16 - (#server.name % 16) ) - 1
@@ -598,7 +598,7 @@ function srvsvc_netshareenumall(smbstate, server)
local level local level
local ctr, referent, count, max_count local ctr, referent, count, max_count
stdnse.print_debug(2, "MSRPC: Calling NetShareEnumAll() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling NetShareEnumAll() [%s]", smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *server_unc -- [in] [string,charset(UTF16)] uint16 *server_unc
arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true) arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true)
@@ -623,7 +623,7 @@ function srvsvc_netshareenumall(smbstate, server)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: NetShareEnumAll() returned successfully") stdnse.debug3("MSRPC: NetShareEnumAll() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -688,7 +688,7 @@ function srvsvc_netsharegetinfo(smbstate, server, share, level)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: NetShareGetInfo() returned successfully") stdnse.debug3("MSRPC: NetShareGetInfo() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -729,7 +729,7 @@ function srvsvc_netsessenum(smbstate, server)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling NetSessEnum() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling NetSessEnum() [%s]", smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *server_unc, -- [in] [string,charset(UTF16)] uint16 *server_unc,
arguments = msrpctypes.marshall_unicode_ptr(server, true) arguments = msrpctypes.marshall_unicode_ptr(server, true)
@@ -760,7 +760,7 @@ function srvsvc_netsessenum(smbstate, server)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: NetSessEnum() returned successfully") stdnse.debug3("MSRPC: NetSessEnum() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -836,7 +836,7 @@ function srvsvc_netservergetstatistics(smbstate, server)
local service = "SERVICE_SERVER" local service = "SERVICE_SERVER"
stdnse.print_debug(2, "MSRPC: Calling NetServerGetStatistics() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling NetServerGetStatistics() [%s]", smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *server_unc, -- [in] [string,charset(UTF16)] uint16 *server_unc,
arguments = msrpctypes.marshall_unicode_ptr(server, true) arguments = msrpctypes.marshall_unicode_ptr(server, true)
@@ -859,7 +859,7 @@ function srvsvc_netservergetstatistics(smbstate, server)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: NetServerGetStatistics() returned successfully") stdnse.debug3("MSRPC: NetServerGetStatistics() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -907,7 +907,7 @@ function srvsvc_netpathcompare(smbstate, server, path1, path2, pathtype, pathfla
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling NetPathCompare(%s, %s) [%s]", path1, path2, smbstate['ip']) stdnse.debug2("MSRPC: Calling NetPathCompare(%s, %s) [%s]", path1, path2, smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *server_unc, -- [in] [string,charset(UTF16)] uint16 *server_unc,
arguments = msrpctypes.marshall_unicode_ptr(server, true) arguments = msrpctypes.marshall_unicode_ptr(server, true)
@@ -930,7 +930,7 @@ function srvsvc_netpathcompare(smbstate, server, path1, path2, pathtype, pathfla
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: NetPathCompare() returned successfully") stdnse.debug3("MSRPC: NetPathCompare() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -970,7 +970,7 @@ function srvsvc_netpathcanonicalize(smbstate, server, path)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling NetPathCanonicalize(%s) [%s]", path, smbstate['ip']) stdnse.debug2("MSRPC: Calling NetPathCanonicalize(%s) [%s]", path, smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *server_unc, -- [in] [string,charset(UTF16)] uint16 *server_unc,
arguments = msrpctypes.marshall_unicode_ptr(server, true) arguments = msrpctypes.marshall_unicode_ptr(server, true)
@@ -995,7 +995,7 @@ function srvsvc_netpathcanonicalize(smbstate, server, path)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: NetPathCanonicalize() returned successfully") stdnse.debug3("MSRPC: NetPathCanonicalize() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1065,7 +1065,7 @@ function spoolss_open_printer(smbstate,printer)
local status, result = call_function(smbstate, 69, arguments) local status, result = call_function(smbstate, 69, arguments)
if not status then if not status then
stdnse.print_debug("MSRPC spoolss_open_printer(): %s ",result) stdnse.debug1("MSRPC spoolss_open_printer(): %s ",result)
end end
return status,result return status,result
@@ -1099,7 +1099,7 @@ function spoolss_start_doc_printer(smbstate,printer_handle,filename)
local status, result = call_function(smbstate, 17, arguments) local status, result = call_function(smbstate, 17, arguments)
if not status then if not status then
stdnse.print_debug("MSRPC spoolss_start_doc_printer(): %s",result) stdnse.debug1("MSRPC spoolss_start_doc_printer(): %s",result)
end end
return status,result return status,result
end end
@@ -1112,7 +1112,7 @@ end
--@param data Actual data to write to a file --@param data Actual data to write to a file
--@return (status, result) If status is false, result is an error message. Otherwise, result is number of bytes written. --@return (status, result) If status is false, result is an error message. Otherwise, result is number of bytes written.
function spoolss_write_printer(smbstate,printer_handle,data) function spoolss_write_printer(smbstate,printer_handle,data)
stdnse.print_debug("len %d", #data) stdnse.debug1("len %d", #data)
local padding_len = 4 - math.fmod(#data,4) local padding_len = 4 - math.fmod(#data,4)
local data_padding = nil local data_padding = nil
if not (padding_len == 4) then if not (padding_len == 4) then
@@ -1125,7 +1125,7 @@ function spoolss_write_printer(smbstate,printer_handle,data)
arguments = arguments .. msrpctypes.marshall_int32(#data) arguments = arguments .. msrpctypes.marshall_int32(#data)
local status,result = call_function(smbstate, 19, arguments) local status,result = call_function(smbstate, 19, arguments)
if not status then if not status then
stdnse.print_debug("MSRPC spoolss_write_printer(): %s",result) stdnse.debug1("MSRPC spoolss_write_printer(): %s",result)
end end
return status,result return status,result
end end
@@ -1139,7 +1139,7 @@ end
function spoolss_end_doc_printer(smbstate,printer_handle) function spoolss_end_doc_printer(smbstate,printer_handle)
local status,result = call_function(smbstate,23,printer_handle) local status,result = call_function(smbstate,23,printer_handle)
if not status then if not status then
stdnse.print_debug("MSRPC spoolss_end_doc_printer(): %s",result) stdnse.debug1("MSRPC spoolss_end_doc_printer(): %s",result)
end end
return status,result return status,result
end end
@@ -1153,7 +1153,7 @@ end
function spoolss_abort_printer(smbstate,printer_handle) function spoolss_abort_printer(smbstate,printer_handle)
local status,result = call_function(smbstate,21,printer_handle) local status,result = call_function(smbstate,21,printer_handle)
if not status then if not status then
stdnse.print_debug("MSRPC spoolss_abort_printer(): %s",result) stdnse.debug1("MSRPC spoolss_abort_printer(): %s",result)
end end
return status,result return status,result
end end
@@ -1215,7 +1215,7 @@ function epmapper_lookup(smbstate,handle)
local status,result = call_function(smbstate,2,params) local status,result = call_function(smbstate,2,params)
if not status then if not status then
stdnse.print_debug("MSRPC epmapper_lookup(): %s",result) stdnse.debug1("MSRPC epmapper_lookup(): %s",result)
end end
local data = result.data local data = result.data
@@ -1239,7 +1239,7 @@ function epmapper_lookup(smbstate,handle)
lookup_response.new_handle = string.sub(data,25,44) lookup_response.new_handle = string.sub(data,25,44)
-- stdnse.print_debug("new_handle: %s", stdnse.tohex(new_handle)) -- stdnse.debug1("new_handle: %s", stdnse.tohex(new_handle))
local num_entries local num_entries
pos, num_entries = bin.unpack("<I",data,45) pos, num_entries = bin.unpack("<I",data,45)
@@ -1295,7 +1295,7 @@ function epmapper_lookup(smbstate,handle)
elseif address_type == 0x1f then elseif address_type == 0x1f then
pos, lookup_response.ncacn_http = bin.unpack(">S",data,pos) pos, lookup_response.ncacn_http = bin.unpack(">S",data,pos)
else else
stdnse.print_debug("unknown address type %x",address_type) stdnse.debug1("unknown address type %x",address_type)
end end
end end
end end
@@ -1344,7 +1344,7 @@ function samr_connect4(smbstate, server)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling Connect4() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling Connect4() [%s]", smbstate['ip'])
-- [in,string,charset(UTF16)] uint16 *system_name, -- [in,string,charset(UTF16)] uint16 *system_name,
arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true) arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true)
@@ -1363,7 +1363,7 @@ function samr_connect4(smbstate, server)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: Connect4() returned successfully") stdnse.debug3("MSRPC: Connect4() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1398,7 +1398,7 @@ function samr_enumdomains(smbstate, connect_handle)
local result local result
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling EnumDomains() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling EnumDomains() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *connect_handle, -- [in,ref] policy_handle *connect_handle,
arguments = msrpctypes.marshall_policy_handle(connect_handle) arguments = msrpctypes.marshall_policy_handle(connect_handle)
@@ -1419,7 +1419,7 @@ function samr_enumdomains(smbstate, connect_handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: EnumDomains() returned successfully") stdnse.debug3("MSRPC: EnumDomains() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1461,7 +1461,7 @@ function samr_lookupdomain(smbstate, connect_handle, domain)
local pos, align local pos, align
local referent_id local referent_id
stdnse.print_debug(2, "MSRPC: Calling LookupDomain(%s) [%s]", domain, smbstate['ip']) stdnse.debug2("MSRPC: Calling LookupDomain(%s) [%s]", domain, smbstate['ip'])
-- [in,ref] policy_handle *connect_handle, -- [in,ref] policy_handle *connect_handle,
arguments = msrpctypes.marshall_policy_handle(connect_handle) arguments = msrpctypes.marshall_policy_handle(connect_handle)
@@ -1478,7 +1478,7 @@ function samr_lookupdomain(smbstate, connect_handle, domain)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: LookupDomain() returned successfully") stdnse.debug3("MSRPC: LookupDomain() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1514,7 +1514,7 @@ function samr_opendomain(smbstate, connect_handle, sid)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenDomain(%s) [%s]", sid, smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenDomain(%s) [%s]", sid, smbstate['ip'])
-- [in,ref] policy_handle *connect_handle, -- [in,ref] policy_handle *connect_handle,
arguments = msrpctypes.marshall_policy_handle(connect_handle) arguments = msrpctypes.marshall_policy_handle(connect_handle)
@@ -1534,7 +1534,7 @@ function samr_opendomain(smbstate, connect_handle, sid)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenDomain() returned successfully") stdnse.debug3("MSRPC: OpenDomain() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1570,7 +1570,7 @@ function samr_enumdomainusers(smbstate, domain_handle)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling EnumDomainUsers() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling EnumDomainUsers() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *domain_handle, -- [in,ref] policy_handle *domain_handle,
arguments = msrpctypes.marshall_policy_handle(domain_handle) arguments = msrpctypes.marshall_policy_handle(domain_handle)
@@ -1594,7 +1594,7 @@ function samr_enumdomainusers(smbstate, domain_handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: EnumDomainUsers() returned successfully") stdnse.debug3("MSRPC: EnumDomainUsers() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1651,7 +1651,7 @@ function samr_querydisplayinfo(smbstate, domain_handle, index, count)
-- This loop is because, in my testing, if I asked for all the results at once, it would blow up (ERR_BUFFER_OVERFLOW). So, instead, -- This loop is because, in my testing, if I asked for all the results at once, it would blow up (ERR_BUFFER_OVERFLOW). So, instead,
-- I put a little loop here and grab the names individually. -- I put a little loop here and grab the names individually.
stdnse.print_debug(2, "MSRPC: Calling QueryDisplayInfo(%d) [%s]", index, smbstate['ip']) stdnse.debug2("MSRPC: Calling QueryDisplayInfo(%d) [%s]", index, smbstate['ip'])
-- [in,ref] policy_handle *domain_handle, -- [in,ref] policy_handle *domain_handle,
arguments = msrpctypes.marshall_policy_handle(domain_handle) arguments = msrpctypes.marshall_policy_handle(domain_handle)
@@ -1679,7 +1679,7 @@ function samr_querydisplayinfo(smbstate, domain_handle, index, count)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: QueryDisplayInfo() returned successfully", i) stdnse.debug3("MSRPC: QueryDisplayInfo() returned successfully", i)
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -1741,7 +1741,7 @@ function samr_querydomaininfo2(smbstate, domain_handle, level)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling QueryDomainInfo2(%d) [%s]", level, smbstate['ip']) stdnse.debug2("MSRPC: Calling QueryDomainInfo2(%d) [%s]", level, smbstate['ip'])
-- [in,ref] policy_handle *domain_handle, -- [in,ref] policy_handle *domain_handle,
arguments = msrpctypes.marshall_policy_handle(domain_handle) arguments = msrpctypes.marshall_policy_handle(domain_handle)
@@ -1757,7 +1757,7 @@ function samr_querydomaininfo2(smbstate, domain_handle, level)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: QueryDomainInfo2() returned successfully") stdnse.debug3("MSRPC: QueryDomainInfo2() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2066,7 +2066,7 @@ end
-- --
-- --
-- pos, result['return'] = msrpctypes.unmarshall_int32(arguments, pos) -- pos, result['return'] = msrpctypes.unmarshall_int32(arguments, pos)
--stdnse.print_debug("Return = %08x\n", result['return']) --stdnse.debug1("Return = %08x\n", result['return'])
-- if(result['return'] == nil) then -- if(result['return'] == nil) then
-- return false, "Read off the end of the packet (samr.getmembersinalias)" -- return false, "Read off the end of the packet (samr.getmembersinalias)"
-- end -- end
@@ -2091,7 +2091,7 @@ function samr_close(smbstate, handle)
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling Close() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling Close() [%s]", smbstate['ip'])
-- [in,out,ref] policy_handle *handle -- [in,out,ref] policy_handle *handle
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -2102,7 +2102,7 @@ function samr_close(smbstate, handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: Close() returned successfully") stdnse.debug3("MSRPC: Close() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2135,7 +2135,7 @@ function lsa_openpolicy2(smbstate, server)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling LsarOpenPolicy2() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling LsarOpenPolicy2() [%s]", smbstate['ip'])
-- [in,unique] [string,charset(UTF16)] uint16 *system_name, -- [in,unique] [string,charset(UTF16)] uint16 *system_name,
arguments = msrpctypes.marshall_unicode_ptr(server, true) arguments = msrpctypes.marshall_unicode_ptr(server, true)
@@ -2154,7 +2154,7 @@ function lsa_openpolicy2(smbstate, server)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: LsarOpenPolicy2() returned successfully") stdnse.debug3("MSRPC: LsarOpenPolicy2() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2193,7 +2193,7 @@ function lsa_lookupnames2(smbstate, policy_handle, names)
local result local result
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling LsarLookupNames2(%s) [%s]", stdnse.strjoin(", ", names), smbstate['ip']) stdnse.debug2("MSRPC: Calling LsarLookupNames2(%s) [%s]", stdnse.strjoin(", ", names), smbstate['ip'])
-- [in] policy_handle *handle, -- [in] policy_handle *handle,
@@ -2229,7 +2229,7 @@ function lsa_lookupnames2(smbstate, policy_handle, names)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: LsarLookupNames2() returned successfully") stdnse.debug3("MSRPC: LsarLookupNames2() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2285,7 +2285,7 @@ function lsa_lookupsids2(smbstate, policy_handle, sids)
local result local result
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling LsarLookupSids2(%s) [%s]", stdnse.strjoin(", ", sids), smbstate['ip']) stdnse.debug2("MSRPC: Calling LsarLookupSids2(%s) [%s]", stdnse.strjoin(", ", sids), smbstate['ip'])
-- [in] policy_handle *handle, -- [in] policy_handle *handle,
arguments = msrpctypes.marshall_policy_handle(policy_handle) arguments = msrpctypes.marshall_policy_handle(policy_handle)
@@ -2343,7 +2343,7 @@ function lsa_lookupsids2(smbstate, policy_handle, sids)
return false, smb.get_status_name(result['return']) .. " (lsa.lookupsids2)" return false, smb.get_status_name(result['return']) .. " (lsa.lookupsids2)"
end end
stdnse.print_debug(3, "MSRPC: LsarLookupSids2(): Returning") stdnse.debug3("MSRPC: LsarLookupSids2(): Returning")
return true, result return true, result
end end
@@ -2359,7 +2359,7 @@ function lsa_close(smbstate, handle)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling LsaClose() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling LsaClose() [%s]", smbstate['ip'])
-- [in,out] policy_handle *handle -- [in,out] policy_handle *handle
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -2385,7 +2385,7 @@ function lsa_close(smbstate, handle)
return false, smb.get_status_name(result['return']) .. " (lsa.close)" return false, smb.get_status_name(result['return']) .. " (lsa.close)"
end end
stdnse.print_debug(3, "MSRPC: LsaClose() returned successfully") stdnse.debug3("MSRPC: LsaClose() returned successfully")
return true, result return true, result
end end
@@ -2413,7 +2413,7 @@ function winreg_openhku(smbstate)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenHKU() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenHKU() [%s]", smbstate['ip'])
-- [in] uint16 *system_name, -- [in] uint16 *system_name,
arguments = msrpctypes.marshall_int16_ptr(0x1337, true) arguments = msrpctypes.marshall_int16_ptr(0x1337, true)
@@ -2429,7 +2429,7 @@ function winreg_openhku(smbstate)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenHKU() returned successfully") stdnse.debug3("MSRPC: OpenHKU() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2463,7 +2463,7 @@ function winreg_openhklm(smbstate)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenHKLM() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenHKLM() [%s]", smbstate['ip'])
-- [in] uint16 *system_name, -- [in] uint16 *system_name,
arguments = msrpctypes.marshall_int16_ptr(0x1337, true) arguments = msrpctypes.marshall_int16_ptr(0x1337, true)
@@ -2479,7 +2479,7 @@ function winreg_openhklm(smbstate)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenHKLM() returned successfully") stdnse.debug3("MSRPC: OpenHKLM() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2512,7 +2512,7 @@ function winreg_openhkpd(smbstate)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenHKPD() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenHKPD() [%s]", smbstate['ip'])
-- [in] uint16 *system_name, -- [in] uint16 *system_name,
arguments = msrpctypes.marshall_int16_ptr(0x1337, true) arguments = msrpctypes.marshall_int16_ptr(0x1337, true)
@@ -2528,7 +2528,7 @@ function winreg_openhkpd(smbstate)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenHKPD() returned successfully") stdnse.debug3("MSRPC: OpenHKPD() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2561,7 +2561,7 @@ function winreg_openhkcu(smbstate)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenHKCU() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenHKCU() [%s]", smbstate['ip'])
-- [in] uint16 *system_name, -- [in] uint16 *system_name,
arguments = msrpctypes.marshall_int16_ptr(0x1337, true) arguments = msrpctypes.marshall_int16_ptr(0x1337, true)
@@ -2577,7 +2577,7 @@ function winreg_openhkcu(smbstate)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenHKCU() returned successfully") stdnse.debug3("MSRPC: OpenHKCU() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2619,7 +2619,7 @@ function winreg_enumkey(smbstate, handle, index, name)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling EnumKey(%d) [%s]", index, smbstate['ip']) stdnse.debug2("MSRPC: Calling EnumKey(%d) [%s]", index, smbstate['ip'])
-- [in,ref] policy_handle *handle, -- [in,ref] policy_handle *handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -2644,7 +2644,7 @@ function winreg_enumkey(smbstate, handle, index, name)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: EnumKey() returned successfully") stdnse.debug3("MSRPC: EnumKey() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2689,7 +2689,7 @@ function winreg_openkey(smbstate, handle, keyname)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenKey(%s) [%s]", keyname, smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenKey(%s) [%s]", keyname, smbstate['ip'])
-- [in,ref] policy_handle *parent_handle, -- [in,ref] policy_handle *parent_handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -2712,7 +2712,7 @@ function winreg_openkey(smbstate, handle, keyname)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenKey() returned successfully") stdnse.debug3("MSRPC: OpenKey() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2749,7 +2749,7 @@ function winreg_queryinfokey(smbstate, handle)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling QueryInfoKey() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling QueryInfoKey() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *handle, -- [in,ref] policy_handle *handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -2773,7 +2773,7 @@ function winreg_queryinfokey(smbstate, handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: QueryInfoKey() returned successfully") stdnse.debug3("MSRPC: QueryInfoKey() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2834,7 +2834,7 @@ function winreg_queryvalue(smbstate, handle, value)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling QueryValue(%s) [%s]", value, smbstate['ip']) stdnse.debug2("MSRPC: Calling QueryValue(%s) [%s]", value, smbstate['ip'])
-- [in,ref] policy_handle *handle, -- [in,ref] policy_handle *handle,
@@ -2861,7 +2861,7 @@ function winreg_queryvalue(smbstate, handle, value)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: QueryValue() returned successfully") stdnse.debug3("MSRPC: QueryValue() returned successfully")
local length, referent_id local length, referent_id
-- Make arguments easier to use -- Make arguments easier to use
@@ -2889,7 +2889,7 @@ function winreg_queryvalue(smbstate, handle, value)
elseif(result['type'] == "REG_NONE") then elseif(result['type'] == "REG_NONE") then
result['value'] = "" result['value'] = ""
else else
stdnse.print_debug("MSRPC ERROR: Unknown type: %s", result['type']) stdnse.debug1("MSRPC ERROR: Unknown type: %s", result['type'])
result['value'] = result['type'] result['value'] = result['type']
end end
else else
@@ -2929,7 +2929,7 @@ function winreg_closekey(smbstate, handle)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling CloseKey() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling CloseKey() [%s]", smbstate['ip'])
-- [in,out,ref] policy_handle *handle -- [in,out,ref] policy_handle *handle
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -2940,7 +2940,7 @@ function winreg_closekey(smbstate, handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: CloseKey() returned successfully") stdnse.debug3("MSRPC: CloseKey() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -2973,7 +2973,7 @@ function svcctl_openscmanagera(smbstate, machinename)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenSCManagerA() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenSCManagerA() [%s]", smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *MachineName, -- [in] [string,charset(UTF16)] uint16 *MachineName,
arguments = msrpctypes.marshall_ascii_ptr("\\\\" .. machinename) arguments = msrpctypes.marshall_ascii_ptr("\\\\" .. machinename)
@@ -2993,7 +2993,7 @@ function svcctl_openscmanagera(smbstate, machinename)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenSCManagerA() returned successfully") stdnse.debug3("MSRPC: OpenSCManagerA() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3034,7 +3034,7 @@ function svcctl_openscmanagerw(smbstate, machinename)
-- return svcctl_openscmanagera(smbstate, machinename) -- return svcctl_openscmanagera(smbstate, machinename)
-- end -- end
stdnse.print_debug(2, "MSRPC: Calling OpenSCManagerW() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenSCManagerW() [%s]", smbstate['ip'])
-- [in] [string,charset(UTF16)] uint16 *MachineName, -- [in] [string,charset(UTF16)] uint16 *MachineName,
arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. machinename, true) arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. machinename, true)
@@ -3054,7 +3054,7 @@ function svcctl_openscmanagerw(smbstate, machinename)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenSCManagerW() returned successfully") stdnse.debug3("MSRPC: OpenSCManagerW() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3090,7 +3090,7 @@ function svcctl_closeservicehandle(smbstate, handle)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling CloseServiceHandle() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling CloseServiceHandle() [%s]", smbstate['ip'])
-- [in,out,ref] policy_handle *handle -- [in,out,ref] policy_handle *handle
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3102,7 +3102,7 @@ function svcctl_closeservicehandle(smbstate, handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenSCManagerA() returned successfully") stdnse.debug3("MSRPC: OpenSCManagerA() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3135,7 +3135,7 @@ function svcctl_createservicew(smbstate, handle, service_name, display_name, pat
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling CreateServiceW() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling CreateServiceW() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *scmanager_handle, -- [in,ref] policy_handle *scmanager_handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3192,7 +3192,7 @@ function svcctl_createservicew(smbstate, handle, service_name, display_name, pat
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: CreateServiceW() returned successfully") stdnse.debug3("MSRPC: CreateServiceW() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3242,7 +3242,7 @@ function svcctl_deleteservice(smbstate, handle)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling DeleteService() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling DeleteService() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *handle -- [in,ref] policy_handle *handle
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3254,7 +3254,7 @@ function svcctl_deleteservice(smbstate, handle)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: DeleteService() returned successfully") stdnse.debug3("MSRPC: DeleteService() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3289,7 +3289,7 @@ function svcctl_openservicew(smbstate, handle, name)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling OpenServiceW() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling OpenServiceW() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *scmanager_handle, -- [in,ref] policy_handle *scmanager_handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3308,7 +3308,7 @@ function svcctl_openservicew(smbstate, handle, name)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: OpenServiceW() returned successfully") stdnse.debug3("MSRPC: OpenServiceW() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3344,7 +3344,7 @@ function svcctl_startservicew(smbstate, handle, args)
local status, result local status, result
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling StartServiceW() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling StartServiceW() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *handle, -- [in,ref] policy_handle *handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3365,7 +3365,7 @@ function svcctl_startservicew(smbstate, handle, args)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: StartServiceW() returned successfully") stdnse.debug3("MSRPC: StartServiceW() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3400,7 +3400,7 @@ function svcctl_controlservice(smbstate, handle, control)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling ControlService() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling ControlService() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *handle, -- [in,ref] policy_handle *handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3417,7 +3417,7 @@ function svcctl_controlservice(smbstate, handle, control)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: ControlService() returned successfully") stdnse.debug3("MSRPC: ControlService() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3453,7 +3453,7 @@ function svcctl_queryservicestatus(smbstate, handle, control)
local arguments local arguments
local pos, align local pos, align
stdnse.print_debug(2, "MSRPC: Calling QueryServiceStatus() [%s]", smbstate['ip']) stdnse.debug2("MSRPC: Calling QueryServiceStatus() [%s]", smbstate['ip'])
-- [in,ref] policy_handle *handle, -- [in,ref] policy_handle *handle,
arguments = msrpctypes.marshall_policy_handle(handle) arguments = msrpctypes.marshall_policy_handle(handle)
@@ -3467,7 +3467,7 @@ function svcctl_queryservicestatus(smbstate, handle, control)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: QueryServiceStatus() returned successfully") stdnse.debug3("MSRPC: QueryServiceStatus() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3512,7 +3512,7 @@ function atsvc_jobadd(smbstate, server, command, time)
-- TODO -- TODO
end end
stdnse.print_debug(2, "MSRPC: Calling AddJob(%s) [%s]", command, smbstate['ip']) stdnse.debug2("MSRPC: Calling AddJob(%s) [%s]", command, smbstate['ip'])
-- [in,unique,string,charset(UTF16)] uint16 *servername, -- [in,unique,string,charset(UTF16)] uint16 *servername,
arguments = msrpctypes.marshall_unicode_ptr(server, true) arguments = msrpctypes.marshall_unicode_ptr(server, true)
@@ -3528,7 +3528,7 @@ function atsvc_jobadd(smbstate, server, command, time)
return false, result return false, result
end end
stdnse.print_debug(3, "MSRPC: AddJob() returned successfully") stdnse.debug3("MSRPC: AddJob() returned successfully")
-- Make arguments easier to use -- Make arguments easier to use
arguments = result['arguments'] arguments = result['arguments']
@@ -3692,7 +3692,7 @@ end
function samr_enum_groups(host) function samr_enum_groups(host)
local i, j local i, j
stdnse.print_debug(1, "MSRPC: Attempting to enumerate groups on %s", host.ip) stdnse.debug1("MSRPC: Attempting to enumerate groups on %s", host.ip)
-- Create the SMB session -- Create the SMB session
local status, smbstate = start_smb(host, SAMR_PATH, true) local status, smbstate = start_smb(host, SAMR_PATH, true)
@@ -3770,7 +3770,7 @@ function samr_enum_groups(host)
end end
-- Print some output -- Print some output
stdnse.print_debug(1, "MSRPC: Found %d groups in %s", #enumaliases_result['sam']['entries'], domain) stdnse.debug1("MSRPC: Found %d groups in %s", #enumaliases_result['sam']['entries'], domain)
-- Record the results -- Record the results
local group_rids = {} local group_rids = {}
@@ -3810,7 +3810,7 @@ function samr_enum_groups(host)
end end
-- Print some output -- Print some output
stdnse.print_debug(1, "MSRPC: Adding group '%s' (RID: %d) with %d members", domains[domain][group_rid]['name'], group_rid, #member_sids) stdnse.debug1("MSRPC: Adding group '%s' (RID: %d) with %d members", domains[domain][group_rid]['name'], group_rid, #member_sids)
-- Save the output -- Save the output
domains[domain][group_rid]['member_sids'] = member_sids domains[domain][group_rid]['member_sids'] = member_sids
@@ -3962,7 +3962,7 @@ function lsa_enum_users(host)
status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids) status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids)
if(status == false) then if(status == false) then
stdnse.print_debug(1, "Error looking up RIDs: %s", lookupsids2_result) stdnse.debug1("Error looking up RIDs: %s", lookupsids2_result)
else else
-- Put the details for each name into an array -- Put the details for each name into an array
-- NOTE: Be sure to mirror any changes here in the next bit! -- NOTE: Be sure to mirror any changes here in the next bit!
@@ -3996,7 +3996,7 @@ function lsa_enum_users(host)
-- Try converting this group of RIDs into names -- Try converting this group of RIDs into names
status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids) status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids)
if(status == false) then if(status == false) then
stdnse.print_debug(1, "Error looking up RIDs: %s", lookupsids2_result) stdnse.debug1("Error looking up RIDs: %s", lookupsids2_result)
else else
-- Put the details for each name into an array -- Put the details for each name into an array
for j = 1, #lookupsids2_result['names']['names'], 1 do for j = 1, #lookupsids2_result['names']['names'], 1 do
@@ -4063,7 +4063,7 @@ function get_user_list(host)
status_lsa, result_lsa = lsa_enum_users(host) status_lsa, result_lsa = lsa_enum_users(host)
if(status_lsa == false) then if(status_lsa == false) then
stdnse.print_debug("MSRPC: Failed to enumerate users through LSA: %s", result_lsa) stdnse.debug1("MSRPC: Failed to enumerate users through LSA: %s", result_lsa)
else else
for i = 1, #result_lsa, 1 do for i = 1, #result_lsa, 1 do
if(result_lsa[i]['name'] ~= nil and result_lsa[i]['type'] == "SID_NAME_USER") then if(result_lsa[i]['name'] ~= nil and result_lsa[i]['type'] == "SID_NAME_USER") then
@@ -4074,7 +4074,7 @@ function get_user_list(host)
status_samr, result_samr = samr_enum_users(host) status_samr, result_samr = samr_enum_users(host)
if(status_samr == false) then if(status_samr == false) then
stdnse.print_debug("MSRPC: Failed to enumerate users through SAMR: %s", result_samr) stdnse.debug1("MSRPC: Failed to enumerate users through SAMR: %s", result_samr)
else else
for i = 1, #result_samr, 1 do for i = 1, #result_samr, 1 do
if(result_samr[i]['name'] ~= nil and result_samr[i]['type'] == "SID_NAME_USER") then if(result_samr[i]['name'] ~= nil and result_samr[i]['type'] == "SID_NAME_USER") then
@@ -4352,7 +4352,7 @@ end
function service_create(host, servicename, path) function service_create(host, servicename, path)
local status, smbstate, bind_result, open_result, create_result, close_result local status, smbstate, bind_result, open_result, create_result, close_result
stdnse.print_debug(1, "Creating service: %s (%s)", servicename, path) stdnse.debug1("Creating service: %s (%s)", servicename, path)
-- Create the SMB session -- Create the SMB session
status, smbstate = start_smb(host, SVCCTL_PATH) status, smbstate = start_smb(host, SVCCTL_PATH)
@@ -4368,7 +4368,7 @@ function service_create(host, servicename, path)
end end
-- Open the service manager -- Open the service manager
stdnse.print_debug(2, "Opening the remote service manager") stdnse.debug2("Opening the remote service manager")
status, open_result = svcctl_openscmanagerw(smbstate, host.ip) status, open_result = svcctl_openscmanagerw(smbstate, host.ip)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4376,7 +4376,7 @@ function service_create(host, servicename, path)
end end
-- Create the service -- Create the service
stdnse.print_debug(2, "Creating the service", servicename) stdnse.debug2("Creating the service", servicename)
status, create_result = svcctl_createservicew(smbstate, open_result['handle'], servicename, servicename, path) status, create_result = svcctl_createservicew(smbstate, open_result['handle'], servicename, servicename, path)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4416,7 +4416,7 @@ end
function service_start(host, servicename, args) function service_start(host, servicename, args)
local status, smbstate, bind_result, open_result, open_service_result, start_result, close_result, query_result local status, smbstate, bind_result, open_result, open_service_result, start_result, close_result, query_result
stdnse.print_debug(1, "Starting service: %s", servicename) stdnse.debug1("Starting service: %s", servicename)
-- Create the SMB session -- Create the SMB session
status, smbstate = start_smb(host, SVCCTL_PATH) status, smbstate = start_smb(host, SVCCTL_PATH)
@@ -4432,7 +4432,7 @@ function service_start(host, servicename, args)
end end
-- Open the service manager -- Open the service manager
stdnse.print_debug(1, "Opening the remote service manager") stdnse.debug1("Opening the remote service manager")
status, open_result = svcctl_openscmanagerw(smbstate, host.ip) status, open_result = svcctl_openscmanagerw(smbstate, host.ip)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4440,7 +4440,7 @@ function service_start(host, servicename, args)
end end
-- Get a handle to the service -- Get a handle to the service
stdnse.print_debug(2, "Getting a handle to the service") stdnse.debug2("Getting a handle to the service")
status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename) status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4448,7 +4448,7 @@ function service_start(host, servicename, args)
end end
-- Start it -- Start it
stdnse.print_debug(2, "Starting the service") stdnse.debug2("Starting the service")
status, start_result = svcctl_startservicew(smbstate, open_service_result['handle'], args) status, start_result = svcctl_startservicew(smbstate, open_service_result['handle'], args)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4456,7 +4456,7 @@ function service_start(host, servicename, args)
end end
-- Wait for it to start (TODO: Check the query result better) -- Wait for it to start (TODO: Check the query result better)
stdnse.print_debug(1, "Waiting for the service to start") stdnse.debug1("Waiting for the service to start")
repeat repeat
status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle']) status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle'])
if(status == false) then if(status == false) then
@@ -4498,7 +4498,7 @@ end
function service_stop(host, servicename) function service_stop(host, servicename)
local status, smbstate, bind_result, open_result, open_service_result, control_result, close_result, query_result local status, smbstate, bind_result, open_result, open_service_result, control_result, close_result, query_result
stdnse.print_debug(1, "Stopping service: %s", servicename) stdnse.debug1("Stopping service: %s", servicename)
-- Create the SMB session -- Create the SMB session
status, smbstate = start_smb(host, SVCCTL_PATH) status, smbstate = start_smb(host, SVCCTL_PATH)
@@ -4514,7 +4514,7 @@ function service_stop(host, servicename)
end end
-- Open the service manager -- Open the service manager
stdnse.print_debug(2, "Opening the remote service manager") stdnse.debug2("Opening the remote service manager")
status, open_result = svcctl_openscmanagerw(smbstate, host.ip) status, open_result = svcctl_openscmanagerw(smbstate, host.ip)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4522,7 +4522,7 @@ function service_stop(host, servicename)
end end
-- Get a handle to the service -- Get a handle to the service
stdnse.print_debug(2, "Getting a handle to the service") stdnse.debug2("Getting a handle to the service")
status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename) status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4530,7 +4530,7 @@ function service_stop(host, servicename)
end end
-- Stop it -- Stop it
stdnse.print_debug(2, "Stopping the service") stdnse.debug2("Stopping the service")
status, control_result = svcctl_controlservice(smbstate, open_service_result['handle'], "SERVICE_CONTROL_STOP") status, control_result = svcctl_controlservice(smbstate, open_service_result['handle'], "SERVICE_CONTROL_STOP")
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4538,7 +4538,7 @@ function service_stop(host, servicename)
end end
-- Wait for it to stop (TODO: Check the query result better) -- Wait for it to stop (TODO: Check the query result better)
stdnse.print_debug(2, "Waiting for the service to stop") stdnse.debug2("Waiting for the service to stop")
repeat repeat
status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle']) status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle'])
if(status == false) then if(status == false) then
@@ -4577,7 +4577,7 @@ end
function service_delete(host, servicename) function service_delete(host, servicename)
local status, smbstate, bind_result, open_result, open_service_result, delete_result, close_result local status, smbstate, bind_result, open_result, open_service_result, delete_result, close_result
stdnse.print_debug(1, "Deleting service: %s", servicename) stdnse.debug1("Deleting service: %s", servicename)
-- Create the SMB session -- Create the SMB session
status, smbstate = start_smb(host, SVCCTL_PATH) status, smbstate = start_smb(host, SVCCTL_PATH)
@@ -4593,7 +4593,7 @@ function service_delete(host, servicename)
end end
-- Open the service manager -- Open the service manager
stdnse.print_debug(2, "Opening the remote service manager") stdnse.debug2("Opening the remote service manager")
status, open_result = svcctl_openscmanagerw(smbstate, host.ip) status, open_result = svcctl_openscmanagerw(smbstate, host.ip)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4601,7 +4601,7 @@ function service_delete(host, servicename)
end end
-- Get a handle to the service -- Get a handle to the service
stdnse.print_debug(2, "Getting a handle to the service: %s", servicename) stdnse.debug2("Getting a handle to the service: %s", servicename)
status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename) status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename)
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)
@@ -4609,7 +4609,7 @@ function service_delete(host, servicename)
end end
-- Delete the service -- Delete the service
stdnse.print_debug(2, "Deleting the service") stdnse.debug2("Deleting the service")
status, delete_result = svcctl_deleteservice(smbstate, open_service_result['handle']) status, delete_result = svcctl_deleteservice(smbstate, open_service_result['handle'])
if(status == false) then if(status == false) then
smb.stop(smbstate) smb.stop(smbstate)

View File

@@ -41,7 +41,7 @@ local function parse_perf_title_database(data, pos)
if(number == nil) then if(number == nil) then
return false, "Couldn't parse the title database: end of string encountered early" return false, "Couldn't parse the title database: end of string encountered early"
elseif(tonumber(number) == nil) then -- Not sure if this actually happens, but it doesn't hurt to check elseif(tonumber(number) == nil) then -- Not sure if this actually happens, but it doesn't hurt to check
stdnse.print_debug(1, "MSRPC: ERROR: Couldn't parse the title database: string found where number expected (%d: '%s')", i, number) stdnse.debug1("MSRPC: ERROR: Couldn't parse the title database: string found where number expected (%d: '%s')", i, number)
return false, "Couldn't parse the title database" return false, "Couldn't parse the title database"
end end
@@ -510,14 +510,14 @@ function get_performance_data(host, objects)
end end
-- Start setting up the result object -- Start setting up the result object
--stdnse.print_debug("Index = %d\n", object_type['ObjectNameTitleIndex']) --stdnse.debug1("Index = %d\n", object_type['ObjectNameTitleIndex'])
local object_name = result['title_database'][object_type['ObjectNameTitleIndex']] local object_name = result['title_database'][object_type['ObjectNameTitleIndex']]
result[object_name] = {} result[object_name] = {}
--stdnse.print_debug("\n\nOBJECT: %s\n", object_name) --stdnse.debug1("\n\nOBJECT: %s\n", object_name)
--stdnse.print_debug(" Counters: %d\n", object_type['NumCounters']) --stdnse.debug1(" Counters: %d\n", object_type['NumCounters'])
--stdnse.print_debug(" Instances: %d\n", object_type['NumInstances']) --stdnse.debug1(" Instances: %d\n", object_type['NumInstances'])
--stdnse.print_debug("-----------------\n") --stdnse.debug1("-----------------\n")
-- Bring the position to the beginning of the counter definitions -- Bring the position to the beginning of the counter definitions
pos = object_start + object_type['HeaderLength'] pos = object_start + object_type['HeaderLength']
@@ -529,7 +529,7 @@ function get_performance_data(host, objects)
msrpc.stop_smb(smbstate) msrpc.stop_smb(smbstate)
return false, pos return false, pos
end end
--stdnse.print_debug(" Counter definition #%2d: [%d bytes] %s\n", j, counter_definitions[j]['CounterSize'], result['title_database'][counter_definitions[j]['CounterNameTitleIndex']]) --stdnse.debug1(" Counter definition #%2d: [%d bytes] %s\n", j, counter_definitions[j]['CounterSize'], result['title_database'][counter_definitions[j]['CounterNameTitleIndex']])
end end
-- Bring the position to the beginning of the instances (or counters) -- Bring the position to the beginning of the instances (or counters)
@@ -556,11 +556,11 @@ function get_performance_data(host, objects)
-- Bring the pos to the start of the counter block -- Bring the pos to the start of the counter block
pos = instance_start + object_instances[j]['ByteLength'] pos = instance_start + object_instances[j]['ByteLength']
--stdnse.print_debug("\n INSTANCE: %s\n", instance_name) --stdnse.debug1("\n INSTANCE: %s\n", instance_name)
--stdnse.print_debug(" Length: %d\n", object_instances[j]['ByteLength']) --stdnse.debug1(" Length: %d\n", object_instances[j]['ByteLength'])
--stdnse.print_debug(" NameOffset: %d\n", object_instances[j]['NameOffset']) --stdnse.debug1(" NameOffset: %d\n", object_instances[j]['NameOffset'])
--stdnse.print_debug(" NameLength: %d\n", object_instances[j]['NameLength']) --stdnse.debug1(" NameLength: %d\n", object_instances[j]['NameLength'])
--stdnse.print_debug(" --------------\n") --stdnse.debug1(" --------------\n")
-- The counter block -- The counter block
local status, counter_block local status, counter_block
@@ -580,7 +580,7 @@ function get_performance_data(host, objects)
end end
local counter_name = result['title_database'][counter_definitions[k]['CounterNameTitleIndex']] local counter_name = result['title_database'][counter_definitions[k]['CounterNameTitleIndex']]
--stdnse.print_debug(" %s: %s\n", counter_name, counter_result) --stdnse.debug1(" %s: %s\n", counter_name, counter_result)
-- Save it in the result -- Save it in the result
result[object_name][instance_name][counter_name] = counter_result result[object_name][instance_name][counter_name] = counter_result
@@ -600,7 +600,7 @@ function get_performance_data(host, objects)
end end
local counter_name = result['title_database'][counter_definitions[k]['CounterNameTitleIndex']] local counter_name = result['title_database'][counter_definitions[k]['CounterNameTitleIndex']]
--stdnse.print_debug(" %s: %s\n", counter_name, counter_result) --stdnse.debug1(" %s: %s\n", counter_name, counter_result)
-- Save it in the result -- Save it in the result
result[object_name][counter_name] = counter_result result[object_name][counter_name] = counter_result

File diff suppressed because it is too large Load Diff

View File

@@ -293,7 +293,7 @@ SqlServerVersionInfo =
elseif versionNumber:match( "^%d+%.%d+%.%d+" ) then elseif versionNumber:match( "^%d+%.%d+%.%d+" ) then
major, minor, revision = versionNumber:match( "^(%d+)%.(%d+)%.(%d+)" ) major, minor, revision = versionNumber:match( "^(%d+)%.(%d+)%.(%d+)" )
else 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 end
self:SetVersion( major, minor, revision, subBuild, source ) self:SetVersion( major, minor, revision, subBuild, source )
@@ -534,7 +534,7 @@ SSRP =
table.insert( instanceStrings, instanceString ) table.insert( instanceStrings, instanceString )
until (not firstInstanceEnd) 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 = {} local instances = {}
for _, instanceString in ipairs( instanceStrings ) do for _, instanceString in ipairs( instanceStrings ) do
@@ -556,7 +556,7 @@ SSRP =
if status then if status then
pipeName = namedpipes.make_pipe_name( host.ip, pipeSubPath ) pipeName = namedpipes.make_pipe_name( host.ip, pipeSubPath )
elseif pipeName ~= nil then 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 end
instance.pipeName = pipeName instance.pipeName = pipeName
@@ -574,11 +574,11 @@ SSRP =
pos, messageType, dataLength = bin.unpack("<CS", responseData, 1) pos, messageType, dataLength = bin.unpack("<CS", responseData, 1)
-- extract the response data (i.e. everything after the 3-byte header) -- extract the response data (i.e. everything after the 3-byte header)
responseData = responseData:sub(4) 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 if ( messageType ~= SSRP.MESSAGE_TYPE.ServerResponse or
dataLength ~= responseData:len() ) then 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() ) SSRP.DEBUG_ID, messageType, dataLength, responseData:len() )
else else
instances = SSRP._ParseSsrpString( host, responseData ) instances = SSRP._ParseSsrpString( host, responseData )
@@ -599,7 +599,7 @@ SSRP =
port = port or SSRP.PORT port = port or SSRP.PORT
if ( SCANNED_PORTS_ONLY and nmap.get_port_state( host, port ) == nil ) then 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" return false, "Discovery disallowed: scanned-ports-only"
end end
@@ -607,7 +607,7 @@ SSRP =
socket:set_timeout(5000) socket:set_timeout(5000)
if ( port.number ~= SSRP.PORT.number ) then 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 end
local status, err = socket:connect( host, port ) local status, err = socket:connect( host, port )
@@ -644,7 +644,7 @@ SSRP =
local instances_all = {} local instances_all = {}
if ( port.number ~= SSRP.PORT.number ) then 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 end
local status, err = socket:sendto(host, port, bin.pack( "C", SSRP.MESSAGE_TYPE.ClientBroadcast )) local status, err = socket:sendto(host, port, bin.pack( "C", SSRP.MESSAGE_TYPE.ClientBroadcast ))
@@ -938,7 +938,7 @@ ColumnData =
coldata = coldata .. '-' .. nextdata coldata = coldata .. '-' .. nextdata
else else
stdnse.print_debug("Unhandled length (%d) for GUIDTYPE", len) stdnse.debug1("Unhandled length (%d) for GUIDTYPE", len)
return pos + len, 'Unsupported Data' return pos + len, 'Unsupported Data'
end end
@@ -1046,7 +1046,7 @@ ColumnData =
elseif ( len == 8 ) then elseif ( len == 8 ) then
pos, coldata = bin.unpack("<L", data, pos) pos, coldata = bin.unpack("<L", data, pos)
else else
stdnse.print_debug("Unhandled length (%d) for DECIMALNTYPE", len) stdnse.debug1("Unhandled length (%d) for DECIMALNTYPE", len)
return pos + len, 'Unsupported Data' return pos + len, 'Unsupported Data'
end end
@@ -1444,7 +1444,7 @@ Token =
local ttype local ttype
pos, ttype = bin.unpack("C", data, pos) pos, ttype = bin.unpack("C", data, pos)
if ( not(Token.Parse[ttype]) ) then 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 ) return -1, ("No parser for token type: 0x%X"):format( ttype )
end end
@@ -1636,32 +1636,32 @@ PreLoginPacket =
end end
expectedOptionLength = OPTION_LENGTH_SERVER[ optionType ] expectedOptionLength = OPTION_LENGTH_SERVER[ optionType ]
if ( not expectedOptionLength ) then 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 expectedOptionLength = -1
end end
pos, optionPos, optionLength = bin.unpack(">SS", bytes, pos) pos, optionPos, optionLength = bin.unpack(">SS", bytes, pos)
if not (optionPos and optionLength) then 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" return false, "Invalid pre-login response"
end end
optionPos = optionPos + 1 -- convert from 0-based index to 1-based index optionPos = optionPos + 1 -- convert from 0-based index to 1-based index
if ( (optionPos + optionLength) > (#bytes + 1) ) then 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.debug2("%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: (optionPos: %s) (optionLength: %s)", "MSSQL", optionPos, optionLength )
return false, "Invalid pre-login response" return false, "Invalid pre-login response"
end end
if ( optionLength ~= expectedOptionLength and expectedOptionLength ~= -1 ) then if ( optionLength ~= expectedOptionLength and expectedOptionLength ~= -1 ) then
stdnse.print_debug( 2, "%s: Option data is incorrect size in pre-login response. ", "MSSQL" ) stdnse.debug2("%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: (optionType: %s) (optionLength: %s)", "MSSQL", optionType, optionLength )
return false, "Invalid pre-login response" return false, "Invalid pre-login response"
end end
optionData = bytes:sub( optionPos, optionPos + optionLength - 1 ) optionData = bytes:sub( optionPos, optionPos + optionLength - 1 )
if #optionData ~= optionLength then 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" return false, "Invalid pre-login response"
end end
@@ -1961,14 +1961,14 @@ TDSStream = {
end end
local status, result, connectionType, errorMessage 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 ) ) "MSSQL", instanceInfo:GetName(), stdnse.strjoin( ", ", connectionPreference ) )
for _, connectionType in ipairs( connectionPreference ) do for _, connectionType in ipairs( connectionPreference ) do
if connectionType == "TCP" then if connectionType == "TCP" then
if not ( instanceInfo.port ) 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() ) "MSSQL", instanceInfo:GetName() )
result = "No TCP port for this instance" result = "No TCP port for this instance"
else else
@@ -1979,7 +1979,7 @@ TDSStream = {
elseif connectionType == "Named Pipes" or connectionType == "NP" then elseif connectionType == "Named Pipes" or connectionType == "NP" then
if not ( instanceInfo.pipeName ) 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() ) "MSSQL", instanceInfo:GetName() )
result = "No named pipe for this instance" result = "No named pipe for this instance"
else else
@@ -1988,7 +1988,7 @@ TDSStream = {
end end
else 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) return false, ("ERROR: Unknown connection preference: %s"):format(connectionType)
end end
@@ -2023,7 +2023,7 @@ TDSStream = {
if ( self._socket ) then return false, "Already connected via TCP" end if ( self._socket ) then return false, "Already connected via TCP" end
if ( SCANNED_PORTS_ONLY and smb.get_port( host ) == nil ) then 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" return false, "Connection disallowed: scanned-ports-only"
end end
@@ -2050,7 +2050,7 @@ TDSStream = {
if ( self._pipe ) then return false, "Already connected via named pipes" end 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 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" return false, "Connection disallowed: scanned-ports-only"
end end
@@ -2075,7 +2075,7 @@ TDSStream = {
if ( not(status) ) then if ( not(status) ) then
self._socket = nil 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" return false, "Socket connection failed"
end end
self._name = string.format( "%s:%s", host.ip, port.number ) 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 -- TDS packet validity check: packet at least as long as the TDS header
if ( readBuffer:len() < 8 ) then 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" return false, "Server returned invalid packet"
end end
@@ -2201,7 +2201,7 @@ TDSStream = {
-- TDS packet validity check: packet type is Response (0x4) -- TDS packet validity check: packet type is Response (0x4)
if ( packetType ~= PacketType.Response ) then 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 ) "MSSQL", self._name, packetType )
return false, "Server returned invalid packet" return false, "Server returned invalid packet"
end end
@@ -2228,7 +2228,7 @@ TDSStream = {
-- TDS packet validity check: packet length matches length from header -- TDS packet validity check: packet length matches length from header
if ( packetLength ~= (thisPacketData:len() + 8) ) then 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() ) "MSSQL", self._name, packetLength, thisPacketData:len() )
return false, "Server returned invalid packet" return false, "Server returned invalid packet"
end end
@@ -2490,7 +2490,7 @@ Helper =
Helper.AddOrMergeInstance( instance ) Helper.AddOrMergeInstance( instance )
table.insert( instances_host, instance ) table.insert( instances_host, instance )
else 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
end end
@@ -2853,7 +2853,7 @@ Helper =
status, response = tdsStream:ConnectEx( instanceInfo ) status, response = tdsStream:ConnectEx( instanceInfo )
if ( not status ) then 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" return false, "Connect failed"
end end
@@ -2873,12 +2873,12 @@ Helper =
if status then if status then
version = preLoginResponse.versionInfo version = preLoginResponse.versionInfo
else 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 "" ) "MSSQL", instanceInfo:GetName(), preLoginResponse or "" )
return false, "Parsing failed" return false, "Parsing failed"
end end
else 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" return false, "Receive failed"
end end
@@ -2925,7 +2925,7 @@ Helper =
end end
if ( not Helper.WasDiscoveryPerformed( host ) ) then 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 ) Helper.Discover( host )
end end
@@ -3078,7 +3078,7 @@ Auth = {
LmResponse = function( password, nonce ) LmResponse = function( password, nonce )
if ( not(HAVE_SSL) ) then if ( not(HAVE_SSL) ) then
stdnse.print_debug("ERROR: Nmap is missing OpenSSL") stdnse.debug1("ERROR: Nmap is missing OpenSSL")
return return
end end

View File

@@ -106,7 +106,7 @@ end
-- <code>status</code> or error message on failure (status == false) -- <code>status</code> or error message on failure (status == false)
function receiveGreeting( socket ) function receiveGreeting( socket )
local catch = function() socket:close() stdnse.print_debug("receiveGreeting(): failed") end local catch = function() socket:close() stdnse.debug1("receiveGreeting(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local data = try( socket:receive_bytes(HEADER_SIZE) ) local data = try( socket:receive_bytes(HEADER_SIZE) )
local pos, response, tmp, _ local pos, response, tmp, _
@@ -193,7 +193,7 @@ end
-- @return response table or error message on failure -- @return response table or error message on failure
function loginRequest( socket, params, username, password, salt ) function loginRequest( socket, params, username, password, salt )
local catch = function() socket:close() stdnse.print_debug("loginRequest(): failed") end local catch = function() socket:close() stdnse.debug1("loginRequest(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local packetno = 1 local packetno = 1
local authversion = params.authversion or "post41" local authversion = params.authversion or "post41"
@@ -330,7 +330,7 @@ end
-- @return table containing the following <code>header</code>, <code>fields</code> and <code>data</code> -- @return table containing the following <code>header</code>, <code>fields</code> and <code>data</code>
function decodeQueryResponse( socket ) function decodeQueryResponse( socket )
local catch = function() socket:close() stdnse.print_debug("decodeQueryResponse(): failed") end local catch = function() socket:close() stdnse.debug1("decodeQueryResponse(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local data, header, pos local data, header, pos
local rs, blocks = {}, {} local rs, blocks = {}, {}
@@ -492,7 +492,7 @@ end
-- @return rows table containing row tables as decoded by <code>decodeDataPackets</code> -- @return rows table containing row tables as decoded by <code>decodeDataPackets</code>
function sqlQuery( socket, query ) function sqlQuery( socket, query )
local catch = function() socket:close() stdnse.print_debug("sqlQuery(): failed") end local catch = function() socket:close() stdnse.debug1("sqlQuery(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local packetno = 0 local packetno = 0
local querylen = query:len() + 1 local querylen = query:len() + 1

View File

@@ -587,7 +587,7 @@ Response = {
if ( self.data ) then if ( self.data ) then
local len = #self.data - pos local len = #self.data - pos
if ( ( #self.data - pos ) ~= ( self.length - 33 ) ) then if ( ( #self.data - pos ) ~= ( self.length - 33 ) ) then
stdnse.print_debug("NCP packet length mismatched") stdnse.debug1("NCP packet length mismatched")
return return
end end
end end

View File

@@ -41,7 +41,7 @@ types = {
-- (eg. "\x20FEEFFDFEDBCACACACACACACACACAAA\x08insecure\x03org") -- (eg. "\x20FEEFFDFEDBCACACACACACACACACAAA\x08insecure\x03org")
function name_encode(name, scope) function name_encode(name, scope)
stdnse.print_debug(3, "Encoding name '%s'", name) stdnse.debug3("Encoding name '%s'", name)
-- Truncate or pad the string to 16 bytes -- Truncate or pad the string to 16 bytes
if(#name >= 16) then if(#name >= 16) then
name = string.sub(name, 1, 16) name = string.sub(name, 1, 16)
@@ -78,7 +78,7 @@ function name_encode(name, scope)
end end
end end
stdnse.print_debug(3, "=> '%s'", L2_encoded) stdnse.debug3("=> '%s'", L2_encoded)
return L2_encoded return L2_encoded
end end
@@ -98,7 +98,7 @@ function name_decode(encoded_name)
local len = string.byte(encoded_name, 1) local len = string.byte(encoded_name, 1)
local i local i
stdnse.print_debug(3, "Decoding name '%s'", encoded_name) stdnse.debug3("Decoding name '%s'", encoded_name)
for i = 2, len + 1, 2 do for i = 2, len + 1, 2 do
local ch = 0 local ch = 0
@@ -121,7 +121,7 @@ function name_decode(encoded_name)
scope = string.sub(scope, 1, #scope - 1) scope = string.sub(scope, 1, #scope - 1)
end end
stdnse.print_debug(3, "=> '%s'", name) stdnse.debug3("=> '%s'", name)
return name, scope return name, scope
end end
@@ -272,12 +272,12 @@ function do_nbstat(host)
local statistics local statistics
local reg local reg
if type(host) == "string" then --ip if type(host) == "string" then --ip
stdnse.print_debug(3, "Performing nbstat on host '%s'", host) stdnse.debug3("Performing nbstat on host '%s'", host)
nmap.registry.netbios = nmap.registry.netbios or {} nmap.registry.netbios = nmap.registry.netbios or {}
nmap.registry.netbios[host] = nmap.registry.netbios[host] or {} nmap.registry.netbios[host] = nmap.registry.netbios[host] or {}
reg = nmap.registry.netbios[host] reg = nmap.registry.netbios[host]
else else
stdnse.print_debug(3, "Performing nbstat on host '%s'", host.ip) stdnse.debug3("Performing nbstat on host '%s'", host.ip)
if host.registry.netbios == nil and if host.registry.netbios == nil and
nmap.registry.netbios ~= nil and nmap.registry.netbios ~= nil and
nmap.registry.netbios[host.ip] ~= nil then nmap.registry.netbios[host.ip] ~= nil then
@@ -289,7 +289,7 @@ function do_nbstat(host)
-- Check if it's cached in the registry for this host -- Check if it's cached in the registry for this host
if(reg["nbstat_names"] ~= nil) then if(reg["nbstat_names"] ~= nil) then
stdnse.print_debug(3, " |_ [using cached value]") stdnse.debug3(" |_ [using cached value]")
return true, reg["nbstat_names"], reg["nbstat_statistics"] return true, reg["nbstat_names"], reg["nbstat_statistics"]
end end

View File

@@ -54,7 +54,7 @@ function tostr(data, indent)
end end
end end
else else
stdnse.print_debug(1, "Error: unknown data type: %s", type(data)) stdnse.debug1("Error: unknown data type: %s", type(data))
end end
return table.concat(str) return table.concat(str)

View File

@@ -81,13 +81,13 @@ Session = {
.. "</credentials></authenticate>") .. "</credentials></authenticate>")
if not status then if not status then
stdnse.print_debug("ERROR: %s", err) stdnse.debug1("ERROR: %s", err)
return false, err return false, err
end end
status, xmldata = self.socket:receive() status, xmldata = self.socket:receive()
if not status then if not status then
stdnse.print_debug("ERROR: %s", xmldata) stdnse.debug1("ERROR: %s", xmldata)
return false, xmldata return false, xmldata
end end
@@ -102,13 +102,13 @@ Session = {
status, err = self.socket:send("<get_targets/>") status, err = self.socket:send("<get_targets/>")
if not status then if not status then
stdnse.print_debug("ERROR: %s", err) stdnse.debug1("ERROR: %s", err)
return false, err return false, err
end end
status, xmldata = self.socket:receive() status, xmldata = self.socket:receive()
if not status then if not status then
stdnse.print_debug("ERROR: %s", xmldata) stdnse.debug1("ERROR: %s", xmldata)
return false, xmldata return false, xmldata
end end

View File

@@ -72,7 +72,7 @@ OSPF = {
_, header.auth_data.hash = bin.unpack(">H"..header.auth_data.length, data, header.length+1) _, header.auth_data.hash = bin.unpack(">H"..header.auth_data.length, data, header.length+1)
else else
-- Shouldn't happen -- Shouldn't happen
stdnse.print_debug("Unknown authentication type " .. header.auth_type) stdnse.debug1("Unknown authentication type " .. header.auth_type)
return nil return nil
end end
header.router_id = ipOps.fromdword(header.router_id) header.router_id = ipOps.fromdword(header.router_id)
@@ -188,7 +188,7 @@ OSPF = {
hello.BDR = ipOps.fromdword(hello.BDR) hello.BDR = ipOps.fromdword(hello.BDR)
if ( ( #data - pos + 1 ) % 4 ~= 0 ) then if ( ( #data - pos + 1 ) % 4 ~= 0 ) then
stdnse.print_debug(2, "Unexpected OSPF packet length, aborting ...") stdnse.debug2("Unexpected OSPF packet length, aborting ...")
return return
end end

View File

@@ -249,7 +249,7 @@ function Packet:new(packet, packet_len, force_continue)
if o.ip_v == 6 then if o.ip_v == 6 then
while o:ipv6_is_extension_header() do while o:ipv6_is_extension_header() do
if not o:ipv6_ext_header_parse(force_continue) or o.ip6_data_offset >= o.packet_len then if not o:ipv6_ext_header_parse(force_continue) or o.ip6_data_offset >= o.packet_len then
stdnse.print_debug("Error while parsing IPv6 extension headers.") stdnse.debug1("Error while parsing IPv6 extension headers.")
return o return o
end end
end end
@@ -258,19 +258,19 @@ function Packet:new(packet, packet_len, force_continue)
if o.ip_p == IPPROTO_TCP then if o.ip_p == IPPROTO_TCP then
if not o:tcp_parse(force_continue) then if not o:tcp_parse(force_continue) then
stdnse.print_debug("Error while parsing TCP packet\n") stdnse.debug1("Error while parsing TCP packet\n")
end end
elseif o.ip_p == IPPROTO_UDP then elseif o.ip_p == IPPROTO_UDP then
if not o:udp_parse(force_continue) then if not o:udp_parse(force_continue) then
stdnse.print_debug("Error while parsing UDP packet\n") stdnse.debug1("Error while parsing UDP packet\n")
end end
elseif o.ip_p == IPPROTO_ICMP then elseif o.ip_p == IPPROTO_ICMP then
if not o:icmp_parse(force_continue) then if not o:icmp_parse(force_continue) then
stdnse.print_debug("Error while parsing ICMP packet\n") stdnse.debug1("Error while parsing ICMP packet\n")
end end
elseif o.ip_p == IPPROTO_ICMPV6 then elseif o.ip_p == IPPROTO_ICMPV6 then
if not o:icmpv6_parse(force_continue) then if not o:icmpv6_parse(force_continue) then
stdnse.print_debug("Error while parsing ICMPv6 packet\n") stdnse.debug1("Error while parsing ICMPv6 packet\n")
end end
end end
return o return o

View File

@@ -89,7 +89,7 @@ v2 =
elseif ( authtype == 0 ) then elseif ( authtype == 0 ) then
response.success = true response.success = true
else else
stdnse.print_debug("unknown auth type: %d", authtype) stdnse.debug1("unknown auth type: %d", authtype)
end end
response.authtype = authtype response.authtype = authtype
@@ -138,7 +138,7 @@ v2 =
return pos, response return pos, response
end end
else else
stdnse.print_debug("Missing decoder for %d", ptype) stdnse.debug1("Missing decoder for %d", ptype)
return -1, ("Missing decoder for %d"):format(ptype) return -1, ("Missing decoder for %d"):format(ptype)
end end
return -1, "Decoding failed" return -1, "Decoding failed"
@@ -159,7 +159,7 @@ v2 =
local tmp = "" local tmp = ""
local ptype, len local ptype, len
local catch = function() socket:close() stdnse.print_debug("processResponse(): failed") end local catch = function() socket:close() stdnse.debug1("processResponse(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
if ( data == nil or data:len() == 0 ) then if ( data == nil or data:len() == 0 ) then
@@ -218,7 +218,7 @@ v2 =
-- result string containing an error message if login fails -- result string containing an error message if login fails
loginRequest = function ( socket, params, username, password, salt ) loginRequest = function ( socket, params, username, password, salt )
local catch = function() socket:close() stdnse.print_debug("loginRequest(): failed") end local catch = function() socket:close() stdnse.debug1("loginRequest(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local response = {} local response = {}
local status, data, len, pos, tmp local status, data, len, pos, tmp
@@ -283,7 +283,7 @@ v3 =
elseif ( authtype == 0 ) then elseif ( authtype == 0 ) then
response.success = true response.success = true
else else
stdnse.print_debug( "unknown auth type: %d", authtype ) stdnse.debug1("unknown auth type: %d", authtype )
end end
response.authtype = authtype response.authtype = authtype
@@ -397,7 +397,7 @@ v3 =
local ptype, len local ptype, len
local header local header
local catch = function() socket:close() stdnse.print_debug("processResponse(): failed") end local catch = function() socket:close() stdnse.debug1("processResponse(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
if ( data:len() - pos < 5 ) then if ( data:len() - pos < 5 ) then
@@ -455,7 +455,7 @@ v3 =
return pos, response return pos, response
end end
else else
stdnse.print_debug( "Missing decoder for %d", header.type ) stdnse.debug1("Missing decoder for %d", header.type )
return -1, ("Missing decoder for %d"):format(header.type) return -1, ("Missing decoder for %d"):format(header.type)
end end
return -1, "Decoding failed" return -1, "Decoding failed"
@@ -474,7 +474,7 @@ v3 =
-- result string containing an error message if login fails -- result string containing an error message if login fails
loginRequest = function ( socket, params, username, password, salt ) loginRequest = function ( socket, params, username, password, salt )
local catch = function() socket:close() stdnse.print_debug("loginRequest(): failed") end local catch = function() socket:close() stdnse.debug1("loginRequest(): failed") end
local try = nmap.new_try(catch) local try = nmap.new_try(catch)
local response, header = {}, {} local response, header = {}, {}
local status, data, len, tmp, _ local status, data, len, tmp, _
@@ -601,7 +601,7 @@ function printErrorMessage( dberror )
return return
end end
for k, v in pairs(dberror) do for k, v in pairs(dberror) do
stdnse.print_debug("%s=%s", k, v) stdnse.debug1("%s=%s", k, v)
end end
end end

View File

@@ -496,7 +496,7 @@ PPPoE = {
if ( PPPoE.TagDecoder[tag] ) then if ( PPPoE.TagDecoder[tag] ) then
pos, decoded = PPPoE.TagDecoder[tag](data, pos, len) pos, decoded = PPPoE.TagDecoder[tag](data, pos, len)
else else
stdnse.print_debug("PPPoE: Unsupported tag (%d)", tag) stdnse.debug1("PPPoE: Unsupported tag (%d)", tag)
pos = pos + len pos = pos + len
end end
local t = PPPoE.Tag:new(tag, raw) local t = PPPoE.Tag:new(tag, raw)

View File

@@ -100,7 +100,7 @@ function test_get(host, port, proxyType, test_url, hostname, pattern)
return false, socket return false, socket
end end
local req = "GET " .. test_url .. " HTTP/1.0\r\nHost: " .. hostname .. "\r\n\r\n" local req = "GET " .. test_url .. " HTTP/1.0\r\nHost: " .. hostname .. "\r\n\r\n"
stdnse.print_debug("GET Request: " .. req) stdnse.debug1("GET Request: " .. req)
return test(socket, req, pattern) return test(socket, req, pattern)
end end
@@ -118,7 +118,7 @@ function test_head(host, port, proxyType, test_url, hostname, pattern)
return false, socket return false, socket
end end
local req = "HEAD " .. test_url .. " HTTP/1.0\r\nHost: " .. hostname .. "\r\n\r\n" local req = "HEAD " .. test_url .. " HTTP/1.0\r\nHost: " .. hostname .. "\r\n\r\n"
stdnse.print_debug("HEAD Request: " .. req) stdnse.debug1("HEAD Request: " .. req)
return test(socket, req, pattern) return test(socket, req, pattern)
end end
@@ -134,7 +134,7 @@ function test_connect(host, port, proxyType, hostname)
return false, socket return false, socket
end end
local req = "CONNECT " .. hostname .. ":80 HTTP/1.0\r\n\r\n" local req = "CONNECT " .. hostname .. ":80 HTTP/1.0\r\n\r\n"
stdnse.print_debug("CONNECT Request: " .. req) stdnse.debug1("CONNECT Request: " .. req)
return test(socket, req, false) return test(socket, req, false)
end end
@@ -262,7 +262,7 @@ function socksHandshake(socket, version, hostname)
err = "Authentication Required" err = "Authentication Required"
else else
-- If no Auth is required, try to establish connection -- If no Auth is required, try to establish connection
stdnse.print_debug("Socks5: No authentication required") stdnse.debug1("Socks5: No authentication required")
-- Socks5 second payload: Version, Command, Null, Address type, Ip-Address, Port number -- Socks5 second payload: Version, Command, Null, Address type, Ip-Address, Port number
paystring = '05 01 00 01 ' .. sip .. '00 50' paystring = '05 01 00 01 ' .. sip .. '00 50'
payload = bin.pack("H",paystring) payload = bin.pack("H",paystring)

View File

@@ -326,7 +326,7 @@ Comm = {
local pos, itut_code = bin.unpack("C", data, 6) local pos, itut_code = bin.unpack("C", data, 6)
if ( itut_code == 0xD0 ) then if ( itut_code == 0xD0 ) then
stdnse.print_debug(2, "RDP: Received ConnectionConfirm response") stdnse.debug2("RDP: Received ConnectionConfirm response")
return true, Response.ConnectionConfirm.parse(data) return true, Response.ConnectionConfirm.parse(data)
elseif ( itut_code == 0xF0 ) then elseif ( itut_code == 0xF0 ) then
return true, Response.MCSConnectResponse.parse(data) return true, Response.MCSConnectResponse.parse(data)

View File

@@ -53,7 +53,7 @@ _ENV = stdnse.module("rmi", stdnse.seeall)
local function dbg(str,...) local function dbg(str,...)
local arg={...} local arg={...}
stdnse.print_debug(3,"RMI:"..str, table.unpack(arg)) stdnse.debug3("RMI:"..str, table.unpack(arg))
end end
-- Convenience function to both print an error message and return <false, msg> -- Convenience function to both print an error message and return <false, msg>
-- Example usage : -- Example usage :
@@ -62,7 +62,7 @@ end
-- end -- end
local function doh(str,...) local function doh(str,...)
local arg={...} local arg={...}
stdnse.print_debug("RMI-ERR:"..tostring(str), table.unpack(arg)) stdnse.debug1("RMI-ERR:"..tostring(str), table.unpack(arg))
return false, str return false, str
end end

View File

@@ -367,7 +367,7 @@ Comm = {
local tmp local tmp
status, tmp = self:GetAdditionalBytes( data, pos, HEADER_LEN - ( data:len() - pos ) ) status, tmp = self:GetAdditionalBytes( data, pos, HEADER_LEN - ( data:len() - pos ) )
if not status then if not status then
stdnse.print_debug(4, stdnse.debug4(
string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes")) string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes"))
return -1, nil return -1, nil
end end
@@ -387,7 +387,7 @@ Comm = {
if header.verifier.length - 8 > 0 then if header.verifier.length - 8 > 0 then
status, data = self:GetAdditionalBytes( data, pos, header.verifier.length - 8 ) status, data = self:GetAdditionalBytes( data, pos, header.verifier.length - 8 )
if not status then if not status then
stdnse.print_debug(4, stdnse.debug4(
string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes")) string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes"))
return -1, nil return -1, nil
end end
@@ -1365,10 +1365,10 @@ NFS = {
CheckStat = function (self, procedurename, version, status) CheckStat = function (self, procedurename, version, status)
if (status ~= NFS.StatCode[version].NFS_OK) then if (status ~= NFS.StatCode[version].NFS_OK) then
if (NFS.StatMsg[status]) then if (NFS.StatMsg[status]) then
stdnse.print_debug(4, stdnse.debug4(
string.format("%s failed: %s", procedurename, NFS.StatMsg[status])) string.format("%s failed: %s", procedurename, NFS.StatMsg[status]))
else else
stdnse.print_debug(4, stdnse.debug4(
string.format("%s failed: code %d", procedurename, status)) string.format("%s failed: code %d", procedurename, status))
end end
@@ -1438,7 +1438,7 @@ NFS = {
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1452,7 +1452,7 @@ NFS = {
response.attributes = {} response.attributes = {}
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1462,7 +1462,7 @@ NFS = {
end end
status, data = comm:GetAdditionalBytes( data, pos, 84 ) status, data = comm:GetAdditionalBytes( data, pos, 84 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, attrib = Util.unmarshall_nfsattr(data, pos, comm.version) pos, attrib = Util.unmarshall_nfsattr(data, pos, comm.version)
@@ -1470,7 +1470,7 @@ NFS = {
-- opaque data -- opaque data
status, data = comm:GetAdditionalBytes( data, pos, 8 ) status, data = comm:GetAdditionalBytes( data, pos, 8 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, _ = bin.unpack(">L", data, pos) pos, _ = bin.unpack(">L", data, pos)
@@ -1481,7 +1481,7 @@ NFS = {
local entry = {} local entry = {}
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1493,14 +1493,14 @@ NFS = {
if ( 3 == comm.version ) then if ( 3 == comm.version ) then
status, data = comm:GetAdditionalBytes( data, pos, 8 ) status, data = comm:GetAdditionalBytes( data, pos, 8 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.fileid = Util.unmarshall_uint64(data, pos ) pos, entry.fileid = Util.unmarshall_uint64(data, pos )
else else
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.fileid = Util.unmarshall_uint32(data, pos) pos, entry.fileid = Util.unmarshall_uint32(data, pos)
@@ -1508,14 +1508,14 @@ NFS = {
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.length = Util.unmarshall_uint32(data, pos) pos, entry.length = Util.unmarshall_uint32(data, pos)
status, data = comm:GetAdditionalBytes( data, pos, entry.length ) status, data = comm:GetAdditionalBytes( data, pos, entry.length )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1523,14 +1523,14 @@ NFS = {
if ( 3 == comm.version ) then if ( 3 == comm.version ) then
status, data = comm:GetAdditionalBytes( data, pos, 8 ) status, data = comm:GetAdditionalBytes( data, pos, 8 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.cookie = Util.unmarshall_uint64(data, pos) pos, entry.cookie = Util.unmarshall_uint64(data, pos)
else else
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.cookie = Util.unmarshall_uint32(data, pos) pos, entry.cookie = Util.unmarshall_uint32(data, pos)
@@ -1590,7 +1590,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1602,20 +1602,20 @@ NFS = {
if (comm.version == 3) then if (comm.version == 3) then
status, data = comm:GetAdditionalBytes( data, pos, 4) status, data = comm:GetAdditionalBytes( data, pos, 4)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
_, len = Util.unmarshall_uint32(data, pos) _, len = Util.unmarshall_uint32(data, pos)
status, data = comm:GetAdditionalBytes( data, pos, len + 4) status, data = comm:GetAdditionalBytes( data, pos, len + 4)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, lookup.fhandle = bin.unpack( "A" .. len + 4, data, pos) pos, lookup.fhandle = bin.unpack( "A" .. len + 4, data, pos)
status, data = comm:GetAdditionalBytes( data, pos, 4) status, data = comm:GetAdditionalBytes( data, pos, 4)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1624,17 +1624,17 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, lookup.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, lookup.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.LookUpDecode: File Attributes follow failed") stdnse.debug4("NFS.LookUpDecode: File Attributes follow failed")
end end
status, data = comm:GetAdditionalBytes( data, pos, 4) status, data = comm:GetAdditionalBytes( data, pos, 4)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1643,30 +1643,30 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, lookup.dir_attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, lookup.dir_attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.LookUpDecode: File Attributes follow failed") stdnse.debug4("NFS.LookUpDecode: File Attributes follow failed")
end end
elseif (comm.version < 3) then elseif (comm.version < 3) then
status, data = comm:GetAdditionalBytes( data, pos, 32) status, data = comm:GetAdditionalBytes( data, pos, 32)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, lookup.fhandle = bin.unpack("A32", data, pos) pos, lookup.fhandle = bin.unpack("A32", data, pos)
status, data = comm:GetAdditionalBytes( data, pos, 64 ) status, data = comm:GetAdditionalBytes( data, pos, 64 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, lookup.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, lookup.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug("NFS.LookUpDecode: NFS unsupported version %d", comm.version) stdnse.debug1("NFS.LookUpDecode: NFS unsupported version %d", comm.version)
return -1, nil return -1, nil
end end
@@ -1711,7 +1711,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1722,19 +1722,19 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, value_follows = bin.unpack(">I", data, pos) pos, value_follows = bin.unpack(">I", data, pos)
if value_follows == 0 then if value_follows == 0 then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Attributes follow failed") stdnse.debug4("NFS.ReadDirPlusDecode: Attributes follow failed")
return -1, nil return -1, nil
end end
status, data = comm:GetAdditionalBytes( data, pos, 84 ) status, data = comm:GetAdditionalBytes( data, pos, 84 )
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1743,7 +1743,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 8) status, data = comm:GetAdditionalBytes(data, pos, 8)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, _ = bin.unpack(">L", data, pos) pos, _ = bin.unpack(">L", data, pos)
@@ -1753,7 +1753,7 @@ NFS = {
local entry, len = {} local entry, len = {}
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1764,7 +1764,7 @@ NFS = {
end end
status, data = comm:GetAdditionalBytes(data, pos, 8) status, data = comm:GetAdditionalBytes(data, pos, 8)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.fileid = bin.unpack(">L", data, pos) pos, entry.fileid = bin.unpack(">L", data, pos)
@@ -1772,27 +1772,27 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.length = bin.unpack(">I", data, pos) pos, entry.length = bin.unpack(">I", data, pos)
status, data = comm:GetAdditionalBytes( data, pos, entry.length ) status, data = comm:GetAdditionalBytes( data, pos, entry.length )
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.name = Util.unmarshall_vopaque(entry.length, data, pos) pos, entry.name = Util.unmarshall_vopaque(entry.length, data, pos)
status, data = comm:GetAdditionalBytes(data, pos, 8) status, data = comm:GetAdditionalBytes(data, pos, 8)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.cookie = bin.unpack(">L", data, pos) pos, entry.cookie = bin.unpack(">L", data, pos)
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1801,18 +1801,18 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, entry.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: %s Attributes follow failed", stdnse.debug4("NFS.ReadDirPlusDecode: %s Attributes follow failed",
entry.name) entry.name)
end end
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1821,19 +1821,19 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
_, len = bin.unpack(">I", data, pos) _, len = bin.unpack(">I", data, pos)
status, data = comm:GetAdditionalBytes(data, pos, len + 4) status, data = comm:GetAdditionalBytes(data, pos, len + 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, entry.fhandle = bin.unpack( "A" .. len + 4, data, pos ) pos, entry.fhandle = bin.unpack( "A" .. len + 4, data, pos )
else else
stdnse.print_debug(4, "NFS.ReadDirPlusDecode: %s handle follow failed", stdnse.debug4("NFS.ReadDirPlusDecode: %s handle follow failed",
entry.name) entry.name)
end end
table.insert(response.entries, entry) table.insert(response.entries, entry)
@@ -1889,7 +1889,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1903,17 +1903,17 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if not status then if not status then
stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, fsstat.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, fsstat.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.FsStatDecode: Attributes follow failed") stdnse.debug4("NFS.FsStatDecode: Attributes follow failed")
end end
status, data = comm:GetAdditionalBytes( data, pos, 52) status, data = comm:GetAdditionalBytes( data, pos, 52)
if not status then if not status then
stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1968,7 +1968,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.FsInfoDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.FsInfoDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -1982,17 +1982,17 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if not status then if not status then
stdnse.print_debug(4, "NFS.FsInfoDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.FsInfoDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, fsinfo.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, fsinfo.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.FsInfoDecode: Attributes follow failed") stdnse.debug4("NFS.FsInfoDecode: Attributes follow failed")
end end
status, data = comm:GetAdditionalBytes(data, pos, 48) status, data = comm:GetAdditionalBytes(data, pos, 48)
if not status then if not status then
stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2050,7 +2050,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.PathConfDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.PathConfDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2064,17 +2064,17 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if not status then if not status then
stdnse.print_debug(4, "NFS.PathConfDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.PathConfDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, pconf.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, pconf.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.PathConfDecode: Attributes follow failed") stdnse.debug4("NFS.PathConfDecode: Attributes follow failed")
end end
status, data = comm:GetAdditionalBytes(data, pos, 24) status, data = comm:GetAdditionalBytes(data, pos, 24)
if not status then if not status then
stdnse.print_debug(4, "NFS.PathConfDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.PathConfDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2129,7 +2129,7 @@ NFS = {
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.AccessDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.AccessDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2143,17 +2143,17 @@ NFS = {
if (value_follows ~= 0) then if (value_follows ~= 0) then
status, data = comm:GetAdditionalBytes(data, pos, 84) status, data = comm:GetAdditionalBytes(data, pos, 84)
if not status then if not status then
stdnse.print_debug(4, "NFS.AccessDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.AccessDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, access.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) pos, access.attributes = Util.unmarshall_nfsattr(data, pos, comm.version)
else else
stdnse.print_debug(4, "NFS.AccessDecode: Attributes follow failed") stdnse.debug4("NFS.AccessDecode: Attributes follow failed")
end end
status, data = comm:GetAdditionalBytes(data, pos, 4) status, data = comm:GetAdditionalBytes(data, pos, 4)
if not status then if not status then
stdnse.print_debug(4, "NFS.AccessDecode: Failed to call GetAdditionalBytes") stdnse.debug4("NFS.AccessDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2267,7 +2267,7 @@ NFS = {
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "GetAttrDecode: Failed to call GetAdditionalBytes") stdnse.debug4("GetAttrDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2281,11 +2281,11 @@ NFS = {
elseif (comm.version == 3) then elseif (comm.version == 3) then
status, data = comm:GetAdditionalBytes( data, pos, 84 ) status, data = comm:GetAdditionalBytes( data, pos, 84 )
else else
stdnse.print_debug(4, "GetAttrDecode: Unsupported version") stdnse.debug4("GetAttrDecode: Unsupported version")
return -1, nil return -1, nil
end end
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "GetAttrDecode: Failed to call GetAdditionalBytes") stdnse.debug4("GetAttrDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
return Util.unmarshall_nfsattr(data, pos, comm.version) return Util.unmarshall_nfsattr(data, pos, comm.version)
@@ -2344,7 +2344,7 @@ NFS = {
status, data = comm:GetAdditionalBytes( data, pos, 4 ) status, data = comm:GetAdditionalBytes( data, pos, 4 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "StatFsDecode: Failed to call GetAdditionalBytes") stdnse.debug4("StatFsDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
@@ -2355,7 +2355,7 @@ NFS = {
status, data = comm:GetAdditionalBytes( data, pos, 20 ) status, data = comm:GetAdditionalBytes( data, pos, 20 )
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "StatFsDecode: Failed to call GetAdditionalBytes") stdnse.debug4("StatFsDecode: Failed to call GetAdditionalBytes")
return -1, nil return -1, nil
end end
pos, statfs.transfer_size, statfs.block_size, pos, statfs.transfer_size, statfs.block_size,
@@ -2383,20 +2383,20 @@ Helper = {
status, mountd = Helper.GetProgramInfo( host, port, "mountd") status, mountd = Helper.GetProgramInfo( host, port, "mountd")
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ShowMounts: GetProgramInfo failed") stdnse.debug4("rpc.Helper.ShowMounts: GetProgramInfo failed")
return status, "rpc.Helper.ShowMounts: GetProgramInfo failed" return status, "rpc.Helper.ShowMounts: GetProgramInfo failed"
end end
mnt_comm = Comm:new('mountd', mountd.version) mnt_comm = Comm:new('mountd', mountd.version)
status, result = mnt_comm:Connect(host, mountd.port) status, result = mnt_comm:Connect(host, mountd.port)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ShowMounts: %s", result) stdnse.debug4("rpc.Helper.ShowMounts: %s", result)
return false, result return false, result
end end
status, mounts = mnt:Export(mnt_comm) status, mounts = mnt:Export(mnt_comm)
mnt_comm:Disconnect() mnt_comm:Disconnect()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ShowMounts: %s", mounts) stdnse.debug4("rpc.Helper.ShowMounts: %s", mounts)
end end
return status, mounts return status, mounts
end, end,
@@ -2421,7 +2421,7 @@ Helper = {
status, mountd = Helper.GetProgramInfo( host, port, "mountd") status, mountd = Helper.GetProgramInfo( host, port, "mountd")
if not status then if not status then
stdnse.print_debug(4, "rpc.Helper.MountPath: GetProgramInfo failed") stdnse.debug4("rpc.Helper.MountPath: GetProgramInfo failed")
return nil, "rpc.Helper.MountPath: GetProgramInfo failed" return nil, "rpc.Helper.MountPath: GetProgramInfo failed"
end end
@@ -2429,14 +2429,14 @@ Helper = {
status, err = mnt_comm:Connect(host, mountd.port) status, err = mnt_comm:Connect(host, mountd.port)
if not status then if not status then
stdnse.print_debug(4, "rpc.Helper.MountPath: %s", err) stdnse.debug4("rpc.Helper.MountPath: %s", err)
return nil, err return nil, err
end end
status, fhandle = mnt:Mount(mnt_comm, path) status, fhandle = mnt:Mount(mnt_comm, path)
if not status then if not status then
mnt_comm:Disconnect() mnt_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.MountPath: %s", fhandle) stdnse.debug4("rpc.Helper.MountPath: %s", fhandle)
return nil, fhandle return nil, fhandle
end end
@@ -2459,7 +2459,7 @@ Helper = {
local status, ret = mnt:Unmount(mnt_comm, path) local status, ret = mnt:Unmount(mnt_comm, path)
mnt_comm:Disconnect() mnt_comm:Disconnect()
if not status then if not status then
stdnse.print_debug(4, "rpc.Helper.UnmountPath: %s", ret) stdnse.debug4("rpc.Helper.UnmountPath: %s", ret)
return nil, ret return nil, ret
end end
@@ -2482,14 +2482,14 @@ Helper = {
status, nfsd = Helper.GetProgramInfo(host, port, "nfs") status, nfsd = Helper.GetProgramInfo(host, port, "nfs")
if not status then if not status then
stdnse.print_debug(4, "rpc.Helper.NfsOpen: GetProgramInfo failed") stdnse.debug4("rpc.Helper.NfsOpen: GetProgramInfo failed")
return nil, "rpc.Helper.NfsOpen: GetProgramInfo failed" return nil, "rpc.Helper.NfsOpen: GetProgramInfo failed"
end end
nfs_comm = Comm:new('nfs', nfsd.version) nfs_comm = Comm:new('nfs', nfsd.version)
status, err = nfs_comm:Connect(host, nfsd.port) status, err = nfs_comm:Connect(host, nfsd.port)
if not status then if not status then
stdnse.print_debug(4, "rpc.Helper.NfsProc: %s", err) stdnse.debug4("rpc.Helper.NfsProc: %s", err)
return nil, err return nil, err
end end
@@ -2508,7 +2508,7 @@ Helper = {
NfsClose = function(nfs_comm) NfsClose = function(nfs_comm)
local status, ret = nfs_comm:Disconnect() local status, ret = nfs_comm:Disconnect()
if not status then if not status then
stdnse.print_debug(4, "rpc.Helper.NfsClose: %s", ret) stdnse.debug4("rpc.Helper.NfsClose: %s", ret)
return nil, ret return nil, ret
end end
@@ -2532,13 +2532,13 @@ Helper = {
status, mountd = Helper.GetProgramInfo( host, port, "mountd", 2) status, mountd = Helper.GetProgramInfo( host, port, "mountd", 2)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ExportStats: GetProgramInfo failed") stdnse.debug4("rpc.Helper.ExportStats: GetProgramInfo failed")
return status, "rpc.Helper.ExportStats: GetProgramInfo failed" return status, "rpc.Helper.ExportStats: GetProgramInfo failed"
end end
status, nfsd = Helper.GetProgramInfo( host, port, "nfs", 2) status, nfsd = Helper.GetProgramInfo( host, port, "nfs", 2)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ExportStats: GetProgramInfo failed") stdnse.debug4("rpc.Helper.ExportStats: GetProgramInfo failed")
return status, "rpc.Helper.ExportStats: GetProgramInfo failed" return status, "rpc.Helper.ExportStats: GetProgramInfo failed"
end end
mnt_comm = Comm:new('mountd', mountd.version) mnt_comm = Comm:new('mountd', mountd.version)
@@ -2546,20 +2546,20 @@ Helper = {
-- TODO: recheck the version mismatch when adding NFSv4 -- TODO: recheck the version mismatch when adding NFSv4
if (nfs_comm.version <= 2 and mnt_comm.version > 2) then if (nfs_comm.version <= 2 and mnt_comm.version > 2) then
stdnse.print_debug(4,"rpc.Helper.ExportStats: versions mismatch, nfs v%d - mount v%d", stdnse.debug4("rpc.Helper.ExportStats: versions mismatch, nfs v%d - mount v%d",
nfs_comm.version, mnt_comm.version) nfs_comm.version, mnt_comm.version)
return false, string.format("versions mismatch, nfs v%d - mount v%d", return false, string.format("versions mismatch, nfs v%d - mount v%d",
nfs_comm.version, mnt_comm.version) nfs_comm.version, mnt_comm.version)
end end
status, result = mnt_comm:Connect(host, mountd.port) status, result = mnt_comm:Connect(host, mountd.port)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", result) stdnse.debug4("rpc.Helper.ExportStats: %s", result)
return status, result return status, result
end end
status, result = nfs_comm:Connect(host, nfsd.port) status, result = nfs_comm:Connect(host, nfsd.port)
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", result) stdnse.debug4("rpc.Helper.ExportStats: %s", result)
return status, result return status, result
end end
@@ -2567,14 +2567,14 @@ Helper = {
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", fhandle) stdnse.debug4("rpc.Helper.ExportStats: %s", fhandle)
return status, fhandle return status, fhandle
end end
status, stats = nfs:StatFs(nfs_comm, fhandle) status, stats = nfs:StatFs(nfs_comm, fhandle)
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", stats) stdnse.debug4("rpc.Helper.ExportStats: %s", stats)
return status, stats return status, stats
end end
@@ -2582,7 +2582,7 @@ Helper = {
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", fhandle) stdnse.debug4("rpc.Helper.ExportStats: %s", fhandle)
return status, fhandle return status, fhandle
end end
return true, stats return true, stats
@@ -2604,13 +2604,13 @@ Helper = {
status, mountd = Helper.GetProgramInfo( host, port, "mountd") status, mountd = Helper.GetProgramInfo( host, port, "mountd")
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.Dir: GetProgramInfo failed") stdnse.debug4("rpc.Helper.Dir: GetProgramInfo failed")
return status, "rpc.Helper.Dir: GetProgramInfo failed" return status, "rpc.Helper.Dir: GetProgramInfo failed"
end end
status, nfsd = Helper.GetProgramInfo( host, port, "nfs") status, nfsd = Helper.GetProgramInfo( host, port, "nfs")
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.Dir: GetProgramInfo failed") stdnse.debug4("rpc.Helper.Dir: GetProgramInfo failed")
return status, "rpc.Helper.Dir: GetProgramInfo failed" return status, "rpc.Helper.Dir: GetProgramInfo failed"
end end
@@ -2619,21 +2619,21 @@ Helper = {
-- TODO: recheck the version mismatch when adding NFSv4 -- TODO: recheck the version mismatch when adding NFSv4
if (nfs_comm.version <= 2 and mnt_comm.version > 2) then if (nfs_comm.version <= 2 and mnt_comm.version > 2) then
stdnse.print_debug(4, "rpc.Helper.Dir: versions mismatch, nfs v%d - mount v%d", stdnse.debug4("rpc.Helper.Dir: versions mismatch, nfs v%d - mount v%d",
nfs_comm.version, mnt_comm.version) nfs_comm.version, mnt_comm.version)
return false, string.format("versions mismatch, nfs v%d - mount v%d", return false, string.format("versions mismatch, nfs v%d - mount v%d",
nfs_comm.version, mnt_comm.version) nfs_comm.version, mnt_comm.version)
end end
status, result = mnt_comm:Connect(host, mountd.port) status, result = mnt_comm:Connect(host, mountd.port)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.Dir: %s", result) stdnse.debug4("rpc.Helper.Dir: %s", result)
return status, result return status, result
end end
status, result = nfs_comm:Connect(host, nfsd.port) status, result = nfs_comm:Connect(host, nfsd.port)
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.Dir: %s", result) stdnse.debug4("rpc.Helper.Dir: %s", result)
return status, result return status, result
end end
@@ -2641,7 +2641,7 @@ Helper = {
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.Dir: %s", fhandle) stdnse.debug4("rpc.Helper.Dir: %s", fhandle)
return status, fhandle return status, fhandle
end end
@@ -2649,7 +2649,7 @@ Helper = {
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.Dir: %s", dirs) stdnse.debug4("rpc.Helper.Dir: %s", dirs)
return status, dirs return status, dirs
end end
@@ -2657,7 +2657,7 @@ Helper = {
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.Dir: %s", fhandle) stdnse.debug4("rpc.Helper.Dir: %s", fhandle)
return status, fhandle return status, fhandle
end end
return true, dirs return true, dirs
@@ -2680,13 +2680,13 @@ Helper = {
status, mountd = Helper.GetProgramInfo( host, port, "mountd") status, mountd = Helper.GetProgramInfo( host, port, "mountd")
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.GetAttributes: GetProgramInfo failed") stdnse.debug4("rpc.Helper.GetAttributes: GetProgramInfo failed")
return status, "rpc.Helper.GetAttributes: GetProgramInfo failed" return status, "rpc.Helper.GetAttributes: GetProgramInfo failed"
end end
status, nfsd = Helper.GetProgramInfo( host, port, "nfs") status, nfsd = Helper.GetProgramInfo( host, port, "nfs")
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.GetAttributes: GetProgramInfo failed") stdnse.debug4("rpc.Helper.GetAttributes: GetProgramInfo failed")
return status, "rpc.Helper.GetAttributes: GetProgramInfo failed" return status, "rpc.Helper.GetAttributes: GetProgramInfo failed"
end end
@@ -2695,7 +2695,7 @@ Helper = {
-- TODO: recheck the version mismatch when adding NFSv4 -- TODO: recheck the version mismatch when adding NFSv4
if (nfs_comm.version <= 2 and mnt_comm.version > 2) then if (nfs_comm.version <= 2 and mnt_comm.version > 2) then
stdnse.print_debug(4, "rpc.Helper.GetAttributes: versions mismatch, nfs v%d - mount v%d", stdnse.debug4("rpc.Helper.GetAttributes: versions mismatch, nfs v%d - mount v%d",
nfs_comm.version, mnt_comm.version) nfs_comm.version, mnt_comm.version)
return false, string.format("versions mismatch, nfs v%d - mount v%d", return false, string.format("versions mismatch, nfs v%d - mount v%d",
nfs_comm.version, mnt_comm.version) nfs_comm.version, mnt_comm.version)
@@ -2703,14 +2703,14 @@ Helper = {
status, result = mnt_comm:Connect(host, mountd.port) status, result = mnt_comm:Connect(host, mountd.port)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", result) stdnse.debug4("rpc.Helper.GetAttributes: %s", result)
return status, result return status, result
end end
status, result = nfs_comm:Connect(host, nfsd.port) status, result = nfs_comm:Connect(host, nfsd.port)
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", result) stdnse.debug4("rpc.Helper.GetAttributes: %s", result)
return status, result return status, result
end end
@@ -2718,7 +2718,7 @@ Helper = {
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", fhandle) stdnse.debug4("rpc.Helper.GetAttributes: %s", fhandle)
return status, fhandle return status, fhandle
end end
@@ -2726,7 +2726,7 @@ Helper = {
if ( not(status) ) then if ( not(status) ) then
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", attribs) stdnse.debug4("rpc.Helper.GetAttributes: %s", attribs)
return status, attribs return status, attribs
end end
@@ -2735,7 +2735,7 @@ Helper = {
mnt_comm:Disconnect() mnt_comm:Disconnect()
nfs_comm:Disconnect() nfs_comm:Disconnect()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", fhandle) stdnse.debug4("rpc.Helper.GetAttributes: %s", fhandle)
return status, fhandle return status, fhandle
end end
@@ -2769,7 +2769,7 @@ Helper = {
status, result = comm:Connect(host, port) status, result = comm:Connect(host, port)
if (not(status)) then if (not(status)) then
mutex "done" mutex "done"
stdnse.print_debug(4, "rpc.Helper.RpcInfo: %s", result) stdnse.debug4("rpc.Helper.RpcInfo: %s", result)
return status, result return status, result
end end
@@ -2778,7 +2778,7 @@ Helper = {
mutex "done" mutex "done"
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "rpc.Helper.RpcInfo: %s", result) stdnse.debug4("rpc.Helper.RpcInfo: %s", result)
end end
return status, result return status, result
@@ -2800,14 +2800,14 @@ Helper = {
status, result = comm:Connect(host, port) status, result = comm:Connect(host, port)
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "rpc.Helper.GetPortForProgram: %s", result) stdnse.debug4("rpc.Helper.GetPortForProgram: %s", result)
return status, result return status, result
end end
status, result = portmap:GetPort(comm, program, protocol, 1 ) status, result = portmap:GetPort(comm, program, protocol, 1 )
comm:Disconnect() comm:Disconnect()
if (not(status)) then if (not(status)) then
stdnse.print_debug(4, "rpc.Helper.GetPortForProgram: %s", result) stdnse.debug4("rpc.Helper.GetPortForProgram: %s", result)
end end
return status, result return status, result
@@ -2942,7 +2942,7 @@ Util =
if Util.FileType[code] then if Util.FileType[code] then
return Util.FileType[code].char return Util.FileType[code].char
else else
stdnse.print_debug(1,"FtypeToChar: Unknown file type, mode: %o", mode) stdnse.debug1("FtypeToChar: Unknown file type, mode: %o", mode)
return "" return ""
end end
end, end,
@@ -2956,7 +2956,7 @@ Util =
if Util.FileType[code] then if Util.FileType[code] then
return Util.FileType[code].str return Util.FileType[code].str
else else
stdnse.print_debug(1,"FtypeToString: Unknown file type, mode: %o", mode) stdnse.debug1("FtypeToString: Unknown file type, mode: %o", mode)
return "" return ""
end end
end, end,
@@ -2972,7 +2972,7 @@ Util =
code = bit.bxor(mode, code) code = bit.bxor(mode, code)
else else
code = mode code = mode
stdnse.print_debug(1,"FmodeToOctalString: Unknown file type, mode: %o", mode) stdnse.debug1("FmodeToOctalString: Unknown file type, mode: %o", mode)
end end
return stdnse.tooctal(code) return stdnse.tooctal(code)
end, end,
@@ -3178,7 +3178,7 @@ Util =
pos, attr.fsid = Util.unmarshall_uint64(data, pos) pos, attr.fsid = Util.unmarshall_uint64(data, pos)
pos, attr.fileid = Util.unmarshall_nfsfileid3(data, pos) pos, attr.fileid = Util.unmarshall_nfsfileid3(data, pos)
else else
stdnse.print_debug(4, "unmarshall_nfsattr: unsupported NFS version %d", stdnse.debug4("unmarshall_nfsattr: unsupported NFS version %d",
nfsversion) nfsversion)
return -1, nil return -1, nil
end end

View File

@@ -169,7 +169,7 @@ Client = {
self.socket:set_timeout(self.timeout) self.socket:set_timeout(self.timeout)
local status = self.socket:connect(self.host, self.port) local status = self.socket:connect(self.host, self.port)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(2, "Failed to connect to the server: %s", self.host.ip) stdnse.debug2("Failed to connect to the server: %s", self.host.ip)
return false, ("Failed to connect to the server: %s"):format(self.host.ip) return false, ("Failed to connect to the server: %s"):format(self.host.ip)
end end
return true return true
@@ -210,7 +210,7 @@ Client = {
-- check if send was successful, in case it wasn't AND -- check if send was successful, in case it wasn't AND
-- this is our last retry, ABORT -- this is our last retry, ABORT
if ( not(status) and 0 == retries - 1 ) then if ( not(status) and 0 == retries - 1 ) then
stdnse.print_debug(2, "Failed to send request to server (%s)", err) stdnse.debug2("Failed to send request to server (%s)", err)
return false, ("Failed to send request to server (%s)"):format(err) return false, ("Failed to send request to server (%s)"):format(err)
-- if send was successful, attempt to receive the response -- if send was successful, attempt to receive the response
elseif ( status ) then elseif ( status ) then
@@ -224,7 +224,7 @@ Client = {
local status, err = self:connect() local status, err = self:connect()
-- if re-connect fails, BAIL out of here -- if re-connect fails, BAIL out of here
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(2, "Failed to reconnect socket to server (%s)", err) stdnse.debug2("Failed to reconnect socket to server (%s)", err)
return false, ("Failed to reconnect socket to server (%s)"):format(err) return false, ("Failed to reconnect socket to server (%s)"):format(err)
end end
end end
@@ -232,7 +232,7 @@ Client = {
until( status or retries == 0 ) until( status or retries == 0 )
if( not(status) ) then if( not(status) ) then
stdnse.print_debug(2, "Failed to receive response from server (%s)", data) stdnse.debug2("Failed to receive response from server (%s)", data)
return false, ("Failed to receive response from server (%s)"):format(data) return false, ("Failed to receive response from server (%s)"):format(data)
end end

View File

@@ -51,7 +51,7 @@ _ENV = stdnse.module("sasl", stdnse.seeall)
local HAVE_SSL, openssl = pcall(require, 'openssl') local HAVE_SSL, openssl = pcall(require, 'openssl')
if ( not(HAVE_SSL) ) then if ( not(HAVE_SSL) ) then
stdnse.print_debug(1, stdnse.debug1(
"sasl.lua: OpenSSL not present, SASL support limited.") "sasl.lua: OpenSSL not present, SASL support limited.")
end end
local MECHANISMS = { } local MECHANISMS = { }
@@ -348,7 +348,7 @@ function check_mechanism(mechanism)
lmech = mechanism lmech = mechanism
lcallback = MECHANISMS[mechanism] lcallback = MECHANISMS[mechanism]
else else
stdnse.print_debug(3, stdnse.debug3(
"sasl library does not support '%s' mechanism", mechanism) "sasl library does not support '%s' mechanism", mechanism)
end end
end end

View File

@@ -291,12 +291,12 @@ function start(host)
state['name'] = result state['name'] = result
end end
else else
stdnse.print_debug(2, "SMB: Resolved netbios name from cache") stdnse.debug2("SMB: Resolved netbios name from cache")
state['name'] = host.registry['netbios_name'] state['name'] = host.registry['netbios_name']
end end
nbcache_mutex "done" nbcache_mutex "done"
stdnse.print_debug(2, "SMB: Starting SMB session for %s (%s)", host.name, host.ip) stdnse.debug2("SMB: Starting SMB session for %s (%s)", host.name, host.ip)
if(port == nil) then if(port == nil) then
return false, "SMB: Couldn't find a valid port to check" return false, "SMB: Couldn't find a valid port to check"
@@ -426,7 +426,7 @@ function stop(smb)
logoff(smb) logoff(smb)
end end
stdnse.print_debug(2, "SMB: Closing socket") stdnse.debug2("SMB: Closing socket")
if(smb['socket'] ~= nil) then if(smb['socket'] ~= nil) then
local status, err = smb['socket']:close() local status, err = smb['socket']:close()
@@ -548,7 +548,7 @@ function start_netbios(host, port, name)
name = names[i] name = names[i]
-- Some debug information -- Some debug information
stdnse.print_debug(1, "SMB: Trying to start NetBIOS session with name = '%s'", name) stdnse.debug1("SMB: Trying to start NetBIOS session with name = '%s'", name)
-- Request a NetBIOS session -- Request a NetBIOS session
local session_request = bin.pack(">CCSzz", local session_request = bin.pack(">CCSzz",
0x81, -- session request 0x81, -- session request
@@ -558,7 +558,7 @@ function start_netbios(host, port, name)
netbios.name_encode("NMAP") -- client name netbios.name_encode("NMAP") -- client name
); );
stdnse.print_debug(3, "SMB: Connecting to %s", host.ip) stdnse.debug3("SMB: Connecting to %s", host.ip)
socket:set_timeout(TIMEOUT) socket:set_timeout(TIMEOUT)
status, err = socket:connect(host, port, "tcp") status, err = socket:connect(host, port, "tcp")
if(status == false) then if(status == false) then
@@ -567,7 +567,7 @@ function start_netbios(host, port, name)
end end
-- Send the session request -- Send the session request
stdnse.print_debug(3, "SMB: Sending NetBIOS session request with name %s", name) stdnse.debug3("SMB: Sending NetBIOS session request with name %s", name)
status, err = socket:send(session_request) status, err = socket:send(session_request)
if(status == false) then if(status == false) then
socket:close() socket:close()
@@ -576,7 +576,7 @@ function start_netbios(host, port, name)
socket:set_timeout(TIMEOUT) socket:set_timeout(TIMEOUT)
-- Receive the session response -- Receive the session response
stdnse.print_debug(3, "SMB: Receiving NetBIOS session response") stdnse.debug3("SMB: Receiving NetBIOS session response")
status, result = socket:receive_buf(match.numbytes(4), true); status, result = socket:receive_buf(match.numbytes(4), true);
if(status == false) then if(status == false) then
socket:close() socket:close()
@@ -589,12 +589,12 @@ function start_netbios(host, port, name)
-- Check for a positive session response (0x82) -- Check for a positive session response (0x82)
if result == 0x82 then if result == 0x82 then
stdnse.print_debug(3, "SMB: Successfully established NetBIOS session with server name %s", name) stdnse.debug3("SMB: Successfully established NetBIOS session with server name %s", name)
return true, socket return true, socket
end end
-- If the session failed, close the socket and try the next name -- If the session failed, close the socket and try the next name
stdnse.print_debug(1, "SMB: Session request failed, trying next name") stdnse.debug1("SMB: Session request failed, trying next name")
socket:close() socket:close()
-- Try the next name -- Try the next name
@@ -603,7 +603,7 @@ function start_netbios(host, port, name)
until i > #names until i > #names
-- We reached the end of our names list -- We reached the end of our names list
stdnse.print_debug(1, "SMB: None of the NetBIOS names worked!") stdnse.debug1("SMB: None of the NetBIOS names worked!")
return false, "SMB: Couldn't find a NetBIOS name that works for the server. Sorry!" return false, "SMB: Couldn't find a NetBIOS name that works for the server. Sorry!"
end end
@@ -734,10 +734,10 @@ local function message_sign(smb, body)
smb['sequence'] = smb['sequence'] + 1 smb['sequence'] = smb['sequence'] + 1
if(smb['mac_key'] == nil) then if(smb['mac_key'] == nil) then
stdnse.print_debug(3, "SMB: Not signing message (missing mac_key)") stdnse.debug3("SMB: Not signing message (missing mac_key)")
return body return body
elseif(nmap.registry.args.smbsign == "disable") then elseif(nmap.registry.args.smbsign == "disable") then
stdnse.print_debug(3, "SMB: Not signing message (disabled by user)") stdnse.debug3("SMB: Not signing message (disabled by user)")
return body return body
end end
@@ -763,13 +763,13 @@ local function message_check_signature(smb, body)
smb['sequence'] = smb['sequence'] + 1 smb['sequence'] = smb['sequence'] + 1
if(smb['mac_key'] == nil) then if(smb['mac_key'] == nil) then
stdnse.print_debug(3, "SMB: Not signing message (missing mac_key)") stdnse.debug3("SMB: Not signing message (missing mac_key)")
return true return true
elseif(nmap.registry.args.smbsign ~= "force" and bit.band(smb['security_mode'], 0x0A) ~= 0) then elseif(nmap.registry.args.smbsign ~= "force" and bit.band(smb['security_mode'], 0x0A) ~= 0) then
stdnse.print_debug(3, "SMB: Not signing message (server doesn't support it -- default)") stdnse.debug3("SMB: Not signing message (server doesn't support it -- default)")
return true return true
elseif(nmap.registry.args.smbsign == "disable" or nmap.registry.args.smbsign == "ignore") then elseif(nmap.registry.args.smbsign == "disable" or nmap.registry.args.smbsign == "ignore") then
stdnse.print_debug(3, "SMB: Not signing message (disabled by user)") stdnse.debug3("SMB: Not signing message (disabled by user)")
return true return true
end end
@@ -818,12 +818,12 @@ function smb_send(smb, header, parameters, data, overrides)
repeat repeat
attempts = attempts - 1 attempts = attempts - 1
stdnse.print_debug(3, "SMB: Sending SMB packet (len: %d, attempts remaining: %d)", #out, attempts) stdnse.debug3("SMB: Sending SMB packet (len: %d, attempts remaining: %d)", #out, attempts)
status, err = smb['socket']:send(out) status, err = smb['socket']:send(out)
until(status or (attempts == 0)) until(status or (attempts == 0))
if(attempts == 0) then if(attempts == 0) then
stdnse.print_debug(1, "SMB: Sending packet failed after 5 tries! Giving up.") stdnse.debug1("SMB: Sending packet failed after 5 tries! Giving up.")
end end
return status, err return status, err
@@ -845,7 +845,7 @@ function smb_read(smb, read_data)
local pos, netbios_data, netbios_length, length, header, parameter_length, parameters, data_length, data local pos, netbios_data, netbios_length, length, header, parameter_length, parameters, data_length, data
local attempts = 5 local attempts = 5
stdnse.print_debug(3, "SMB: Receiving SMB packet") stdnse.debug3("SMB: Receiving SMB packet")
-- Receive the response -- we make sure to receive at least 4 bytes, the length of the NetBIOS length -- Receive the response -- we make sure to receive at least 4 bytes, the length of the NetBIOS length
smb['socket']:set_timeout(TIMEOUT) smb['socket']:set_timeout(TIMEOUT)
@@ -857,7 +857,7 @@ function smb_read(smb, read_data)
status, netbios_data = smb['socket']:receive_buf(match.numbytes(4), true); status, netbios_data = smb['socket']:receive_buf(match.numbytes(4), true);
if ( not(status) and netbios_data == "EOF" ) then if ( not(status) and netbios_data == "EOF" ) then
stdnse.print_debug(1, "SMB: ERROR: Server disconnected the connection") stdnse.debug1("SMB: ERROR: Server disconnected the connection")
return false, "SMB: ERROR: Server disconnected the connection" return false, "SMB: ERROR: Server disconnected the connection"
end end
until(status or (attempts == 0)) until(status or (attempts == 0))
@@ -893,7 +893,7 @@ function smb_read(smb, read_data)
local result = netbios_data .. smb_data local result = netbios_data .. smb_data
if(#result ~= length) then if(#result ~= length) then
stdnse.print_debug(1, "SMB: ERROR: Received wrong number of bytes, there will likely be issues (received %d, expected %d)", #result, length) stdnse.debug1("SMB: ERROR: Received wrong number of bytes, there will likely be issues (received %d, expected %d)", #result, length)
return false, string.format("SMB: ERROR: Didn't receive the expected number of bytes; received %d, expected %d. This will almost certainly cause some errors.", #result, length) return false, string.format("SMB: ERROR: Didn't receive the expected number of bytes; received %d, expected %d. This will almost certainly cause some errors.", #result, length)
end end
@@ -937,7 +937,7 @@ function smb_read(smb, read_data)
data = nil data = nil
end end
stdnse.print_debug(3, "SMB: Received %d bytes", #result) stdnse.debug3("SMB: Received %d bytes", #result)
return true, header, parameters, data return true, header, parameters, data
end end
@@ -998,7 +998,7 @@ function negotiate_protocol(smb, overrides)
end end
-- Send the negotiate request -- Send the negotiate request
stdnse.print_debug(2, "SMB: Sending SMB_COM_NEGOTIATE") stdnse.debug2("SMB: Sending SMB_COM_NEGOTIATE")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(status == false) then if(status == false) then
return false, err return false, err
@@ -1179,7 +1179,7 @@ local function start_session_basic(smb, log_errors, overrides)
) )
-- Send the session setup request -- Send the session setup request
stdnse.print_debug(2, "SMB: Sending SMB_COM_SESSION_SETUP_ANDX") stdnse.debug2("SMB: Sending SMB_COM_SESSION_SETUP_ANDX")
result, err = smb_send(smb, header, parameters, data, overrides) result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -1221,17 +1221,17 @@ local function start_session_basic(smb, log_errors, overrides)
-- Check if they're using an un-supported system -- Check if they're using an un-supported system
if(os == nil or lanmanager == nil or domain == nil) then if(os == nil or lanmanager == nil or domain == nil) then
stdnse.print_debug(1, "SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip']) stdnse.debug1("SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip'])
elseif(os == "Unix" or string.sub(lanmanager, 1, 5) == "Samba") then elseif(os == "Unix" or string.sub(lanmanager, 1, 5) == "Samba") then
stdnse.print_debug(1, "SMB: WARNING: the server appears to be Unix; your mileage may vary.") stdnse.debug1("SMB: WARNING: the server appears to be Unix; your mileage may vary.")
end end
-- Check if they were logged in as a guest -- Check if they were logged in as a guest
if(log_errors == nil or log_errors == true) then if(log_errors == nil or log_errors == true) then
if(smb['is_guest'] == 1) then if(smb['is_guest'] == 1) then
stdnse.print_debug(1, "SMB: Login as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", domain, stdnse.string_or_blank(username)) stdnse.debug1("SMB: Login as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", domain, stdnse.string_or_blank(username))
else else
stdnse.print_debug(2, "SMB: Login as %s\\%s succeeded", domain, stdnse.string_or_blank(username)) stdnse.debug2("SMB: Login as %s\\%s succeeded", domain, stdnse.string_or_blank(username))
end end
end end
@@ -1250,12 +1250,12 @@ local function start_session_basic(smb, log_errors, overrides)
end end
local backoff = math.random() * 10 local backoff = math.random() * 10
stdnse.print_debug(1, "SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100) stdnse.debug1("SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100)
stdnse.sleep(backoff) stdnse.sleep(backoff)
else else
-- This username failed, print a warning and keep going -- This username failed, print a warning and keep going
if(log_errors == nil or log_errors == true) then if(log_errors == nil or log_errors == true) then
stdnse.print_debug(1, "SMB: Login as %s\\%s failed (%s)", domain, stdnse.string_or_blank(username), get_status_name(status)) stdnse.debug1("SMB: Login as %s\\%s failed (%s)", domain, stdnse.string_or_blank(username), get_status_name(status))
end end
-- Go to the next account -- Go to the next account
@@ -1270,7 +1270,7 @@ local function start_session_basic(smb, log_errors, overrides)
end end
if(log_errors ~= false) then if(log_errors ~= false) then
stdnse.print_debug(1, "SMB: ERROR: %s", username) stdnse.debug1("SMB: ERROR: %s", username)
end end
if (status ~= nil) then if (status ~= nil) then
@@ -1392,7 +1392,7 @@ local function start_session_extended(smb, log_errors, overrides)
) )
-- Send the session setup request -- Send the session setup request
stdnse.print_debug(2, "SMB: Sending SMB_COM_SESSION_SETUP_ANDX") stdnse.debug2("SMB: Sending SMB_COM_SESSION_SETUP_ANDX")
result, err = smb_send(smb, header, parameters, data, overrides) result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -1451,17 +1451,17 @@ local function start_session_extended(smb, log_errors, overrides)
if(status_name == "NT_STATUS_SUCCESS") then if(status_name == "NT_STATUS_SUCCESS") then
-- Check if they're using an un-supported system -- Check if they're using an un-supported system
if(os == nil or lanmanager == nil) then if(os == nil or lanmanager == nil) then
stdnse.print_debug(1, "SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip']) stdnse.debug1("SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip'])
elseif(os == "Unix" or string.sub(lanmanager, 1, 5) == "Samba") then elseif(os == "Unix" or string.sub(lanmanager, 1, 5) == "Samba") then
stdnse.print_debug(1, "SMB: WARNING: the server appears to be Unix; your mileage may vary.") stdnse.debug1("SMB: WARNING: the server appears to be Unix; your mileage may vary.")
end end
-- Check if they were logged in as a guest -- Check if they were logged in as a guest
if(log_errors == nil or log_errors == true) then if(log_errors == nil or log_errors == true) then
if(smb['is_guest'] == 1) then if(smb['is_guest'] == 1) then
stdnse.print_debug(1, "SMB: Extended login to %s as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", smb['ip'], domain, stdnse.string_or_blank(username)) stdnse.debug1("SMB: Extended login to %s as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", smb['ip'], domain, stdnse.string_or_blank(username))
else else
stdnse.print_debug(2, "SMB: Extended login to %s as %s\\%s succeeded", smb['ip'], domain, stdnse.string_or_blank(username)) stdnse.debug2("SMB: Extended login to %s as %s\\%s succeeded", smb['ip'], domain, stdnse.string_or_blank(username))
end end
end end
@@ -1482,12 +1482,12 @@ local function start_session_extended(smb, log_errors, overrides)
end end
local backoff = math.random() * 10 local backoff = math.random() * 10
stdnse.print_debug(1, "SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100) stdnse.debug1("SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100)
stdnse.sleep(backoff) stdnse.sleep(backoff)
else else
-- Display a message to the user, and try the next account -- Display a message to the user, and try the next account
if(log_errors == nil or log_errors == true) then if(log_errors == nil or log_errors == true) then
stdnse.print_debug(1, "SMB: Extended login to %s as %s\\%s failed (%s)", smb['ip'], domain, stdnse.string_or_blank(username), status_name) stdnse.debug1("SMB: Extended login to %s as %s\\%s failed (%s)", smb['ip'], domain, stdnse.string_or_blank(username), status_name)
end end
-- Go to the next account -- Go to the next account
@@ -1508,7 +1508,7 @@ local function start_session_extended(smb, log_errors, overrides)
end -- Loop over the accounts end -- Loop over the accounts
if(log_errors == nil or log_errors == true) then if(log_errors == nil or log_errors == true) then
stdnse.print_debug(1, "SMB: ERROR: All logins failed, sorry it didn't work out!") stdnse.debug1("SMB: ERROR: All logins failed, sorry it didn't work out!")
end end
return false, status_name return false, status_name
@@ -1595,7 +1595,7 @@ function tree_connect(smb, path, overrides)
) )
-- Send the tree connect request -- Send the tree connect request
stdnse.print_debug(2, "SMB: Sending SMB_COM_TREE_CONNECT_ANDX") stdnse.debug2("SMB: Sending SMB_COM_TREE_CONNECT_ANDX")
result, err = smb_send(smb, header, parameters, data, overrides) result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -1641,7 +1641,7 @@ function tree_disconnect(smb, overrides)
header = smb_encode_header(smb, command_codes['SMB_COM_TREE_DISCONNECT'], overrides) header = smb_encode_header(smb, command_codes['SMB_COM_TREE_DISCONNECT'], overrides)
-- Send the tree disconnect request -- Send the tree disconnect request
stdnse.print_debug(2, "SMB: Sending SMB_COM_TREE_DISCONNECT") stdnse.debug2("SMB: Sending SMB_COM_TREE_DISCONNECT")
local result, err = smb_send(smb, header, "", "", overrides) local result, err = smb_send(smb, header, "", "", overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -1690,7 +1690,7 @@ function logoff(smb, overrides)
) )
-- Send the tree disconnect request -- Send the tree disconnect request
stdnse.print_debug(2, "SMB: Sending SMB_COM_LOGOFF_ANDX") stdnse.debug2("SMB: Sending SMB_COM_LOGOFF_ANDX")
local result, err = smb_send(smb, header, parameters, "", overrides) local result, err = smb_send(smb, header, parameters, "", overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -1715,7 +1715,7 @@ function logoff(smb, overrides)
end end
if(status == 0xc0000022) then if(status == 0xc0000022) then
stdnse.print_debug(1, "SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures") stdnse.debug1("SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures")
return false, "SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures" return false, "SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures"
end end
if(status ~= 0) then if(status ~= 0) then
@@ -1774,7 +1774,7 @@ function create_file(smb, path, overrides)
data = bin.pack("z", path) data = bin.pack("z", path)
-- Send the create file -- Send the create file
stdnse.print_debug(2, "SMB: Sending SMB_COM_NT_CREATE_ANDX") stdnse.debug2("SMB: Sending SMB_COM_NT_CREATE_ANDX")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
mutex "done" mutex "done"
@@ -1799,7 +1799,7 @@ function create_file(smb, path, overrides)
if(error_count > 10) then if(error_count > 10) then
return false, "SMB: ERROR: Server returned NT_STATUS_PIPE_NOT_AVAILABLE too many times; giving up." return false, "SMB: ERROR: Server returned NT_STATUS_PIPE_NOT_AVAILABLE too many times; giving up."
end end
stdnse.print_debug(1, "WARNING: Server refused connection with NT_STATUS_PIPE_NOT_AVAILABLE; trying again") stdnse.debug1("WARNING: Server refused connection with NT_STATUS_PIPE_NOT_AVAILABLE; trying again")
stdnse.sleep(.2) stdnse.sleep(.2)
end end
until (status ~= 0xc00000ac) until (status ~= 0xc00000ac)
@@ -1866,7 +1866,7 @@ function read_file(smb, offset, count, overrides)
data = "" data = ""
-- Send the create file -- Send the create file
stdnse.print_debug(2, "SMB: Sending SMB_COM_READ_ANDX") stdnse.debug2("SMB: Sending SMB_COM_READ_ANDX")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -1961,7 +1961,7 @@ function write_file(smb, write_data, offset, overrides)
data = write_data data = write_data
-- Send the create file -- Send the create file
stdnse.print_debug(2, "SMB: Sending SMB_COM_WRITE_ANDX") stdnse.debug2("SMB: Sending SMB_COM_WRITE_ANDX")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -2021,7 +2021,7 @@ function close_file(smb, overrides)
data = "" data = ""
-- Send the close file -- Send the close file
stdnse.print_debug(2, "SMB: Sending SMB_CLOSE") stdnse.debug2("SMB: Sending SMB_CLOSE")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -2070,7 +2070,7 @@ function delete_file(smb, path, overrides)
path) path)
-- Send the close file -- Send the close file
stdnse.print_debug(2, "SMB: Sending SMB_CLOSE") stdnse.debug2("SMB: Sending SMB_CLOSE")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -2152,7 +2152,7 @@ local function send_transaction2(smb, sub_command, function_parameters, function
data = data .. (function_data or '') data = data .. (function_data or '')
-- Send the transaction request -- Send the transaction request
stdnse.print_debug(2, "SMB: Sending SMB_COM_TRANSACTION2") stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -2299,7 +2299,7 @@ function send_transaction_named_pipe(smb, function_parameters, function_data, pi
data = data .. (function_data or '') data = data .. (function_data or '')
-- Send the transaction request -- Send the transaction request
stdnse.print_debug(2, "SMB: Sending SMB_COM_TRANSACTION") stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -2386,7 +2386,7 @@ function send_transaction_waitnamedpipe(smb, priority, pipe, overrides)
data = bin.pack("<zA", pipe, padding); data = bin.pack("<zA", pipe, padding);
-- Send the transaction request -- Send the transaction request
stdnse.print_debug(2, "SMB: Sending SMB_COM_TRANSACTION (WaitNamedPipe)") stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION (WaitNamedPipe)")
local result, err = smb_send(smb, header, parameters, data, overrides) local result, err = smb_send(smb, header, parameters, data, overrides)
if(result == false) then if(result == false) then
return false, err return false, err
@@ -2439,7 +2439,7 @@ function file_upload(host, localfile, share, remotefile, overrides, encoded)
-- If the open failed, try to search for the file -- If the open failed, try to search for the file
if(not(handle)) then if(not(handle)) then
stdnse.print_debug(1, "Couldn't open %s directly, searching Nmap's paths...", localfile) stdnse.debug1("Couldn't open %s directly, searching Nmap's paths...", localfile)
local filename = nmap.fetchfile(localfile) local filename = nmap.fetchfile(localfile)
-- Check if it was found -- Check if it was found
@@ -2675,7 +2675,7 @@ function file_delete(host, share, remotefile)
for _, file in ipairs(remotefile) do for _, file in ipairs(remotefile) do
status, err = delete_file(smbstate, file) status, err = delete_file(smbstate, file)
if(status == false) then if(status == false) then
stdnse.print_debug(1, "SMB: Couldn't delete %s\\%s: %s", share, file, err) stdnse.debug1("SMB: Couldn't delete %s\\%s: %s", share, file, err)
if(err ~= 'NT_STATUS_OBJECT_NAME_NOT_FOUND') then if(err ~= 'NT_STATUS_OBJECT_NAME_NOT_FOUND') then
stop(smbstate) stop(smbstate)
return false, err return false, err
@@ -3045,20 +3045,20 @@ function share_host_returns_proper_error(host, use_anonymous)
end end
-- Connect to the share -- Connect to the share
stdnse.print_debug(1, "SMB: Trying a random share to see if server responds properly: %s", share) stdnse.debug1("SMB: Trying a random share to see if server responds properly: %s", share)
status, err = tree_connect(smbstate, share, overrides) status, err = tree_connect(smbstate, share, overrides)
if(status == false) then if(status == false) then
-- If the error is NT_STATUS_ACCESS_DENIED (0xc0000022), that's bad -- we don't want non-existent shares -- If the error is NT_STATUS_ACCESS_DENIED (0xc0000022), that's bad -- we don't want non-existent shares
-- showing up as 'access denied'. Any other error is ok. -- showing up as 'access denied'. Any other error is ok.
if(err == 0xc0000022 or err == 'NT_STATUS_ACCESS_DENIED') then if(err == 0xc0000022 or err == 'NT_STATUS_ACCESS_DENIED') then
stdnse.print_debug(1, "SMB: Server doesn't return proper value for non-existent shares (returns ACCESS_DENIED)") stdnse.debug1("SMB: Server doesn't return proper value for non-existent shares (returns ACCESS_DENIED)")
stop(smbstate) stop(smbstate)
return true, false return true, false
end end
else else
-- If we were actually able to connect to this share, then there's probably a serious issue -- If we were actually able to connect to this share, then there's probably a serious issue
stdnse.print_debug(1, "SMB: Server doesn't return proper value for non-existent shares (accepts the connection)") stdnse.debug1("SMB: Server doesn't return proper value for non-existent shares (accepts the connection)")
stop(smbstate) stop(smbstate)
return true, false return true, false
end end
@@ -3083,7 +3083,7 @@ function share_get_details(host, share)
details['name'] = share details['name'] = share
-- Check if the current user can read the share -- Check if the current user can read the share
stdnse.print_debug(1, "SMB: Checking if share %s can be read by the current user", share) stdnse.debug1("SMB: Checking if share %s can be read by the current user", share)
status, result = share_user_can_read(host, share) status, result = share_user_can_read(host, share)
if(status == false) then if(status == false) then
return false, result return false, result
@@ -3091,14 +3091,14 @@ function share_get_details(host, share)
details['user_can_read'] = result details['user_can_read'] = result
-- Check if the anonymous reader can read the share -- Check if the anonymous reader can read the share
stdnse.print_debug(1, "SMB: Checking if share %s can be read by the anonymous user", share) stdnse.debug1("SMB: Checking if share %s can be read by the anonymous user", share)
status, result = share_anonymous_can_read(host, share) status, result = share_anonymous_can_read(host, share)
if(status == true) then if(status == true) then
details['anonymous_can_read'] = result details['anonymous_can_read'] = result
end end
-- Check if the current user can write to the share -- Check if the current user can write to the share
stdnse.print_debug(1, "SMB: Checking if share %s can be written by the current user", share) stdnse.debug1("SMB: Checking if share %s can be written by the current user", share)
status, result = share_user_can_write(host, share) status, result = share_user_can_write(host, share)
if(status == false) then if(status == false) then
if(result == "NT_STATUS_OBJECT_NAME_NOT_FOUND") then if(result == "NT_STATUS_OBJECT_NAME_NOT_FOUND") then
@@ -3110,7 +3110,7 @@ function share_get_details(host, share)
details['user_can_write'] = result details['user_can_write'] = result
-- Check if the anonymous user can write to the share -- Check if the anonymous user can write to the share
stdnse.print_debug(1, "SMB: Checking if share %s can be written by the anonymous user", share) stdnse.debug1("SMB: Checking if share %s can be written by the anonymous user", share)
status, result = share_anonymous_can_write(host, share) status, result = share_anonymous_can_write(host, share)
if(status == false and result == "NT_STATUS_OBJECT_NAME_NOT_FOUND") then if(status == false and result == "NT_STATUS_OBJECT_NAME_NOT_FOUND") then
details['anonymous_can_write'] = "NT_STATUS_OBJECT_NAME_NOT_FOUND" details['anonymous_can_write'] = "NT_STATUS_OBJECT_NAME_NOT_FOUND"
@@ -3122,7 +3122,7 @@ function share_get_details(host, share)
status, result = msrpc.get_share_info(host, share) status, result = msrpc.get_share_info(host, share)
if(status == false) then if(status == false) then
-- We don't stop for this error (it's pretty common since administrative privileges are required here) -- We don't stop for this error (it's pretty common since administrative privileges are required here)
stdnse.print_debug(1, "SMB: Failed to get share info for %s: %s", share, result) stdnse.debug1("SMB: Failed to get share info for %s: %s", share, result)
details['details'] = result details['details'] = result
else else
-- Process the result a bit -- Process the result a bit
@@ -3155,13 +3155,13 @@ function share_get_list(host)
local share_details = {} local share_details = {}
-- Try and do this the good way, make a MSRPC call to get the shares -- Try and do this the good way, make a MSRPC call to get the shares
stdnse.print_debug(1, "SMB: Attempting to log into the system to enumerate shares") stdnse.debug1("SMB: Attempting to log into the system to enumerate shares")
enum_status, shares = msrpc.enum_shares(host) enum_status, shares = msrpc.enum_shares(host)
-- If that failed, try doing it with brute force. This almost certainly won't find everything, but it's the -- If that failed, try doing it with brute force. This almost certainly won't find everything, but it's the
-- best we can do. -- best we can do.
if(enum_status == false) then if(enum_status == false) then
stdnse.print_debug(1, "SMB: Enumerating shares failed, guessing at common ones (%s)", shares) stdnse.debug1("SMB: Enumerating shares failed, guessing at common ones (%s)", shares)
extra = string.format("ERROR: Enumerating shares failed, guessing at common ones (%s)", shares) extra = string.format("ERROR: Enumerating shares failed, guessing at common ones (%s)", shares)
-- Take some common share names I've seen (thanks to Brandon Enright for most of these, except the last few) -- Take some common share names I've seen (thanks to Brandon Enright for most of these, except the last few)
@@ -3178,7 +3178,7 @@ function share_get_list(host)
shares[ sharesLength + shareItr ] = shares[ shareItr ] .. '$' shares[ sharesLength + shareItr ] = shares[ shareItr ] .. '$'
end end
else else
stdnse.print_debug(1, "SMB: Found %d shares, will attempt to find more information", #shares) stdnse.debug1("SMB: Found %d shares, will attempt to find more information", #shares)
end end
-- Sort the shares -- Sort the shares
@@ -3201,12 +3201,12 @@ function share_get_list(host)
-- Get more information on each share -- Get more information on each share
for i = 1, #shares, 1 do for i = 1, #shares, 1 do
local status, result local status, result
stdnse.print_debug(1, "SMB: Getting information for share: %s", shares[i]) stdnse.debug1("SMB: Getting information for share: %s", shares[i])
status, result = share_get_details(host, shares[i]) status, result = share_get_details(host, shares[i])
if(status == false and result == 'NT_STATUS_BAD_NETWORK_NAME') then if(status == false and result == 'NT_STATUS_BAD_NETWORK_NAME') then
stdnse.print_debug(1, "SMB: Share doesn't exist: %s", shares[i]) stdnse.debug1("SMB: Share doesn't exist: %s", shares[i])
elseif(status == false) then elseif(status == false) then
stdnse.print_debug(1, "SMB: Error while getting share details: %s", result) stdnse.debug1("SMB: Error while getting share details: %s", result)
return false, result return false, result
else else
-- Save the share details -- Save the share details
@@ -3447,46 +3447,46 @@ function is_admin(host, username, domain, password, password_hash, hash_type)
local status, smbstate, err, result local status, smbstate, err, result
local overrides = get_overrides(username, domain, password, password_hash, hash_type) local overrides = get_overrides(username, domain, password, password_hash, hash_type)
stdnse.print_debug("SMB: Checking if %s is an administrator", username) stdnse.debug1("SMB: Checking if %s is an administrator", username)
status, smbstate = start(host) status, smbstate = start(host)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Failed to start SMB: %s [%s]", smbstate, username) stdnse.debug1("SMB; is_admin: Failed to start SMB: %s [%s]", smbstate, username)
stop(smbstate) stop(smbstate)
return false return false
end end
status, err = negotiate_protocol(smbstate, overrides) status, err = negotiate_protocol(smbstate, overrides)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Failed to negotiate protocol: %s [%s]", err, username) stdnse.debug1("SMB; is_admin: Failed to negotiate protocol: %s [%s]", err, username)
stop(smbstate) stop(smbstate)
return false return false
end end
status, err = start_session(smbstate, overrides) status, err = start_session(smbstate, overrides)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Failed to start session %s [%s]", err, username) stdnse.debug1("SMB; is_admin: Failed to start session %s [%s]", err, username)
stop(smbstate) stop(smbstate)
return false return false
end end
status, err = tree_connect(smbstate, "IPC$", overrides) status, err = tree_connect(smbstate, "IPC$", overrides)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Failed to connect tree: %s [%s]", err, username) stdnse.debug1("SMB; is_admin: Failed to connect tree: %s [%s]", err, username)
stop(smbstate) stop(smbstate)
return false return false
end end
status, err = create_file(smbstate, msrpc.SRVSVC_PATH, overrides) status, err = create_file(smbstate, msrpc.SRVSVC_PATH, overrides)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Failed to create file: %s [%s]", err, username) stdnse.debug1("SMB; is_admin: Failed to create file: %s [%s]", err, username)
stop(smbstate) stop(smbstate)
return false return false
end end
status, err = msrpc.bind(smbstate, msrpc.SRVSVC_UUID, msrpc.SRVSVC_VERSION, nil) status, err = msrpc.bind(smbstate, msrpc.SRVSVC_UUID, msrpc.SRVSVC_VERSION, nil)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Failed to bind: %s [%s]", err, username) stdnse.debug1("SMB; is_admin: Failed to bind: %s [%s]", err, username)
stop(smbstate) stop(smbstate)
return false return false
end end
@@ -3494,7 +3494,7 @@ function is_admin(host, username, domain, password, password_hash, hash_type)
-- Call netservergetstatistics for 'server' -- Call netservergetstatistics for 'server'
status, err = msrpc.srvsvc_netservergetstatistics(smbstate, host.ip) status, err = msrpc.srvsvc_netservergetstatistics(smbstate, host.ip)
if(status == false) then if(status == false) then
stdnse.print_debug("SMB; is_admin: Couldn't get server stats (may be normal): %s [%s]", err, username) stdnse.debug1("SMB; is_admin: Couldn't get server stats (may be normal): %s [%s]", err, username)
stop(smbstate) stop(smbstate)
return false return false
end end
@@ -4158,7 +4158,7 @@ namedpipes =
pipeSubPath = match pipeSubPath = match
status = true status = true
if writeToDebugLog then if writeToDebugLog then
stdnse.print_debug( 2, "%s: Converting %s to subpath %s", NP_LIBRARY_NAME, pipeName, match ) stdnse.debug2("%s: Converting %s to subpath %s", NP_LIBRARY_NAME, pipeName, match )
end end
else else
status = false status = false
@@ -4196,7 +4196,7 @@ namedpipes =
connect = function( self, host, pipeSubPath, overrides ) connect = function( self, host, pipeSubPath, overrides )
stdnse.print_debug( 2, "%s: connect() called with %s", NP_LIBRARY_NAME, tostring( pipeSubPath ) ) stdnse.debug2("%s: connect() called with %s", NP_LIBRARY_NAME, tostring( pipeSubPath ) )
self._overrides = overrides or {} self._overrides = overrides or {}
self._host = host self._host = host
self._pipeSubPath = pipeSubPath self._pipeSubPath = pipeSubPath
@@ -4208,13 +4208,13 @@ namedpipes =
local status local status
status, self._pipeSubPath = namedpipes.get_pipe_subpath( self._pipeSubPath, true ) status, self._pipeSubPath = namedpipes.get_pipe_subpath( self._pipeSubPath, true )
if ( not status ) then if ( not status ) then
stdnse.print_debug( 1, "%s: Attempt to connect to invalid pipe name: %s", NP_LIBRARY_NAME, tostring( pipeSubPath ) ) stdnse.debug1("%s: Attempt to connect to invalid pipe name: %s", NP_LIBRARY_NAME, tostring( pipeSubPath ) )
return false, "Invalid pipe name" return false, "Invalid pipe name"
end end
end end
self.name = namedpipes.make_pipe_name( self._host.ip, self._pipeSubPath ) self.name = namedpipes.make_pipe_name( self._host.ip, self._pipeSubPath )
stdnse.print_debug( 2, "%s: Connecting to named pipe: %s", NP_LIBRARY_NAME, self.name ) stdnse.debug2("%s: Connecting to named pipe: %s", NP_LIBRARY_NAME, self.name )
local status, result, errorMessage local status, result, errorMessage
local bool_negotiate_protocol, bool_start_session, bool_disable_extended = true, true, false local bool_negotiate_protocol, bool_start_session, bool_disable_extended = true, true, false
status, result = start_ex( self._host, bool_negotiate_protocol, bool_start_session, status, result = start_ex( self._host, bool_negotiate_protocol, bool_start_session,
@@ -4224,7 +4224,7 @@ namedpipes =
self._smbstate = result self._smbstate = result
else else
errorMessage = string.format( "Connection failed: %s", result ) errorMessage = string.format( "Connection failed: %s", result )
stdnse.print_debug( 2, "%s: Connection to named pipe (%s) failed: %s", stdnse.debug2("%s: Connection to named pipe (%s) failed: %s",
NP_LIBRARY_NAME, self.name, errorMessage ) NP_LIBRARY_NAME, self.name, errorMessage )
end end
@@ -4234,17 +4234,17 @@ namedpipes =
disconnect = function( self ) disconnect = function( self )
if ( self._smbstate ) then if ( self._smbstate ) then
stdnse.print_debug( 2, "%s: Disconnecting named pipe: %s", NP_LIBRARY_NAME, self.name ) stdnse.debug2("%s: Disconnecting named pipe: %s", NP_LIBRARY_NAME, self.name )
return stop( self._smbstate ) return stop( self._smbstate )
else else
stdnse.print_debug( 2, "%s: disconnect() called, but SMB connection is already closed: %s", NP_LIBRARY_NAME, self.name ) stdnse.debug2("%s: disconnect() called, but SMB connection is already closed: %s", NP_LIBRARY_NAME, self.name )
end end
end, end,
send = function( self, messageData ) send = function( self, messageData )
if not self._smbstate then if not self._smbstate then
stdnse.print_debug( 2, "%s: send() called on closed pipe (%s)", NP_LIBRARY_NAME, self.name ) stdnse.debug2("%s: send() called on closed pipe (%s)", NP_LIBRARY_NAME, self.name )
return false, "Failed to send message on named pipe" return false, "Failed to send message on named pipe"
end end
@@ -4255,7 +4255,7 @@ namedpipes =
-- if status is true, result is data that we don't need to pay attention to -- if status is true, result is data that we don't need to pay attention to
if not status then if not status then
stdnse.print_debug( 2, "%s: Write to named pipe (%s) failed: %s", stdnse.debug2("%s: Write to named pipe (%s) failed: %s",
NP_LIBRARY_NAME, self.name, result ) NP_LIBRARY_NAME, self.name, result )
errorMessage = "Failed to send message on named pipe", result errorMessage = "Failed to send message on named pipe", result
end end
@@ -4266,7 +4266,7 @@ namedpipes =
receive = function( self ) receive = function( self )
if not self._smbstate then if not self._smbstate then
stdnse.print_debug( 2, "%s: receive() called on closed pipe (%s)", NP_LIBRARY_NAME, self.name ) stdnse.debug2("%s: receive() called on closed pipe (%s)", NP_LIBRARY_NAME, self.name )
return false, "Failed to read from named pipe" return false, "Failed to read from named pipe"
end end
@@ -4280,7 +4280,7 @@ namedpipes =
if status and result.data then if status and result.data then
messageData = result.data messageData = result.data
else else
stdnse.print_debug( 2, "%s: Read from named pipe (%s) failed: %s", stdnse.debug2("%s: Read from named pipe (%s) failed: %s",
NP_LIBRARY_NAME, self.name, result ) NP_LIBRARY_NAME, self.name, result )
return false, "Failed to read from named pipe", result return false, "Failed to read from named pipe", result
end end
@@ -4291,7 +4291,7 @@ namedpipes =
if status and result.data then if status and result.data then
messageData = messageData .. result.data messageData = messageData .. result.data
else else
stdnse.print_debug( 2, "%s: Read additional data from named pipe (%s) failed: %s", stdnse.debug2("%s: Read additional data from named pipe (%s) failed: %s",
NP_LIBRARY_NAME, self.name, result ) NP_LIBRARY_NAME, self.name, result )
return false, "Failed to read from named pipe", result return false, "Failed to read from named pipe", result
end end

View File

@@ -217,7 +217,7 @@ function add_account(host, username, domain, password, password_hash, hash_type,
table.sort(host.registry['smbaccounts'], function(a,b) return a['account_type'] > b['account_type'] end) table.sort(host.registry['smbaccounts'], function(a,b) return a['account_type'] > b['account_type'] end)
-- Print a debug message -- Print a debug message
stdnse.print_debug(1, "SMB: Added account '%s' to account list", username) stdnse.debug1("SMB: Added account '%s' to account list", username)
-- Reset the credentials -- Reset the credentials
next_account(host, 1) next_account(host, 1)
@@ -316,7 +316,7 @@ function init_account(host)
-- Add the account, if we got a password -- Add the account, if we got a password
if(password == nil and password_hash == nil) then if(password == nil and password_hash == nil) then
stdnse.print_debug(1, "SMB: Either smbpass, smbpassword, or smbhash have to be passed as script arguments to use an account") stdnse.debug1("SMB: Either smbpass, smbpassword, or smbhash have to be passed as script arguments to use an account")
else else
add_account(host, username, domain, password, password_hash, hash_type) add_account(host, username, domain, password, password_hash, hash_type)
end end
@@ -362,7 +362,7 @@ local function lm_create_hash(password)
end end
password = table.concat(buf) password = table.concat(buf)
local nsedebug = require 'nsedebug' local nsedebug = require 'nsedebug'
stdnse.print_debug("LM Password: %s", stdnse.tohex(password)) stdnse.debug1("LM Password: %s", stdnse.tohex(password))
end end
-- If password is under 14 characters, pad it to 14 -- If password is under 14 characters, pad it to 14
@@ -436,7 +436,7 @@ function lm_create_response(lanman, challenge)
-- Print a warning message if a blank challenge is received, and create a phony challenge. A blank challenge is -- Print a warning message if a blank challenge is received, and create a phony challenge. A blank challenge is
-- invalid in the protocol, and causes some versions of OpenSSL to abort with no possible error handling. -- invalid in the protocol, and causes some versions of OpenSSL to abort with no possible error handling.
if(challenge == "") then if(challenge == "") then
stdnse.print_debug(1, "SMB: ERROR: Server returned invalid (blank) challenge value (should be 8 bytes); failing login to avoid OpenSSL crash.") stdnse.debug1("SMB: ERROR: Server returned invalid (blank) challenge value (should be 8 bytes); failing login to avoid OpenSSL crash.")
challenge = "AAAAAAAA" challenge = "AAAAAAAA"
end end
@@ -625,7 +625,7 @@ function get_password_response(ip, username, domain, password, password_hash, ha
-- Check for a blank password -- Check for a blank password
if(password == nil and password_hash == nil) then if(password == nil and password_hash == nil) then
stdnse.print_debug(2, "SMB: Couldn't find password or hash to use (assuming blank)") stdnse.debug2("SMB: Couldn't find password or hash to use (assuming blank)")
password = "" password = ""
end end
@@ -641,19 +641,19 @@ function get_password_response(ip, username, domain, password, password_hash, ha
else else
if(password_hash ~= nil) then if(password_hash ~= nil) then
if(string.find(password_hash, "^" .. string.rep("%x%x", 16) .. "$")) then if(string.find(password_hash, "^" .. string.rep("%x%x", 16) .. "$")) then
stdnse.print_debug(2, "SMB: Found a 16-byte hex string") stdnse.debug2("SMB: Found a 16-byte hex string")
lm_hash = bin.pack("H", password_hash:sub(1, 32)) lm_hash = bin.pack("H", password_hash:sub(1, 32))
ntlm_hash = bin.pack("H", password_hash:sub(1, 32)) ntlm_hash = bin.pack("H", password_hash:sub(1, 32))
elseif(string.find(password_hash, "^" .. string.rep("%x%x", 32) .. "$")) then elseif(string.find(password_hash, "^" .. string.rep("%x%x", 32) .. "$")) then
stdnse.print_debug(2, "SMB: Found a 32-byte hex string") stdnse.debug2("SMB: Found a 32-byte hex string")
lm_hash = bin.pack("H", password_hash:sub(1, 32)) lm_hash = bin.pack("H", password_hash:sub(1, 32))
ntlm_hash = bin.pack("H", password_hash:sub(33, 64)) ntlm_hash = bin.pack("H", password_hash:sub(33, 64))
elseif(string.find(password_hash, "^" .. string.rep("%x%x", 16) .. "." .. string.rep("%x%x", 16) .. "$")) then elseif(string.find(password_hash, "^" .. string.rep("%x%x", 16) .. "." .. string.rep("%x%x", 16) .. "$")) then
stdnse.print_debug(2, "SMB: Found two 16-byte hex strings") stdnse.debug2("SMB: Found two 16-byte hex strings")
lm_hash = bin.pack("H", password_hash:sub(1, 32)) lm_hash = bin.pack("H", password_hash:sub(1, 32))
ntlm_hash = bin.pack("H", password_hash:sub(34, 65)) ntlm_hash = bin.pack("H", password_hash:sub(34, 65))
else else
stdnse.print_debug(1, "SMB: ERROR: Hash(es) provided in an invalid format (should be 32, 64, or 65 hex characters)") stdnse.debug1("SMB: ERROR: Hash(es) provided in an invalid format (should be 32, 64, or 65 hex characters)")
lm_hash = nil lm_hash = nil
ntlm_hash = nil ntlm_hash = nil
end end
@@ -662,18 +662,18 @@ function get_password_response(ip, username, domain, password, password_hash, ha
-- At this point, we should have a good lm_hash and ntlm_hash if we're getting one -- At this point, we should have a good lm_hash and ntlm_hash if we're getting one
if(lm_hash == nil or ntlm_hash == nil) then if(lm_hash == nil or ntlm_hash == nil) then
stdnse.print_debug(2, "SMB: Couldn't determine which password to use, using a blank one") stdnse.debug2("SMB: Couldn't determine which password to use, using a blank one")
return "", "" return "", ""
end end
-- Output what we've got so far -- Output what we've got so far
stdnse.print_debug(2, "SMB: Lanman hash: %s", stdnse.tohex(lm_hash)) stdnse.debug2("SMB: Lanman hash: %s", stdnse.tohex(lm_hash))
stdnse.print_debug(2, "SMB: NTLM hash: %s", stdnse.tohex(ntlm_hash)) stdnse.debug2("SMB: NTLM hash: %s", stdnse.tohex(ntlm_hash))
-- Hash the password the way the user wants -- Hash the password the way the user wants
if(hash_type == "v1") then if(hash_type == "v1") then
-- LM and NTLM are hashed with their respective algorithms -- LM and NTLM are hashed with their respective algorithms
stdnse.print_debug(2, "SMB: Creating v1 response") stdnse.debug2("SMB: Creating v1 response")
status, lm_response = lm_create_response(lm_hash, challenge) status, lm_response = lm_create_response(lm_hash, challenge)
status, ntlm_response = ntlm_create_response(ntlm_hash, challenge) status, ntlm_response = ntlm_create_response(ntlm_hash, challenge)
@@ -681,7 +681,7 @@ function get_password_response(ip, username, domain, password, password_hash, ha
elseif(hash_type == "lm") then elseif(hash_type == "lm") then
-- LM is hashed with its algorithm, NTLM is blank -- LM is hashed with its algorithm, NTLM is blank
stdnse.print_debug(2, "SMB: Creating LMv1 response") stdnse.debug2("SMB: Creating LMv1 response")
status, lm_response = lm_create_response(lm_hash, challenge) status, lm_response = lm_create_response(lm_hash, challenge)
ntlm_response = "" ntlm_response = ""
@@ -689,7 +689,7 @@ function get_password_response(ip, username, domain, password, password_hash, ha
elseif(hash_type == "ntlm") then elseif(hash_type == "ntlm") then
-- LM and NTLM both use the NTLM algorithm -- LM and NTLM both use the NTLM algorithm
stdnse.print_debug(2, "SMB: Creating NTLMv1 response") stdnse.debug2("SMB: Creating NTLMv1 response")
status, lm_response = ntlm_create_response(ntlm_hash, challenge) status, lm_response = ntlm_create_response(ntlm_hash, challenge)
status, ntlm_response = ntlm_create_response(ntlm_hash, challenge) status, ntlm_response = ntlm_create_response(ntlm_hash, challenge)
@@ -697,22 +697,22 @@ function get_password_response(ip, username, domain, password, password_hash, ha
elseif(hash_type == "v2") then elseif(hash_type == "v2") then
-- LM and NTLM are hashed with their respective v2 algorithms -- LM and NTLM are hashed with their respective v2 algorithms
stdnse.print_debug(2, "SMB: Creating v2 response") stdnse.debug2("SMB: Creating v2 response")
status, lm_response = lmv2_create_response(ntlm_hash, username, domain, challenge) status, lm_response = lmv2_create_response(ntlm_hash, username, domain, challenge)
status, ntlm_response = ntlmv2_create_response(ntlm_hash, username, domain, challenge, 24) status, ntlm_response = ntlmv2_create_response(ntlm_hash, username, domain, challenge, 24)
elseif(hash_type == "lmv2") then elseif(hash_type == "lmv2") then
-- LM is hashed with its v2 algorithm, NTLM is blank -- LM is hashed with its v2 algorithm, NTLM is blank
stdnse.print_debug(2, "SMB: Creating LMv2 response") stdnse.debug2("SMB: Creating LMv2 response")
status, lm_response = lmv2_create_response(ntlm_hash, username, domain, challenge) status, lm_response = lmv2_create_response(ntlm_hash, username, domain, challenge)
ntlm_response = "" ntlm_response = ""
else else
-- Default to NTLMv1 -- Default to NTLMv1
if(hash_type ~= nil) then if(hash_type ~= nil) then
stdnse.print_debug(1, "SMB: Invalid login type specified ('%s'), using default (NTLM)", hash_type) stdnse.debug1("SMB: Invalid login type specified ('%s'), using default (NTLM)", hash_type)
else else
stdnse.print_debug(1, "SMB: No login type specified, using default (NTLM)") stdnse.debug1("SMB: No login type specified, using default (NTLM)")
end end
status, lm_response = ntlm_create_response(ntlm_hash, challenge) status, lm_response = ntlm_create_response(ntlm_hash, challenge)
@@ -720,8 +720,8 @@ function get_password_response(ip, username, domain, password, password_hash, ha
end end
stdnse.print_debug(2, "SMB: Lanman response: %s", stdnse.tohex(lm_response)) stdnse.debug2("SMB: Lanman response: %s", stdnse.tohex(lm_response))
stdnse.print_debug(2, "SMB: NTLM response: %s", stdnse.tohex(ntlm_response)) stdnse.debug2("SMB: NTLM response: %s", stdnse.tohex(ntlm_response))
return lm_response, ntlm_response, mac_key return lm_response, ntlm_response, mac_key
end end
@@ -830,11 +830,11 @@ function get_host_info_from_security_blob(security_blob)
-- Do some validation on the NTLMSSP message -- Do some validation on the NTLMSSP message
if ( identifier ~= "NTLMSSP\0" ) then if ( identifier ~= "NTLMSSP\0" ) then
stdnse.print_debug( 1, "SMB: Invalid NTLM challenge message: unexpected signature." ) stdnse.debug1("SMB: Invalid NTLM challenge message: unexpected signature." )
return false, "Invalid NTLM challenge message" return false, "Invalid NTLM challenge message"
-- Per MS-NLMP, this field must be 2 for an NTLM challenge message -- Per MS-NLMP, this field must be 2 for an NTLM challenge message
elseif ( message_type ~= 0x2 ) then elseif ( message_type ~= 0x2 ) then
stdnse.print_debug( 1, "SMB: Invalid NTLM challenge message: unexpected message type: %d.", message_type ) stdnse.debug1("SMB: Invalid NTLM challenge message: unexpected message type: %d.", message_type )
return false, "Invalid message type in NTLM challenge message" return false, "Invalid message type in NTLM challenge message"
end end

View File

@@ -227,12 +227,12 @@ check_reply = function(cmd, reply)
return true, reply return true, reply
end end
else else
stdnse.print_debug(3, stdnse.debug3(
"SMTP: check_smtp_reply failed: %s not supported", cmd) "SMTP: check_smtp_reply failed: %s not supported", cmd)
return false, string.format("SMTP: %s %s", cmd, reply) return false, string.format("SMTP: %s %s", cmd, reply)
end end
end end
stdnse.print_debug(3, stdnse.debug3(
"SMTP: check_smtp_reply failed: %s %s", cmd, reply) "SMTP: check_smtp_reply failed: %s %s", cmd, reply)
return false, string.format("SMTP: %s %s", cmd, reply) return false, string.format("SMTP: %s %s", cmd, reply)
end end
@@ -259,14 +259,14 @@ query = function(socket, cmd, data, lines)
local st, ret = socket:send(string.format("%s\r\n", cmd)) local st, ret = socket:send(string.format("%s\r\n", cmd))
if not st then if not st then
socket:close() socket:close()
stdnse.print_debug(3, "SMTP: failed to send %s request.", cmd) stdnse.debug3("SMTP: failed to send %s request.", cmd)
return st, string.format("SMTP failed to send %s request.", cmd) return st, string.format("SMTP failed to send %s request.", cmd)
end end
st, ret = socket:receive_lines(lines or 1) st, ret = socket:receive_lines(lines or 1)
if not st then if not st then
socket:close() socket:close()
stdnse.print_debug(3, "SMTP %s: failed to receive data: %s.", stdnse.debug3("SMTP %s: failed to receive data: %s.",
cmd, (ERROR_MESSAGES[ret] or 'unspecified error')) cmd, (ERROR_MESSAGES[ret] or 'unspecified error'))
return st, string.format("SMTP %s: failed to receive data: %s", return st, string.format("SMTP %s: failed to receive data: %s",
cmd, (ERROR_MESSAGES[ret] or 'unspecified error')) cmd, (ERROR_MESSAGES[ret] or 'unspecified error'))
@@ -580,7 +580,7 @@ end
-- --
-- @param socket connected to server. -- @param socket connected to server.
quit = function(socket) quit = function(socket)
stdnse.print_debug(3, "SMTP: sending 'QUIT'.") stdnse.debug3("SMTP: sending 'QUIT'.")
socket:send("QUIT\r\n") socket:send("QUIT\r\n")
socket:close() socket:close()
end end

View File

@@ -464,7 +464,7 @@ function snmpWalk( socket, base_oid )
status, err = socket:send(payload) status, err = socket:send(payload)
if ( not( status ) ) then if ( not( status ) ) then
stdnse.print_debug("snmp.snmpWalk: Send failed") stdnse.debug1("snmp.snmpWalk: Send failed")
return false, err return false, err
end end
@@ -472,7 +472,7 @@ function snmpWalk( socket, base_oid )
if ( not( status ) ) then if ( not( status ) ) then
-- Unless we have a useful error message, don't report it -- Unless we have a useful error message, don't report it
if ( response ~= "ERROR" ) then if ( response ~= "ERROR" ) then
stdnse.print_debug("snmp.snmpWalk: Received no answer (%s)", response) stdnse.debug1("snmp.snmpWalk: Received no answer (%s)", response)
return false, response return false, response
end end
return false, nil return false, nil

View File

@@ -86,7 +86,7 @@ transport.payload = function( packet )
assert(packet_length and padding_length) assert(packet_length and padding_length)
payload_length = packet_length - padding_length - 1 payload_length = packet_length - padding_length - 1
if packet_length ~= packet:len() then if packet_length ~= packet:len() then
stdnse.print_debug("SSH-2 packet doesn't match length: payload_length is %d but total length is only %d.", packet_length, packet:len()) stdnse.debug1("SSH-2 packet doesn't match length: payload_length is %d but total length is only %d.", packet_length, packet:len())
return nil return nil
end end
offset, payload = bin.unpack( ">A" .. payload_length, packet, offset ) offset, payload = bin.unpack( ">A" .. payload_length, packet, offset )
@@ -179,7 +179,7 @@ fetch_host_key = function( host, port, key_type )
if not tostring(kex_init.server_host_key_algorithms):find( key_type, 1, true ) then if not tostring(kex_init.server_host_key_algorithms):find( key_type, 1, true ) then
-- server does not support host key type -- server does not support host key type
stdnse.print_debug( 2, "Hostkey type '%s' not supported by server.", key_type ) stdnse.debug2("Hostkey type '%s' not supported by server.", key_type )
return return
end end
@@ -225,7 +225,7 @@ fetch_host_key = function( host, port, key_type )
algorithm = "ECDSA" algorithm = "ECDSA"
bits = "521" bits = "521"
else else
stdnse.print_debug( "Unsupported key type: %s", key_type ) stdnse.debug1("Unsupported key type: %s", key_type )
end end
return { key=base64.enc(public_host_key), key_type=key_type, fp_input=public_host_key, bits=bits, return { key=base64.enc(public_host_key), key_type=key_type, fp_input=public_host_key, bits=bits,

View File

@@ -56,8 +56,8 @@ StartTLS = {
status, result = s:receive_lines(1) status, result = s:receive_lines(1)
if not (string.match(result, "^234")) then if not (string.match(result, "^234")) then
stdnse.print_debug(1,"%s",result) stdnse.debug1("%s",result)
stdnse.print_debug(1,"AUTH TLS failed or unavailable. Enable --script-trace to see what is happening.") stdnse.debug1("AUTH TLS failed or unavailable. Enable --script-trace to see what is happening.")
-- Send QUIT to clean up server side connection -- Send QUIT to clean up server side connection
local query = "QUIT\r\n" local query = "QUIT\r\n"
@@ -77,7 +77,7 @@ StartTLS = {
if status then if status then
status,err = s:reconnect_ssl() status,err = s:reconnect_ssl()
if not status then if not status then
stdnse.print_debug(1,"Could not establish SSL session after STARTTLS command.") stdnse.debug1("Could not establish SSL session after STARTTLS command.")
s:close() s:close()
return false, "Failed to connect to SMTP server" return false, "Failed to connect to SMTP server"
else else
@@ -113,7 +113,7 @@ StartTLS = {
status, result = s:receive_lines(1) status, result = s:receive_lines(1)
if not (string.match(result, "STARTTLS")) then if not (string.match(result, "STARTTLS")) then
stdnse.print_debug(1, "Server doesn't support STARTTLS") stdnse.debug1("Server doesn't support STARTTLS")
return false, "Failed to connect to IMAP server" return false, "Failed to connect to IMAP server"
end end
@@ -123,7 +123,7 @@ StartTLS = {
status, result = s:receive_lines(1) status, result = s:receive_lines(1)
if not (string.match(result, "OK")) then if not (string.match(result, "OK")) then
stdnse.print_debug(1, string.format("Error: %s", result)) stdnse.debug1(string.format("Error: %s", result))
return false, "Failed to connect to IMAP server" return false, "Failed to connect to IMAP server"
end end
end end
@@ -192,7 +192,7 @@ StartTLS = {
ldapOp = asn1.intToBER(tmp) ldapOp = asn1.intToBER(tmp)
if ldapOp.number ~= ExtendedResponse then if ldapOp.number ~= ExtendedResponse then
stdnse.print_debug(1, string.format( stdnse.debug1(string.format(
"STARTTLS failed (got wrong op number: %d)", ldapOp.number)) "STARTTLS failed (got wrong op number: %d)", ldapOp.number))
return false, "STARTTLS failed" return false, "STARTTLS failed"
end end
@@ -202,7 +202,7 @@ StartTLS = {
pos, resultCode = ldap.decode(response, pos) pos, resultCode = ldap.decode(response, pos)
if resultCode ~= 0 then if resultCode ~= 0 then
stdnse.print_debug(1, string.format( stdnse.debug1(string.format(
"STARTTLS failed (LDAP error code is: %d)", resultCode)) "STARTTLS failed (LDAP error code is: %d)", resultCode))
return false, "STARTTLS failed" return false, "STARTTLS failed"
end end
@@ -253,7 +253,7 @@ StartTLS = {
status, result = s:receive_lines(1) status, result = s:receive_lines(1)
if not (string.match(result, "OK")) then if not (string.match(result, "OK")) then
stdnse.print_debug(1, string.format("Error: %s", result)) stdnse.debug1(string.format("Error: %s", result))
return false, "Failed to connect to POP3 server" return false, "Failed to connect to POP3 server"
end end
end end
@@ -307,8 +307,8 @@ StartTLS = {
status, resultEHLO = s:receive_lines(1) status, resultEHLO = s:receive_lines(1)
if not (string.match(resultEHLO, "^250")) then if not (string.match(resultEHLO, "^250")) then
stdnse.print_debug(1,"%s",resultEHLO) stdnse.debug1("%s",resultEHLO)
stdnse.print_debug(1,"EHLO with errors or timeout. Enable --script-trace to see what is happening.") stdnse.debug1("EHLO with errors or timeout. Enable --script-trace to see what is happening.")
return false, "Failed to connect to SMTP server" return false, "Failed to connect to SMTP server"
end end
@@ -320,8 +320,8 @@ StartTLS = {
status, resultEHLO = s:receive_lines(1) status, resultEHLO = s:receive_lines(1)
if not (string.match(resultEHLO, "^220")) then if not (string.match(resultEHLO, "^220")) then
stdnse.print_debug(1,"%s",resultEHLO) stdnse.debug1("%s",resultEHLO)
stdnse.print_debug(1,"STARTTLS failed or unavailable. Enable --script-trace to see what is happening.") stdnse.debug1("STARTTLS failed or unavailable. Enable --script-trace to see what is happening.")
-- Send QUIT to clean up server side connection -- Send QUIT to clean up server side connection
local query = "QUIT\r\n" local query = "QUIT\r\n"
@@ -341,7 +341,7 @@ StartTLS = {
if status then if status then
status,err = s:reconnect_ssl() status,err = s:reconnect_ssl()
if not status then if not status then
stdnse.print_debug(1,"Could not establish SSL session after STARTTLS command.") stdnse.debug1("Could not establish SSL session after STARTTLS command.")
s:close() s:close()
return false, "Failed to connect to SMTP server" return false, "Failed to connect to SMTP server"
else else
@@ -360,30 +360,30 @@ StartTLS = {
status, err = sock:connect(host, port) status, err = sock:connect(host, port)
if not status then if not status then
sock:close() sock:close()
stdnse.print_debug("Can't send: %s", err) stdnse.debug1("Can't send: %s", err)
return false, "Failed to connect to XMPP server" return false, "Failed to connect to XMPP server"
end end
status, err = sock:send(xmppStreamStart) status, err = sock:send(xmppStreamStart)
if not status then if not status then
stdnse.print_debug("Couldn't send: %s", err) stdnse.debug1("Couldn't send: %s", err)
sock:close() sock:close()
return false, "Failed to connect to XMPP server" return false, "Failed to connect to XMPP server"
end end
status, result = sock:receive() status, result = sock:receive()
if not status then if not status then
stdnse.print_debug("Couldn't receive: %s", err) stdnse.debug1("Couldn't receive: %s", err)
sock:close() sock:close()
return false, "Failed to connect to XMPP server" return false, "Failed to connect to XMPP server"
end end
status, err = sock:send(xmppStartTLS) status, err = sock:send(xmppStartTLS)
if not status then if not status then
stdnse.print_debug("Couldn't send: %s", err) stdnse.debug1("Couldn't send: %s", err)
sock:close() sock:close()
return false, "Failed to connect to XMPP server" return false, "Failed to connect to XMPP server"
end end
status, result = sock:receive() status, result = sock:receive()
if not status then if not status then
stdnse.print_debug("Couldn't receive: %s", err) stdnse.debug1("Couldn't receive: %s", err)
sock:close() sock:close()
return false, "Failed to connect to XMPP server" return false, "Failed to connect to XMPP server"
end end
@@ -393,7 +393,7 @@ StartTLS = {
status, result = sock:receive() -- might not be in the first reply status, result = sock:receive() -- might not be in the first reply
if not status then if not status then
stdnse.print_debug("Couldn't receive: %s", err) stdnse.debug1("Couldn't receive: %s", err)
sock:close() sock:close()
return false, "Failed to connect to XMPP server" return false, "Failed to connect to XMPP server"
end end
@@ -493,7 +493,7 @@ function getCertificate(host, port)
if ( host.registry["ssl-cert"] and if ( host.registry["ssl-cert"] and
host.registry["ssl-cert"][port.number] ) then host.registry["ssl-cert"][port.number] ) then
stdnse.print_debug(2, "sslcert: Returning cached SSL certificate") stdnse.debug2("sslcert: Returning cached SSL certificate")
mutex "done" mutex "done"
return true, host.registry["ssl-cert"][port.number] return true, host.registry["ssl-cert"][port.number]
end end

View File

@@ -143,7 +143,7 @@ Attribute = {
( attr.type == Attribute.SOURCE_ADDRESS ) or ( attr.type == Attribute.SOURCE_ADDRESS ) or
( attr.type == Attribute.CHANGED_ADDRESS ) ) then ( attr.type == Attribute.CHANGED_ADDRESS ) ) then
if ( attr.length ~= 8 ) then if ( attr.length ~= 8 ) then
stdnse.print_debug(2, "Incorrect attribute length") stdnse.debug2("Incorrect attribute length")
end end
attr.addr = parseAddress(data, pos) attr.addr = parseAddress(data, pos)
elseif( attr.type == Attribute.SERVER ) then elseif( attr.type == Attribute.SERVER ) then

View File

@@ -82,7 +82,7 @@ add = function (...)
-- Force the check here, but it would be better if scripts -- Force the check here, but it would be better if scripts
-- check ALLOW_NEW_TARGETS before calling target.add() -- check ALLOW_NEW_TARGETS before calling target.add()
if not ALLOW_NEW_TARGETS then if not ALLOW_NEW_TARGETS then
stdnse.print_debug(1, stdnse.debug1(
"ERROR: to add targets run with --script-args 'newtargets'") "ERROR: to add targets run with --script-args 'newtargets'")
return false, "to add targets run with --script-args 'newtargets'" return false, "to add targets run with --script-args 'newtargets'"
end end
@@ -97,7 +97,7 @@ add = function (...)
new_targets.count = calc_max_targets(new_targets.count) new_targets.count = calc_max_targets(new_targets.count)
if new_targets.count == 0 then if new_targets.count == 0 then
stdnse.print_debug(3, stdnse.debug3(
"Warning: Maximum new targets reached, no more new targets.") "Warning: Maximum new targets reached, no more new targets.")
return false, "Maximum new targets reached, no more new targets." return false, "Maximum new targets reached, no more new targets."
end end
@@ -105,7 +105,7 @@ add = function (...)
local hosts, err = nmap.add_targets(table.unpack(new_targets,1,new_targets.count)) local hosts, err = nmap.add_targets(table.unpack(new_targets,1,new_targets.count))
if hosts == 0 then if hosts == 0 then
stdnse.print_debug(3, "%s", err) stdnse.debug3("%s", err)
return false, err return false, err
end end

View File

@@ -158,7 +158,7 @@ local function dispatcher()
end end
state = "STOPPED" state = "STOPPED"
s_condvar "broadcast" s_condvar "broadcast"
stdnse.print_debug("Exiting _dispatcher") stdnse.debug1("Exiting _dispatcher")
end end
-- Processes a new incoming file transfer -- Processes a new incoming file transfer
@@ -179,7 +179,7 @@ local function processConnection( host, port, data )
-- If we get anything else than a write request, abort the connection -- If we get anything else than a write request, abort the connection
if ( OpCode.WRQ ~= op ) then if ( OpCode.WRQ ~= op ) then
stdnse.print_debug("Unsupported opcode") stdnse.debug1("Unsupported opcode")
socket:send( tostring(Packet.ERROR:new(0, "TFTP server has write-only support"))) socket:send( tostring(Packet.ERROR:new(0, "TFTP server has write-only support")))
end end
@@ -203,7 +203,7 @@ local function processConnection( host, port, data )
lastread = os.time() lastread = os.time()
pos, op = bin.unpack(">S", pdata) pos, op = bin.unpack(">S", pdata)
if ( OpCode.DATA ~= op ) then if ( OpCode.DATA ~= op ) then
stdnse.print_debug("Expected a data packet, terminating TFTP transfer") stdnse.debug1("Expected a data packet, terminating TFTP transfer")
end end
local block, data local block, data
@@ -251,7 +251,7 @@ local function processConnection( host, port, data )
end end
filecontent = filecontent .. blocks[i] filecontent = filecontent .. blocks[i]
end end
stdnse.print_debug("Finished receiving file \"%s\"", filename) stdnse.debug1("Finished receiving file \"%s\"", filename)
-- Add anew file to the global infiles table -- Add anew file to the global infiles table
table.insert( infiles, File:new(filename, filecontent, host) ) table.insert( infiles, File:new(filename, filecontent, host) )

View File

@@ -618,13 +618,13 @@ function record_read(buffer, i)
local j, typ, proto = bin.unpack(">CS", buffer, i) local j, typ, proto = bin.unpack(">CS", buffer, i)
local name = find_key(TLS_CONTENTTYPE_REGISTRY, typ) local name = find_key(TLS_CONTENTTYPE_REGISTRY, typ)
if name == nil then if name == nil then
stdnse.print_debug("Unknown TLS ContentType: %d", typ) stdnse.debug1("Unknown TLS ContentType: %d", typ)
return j, nil return j, nil
end end
h["type"] = name h["type"] = name
name = find_key(PROTOCOLS, proto) name = find_key(PROTOCOLS, proto)
if name == nil then if name == nil then
stdnse.print_debug("Unknown TLS Protocol: 0x%x", typ) stdnse.debug1("Unknown TLS Protocol: 0x%x", typ)
return j, nil return j, nil
end end
h["protocol"] = name h["protocol"] = name
@@ -698,14 +698,14 @@ function record_read(buffer, i)
b["compressor"] = find_key(COMPRESSORS, b["compressor"]) b["compressor"] = find_key(COMPRESSORS, b["compressor"])
else else
-- TODO: implement other handshake message types -- TODO: implement other handshake message types
stdnse.print_debug(2, "Unknown handshake message type: %s", b["type"]) stdnse.debug2("Unknown handshake message type: %s", b["type"])
j = msg_end j = msg_end
end end
elseif h["type"] == "heartbeat" then elseif h["type"] == "heartbeat" then
j, b["type"], b["payload_length"] = bin.unpack("C>S", buffer, j) j, b["type"], b["payload_length"] = bin.unpack("C>S", buffer, j)
j, b["payload"], b["padding"] = bin.unpack("PP", buffer, j) j, b["payload"], b["padding"] = bin.unpack("PP", buffer, j)
else else
stdnse.print_debug("Unknown message type: %s", h["type"]) stdnse.debug1("Unknown message type: %s", h["type"])
end end
end end

View File

@@ -1137,7 +1137,7 @@ Packet.QueryResponseAck = {
pos, marker = bin.unpack("C", data, pos) pos, marker = bin.unpack("C", data, pos)
end end
if ( marker ~= 0x07 ) then if ( marker ~= 0x07 ) then
stdnse.print_debug(2, "Encountered unknown marker: %d", marker) stdnse.debug2("Encountered unknown marker: %d", marker)
break break
end end
@@ -1624,7 +1624,7 @@ Helper = {
end end
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(2, "ERROR: Version %s is not yet supported", self.os) stdnse.debug2("ERROR: Version %s is not yet supported", self.os)
return false, ("ERROR: Connect to version %s is not yet supported"):format(self.os) return false, ("ERROR: Connect to version %s is not yet supported"):format(self.os)
end end
@@ -1781,7 +1781,7 @@ Helper = {
end end
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(2, "ERROR: Version %s is not yet supported", self.os) stdnse.debug2("ERROR: Version %s is not yet supported", self.os)
return false, ("ERROR: Querying version %s is not yet supported"):format(self.os) return false, ("ERROR: Querying version %s is not yet supported"):format(self.os)
end end

View File

@@ -158,7 +158,7 @@ run_tests = function(to_test)
end end
local fails = stdnse.output_table() local fails = stdnse.output_table()
for _,lib in ipairs(to_test) do for _,lib in ipairs(to_test) do
stdnse.print_debug(1, "Testing %s", lib) stdnse.debug1("Testing %s", lib)
local thelib = require(lib) local thelib = require(lib)
local failed = 0 local failed = 0
if rawget(thelib,"test_suite") ~= nil then if rawget(thelib,"test_suite") ~= nil then
@@ -216,7 +216,7 @@ TestSuite = {
local passes = 0 local passes = 0
self:setup() self:setup()
for _,test in ipairs(self.tests) do for _,test in ipairs(self.tests) do
stdnse.print_debug(2, "| Test: %s...", test[2]) stdnse.debug2("| Test: %s...", test[2])
local status, note = test[1](self) local status, note = test[1](self)
local result local result
local lvl = 2 local lvl = 2
@@ -227,7 +227,7 @@ TestSuite = {
result = "Fail" result = "Fail"
lvl = 1 lvl = 1
if nmap.debugging() < 2 then if nmap.debugging() < 2 then
stdnse.print_debug(1, "| Test: %s...", test[2]) stdnse.debug1("| Test: %s...", test[2])
end end
failures = failures + 1 failures = failures + 1
end end
@@ -237,7 +237,7 @@ TestSuite = {
stdnse.print_debug(lvl, "| \\_result: %s", result) stdnse.print_debug(lvl, "| \\_result: %s", result)
end end
end end
stdnse.print_debug(1, "|_%d of %d tests passed", passes, #self.tests) stdnse.debug1("|_%d of %d tests passed", passes, #self.tests)
self:teardown() self:teardown()
return failures, #self.tests return failures, #self.tests
end, end,

View File

@@ -233,7 +233,7 @@ Comm = {
-- check to see if the IP address returned matches the IP address we scanned -- check to see if the IP address returned matches the IP address we scanned
if xhost ~= self.host.ip then if xhost ~= self.host.ip then
stdnse.print_debug("IP addresses did not match! Found %s, using %s instead.", xhost, self.host.ip) stdnse.debug1("IP addresses did not match! Found %s, using %s instead.", xhost, self.host.ip)
xhost = self.host.ip xhost = self.host.ip
end end

View File

@@ -127,13 +127,13 @@ VNC = {
self.protover = VNC.versions[data] self.protover = VNC.versions[data]
if ( not(self.protover) ) then if ( not(self.protover) ) then
stdnse.print_debug("ERROR: VNC:handshake unsupported version (%s)", data:sub(1,11)) stdnse.debug1("ERROR: VNC:handshake unsupported version (%s)", data:sub(1,11))
return false, ("Unsupported version (%s)"):format(data:sub(1,11)) return false, ("Unsupported version (%s)"):format(data:sub(1,11))
end end
status = self.socket:send( self.cli_version ) status = self.socket:send( self.cli_version )
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("ERROR: VNC:handshake failed to send client version") stdnse.debug1("ERROR: VNC:handshake failed to send client version")
return false, "ERROR: VNC:handshake failed" return false, "ERROR: VNC:handshake failed"
end end
@@ -167,7 +167,7 @@ VNC = {
else else
local status, tmp = self.socket:receive_buf(match.numbytes(1), true) local status, tmp = self.socket:receive_buf(match.numbytes(1), true)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("ERROR: VNC:handshake failed to receive security data") stdnse.debug1("ERROR: VNC:handshake failed to receive security data")
return false, "ERROR: VNC:handshake failed to receive security data" return false, "ERROR: VNC:handshake failed to receive security data"
end end
@@ -178,7 +178,7 @@ VNC = {
status, tmp = self.socket:receive_buf(match.numbytes(vncsec.count), true) status, tmp = self.socket:receive_buf(match.numbytes(vncsec.count), true)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("ERROR: VNC:handshake failed to receive security data") stdnse.debug1("ERROR: VNC:handshake failed to receive security data")
return false, "ERROR: VNC:handshake failed to receive security data" return false, "ERROR: VNC:handshake failed to receive security data"
end end

View File

@@ -1371,7 +1371,7 @@ local l_make_output = function(fid_table, entries, filter)
end end
if next(hosts) then if next(hosts) then
stdnse.print_debug(3, stdnse.debug3(
"vulns.lua: sorting vulnerability entries for %d host", "vulns.lua: sorting vulnerability entries for %d host",
#hosts) #hosts)
sort(hosts, sort_hosts) sort(hosts, sort_hosts)

View File

@@ -167,7 +167,7 @@ Response = {
self.length = 16 + 2 + 1 self.length = 16 + 2 + 1
pos, self.ip = bin.unpack("H16", self.data, pos) pos, self.ip = bin.unpack("H16", self.data, pos)
else else
stdnse.print_debug("Unknown address type (length: %d)", addr_len) stdnse.debug1("Unknown address type (length: %d)", addr_len)
return false, "Unknown address type" return false, "Unknown address type"
end end
pos, self.port = bin.unpack(">S", self.data, pos) pos, self.port = bin.unpack(">S", self.data, pos)
@@ -306,7 +306,7 @@ Response = {
fromString = function(data) fromString = function(data)
local find = Response.FIND_NODE:new(data) local find = Response.FIND_NODE:new(data)
if ( find.header.proto_version < 13 ) then if ( find.header.proto_version < 13 ) then
stdnse.print_debug("ERROR: Unsupported version %d", find.header.proto_version) stdnse.debug1("ERROR: Unsupported version %d", find.header.proto_version)
return false return false
end end
@@ -390,7 +390,7 @@ Response = {
return Response.ERROR.fromString(data) return Response.ERROR.fromString(data)
end end
stdnse.print_debug("ERROR: Unknown response received from server") stdnse.debug1("ERROR: Unknown response received from server")
return false, "Failed to parse response" return false, "Failed to parse response"
end, end,

View File

@@ -255,7 +255,7 @@ Comm = {
local _, ip local _, ip
status, _, _, ip, _ = self.socket:get_info() status, _, _, ip, _ = self.socket:get_info()
if( not(status) ) then if( not(status) ) then
stdnse.print_debug( 3, "wsdd.recvProbeMatches: ERROR: Failed to get socket info" ) stdnse.debug3("wsdd.recvProbeMatches: ERROR: Failed to get socket info" )
return false, "ERROR: Failed to get socket info" return false, "ERROR: Failed to get socket info"
end end