{"action":"opened","number":6821,"pull_request":{"url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/6821","id":67777048,"html_url":"https://github.com/rapid7/metasploit-framework/pull/6821","diff_url":"https://github.com/rapid7/metasploit-framework/pull/6821.diff","patch_url":"https://github.com/rapid7/metasploit-framework/pull/6821.patch","issue_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/6821","number":6821,"state":"open","locked":false,"title":"Fix #6806 and #6820 - Fix send_request_cgi! redirection","user":{"login":"wchen-r7","id":1170914,"avatar_url":"https://avatars.githubusercontent.com/u/1170914?v=3","gravatar_id":"","url":"https://api.github.com/users/wchen-r7","html_url":"https://github.com/wchen-r7","followers_url":"https://api.github.com/users/wchen-r7/followers","following_url":"https://api.github.com/users/wchen-r7/following{/other_user}","gists_url":"https://api.github.com/users/wchen-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/wchen-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wchen-r7/subscriptions","organizations_url":"https://api.github.com/users/wchen-r7/orgs","repos_url":"https://api.github.com/users/wchen-r7/repos","events_url":"https://api.github.com/users/wchen-r7/events{/privacy}","received_events_url":"https://api.github.com/users/wchen-r7/received_events","type":"User","site_admin":false},"body":"# What this patch does\r\n\r\nThis patch fixes two problems:\r\n\r\n1. 6820 - If the HTTP server returns a relative path (example: /test), there is no host to extract, therefore the HOST header in the HTTP request ends up being empty. When the web server sees this, it might return an HTTP 400 Bad Request, and the redirection fails.\r\n\r\n2. 6806 - If the HTTP server returns a relative path that begins with a dot, send_request_cgi! will literally send that in the GET request. Since that isn't a valid GET request path format, the redirection fails.\r\n\r\nFix #6806\r\nFix #6820\r\n\r\n## Verification\r\n\r\n- [ ] Make sure Travis is green\r\n- [ ] Save the following script in ~/.msf4/modules/auxiliary/http_server.rb (if you have the folders, create them)\r\n\r\n```ruby\r\nrequire 'msf/core'\r\n\r\nclass MetasploitModule < Msf::Auxiliary\r\n\r\n  include Msf::Exploit::Remote::HttpServer\r\n\r\n  def initialize(info={})\r\n    super(update_info(info,\r\n      'Name'           => \"HttpServer test\",\r\n      'Description'    => %q{ HttpServer test },\r\n      'License'        => MSF_LICENSE,\r\n      'Author'         => [ 'sinn3r' ],\r\n      'Platform'       => 'win',\r\n      'Targets'        => [ [ 'Generic', {} ] ],\r\n      'DisclosureDate' => \"Apr 1 2016\",\r\n      'DefaultOptions' => { 'URIPATH' => '/' },\r\n      'DefaultTarget'  => 0))\r\n  end\r\n\r\n  def run\r\n    exploit\r\n  end\r\n\r\n  def on_request_uri(cli, request)\r\n    case request.uri\r\n    when '/'\r\n      send_redirect(cli, './redirect1')\r\n    when '/redirect1'\r\n      print_good('The client has found the right path')\r\n      send_response(cli, 'OK')\r\n    else\r\n      print_error(\"Incorrect path.\")\r\n      send_not_found(cli)\r\n    end\r\n  end\r\n\r\nend\r\n```\r\n\r\n- [ ] Save the following script in ~/.msf4/modules/auxiliary/http_test.rb\r\n\r\n```ruby\r\nrequire 'msf/core'\r\n\r\nclass MetasploitModule < Msf::Auxiliary\r\n\r\n  include Msf::Exploit::Remote::HttpClient\r\n\r\n  def initialize(info = {})\r\n    super(update_info(info,\r\n      'Name'           => 'HttpClient Test',\r\n      'Description'    => %q{\r\n        HttpClient\r\n      },\r\n      'Author'         => [ 'sinn3r' ],\r\n      'License'        => MSF_LICENSE\r\n    ))\r\n  end\r\n\r\n  def run\r\n    res = send_request_cgi!({\r\n      'rhost' => datastore['RHOST'],\r\n      'uri' => '/'\r\n    })\r\n\r\n    if res\r\n      puts res.body\r\n    else\r\n      print_error(\"Timed out\")\r\n    end\r\n  end\r\n\r\nend\r\n```\r\n\r\n- [ ] Start msfconsole\r\n- [ ] Do: ```use auxiliary/http_server```\r\n- [ ] Do: ```run```. At this point, the HTTP server should be listening.\r\n- [ ] Start another msfconsole\r\n- [ ] Do: ```use auxiliary/http_test```\r\n- [ ] Do: ```set RHOST [IP]``` (The IP should be the web server's IP)\r\n- [ ] Do: ```set RPORT 8080``` (8080 is the default port of http_server)\r\n- [ ] Run auxiliary_test\r\n- [ ] In the msfconsole where auxiliary/http_test is, you should see the message: ```OK```\r\n- [ ] In the msfconsole where auxiliary/http_server is, you should see the message: ```The client has found the right path``` (in green)","created_at":"2016-04-25T19:47:56Z","updated_at":"2016-04-25T19:47:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/6821/commits","review_comments_url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/6821/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/6821/comments","statuses_url":"https://api.github.com/repos/rapid7/metasploit-framework/statuses/47d52a250e38261033d5b6a926f4e4e9ec08aa2b","head":{"label":"wchen-r7:fix_6806","ref":"fix_6806","sha":"47d52a250e38261033d5b6a926f4e4e9ec08aa2b","user":{"login":"wchen-r7","id":1170914,"avatar_url":"https://avatars.githubusercontent.com/u/1170914?v=3","gravatar_id":"","url":"https://api.github.com/users/wchen-r7","html_url":"https://github.com/wchen-r7","followers_url":"https://api.github.com/users/wchen-r7/followers","following_url":"https://api.github.com/users/wchen-r7/following{/other_user}","gists_url":"https://api.github.com/users/wchen-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/wchen-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wchen-r7/subscriptions","organizations_url":"https://api.github.com/users/wchen-r7/orgs","repos_url":"https://api.github.com/users/wchen-r7/repos","events_url":"https://api.github.com/users/wchen-r7/events{/privacy}","received_events_url":"https://api.github.com/users/wchen-r7/received_events","type":"User","site_admin":false},"repo":{"id":3789747,"name":"metasploit-framework","full_name":"wchen-r7/metasploit-framework","owner":{"login":"wchen-r7","id":1170914,"avatar_url":"https://avatars.githubusercontent.com/u/1170914?v=3","gravatar_id":"","url":"https://api.github.com/users/wchen-r7","html_url":"https://github.com/wchen-r7","followers_url":"https://api.github.com/users/wchen-r7/followers","following_url":"https://api.github.com/users/wchen-r7/following{/other_user}","gists_url":"https://api.github.com/users/wchen-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/wchen-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wchen-r7/subscriptions","organizations_url":"https://api.github.com/users/wchen-r7/orgs","repos_url":"https://api.github.com/users/wchen-r7/repos","events_url":"https://api.github.com/users/wchen-r7/events{/privacy}","received_events_url":"https://api.github.com/users/wchen-r7/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wchen-r7/metasploit-framework","description":"Metasploit Framework","fork":true,"url":"https://api.github.com/repos/wchen-r7/metasploit-framework","forks_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/forks","keys_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/teams","hooks_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/hooks","issue_events_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/issues/events{/number}","events_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/events","assignees_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/assignees{/user}","branches_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/branches{/branch}","tags_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/tags","blobs_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/languages","stargazers_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/stargazers","contributors_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/contributors","subscribers_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/subscribers","subscription_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/subscription","commits_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/contents/{+path}","compare_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/merges","archive_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/downloads","issues_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/issues{/number}","pulls_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/labels{/name}","releases_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/releases{/id}","deployments_url":"https://api.github.com/repos/wchen-r7/metasploit-framework/deployments","created_at":"2012-03-21T18:19:05Z","updated_at":"2016-04-25T18:12:48Z","pushed_at":"2016-04-25T19:36:28Z","git_url":"git://github.com/wchen-r7/metasploit-framework.git","ssh_url":"git@github.com:wchen-r7/metasploit-framework.git","clone_url":"https://github.com/wchen-r7/metasploit-framework.git","svn_url":"https://github.com/wchen-r7/metasploit-framework","homepage":"http://www.metasploit.com/","size":289543,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":7,"default_branch":"master"}},"base":{"label":"rapid7:master","ref":"master","sha":"f28d280199ccc00ba98e34568a96a8e154c37e06","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}","deployments_url":"https://api.github.com/repos/rapid7/metasploit-framework/deployments","created_at":"2011-08-30T06:13:20Z","updated_at":"2016-04-25T18:12:48Z","pushed_at":"2016-04-25T07:53:06Z","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":1287411,"stargazers_count":5615,"watchers_count":5615,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3922,"mirror_url":null,"open_issues_count":271,"forks":3922,"open_issues":271,"watchers":5615,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/6821"},"html":{"href":"https://github.com/rapid7/metasploit-framework/pull/6821"},"issue":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/issues/6821"},"comments":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/issues/6821/comments"},"review_comments":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/6821/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/6821/commits"},"statuses":{"href":"https://api.github.com/repos/rapid7/metasploit-framework/statuses/47d52a250e38261033d5b6a926f4e4e9ec08aa2b"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":68,"deletions":12,"changed_files":2}}