forked from bonsaiviking/nmap-completion
/
ncat
42 lines (38 loc) · 1.77 KB
/
ncat
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
# bash completion for Ncat
_ncat() {
COMPREPLY=()
local cur prev
cur=$(_get_cword)
prev=${COMP_WORDS[COMP_CWORD-1]}
local common_opts all_opts file_opts time_opts
# These options are short-option-only, are the same as traditional netcat
# or are commonly used and helpful (e.g. --help)
common_opts="-4 -6 -C -e -g -G -p -s -l -k -n -t -u -v -w --help --proxy --ssl --version"
all_opts="-4 -6 -C --crlf -c --sh-exec -e --exec -g -G -m --max-conns -h --help -d --delay -o --output -x --hex-dump -i --idle-timeout -p --source-port -s --source -l --listen -k --keep-open -n --nodns -t --telnet -u --udp --sctp -v -vv -vvv --verbose -w --wait --send-only --recv-only --allow --allowfile --deny --denyfile --broker --chat --proxy --proxy-type --proxy-auth --ssl --ssl-cert --ssl-key --ssl-verify --ssl-trustfile --version --unixsock --append-output"
file_opts="-o --output -x --hex-dump --allowfile --denyfile --ssl-cert --ssl-key --ssl-trustfile --lua-exec"
time_opts="-d --delay -i --idle-timeout -w --wait"
if [[ "$cur" == - ]]; then
COMPREPLY=( $( compgen -W "$common_opts" -- $cur ) )
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$all_opts" -- $cur ) )
else
case "$prev" in
--proxy-type)
COMPREPLY=( $( compgen -W "http socks4" -- "$cur" ) )
;;
+(${file_opts// /|}))
_filedir
;;
+(${time_opts// /|}))
local digits=${cur%%+([msh])}
COMPREPLY=( $( compgen -W "${digits}ms ${digits}s ${digits}m ${digits}h $digits" -- "$cur" ) )
;;
*)
return 0
;;
esac
fi
return 0
}
complete -F _ncat -o default ncat
# vim:ft=sh