Used metasploit's cache to make completion faster

master
Jonathan Hodgson 5 years ago
parent b113ea3ee4
commit 9e2a6f1897
  1. 25
      shells/zsh/completion/_msfvenom

@ -18,7 +18,6 @@
# #
# * Spencer McIntyre # * Spencer McIntyre
# #
# * Extended by Jonathan Hodgson
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_msfvenom_archs_list=( _msfvenom_archs_list=(
@ -208,27 +207,19 @@ _msfvenom_platform() {
_describe -t platforms 'available platforms' _msfvenom_platforms_list || compadd "$@" _describe -t platforms 'available platforms' _msfvenom_platforms_list || compadd "$@"
} }
local -a _msfvenom_payload_list
if [ -f "$HOME/.local/cache/msfvenom/payloads.txt" ]; then
while read line; do
_msfvenom_payload_list+=("$line")
done < "$HOME/.local/cache/msfvenom/payloads.txt"
fi
_msfvenom_payload() { _msfvenom_payload() {
if [ ${#_msfvenom_payload_list[@]} -ne 0 ]; then local cacheFile="$HOME/.msf4/store/modules_metadata.json"
_describe -t payloads 'available payloads' _msfvenom_payload_list || compadd "$@" local -a _msfvenom_payloads_list
[ -f "$cacheFile" ] || cacheFile="/opt/metasploit/db/modules_metadata_base.json"
if [ ! -f "$cacheFile" ]; then
_message -r "Cannot find metasploit cache file. Run msfconsole to populate it"
compadd "$@"
else else
_message -r "You need to pre-populate the payload cache, run the following commands:" _msfvenom_payloads_list=("${(f)$(sed -n '/"type": "payload"/,/"ref_name"/p' "$cacheFile" | grep -E '(ref_name|description)' | cut -d '"' -f 4 | sed -n 'h;n;p;g;p' | sed 'N;s/\n/:/')}")
_message -r "" _describe -t payloads 'available payloads' _msfvenom_payloads_list || compadd "$@"
_message -r "mkdir -p \$HOME/.local/cache/msfvenom/"
_message -r "msfvenom --list payloads 2> /dev/null | tail -n +5 | sed '2d' | awk -F ' +' '{print \$2 \":\" \$3}' > \$HOME/.local/cache/msfvenom/payloads.txt"
fi fi
} }
_arguments \ _arguments \
"--smallest[Generate the smallest possible payload using all available encoders]" \ "--smallest[Generate the smallest possible payload using all available encoders]" \
"--sec-name[The new section name to use when generating large Windows binaries. Default: random 4-character alpha string]" \ "--sec-name[The new section name to use when generating large Windows binaries. Default: random 4-character alpha string]" \

Loading…
Cancel
Save