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/juniper_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::Juniper
8
include Msf::Exploit::Deprecated
9
moved_from 'auxiliary/admin/juniper/juniper_config'
10
11
def initialize(info = {})
12
super(
13
update_info(
14
info,
15
'Name' => 'Juniper Configuration Importer',
16
'Description' => %q{
17
This module imports a Juniper ScreenOS or JunOS device configuration.
18
},
19
'License' => MSF_LICENSE,
20
'Author' => ['h00die'],
21
'Actions' => [
22
['JUNOS', { 'Description' => 'Import JunOS Config File' }],
23
['SCREENOS', { 'Description' => 'Import ScreenOS Config File' }],
24
],
25
'DefaultAction' => 'JUNOS',
26
'Notes' => {
27
'Stability' => [],
28
'SideEffects' => [],
29
'Reliability' => []
30
}
31
)
32
)
33
34
register_options(
35
[
36
OptPath.new('CONFIG', [true, 'Path to configuration to import']),
37
Opt::RHOST(),
38
Opt::RPORT(22)
39
]
40
)
41
end
42
43
def run
44
unless ::File.exist?(datastore['CONFIG'])
45
fail_with Failure::BadConfig, "Juniper config file #{datastore['CONFIG']} does not exist!"
46
end
47
juniper_config = ::File.open(datastore['CONFIG'], 'rb')
48
print_status('Importing config')
49
if action.name == 'JUNOS'
50
juniper_junos_config_eater(datastore['RHOSTS'], datastore['RPORT'], juniper_config.read)
51
elsif action.name == 'SCREENOS'
52
juniper_screenos_config_eater(datastore['RHOSTS'], datastore['RPORT'], juniper_config.read)
53
end
54
print_good('Config import successful')
55
end
56
end
57
58