@@ -16,11 +16,9 @@ def initialize
16
16
'Author' => 'Fatih Ozavci <viproy.com/fozavci>' ,
17
17
'License' => MSF_LICENSE ,
18
18
'Actions' => [
19
- [ 'Sniff' , { 'Description' => 'Sniffs CDP packets' } ] ,
20
19
[ 'Spoof' , { 'Description' => 'Sends spoofed CDP packets' } ]
21
20
] ,
22
- 'PassiveActions' => %w( Sniff ) ,
23
- 'DefaultAction' => 'Sniff'
21
+ 'DefaultAction' => 'Spoof'
24
22
)
25
23
register_options (
26
24
[
@@ -61,8 +59,6 @@ def run
61
59
case action . name
62
60
when 'Spoof'
63
61
do_spoof
64
- when 'Sniff'
65
- do_sniff
66
62
else
67
63
# this should never happen
68
64
fail ArgumentError , "Invalid action #{ action . name } "
@@ -72,81 +68,6 @@ def run
72
68
end
73
69
end
74
70
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
-
150
71
def do_spoof
151
72
print_status ( "Sending CDP message on #{ interface } " )
152
73
p = prep_cdp # Preparation of the CDP content
0 commit comments