1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-12 10:49:02 +00:00

Moved EIGRP decoding in packetdecoders.lua to use eigrp.lua library.

This commit is contained in:
kroosec
2012-08-15 09:17:20 +00:00
parent 8d71da78de
commit 8ff4cebbf7

View File

@@ -187,8 +187,8 @@ Decoders = {
}, },
-- EIGRP Query & Update -- EIGRP Update
['020[13]....00000000'] = { ['0201....0000'] = {
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
@@ -204,548 +204,500 @@ Decoders = {
if ( p.ip_p ~= 88 ) then return end if ( p.ip_p ~= 88 ) then return end
local data = layer3:sub(p.ip_data_offset + 1) local data = layer3:sub(p.ip_data_offset + 1)
local eigrp = require("eigrp")
local route_type, proto_name
-- Extract the EIGRP header -- Extract the EIGRP header
local pos, ver, opcode, checksum, flags, seq, ack, asnum = bin.unpack(">CCSiiii", data) local response = eigrp.EIGRP.parse(data)
local route_type, size, nexthop, delay, bandwidth, temp, mtu, orig_router, orig_as, arbtag if response then
local hop_count, reliability, load, reserved, mask -- Iterate over tlv tables
local destination for _, tlv in pairs(response.tlvs) do
if eigrp.EIGRP.isRoutingTLV(tlv.type) then
-- Iterate over the routes
while ( pos < #data ) do
-- Get the route type as the packet construction varies
pos,route_type = bin.unpack(">S", data, pos)
if ( route_type == 258 ) then
route_type = 'internal'
pos, size, nexthop, delay, bandwidth, temp, mtu = bin.unpack(">SiiiCS", data, pos)
pos, hop_count, reliability, load, reserved, mask = bin.unpack(">CCCSC", data, pos)
local oct1, oct2, oct3, oct4 = 0, 0, 0, 0 if ( not(self.results) ) then
-- unneeded address octets are left out of the packets, lets fill in the gaps self.results = tab.new(7)
if ( size == 29 ) then tab.addrow(self.results, 'Sender IP', 'AS#', 'Route Type', 'Destination', 'Next hop', 'Ext Protocol', 'Orig Router ID')
-- mask 25 or above end
pos, oct1, oct2, oct3, oct4 = bin.unpack(">CCCC", data, pos) if tlv.type == 0x102 then
elseif ( size == 28 ) then route_type = "Internal"
pos, oct1, oct2, oct3 = bin.unpack(">CCC", data, pos) elseif tlv.type == 0x103 then
elseif ( size == 27 ) then route_type = "External"
pos, oct1, oct2 = bin.unpack(">CC", data, pos) for name, value in pairs(eigrp.EXT_PROTO) do
elseif ( size == 26 ) then if value == tlv.eproto then
pos, oct1 = bin.unpack(">C", data, pos) proto_name = name
break
end
end end
end
destination = oct1 .. '.' .. oct2 .. '.' .. oct3 .. '.' .. oct4 .. "/" .. mask if ( not(self.dups[("%s:%s:s:%s"):format(p.ip_src, response.as, tlv.type, tlv.dst)]) ) then
orig_router = 'n/a'
elseif ( route_type == 259 ) then
-- external route, from a different routing protocol
pos, size, nexthop = bin.unpack(">Si", data, pos)
local orig_rtr_oct1, orig_rtr_oct2, orig_rtr_oct3, orig_rtr_oct4, ext_proto_id, ext_metric
pos, orig_rtr_oct1, orig_rtr_oct2, orig_rtr_oct3, orig_rtr_oct4 = bin.unpack(">CCCC", data, pos)
orig_router = orig_rtr_oct1 .. '.' .. orig_rtr_oct2 .. '.' .. orig_rtr_oct3 .. '.' .. orig_rtr_oct4
pos, orig_as, arbtag, ext_metric = bin.unpack(">iii", data, pos)
pos, reserved, ext_proto_id, flags, delay, bandwidth = bin.unpack(">SCCii", data, pos)
pos, temp, mtu, hop_count, reliability, load, reserved, mask = bin.unpack(">CSCCCSC", data, pos)
local oct1, oct2, oct3, oct4 = 0, 0, 0, 0
-- unneeded address octets are left out of the packets, lets fill in the gaps
if ( size == 49 ) then
-- mask 25 or above
pos, oct1, oct2, oct3, oct4 = bin.unpack(">CCCC", data, pos)
elseif ( size == 48 ) then
pos, oct1, oct2, oct3 = bin.unpack(">CCC", data, pos)
elseif ( size == 47 ) then
pos, oct1, oct2 = bin.unpack(">CC", data, pos)
elseif ( size == 46 ) then
pos, oct1 = bin.unpack(">C", data, pos)
end
destination = oct1 .. '.' .. oct2 .. '.' .. oct3 .. '.' .. oct4 .. "/" .. mask
local Proto_Types = {
[1] = 'external (IGRP)',
[2] = 'external (EIGRP)',
[3] = 'external (static)',
[4] = 'external (RIP)',
[6] = 'external (OSPF)',
[9] = 'external (RIP)'
}
route_type = Proto_Types[ext_proto_id]
end
if ( not(self.results) ) then
self.results = tab.new(9)
tab.addrow(self.results, 'sender ip', 'AS#', 'route type', 'destination', 'hop', 'bandwidth', 'delay', 'seq','orig router')
end
if (delay == -1) then delay = 'unreachable' end
if ( not(self.dups[("%s:%s:s:%s"):format(p.ip_src,asnum,destination,seq)]) ) 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
self.dups[("%s:%s:%s:%s"):format(p.ip_src,asnum,destination,seq)] = true self.dups[("%s:%s:%s:%s"):format(p.ip_src, response.as, tlv.type, tlv.dst)] = true
tab.addrow( self.results, p.ip_src, asnum, route_type, destination, hop_count, bandwidth, delay, seq, orig_router ) tab.addrow( self.results, p.ip_src, response.as, route_type, tlv.dst, tlv.nexth, proto_name or 'X', tlv.orouterid or 'X')
end
end end
end
end end
end, end,
getResults = function(self) return { name = "EIGRP Update", (self.results and tab.dump(self.results) or "") } end,
getResults = function(self) return { name = "EIGRP Query", (self.results and tab.dump(self.results) or "") } end, },
},
['0205....00000000'] = {
new = function(self) ['0205....0000'] = {
new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
process = function(self, layer3)
process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 ) local p = packet.Packet:new( layer3, #layer3 )
-- EIGRP is IP protocol 88 (0x58), so verify this -- EIGRP is IP protocol 88 (0x58), so verify this
if ( p.ip_p ~= 88 ) then return end if ( p.ip_p ~= 88 ) then return end
local data = layer3:sub(p.ip_data_offset + 1) local data = layer3:sub(p.ip_data_offset + 1)
local eigrp = require("eigrp")
-- Extract the EIGRP header -- Extract the EIGRP header
local pos, ver, opcode, checksum, flags, seq, ack, asnum = bin.unpack(">CCSiiii", data) local response = eigrp.EIGRP.parse(data)
-- See if Software version TLV is included
-- Skip the parameters for now. local swvertlv
pos = pos + 10 for num, tlv in pairs(response.tlvs) do
if tlv.type == eigrp.TLV.SWVER then
local holdtime, software, size, ios_major, ios_minor, eigrp_major, eigrp_minor swvertlv = num
pos, holdtime, software, size, ios_major, ios_minor, eigrp_major, eigrp_minor = bin.unpack(">SSSCCCC", data, pos) end
end
if ( not(self.results) ) then if swvertlv then
if ( not(self.results) ) then
self.results = tab.new(5) self.results = tab.new(5)
tab.addrow(self.results, 'sender ip', 'AS number', 'hold time', 'EIGRP version', 'IOS version') tab.addrow(self.results, 'Sender IP', 'AS number', 'EIGRP version', 'IOS version')
end end
if ( not(self.dups[("%s:%s"):format(p.ip_src,asnum)]) ) then if ( not(self.dups[("%s:%s"):format(p.ip_src,response.as)]) ) 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
self.dups[("%s:%s"):format(p.ip_src,asnum)] = true self.dups[("%s:%s"):format(p.ip_src,response.as)] = true
tab.addrow( self.results, p.ip_src, asnum, holdtime, eigrp_major .. '.' .. eigrp_minor, ios_major .. '.' .. ios_minor ) tab.addrow( self.results, p.ip_src, response.as, response.tlvs[swvertlv].majv .. '.' .. response.tlvs[swvertlv].minv, response.tlvs[swvertlv].majtlv .. '.' .. response.tlvs[swvertlv].mintlv)
end end
end
end, end,
getResults = function(self) return { name = "EIGRP Hello", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "EIGRP Hello", (self.results and tab.dump(self.results) or "") } end,
}, },
-- OSPF -- OSPF
['0201'] = { -- OSPFv2 Hello packet ['02010'] = { -- OSPFv2 Hello packet
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
process = function(self, layer3) process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 ) local p = packet.Packet:new( layer3, #layer3 )
-- IP Protocol is 89 for OSPF -- IP Protocol is 89 for OSPF
if p.ip_p ~= 89 then return end if p.ip_p ~= 89 then return end
local ospf = require("ospf") local ospf = require("ospf")
local data = layer3:sub(p.ip_data_offset + 1)
local header = ospf.OSPF.Header.parse(data)
if header then
if not(self.results) then
self.results = tab.new(5)
tab.addrow(self.results, 'Source IP', 'Router ID', 'Area ID', 'Auth Type', 'Password')
end
local srcip = p.ip_src
local areaid = header.area_id
local routerid = header.router_id
local authtype = header.auth_type
local authdata
-- Format authentication type and data
if header.auth_type == 0 then
authtype = "None"
authdata = ''
elseif header.auth_type == 1 then
authtype = "Password"
authdata = header.auth_data.password
elseif header.auth_type == 2 then
authtype = "OSPF MD5"
authdata = "" -- Not really helpful, as the MD5
-- is applied to the whole packet+password
else
-- Error
stdnse.print_debug("Unknown OSPF auth type %d", header.auth_type)
return
end
if ( not(self.dups[("%s:%s"):format(routerid,areaid)]) ) then local data = layer3:sub(p.ip_data_offset + 1)
if ( target.ALLOW_NEW_TARGETS ) then target.add(routerid) end local header = ospf.OSPF.Header.parse(data)
self.dups[("%s:%s"):format(routerid,areaid)] = true if header then
tab.addrow( self.results, srcip, routerid, areaid, authtype, authdata) if not(self.results) then
end self.results = tab.new(5)
tab.addrow(self.results, 'Source IP', 'Router ID', 'Area ID', 'Auth Type', 'Password')
end
local srcip = p.ip_src
local areaid = header.area_id
local routerid = header.router_id
local authtype = header.auth_type
local authdata
-- Format authentication type and data
if header.auth_type == 0 then
authtype = "None"
authdata = ''
elseif header.auth_type == 1 then
authtype = "Password"
authdata = header.auth_data.password
elseif header.auth_type == 2 then
authtype = "OSPF MD5"
authdata = "" -- Not really helpful, as the MD5
-- is applied to the whole packet+password
else else
return nil -- Error
stdnse.print_debug("Unknown OSPF auth type %d", header.auth_type)
return
end end
if ( not(self.dups[("%s:%s"):format(routerid,areaid)]) ) then
if ( target.ALLOW_NEW_TARGETS ) then target.add(routerid) end
self.dups[("%s:%s"):format(routerid,areaid)] = true
tab.addrow( self.results, srcip, routerid, areaid, authtype, authdata)
end
else
return nil
end
end, end,
getResults = function(self) return { name = "OSPF Hello", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "OSPF Hello", (self.results and tab.dump(self.results) or "") } end,
},
}, },
},
udp = {
udp = {
-- DHCP
-- DHCP [68] = {
[68] = {
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
getOption = function(options, name) getOption = function(options, name)
for _, v in ipairs(options) do for _, v in ipairs(options) do
if ( v.name == name ) then if ( v.name == name ) then
if ( type(v.value) == "table" ) then if ( type(v.value) == "table" ) then
return stdnse.strjoin(", ", v.value) return stdnse.strjoin(", ", v.value)
else else
return v.value return v.value
end end
end
end end
end
end, end,
process = function(self, layer3) process = function(self, layer3)
local dhcp = require("dhcp") local dhcp = require("dhcp")
local p = packet.Packet:new( layer3, #layer3 ) local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9) local data = layer3:sub(p.udp_offset + 9)
-- the dhcp.parse function isn't optimal for doing
-- this, but it will do for now. First, we need to
-- extract the xid as the parse function checks that it
-- was the same as in the request, which we didn't do.
local pos, msgtype, _, _, _, xid = bin.unpack("<CCCCA4", data)
-- attempt to parse the data -- the dhcp.parse function isn't optimal for doing
local status, result = dhcp.dhcp_parse(data, xid) -- this, but it will do for now. First, we need to
-- extract the xid as the parse function checks that it
if ( status ) then -- was the same as in the request, which we didn't do.
if ( not(self.results) ) then local pos, msgtype, _, _, _, xid = bin.unpack("<CCCCA4", data)
self.results = tab.new(5)
tab.addrow(self.results, "srv ip", "cli ip", "mask", "gw", "dns" )
end
local uniq_key = ("%s:%s"):format(p.ip_src, result.yiaddr_str)
if ( not(self.dups[uniq_key]) ) then -- attempt to parse the data
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end local status, result = dhcp.dhcp_parse(data, xid)
local mask = self.getOption(result.options, "Subnet Mask") or "-"
local gw = self.getOption(result.options, "Router") or "-"
local dns = self.getOption(result.options, "Domain Name Server") or "-"
tab.addrow(self.results, p.ip_src, result.yiaddr_str, mask, gw, dns )
end
end
end,
getResults = function(self) return { name = "DHCP", (self.results and tab.dump(self.results) or "") } end,
},
-- Netbios
[137] = {
new = function(self)
local o = { dups = {} }
setmetatable(o, self)
self.__index = self
return o
end,
process = function(self, layer3)
local dns = require('dns')
local bin = require('bin')
local netbios = require('netbios')
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
local dresp = dns.decode(data)
if ( not(dresp.questions) or #dresp.questions < 1 ) then return end
local name = netbios.name_decode("\32" .. dresp.questions[1].dname)
if ( status ) then
if ( not(self.results) ) then if ( not(self.results) ) then
self.results = tab.new(2) self.results = tab.new(5)
tab.addrow( self.results, 'ip', 'query' ) tab.addrow(self.results, "srv ip", "cli ip", "mask", "gw", "dns" )
end end
local uniq_key = ("%s:%s"):format(p.ip_src, result.yiaddr_str)
-- check for duplicates
if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then if ( not(self.dups[uniq_key]) ) 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
tab.addrow( self.results, p.ip_src, name ) local mask = self.getOption(result.options, "Subnet Mask") or "-"
self.dups[("%s:%s"):format(p.ip_src, name)] = true local gw = self.getOption(result.options, "Router") or "-"
local dns = self.getOption(result.options, "Domain Name Server") or "-"
tab.addrow(self.results, p.ip_src, result.yiaddr_str, mask, gw, dns )
end end
end
end,
getResults = function(self) return { name = "DHCP", (self.results and tab.dump(self.results) or "") } end,
},
-- Netbios
[137] = {
new = function(self)
local o = { dups = {} }
setmetatable(o, self)
self.__index = self
return o
end,
process = function(self, layer3)
local dns = require('dns')
local bin = require('bin')
local netbios = require('netbios')
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
local dresp = dns.decode(data)
if ( not(dresp.questions) or #dresp.questions < 1 ) then return end
local name = netbios.name_decode("\32" .. dresp.questions[1].dname)
if ( not(self.results) ) then
self.results = tab.new(2)
tab.addrow( self.results, 'ip', 'query' )
end
-- check for duplicates
if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
tab.addrow( self.results, p.ip_src, name )
self.dups[("%s:%s"):format(p.ip_src, name)] = true
end
end, end,
getResults = function(self) return { name = "Netbios", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "Netbios", (self.results and tab.dump(self.results) or "") } end,
}, },
--- SSDP
[1900] = {
--- SSDP
[1900] = {
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
local headers = stdnse.strsplit("\r\n", data) process = function(self, layer3)
for _, h in ipairs(headers) do local p = packet.Packet:new( layer3, #layer3 )
local st = "" local data = layer3:sub(p.udp_offset + 9)
if ( h:match("^ST:.*") ) then
st = h:match("^ST:(.*)") local headers = stdnse.strsplit("\r\n", data)
if ( not(self.results) ) then for _, h in ipairs(headers) do
self.results = tab.new(1) local st = ""
tab.addrow( self.results, 'ip', 'uri' ) if ( h:match("^ST:.*") ) then
end st = h:match("^ST:(.*)")
if ( not(self.dups[("%s:%s"):format(p.ip_src,st)]) ) then if ( not(self.results) ) then
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end self.results = tab.new(1)
tab.addrow( self.results, p.ip_src, st ) tab.addrow( self.results, 'ip', 'uri' )
self.dups[("%s:%s"):format(p.ip_src,st)] = true end
end if ( not(self.dups[("%s:%s"):format(p.ip_src,st)]) ) then
end if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end tab.addrow( self.results, p.ip_src, st )
self.dups[("%s:%s"):format(p.ip_src,st)] = true
end
end
end
end, end,
getResults = function(self) return { name = "SSDP", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "SSDP", (self.results and tab.dump(self.results) or "") } end,
},
--- HSRP },
[1985] = {
--- HSRP
[1985] = {
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
local ipOps = require("ipOps")
local State = {
[0] = "Initial",
[1] = "Learn",
[2] = "Listen",
[4] = "Speak",
[8] = "Standby",
[16] = "Active"
}
local Op = {
[0] = "Hello",
[1] = "Coup",
[2] = "Resign",
}
local pos, version, op, state, _, _, prio, group, _, secret = bin.unpack("CCCCCCCCz", data) process = function(self, layer3)
if ( version ~= 0 ) then return end local p = packet.Packet:new( layer3, #layer3 )
pos = pos + ( 7 - #secret ) local data = layer3:sub(p.udp_offset + 9)
local virtip local ipOps = require("ipOps")
pos, virtip = bin.unpack("<I", data, pos)
local State = {
if ( not(self.dups[p.ip_src]) ) then [0] = "Initial",
if ( not(self.results) ) then [1] = "Learn",
self.results = tab.new(7) [2] = "Listen",
tab.addrow(self.results, 'ip', 'version', 'op', 'state', 'prio', 'group', 'secret', 'virtual ip') [4] = "Speak",
end [8] = "Standby",
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end [16] = "Active"
self.dups[p.ip_src] = true }
tab.addrow(self.results, p.ip_src, version, Op[op], State[state], prio, group, secret, ipOps.fromdword(virtip))
local Op = {
[0] = "Hello",
[1] = "Coup",
[2] = "Resign",
}
local pos, version, op, state, _, _, prio, group, _, secret = bin.unpack("CCCCCCCCz", data)
if ( version ~= 0 ) then return end
pos = pos + ( 7 - #secret )
local virtip
pos, virtip = bin.unpack("<I", data, pos)
if ( not(self.dups[p.ip_src]) ) then
if ( not(self.results) ) then
self.results = tab.new(7)
tab.addrow(self.results, 'ip', 'version', 'op', 'state', 'prio', 'group', 'secret', 'virtual ip')
end end
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
self.dups[p.ip_src] = true
tab.addrow(self.results, p.ip_src, version, Op[op], State[state], prio, group, secret, ipOps.fromdword(virtip))
end
end, end,
getResults = function(self) return { name = "HSRP", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "HSRP", (self.results and tab.dump(self.results) or "") } end,
}, },
-- Dropbox -- Dropbox
[17500] = { [17500] = {
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
process = function(self, layer3) process = function(self, layer3)
local json = require("json") local json = require("json")
local p = packet.Packet:new( layer3, #layer3 ) local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9) local data = layer3:sub(p.udp_offset + 9)
local status, info = json.parse(data) local status, info = json.parse(data)
if ( not(status) ) then if ( not(status) ) then
return false, "Failed to parse JSON data" return false, "Failed to parse JSON data"
end end
-- Add host to list. -- Add host to list.
for _, key1 in pairs({"namespaces", "version"}) do for _, key1 in pairs({"namespaces", "version"}) do
for key2, val in pairs(info[key1]) do for key2, val in pairs(info[key1]) do
info[key1][key2] = tostring(info[key1][key2]) info[key1][key2] = tostring(info[key1][key2])
end
end
if ( not(self.results) ) then
self.results = tab.new(6)
tab.addrow(
self.results,
'displayname',
'ip',
'port',
'version',
'host_int',
'namespaces'
)
end
if ( not(self.dups[p.ip_src]) ) then
tab.addrow(
self.results,
info.displayname,
p.ip_src,
info.port,
stdnse.strjoin(".", info.version),
info.host_int,
stdnse.strjoin(", ", info.namespaces)
)
self.dups[p.ip_src] = true
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end end
end
if ( not(self.results) ) then
self.results = tab.new(6)
tab.addrow(
self.results,
'displayname',
'ip',
'port',
'version',
'host_int',
'namespaces'
)
end
if ( not(self.dups[p.ip_src]) ) then
tab.addrow(
self.results,
info.displayname,
p.ip_src,
info.port,
stdnse.strjoin(".", info.version),
info.host_int,
stdnse.strjoin(", ", info.namespaces)
)
self.dups[p.ip_src] = true
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end
end, end,
getResults = function(self) return { name = "DropBox", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "DropBox", (self.results and tab.dump(self.results) or "") } end,
},
--- Squeezebox Discovery
[3483] = {
new = function(self)
local o = { dups = {} }
setmetatable(o, self)
self.__index = self
return o
end,
process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
if ( data:match("^eIPAD") ) then
if ( not(self.results) ) then
self.results = tab.new(1)
tab.addrow( self.results, 'ip' )
end
if ( not(self.dups[p.ip_src]) ) then
tab.addrow( self.results, p.ip_src )
self.dups[p.ip_src] = true
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end
end
end,
getResults = function(self) return { name = "Squeezebox Discovery", (self.results and tab.dump(self.results) or "") } end,
},
-- Multicast DNS/BonJour/ZeroConf
[5353] = {
new = function(self)
local o = { dups = {} }
setmetatable(o, self)
self.__index = self
return o
end,
process = function(self, layer3)
local dns = require('dns')
local bin = require('bin')
local p = packet.Packet:new( layer3, #layer3 ) },
local data = layer3:sub(p.udp_offset + 9)
local dresp = dns.decode(data) --- Squeezebox Discovery
local name [3483] = {
if ( dresp.questions and #dresp.questions > 0 ) then new = function(self)
name = dresp.questions[1].dname local o = { dups = {} }
elseif ( dresp.answers and #dresp.answers > 0 ) then setmetatable(o, self)
name = dresp.answers[1].dname self.__index = self
end return o
end,
if ( not(name) ) then return end
process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
if ( data:match("^eIPAD") ) then
if ( not(self.results) ) then if ( not(self.results) ) then
self.results = tab.new(2) self.results = tab.new(1)
tab.addrow( self.results, 'ip', 'query' ) tab.addrow( self.results, 'ip' )
end end
-- check for duplicates if ( not(self.dups[p.ip_src]) ) then
if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then tab.addrow( self.results, p.ip_src )
tab.addrow( self.results, p.ip_src, name ) self.dups[p.ip_src] = true
self.dups[("%s:%s"):format(p.ip_src, name)] = true if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end end
end
end,
getResults = function(self) return { name = "Squeezebox Discovery", (self.results and tab.dump(self.results) or "") } end,
},
-- Multicast DNS/BonJour/ZeroConf
[5353] = {
new = function(self)
local o = { dups = {} }
setmetatable(o, self)
self.__index = self
return o
end,
process = function(self, layer3)
local dns = require('dns')
local bin = require('bin')
local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9)
local dresp = dns.decode(data)
local name
if ( dresp.questions and #dresp.questions > 0 ) then
name = dresp.questions[1].dname
elseif ( dresp.answers and #dresp.answers > 0 ) then
name = dresp.answers[1].dname
end
if ( not(name) ) then return end
if ( not(self.results) ) then
self.results = tab.new(2)
tab.addrow( self.results, 'ip', 'query' )
end
-- check for duplicates
if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then
tab.addrow( self.results, p.ip_src, name )
self.dups[("%s:%s"):format(p.ip_src, name)] = true
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end
end, end,
getResults = function(self) return { name = "MDNS", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "MDNS", (self.results and tab.dump(self.results) or "") } end,
}, },
--- Spotify --- Spotify
[57621] = { [57621] = {
new = function(self) new = function(self)
local o = { dups = {} } local o = { dups = {} }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end, end,
process = function(self, layer3) process = function(self, layer3)
local p = packet.Packet:new( layer3, #layer3 ) local p = packet.Packet:new( layer3, #layer3 )
local data = layer3:sub(p.udp_offset + 9) local data = layer3:sub(p.udp_offset + 9)
if ( data:match("^SpotUdp") ) then if ( data:match("^SpotUdp") ) then
if ( not(self.results) ) then if ( not(self.results) ) then
self.results = tab.new(1) self.results = tab.new(1)
tab.addrow( self.results, 'ip' ) tab.addrow( self.results, 'ip' )
end
if ( not(self.dups[p.ip_src]) ) then
tab.addrow( self.results, p.ip_src )
self.dups[p.ip_src] = true
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end
end end
if ( not(self.dups[p.ip_src]) ) then
tab.addrow( self.results, p.ip_src )
self.dups[p.ip_src] = true
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
end
end
end, end,
getResults = function(self) return { name = "Spotify", (self.results and tab.dump(self.results) or "") } end, getResults = function(self) return { name = "Spotify", (self.results and tab.dump(self.results) or "") } end,
}
} }
}
}
}