Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/networking/mikrotik_config.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Mikrotik78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Mikrotik Configuration Importer',13'Description' => %q{14This module imports a Mikrotik device configuration.15},16'License' => MSF_LICENSE,17'Author' => ['h00die'],18'Actions' => [19['ROUTEROS', { 'Description' => 'Import RouterOS Config File' }],20['SWOS', { 'Description' => 'Import SwOS Config File' }],21],22'DefaultAction' => 'ROUTEROS',23'Notes' => {24'Stability' => [],25'SideEffects' => [],26'Reliability' => []27}28)29)3031register_options(32[33OptPath.new('CONFIG', [true, 'Path to configuration to import']),34Opt::RHOST(),35Opt::RPORT(22)36]37)38end3940def run41unless ::File.exist?(datastore['CONFIG'])42fail_with(Failure::BadConfig, "Mikrotik config file #{datastore['CONFIG']} does not exist!")43end44mikrotik_config = ::File.open(datastore['CONFIG'], 'rb')45print_status('Importing config')46if action.name == 'ROUTEROS'47print_bad('SWB files are typically SWOS, check action') if datastore['CONFIG'].ends_with?('.swb')48mikrotik_routeros_config_eater(datastore['RHOSTS'], datastore['RPORT'], mikrotik_config.read)49elsif action.name == 'SWOS'50mikrotik_swos_config_eater(datastore['RHOSTS'], datastore['RPORT'], mikrotik_config.read)51end52print_good('Config import successful')53end54end555657