#compdef msfvenom #autoload # # zsh completion for msfvenom in Metasploit Framework Project (https://www.metasploit.com) # # github: https://github.com/Green‐m/msfvenom‐zsh‐completion # # author: Green‐m (greenm.xxoo@gmail.com) # # license: GNU General Public License v3.0 # # Copyright (c) 2018, Green‐m # All rights reserved. #
VENOM_CACHE_FILE=~/.zsh/venom‐cache
venom‐clear‐cache() { rm $VENOM_CACHE_FILE }
venom‐cache‐payloads() {
if [ ‐x "$(command ‐v msfvenom)" ] then VENOM="msfvenom" elif [ ‐n "$_comp_command1" ] then VENOM=$_comp_command1 else echo "Cound not find msfvenom path in system env, please run msfvenom with path." fi
if [[ ! ‐d ${VENOM_CACHE_FILE:h} ]]; then mkdir ‐p ${VENOM_CACHE_FILE:h} fi
if [[ ! ‐f $VENOM_CACHE_FILE ]]; then echo ‐n "(...caching Metasploit Payloads...)" $VENOM ‐‐list payload|grep ‐e "^.*\/" | awk '{print $1}' >> $VENOM_CA CHE_FILE fi }
_msfvenom() {
local curcontext="$curcontext" state line typeset ‐A opt_args
_arguments ‐C \ '(‐h ‐‐help)'{‐h,‐‐help}'[show help]' \ '(‐l ‐‐list)'{‐l,‐‐list}'[List all modules for type. Types are: paylo ads, encoders, nops, platforms, archs, encrypt, formats, all]' \ '(‐p ‐‐payload)'{‐p,‐‐payload}'[Payload to use (‐‐list payloads to list, ‐‐list‐options for arguments). Specify ‐ or STDIN for custom]' \ '(‐‐list‐options)‐‐list‐options[List ‐‐payload <value> standard, adva nced and evasion options]' \ '(‐f ‐‐format)'{‐f,‐‐format}'[Output format (use ‐‐list formats to li st)]' \ '(‐e ‐‐encoder)'{‐e,‐‐encoder}'[The encoder to use (use ‐‐list encoders to list)]' \ '(‐‐smallest)‐‐smallest[Generate the smallest possible payload using all available encoders]' \ '(‐‐encrypt)‐‐encrypt[The type of encryption or encoding to apply to the shellcode (use ‐‐list encrypt to list)]' \ '(‐‐encrypt‐key)‐‐encrypt‐key[A key to be used for ‐‐encrypt]' \ '(‐‐encrypt‐iv)‐‐encrypt‐iv[An initialization vector for ‐‐encrypt]' \ '(‐a ‐‐arch)'{‐a,‐‐arch}'[the architecture to use for ‐‐payload and ‐ ‐encoders (use ‐‐list archs to list)]' \ '(‐‐platform)‐‐platform[The platform for ‐‐payload (use ‐‐list platfo rms to list)]' \ '(‐o ‐‐out)'{‐o,‐‐out}'[Save the payload to a file]' \ '(‐b ‐‐bad‐chars)'{‐b,‐‐bad‐chars}'[Characters to avoid example: "\x0 0\xff"]' \ '(‐n ‐‐nopsled)'{‐n,‐‐nopsled}'[Prepend a nopsled of \[length\] size on to the payload]' \ '(‐‐encoder‐space)‐‐encoder‐space[The maximum size of the encoded pay load (defaults to the ‐s value)]' \ '(‐i ‐‐iterations)'{‐i,‐‐iterations}'[The number of times to encode t he payload]' \ '(‐c ‐‐add‐code)'{‐c,‐‐add‐code}'[Specify an additional win32 shellcode file to include]' \ '(‐x ‐‐template)'{‐x,‐‐template}'[Specify a custom executable file to use as a template]' \ '(‐k ‐‐keep)'{‐k,‐‐keep}'[Preserve the ‐‐template behaviour and inject the payload as a new thread]' \ '(‐v ‐‐var‐name)'{‐v,‐‐var‐name}'[Specify a custom variable name to use for certain output formats]' \ '(‐t ‐‐timeout)'{‐t,‐‐timeout}'[The number of seconds to wait when re ading the payload from STDIN (default 30, 0 to disable)]' \ '*: :($(__msfvenom_options))' && ret=0
lastword=${words[${#words[@]}‐1]}
case "$lastword" in (‐p|‐‐payload) _values 'payload' $(__msfvenom_payloads) ;;
(‐l|‐‐list) local lists=('payloads' 'encoders' 'nops' 'platforms' 'archs' 'encrypt' 'formats' 'all')
_values 'list' $lists ;;
(‐encrypt) local encrypts=('aes256' 'base64' 'rc4' 'xor') _values 'encrypt' $encrypts ;;