1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/usr/bin/env bash
# cache list of shellcodes
_shellcraft_shellcodes=$(pwn shellcraft -l)
_shellcraft()
{
COMPREPLY=()
local cur prev opts word code
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-h --help -? --show -o --out -f --format"
if [ "${prev}" == "-f" -o \
"${prev}" == "--format" \
] ; then
opts="raw str c hex asm p hexii"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [ "${prev}" == "-o" -o \
"${prev}" == "--out" \
] ; then
COMPREPLY=( $(compgen -f ${cur}))
return 0
fi
if [[ "${cur}" == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# check if a shellcode was already chosen
for word in "${COMP_WORDS[@]}" ; do
for code in ${_shellcraft_shellcodes} ; do
if [ "${word}" == "${code}" ] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
done
done
# complete shellcode name
COMPREPLY=( $(compgen -W "${_shellcraft_shellcodes}" -- ${cur}) )
}
complete -F _shellcraft pwn shellcraft
complete -F _shellcraft shellcraft
|