#compdef htbbox
# zsh completion for htbbox (modules/features/pentest/_htbbox.py)
_htbbox_boxes() {
local -a boxes
boxes=( ${HTB_ROOT:-$HOME/htb}/*(N/:t) )
_describe -t boxes 'box' boxes
}
_htbbox() {
local -a cmds
cmds=(
'new:scaffold a box (name ip os difficulty [hosts], any order)'
'use:make a box current ($BOX, $TARGET, /etc/hosts)'
'target:what $TARGET points at right now'
'clear:forget the current target (keeps box files)'
'ls:all boxes, newest first'
'info:the box card'
'path:the box directory'
'json:raw box.json, or one key'
'set:change a field (ip os difficulty status domain name)'
'host:add hostnames'
'cred:add or list credentials'
'flag:record the user or root flag'
'note:add or list notes'
'ports:import open ports from recon/*.xml'
'help:usage'
)
if (( CURRENT == 2 )); then
_describe -t commands 'htbbox command' cmds
return
fi
case $words[2] in
new)
_alternative \
'os:os:(windows linux freebsd openbsd android other)' \
'difficulty:difficulty:(easy medium hard insane)' \
'flags:flag:(-n -i -o -d -H -t)' ;;
use|info|path) _htbbox_boxes ;;
json) _alternative 'boxes:box:_htbbox_boxes' 'keys:key:(name slug ip os difficulty hostnames domain status flags creds ports notes)' ;;
set)
case $CURRENT in
3) _values 'key' name ip os difficulty status domain ;;
4) case $words[3] in
os) _values 'os' windows linux freebsd openbsd android other ;;
difficulty) _values 'difficulty' easy medium hard insane ;;
status) _values 'status' active user root retired paused ;;
esac ;;
esac ;;
flag) (( CURRENT == 3 )) && _values 'flag' user root ;;
ports) _files -g '*.xml' ;;
esac
[[ $words[CURRENT-1] == (-b|--box) ]] && _htbbox_boxes
}
_htbbox "$@"