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/lib/msf/core/auxiliary/brocade.rb
Views: 11784
# -*- coding: binary -*-12module Msf3###4#5# This module provides methods for working with Brocade equipment6#7###8module Auxiliary::Brocade9include Msf::Auxiliary::Report1011def create_credential_and_login(opts = {})12return nil unless active_db?1314if respond_to?(:[]) && self[:task]15opts[:task_id] ||= self[:task].record.id16end1718core = opts.fetch(:core, create_credential(opts))19access_level = opts.fetch(:access_level, nil)20last_attempted_at = opts.fetch(:last_attempted_at, nil)21status = opts.fetch(:status, Metasploit::Model::Login::Status::UNTRIED)2223login_object = nil24retry_transaction do25service_object = create_credential_service(opts)26login_object = Metasploit::Credential::Login.where(core_id: core.id, service_id: service_object.id).first_or_initialize2728if opts[:task_id]29login_object.tasks << Mdm::Task.find(opts[:task_id])30end3132login_object.access_level = access_level if access_level33login_object.last_attempted_at = last_attempted_at if last_attempted_at34if status == Metasploit::Model::Login::Status::UNTRIED35if login_object.last_attempted_at.nil?36login_object.status = status37end38else39login_object.status = status40end41login_object.save!42end4344login_object45end4647def brocade_config_eater(thost, tport, config)48# this is for brocade type devices.49# It is similar to cisco50# Docs: enable password-display -> http://wwwaem.brocade.com/content/html/en/command-reference-guide/fastiron-08040-commandref/GUID-169889CD-1A74-4A23-AC78-38796692374F.html5152if framework.db.active53credential_data = {54address: thost,55port: tport,56protocol: 'tcp',57workspace_id: myworkspace_id,58origin_type: :service,59private_type: :nonreplayable_hash,60service_name: '',61module_fullname: fullname,62status: Metasploit::Model::Login::Status::UNTRIED63}64end6566store_loot('brocade.config', 'text/plain', thost, config.strip, 'config.txt', 'Brocade Configuration')6768# Brocade has this one configuration called "password display". With it, we get hashes. With out it, just ...69if config =~ /enable password-display/70print_good('password-display is enabled, hashes will be displayed in config')71else72print_bad('password-display is disabled, no password hashes displayed in config')73end7475# enable password76# Example lines:77# enable super-user-password 8 $1$QP3H93Wm$uxYAs2HmAK01QiP3ig5tm.78config.scan(/enable super-user-password 8 (?<admin_password_hash>.+)/i).each do |result|79admin_hash = result[0].strip80next if admin_hash == '.....'8182print_good("enable password hash #{admin_hash}")83next unless framework.db.active8485cred = credential_data.dup86cred[:username] = 'enable'87cred[:private_data] = admin_hash88create_credential_and_login(cred)89end9091# user account92# Example lines:93# username brocade password 8 $1$YBaHUWpr$PzeUrP0XmVOyVNM5rYy99/94config.scan(%r{username "?(?<user_name>[a-z0-9]+)"? password (?<user_type>\w+) (?<user_hash>[0-9a-z=\$/\.]{34})}i).each do |result|95user_name = result[0].strip96user_type = result[1].strip97user_hash = result[2].strip98next if user_hash == '.....'99100print_good("User #{user_name} of type #{user_type} found with password hash #{user_hash}.")101next unless framework.db.active102103cred = credential_data.dup104cred[:username] = user_name105cred[:private_data] = user_hash106create_credential_and_login(cred)107end108109# snmp110# Example lines:111# snmp-server community 1 $Si2^=d rw112# these at times look base64 encoded, which they may be, but are also encrypted113config.scan(/snmp-server community (?<snmp_id>[\d]+) (?<snmp_community>.+) (?<snmp_permissions>rw|ro)/i).each do |result|114snmp_community = result[1].strip115snmp_permissions = result[2].strip116next if snmp_community == '.....'117118print_good("#{'ENCRYPTED ' if snmp_community.start_with?('$')}SNMP community #{snmp_community} with permissions #{snmp_permissions}")119next unless framework.db.active120121cred = credential_data.dup122cred[:protocol] = 'udp'123cred[:port] = 161124cred[:service_name] = 'snmp'125cred[:private_data] = snmp_community126create_credential_and_login(cred)127end128129end130end131end132133134