summaryrefslogtreecommitdiff
path: root/dev-db/sqlmap/files/sqlmap.bash-completion
blob: 47e11297ed8993bfcf838d197038458ed4e6cb42 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# bash completion for sqlmap by Korznikov Alexander
# source: http://www.korznikov.com/2014/12/bash-tab-completion-for-awesome-tool.html
# cp sqlmap_bash_completion /etc/bash_completion.d/sqlmap

tamper=$(ls /usr/share/sqlmap/tamper|grep -v "__" |sed ':a;N;$!ba;s/\n/ /g')

_sqlmap()
{
    local cur prev

    COMPREPLY=()
    cur=`_get_cword`
    prev=`_get_pword`

    case $prev in

  # List directory content
  --tamper)
     COMPREPLY=( $( compgen -W "$tamper" -- "$cur" ) )
     return 0
     ;;
  --output-dir|-t|-l|-m|-r|--load-cookies|--proxy-file|--sql-file|--shared-lib|--file-write)
     _filedir
     return 0
     ;;
  -c)
     _filedir ini
     return 0
     ;;
  --method)
     COMPREPLY=( $( compgen -W 'GET POST PUT' -- "$cur" ) )
     return 0
     ;;
  --auth-type)
     COMPREPLY=( $( compgen -W 'Basic Digest NTLM PKI' -- "$cur" ) )
     return 0
     ;;
  --tor-type)
     COMPREPLY=( $( compgen -W 'HTTP SOCKS4 SOCKS5' -- "$cur" ) )
     return 0
     ;;
  -v)
     COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- "$cur" ) )
     return 0
     ;;
  --dbms)
     COMPREPLY=( $( compgen -W 'mysql mssql access postgres' -- "$cur" ) )
     return 0
     ;;
  --level|--crawl)
     COMPREPLY=( $( compgen -W '1 2 3 4 5' -- "$cur" ) )
     return 0
     ;;
  --risk)
     COMPREPLY=( $( compgen -W '0 1 2 3' -- "$cur" ) )
     return 0
     ;;
  --technique)
     COMPREPLY=( $( compgen -W 'B E U S T Q' -- "$cur" ) )
     return 0
     ;;
  -s)
     _filedir sqlite
     return 0
     ;;
  --dump-format)
     COMPREPLY=( $( compgen -W 'CSV HTML SQLITE' -- "$cur" ) )
     return 0
     ;;
  -x)
     _filedir xml
     return 0
     ;;
    esac

    if [[ "$cur" == * ]]; then
    COMPREPLY=( $( compgen -W '-h --help -hh --version -v -d -u --url -l -x -m -r -g -c --method \
     --data --param-del --cookie --cookie-del --load-cookies \
     --drop-set-cookie --user-agent --random-agent --host --referer \
     --headers --auth-type --auth-cred --auth-private --ignore-401 \
     --proxy --proxy-cred --proxy-file --ignore-proxy --tor --tor-port \
     --tor-type --check-tor --delay --timeout --retries --randomize \
     --safe-url --safe-freq --skip-urlencode --csrf-token --csrf-url \
     --force-ssl --hpp --eval -o --predict-output --keep-alive \
     --null-connection --threads -p  --skip --dbms --dbms-cred \
     --os --invalid-bignum --invalid-logical --invalid-string \
     --no-cast --no-escape --prefix --suffix --tamper --level \
     --risk --string --not-string --regexp --code --text-only \
     --titles --technique --time-sec --union-cols --union-char \
     --union-from --dns-domain --second-order -f --fingerprint \
     -a --all -b --banner --current-user --current-db --hostname \
     --is-dba --users --passwords --privileges --roles --dbs --tables \
     --columns --schema --count --dump --dump-all --search --comments \
     -D -T -C -X -U --exclude-sysdbs --where --start --stop \
     --first --last --sql-query --sql-shell --sql-file --common-tables \
     --common-columns --udf-inject --shared-lib --file-read --file-write \
     --file-dest --os-cmd --os-shell --os-pwn --os-smbrelay --os-bof \
     --priv-esc --msf-path --tmp-path --reg-read --reg-add --reg-del \
     --reg-key --reg-value --reg-data --reg-type -s -t --batch \
     --charset --crawl --csv-del --dump-format --eta --flush-session \
     --forms --fresh-queries --hex --output-dir --parse-errors \
     --pivot-column --save --scope --test-filter --update \
     -z --alert --answers --beep --check-waf --cleanup \
     --dependencies --disable-coloring --gpage --identify-waf \
     --mobile --page-rank --purge-output --smart \
     --sqlmap-shell --wizard' -- "$cur" ) )
    # this removes any options from the list of completions that have
    # already been specified somewhere on the command line, as long as
    # these options can only be used once (in a word, "options", in
    # opposition to "tests" and "actions", as in the find(1) manpage).
    onlyonce=' -h --help -hh --version -v -d -u --url -l -x -m -r -g -c \
     --drop-set-cookie --random-agent \
     --ignore-401 \
     --ignore-proxy --tor \
     --check-tor \
     --skip-urlencode \
     --force-ssl --hpp -o --predict-output --keep-alive \
     --null-connection -p \
     --invalid-bignum --invalid-logical --invalid-string \
     --no-cast --no-escape \
     --text-only \
     --titles \
     -f --fingerprint \
     -a --all -b --banner --current-user --current-db --hostname \
     --is-dba --users --passwords --privileges --roles --dbs --tables \
     --columns --schema --count --dump --dump-all --search --comments \
     -D -T -C -X -U --exclude-sysdbs \
     --sql-shell --common-tables \
     --common-columns --udf-inject \
     --os-shell --os-pwn --os-smbrelay --os-bof \
     --priv-esc --reg-read --reg-add --reg-del \
     -s -t --batch \
     --eta --flush-session \
     --forms --fresh-queries --hex --parse-errors \
     --save --update \
     -z --beep --check-waf --cleanup \
     --dependencies --disable-coloring --identify-waf \
     --mobile --page-rank --purge-output --smart \
     --sqlmap-shell --wizard '
    COMPREPLY=( $( \
           (while read -d ' ' i; do
            [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
            continue
            # flatten array with spaces on either side,
            # otherwise we cannot grep on word boundaries of
            # first and last word
            COMPREPLY=" ${COMPREPLY[@]} "
            # remove word from list of completions
            COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
            done
            printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
          ) )

#    else
#        _filedir bat
    fi
} &&
complete -F _sqlmap sqlmap