CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/networking/mikrotik_config.rb
Views: 11655
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Auxiliary::Mikrotik
8
9
def initialize(info = {})
10
super(
11
update_info(
12
info,
13
'Name' => 'Mikrotik Configuration Importer',
14
'Description' => %q{
15
This module imports a Mikrotik device configuration.
16
},
17
'License' => MSF_LICENSE,
18
'Author' => ['h00die'],
19
'Actions' => [
20
['ROUTEROS', { 'Description' => 'Import RouterOS Config File' }],
21
['SWOS', { 'Description' => 'Import SwOS Config File' }],
22
],
23
'DefaultAction' => 'ROUTEROS',
24
'Notes' => {
25
'Stability' => [],
26
'SideEffects' => [],
27
'Reliability' => []
28
}
29
)
30
)
31
32
register_options(
33
[
34
OptPath.new('CONFIG', [true, 'Path to configuration to import']),
35
Opt::RHOST(),
36
Opt::RPORT(22)
37
]
38
)
39
end
40
41
def run
42
unless ::File.exist?(datastore['CONFIG'])
43
fail_with(Failure::BadConfig, "Mikrotik config file #{datastore['CONFIG']} does not exist!")
44
end
45
mikrotik_config = ::File.open(datastore['CONFIG'], 'rb')
46
print_status('Importing config')
47
if action.name == 'ROUTEROS'
48
print_bad('SWB files are typically SWOS, check action') if datastore['CONFIG'].ends_with?('.swb')
49
mikrotik_routeros_config_eater(datastore['RHOSTS'], datastore['RPORT'], mikrotik_config.read)
50
elsif action.name == 'SWOS'
51
mikrotik_swos_config_eater(datastore['RHOSTS'], datastore['RPORT'], mikrotik_config.read)
52
end
53
print_good('Config import successful')
54
end
55
end
56
57