Skip to content

Commit 2d484a3

Browse files
committed
Remove sniffing capabilities from cdp -- use wireshark/tcpdump instead
1 parent 39d6910 commit 2d484a3

File tree

1 file changed

+1
-80
lines changed
  • modules/auxiliary/spoof/cisco

1 file changed

+1
-80
lines changed

modules/auxiliary/spoof/cisco/cdp.rb

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ def initialize
1616
'Author' => 'Fatih Ozavci <viproy.com/fozavci>',
1717
'License' => MSF_LICENSE,
1818
'Actions' => [
19-
['Sniff', { 'Description' => 'Sniffs CDP packets' }],
2019
['Spoof', { 'Description' => 'Sends spoofed CDP packets' }]
2120
],
22-
'PassiveActions' => %w(Sniff),
23-
'DefaultAction' => 'Sniff'
21+
'DefaultAction' => 'Spoof'
2422
)
2523
register_options(
2624
[
@@ -61,8 +59,6 @@ def run
6159
case action.name
6260
when 'Spoof'
6361
do_spoof
64-
when 'Sniff'
65-
do_sniff
6662
else
6763
# this should never happen
6864
fail ArgumentError, "Invalid action #{action.name}"
@@ -72,81 +68,6 @@ def run
7268
end
7369
end
7470

75-
def do_sniff
76-
print_status("Sniffing traffic on #{interface}")
77-
lbl = ["CDP Version\t", "Device Id\t", "IP Address\t", "Switch Port\t", "Capabilities", "Software\t", "Platform\t", nil, "Cluster Management", "VTP Domain Management" , "Native VLAN\t", nil, nil, nil, nil, "VoIP VLAN Query"]
78-
each_packet do |pkt|
79-
p = PacketFu::Packet.parse(pkt)
80-
next unless p.proto != ["Eth", "LLDP"] && p.payload =~ /\x01\x00\x0C\xCC\xCC\xCC/
81-
pay = p.payload
82-
pos = 30
83-
cdp = pay[22].getbyte(0)
84-
report = "CDP Version\t\t: #{cdp}\n"
85-
if cdp == 2
86-
while true
87-
type = pay[pos - 4, 2].getbyte(1)
88-
break if pay[pos - 2, 2].nil?
89-
l = pay[pos - 2, 2].unpack('H*')[0].to_i(16)
90-
case type
91-
when 1
92-
d = pay[pos, l]
93-
d.chop! if d[-1] == "\n"
94-
report << " #{lbl[type]} \t: #{d}\n"
95-
when 2
96-
if pay[pos, 4].unpack('H*')[0].to_i(16) == 1
97-
addr = pay[pos + 9, 4]
98-
ip = []
99-
4.times { |i| ip << "#{addr.getbyte(i)}" }
100-
report << " #{lbl[type]}\t: #{ip.join(".")}\n"
101-
end
102-
when 3
103-
report << " #{lbl[type]}\t: #{pay[pos,l]}\n"
104-
when 4
105-
c = pay[pos + 3, 1].getbyte(0)
106-
c = c.to_s(2)
107-
caps = ["Repeater\t\t", "IGMP Capable\t\t", "Host\t\t\t", "Switch\t\t", "Source Route Bridge\t", "Transparent Bridge\t", "Router\t\t"]
108-
report << " #{lbl[type]}\t: \n"
109-
c.length.times do
110-
if c[-1].to_i == 1
111-
report << "\t\t\t #{caps[-1]} : Yes\n"
112-
else
113-
report << "\t\t\t #{caps[-1]} : No\n"
114-
end
115-
c.chop!
116-
caps.delete_at(-1)
117-
end
118-
unless caps.empty?
119-
caps.each do |missing_cap|
120-
report << "\t\t\t #{missing_cap}: No\n"
121-
end
122-
end
123-
when 5
124-
report << " #{lbl[type]}\t: #{pay[pos, l].split("\n").join("\n\t\t\t ")}\n"
125-
when 8
126-
# TODO?
127-
# report << " #{lbl[type]}\t:\n"
128-
# report << " IP: #{pay[pos+14,4]}\n"
129-
when 10
130-
report << " #{lbl[type]}\t: #{pay[pos, 2].unpack('H*')[0].to_i(16)}\n"
131-
when 15
132-
report << " #{lbl[type]}\t: #{pay[pos + 1, 2].unpack('H*')[0].to_i(16)}\n"
133-
else
134-
report << " #{lbl[type]}\t: #{pay[pos, l]}\n" if lbl[type]
135-
end
136-
if pos > pay.length
137-
break
138-
else
139-
pos += l
140-
end
141-
end
142-
else
143-
report << " TTL\t\t\t: #{pay[23].unpack('H*')[0].to_i(16)}"
144-
end
145-
print_good("#{report}")
146-
end
147-
print_status("Finished sniffing")
148-
end
149-
15071
def do_spoof
15172
print_status("Sending CDP message on #{interface}")
15273
p = prep_cdp # Preparation of the CDP content

0 commit comments

Comments
 (0)