Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 10 May 2012 19:16:43 +0200
From: Frank Dittrich <frank_dittrich@...mail.com>
To: john-dev@...ts.openwall.com
Subject: Re: bash auto-completion for john

On 05/09/2012 07:18 PM, Solar Designer wrote:
> I see that john.bash_completion is in magnum-jumbo now (great!), but it
> is lacking a copyright and license statement.

The attached file now contains the following:
# bash completion for john and unique commands (John the Ripper)
#
# This software is Copyright © 2012 Frank Dittrich
# and hereby released to the general public under the following terms:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
#
# Minor improvements suggested by Aleksey Cherepanov have been
# incorporated.

I hope this is OK. If not, please suggest what needs to be changed.

I also added some comments how to make bash completion for john and
unique work (the new make target already takes care of this):

# This file needs to be copied to /etc/bash_completion.d/john
# alternatively, a link /etc/bash_completion.d/john will work as well.
#
# To make the new completion rules work, you need to logout and login,
# or source /etc/bash_completion instead.


I also added some information how to use the same completion logic for
other binaries (if you created different binaries with various
compilation options or for different make targets):

# To use the same completion rules not just for john, but for
# differently named binaries (say john-omp, john-sse2i, john-avx,
# john-cuda, john-gpu, ...),
# just use this command to get the current expansion rule settings:
#       complete -p |grep " john"
#
# If the output is
#       complete -F _john john
# you can use this command to activate the same completion rules
# for john-omp:
#       complete -F _john john-omp
#
# To use these completion rules permanently, you might add
#       complete -F _john john-omp
# to your ~/.bashrc file.

Other changes:

1.
For --make-charset=, completion will now list directories and .chr
files, not longer all files and directories.
(I still think I should further restrict this to just directories, to
make accidentally overwriting all.chr less likely.)

2.
New expansion logic for --salts=, --users=, --groups=, --shells=

$ ./john --salts=
COUNT   -COUNT

$ ./john --users=
-LOGIN,...  LOGIN,...   -UID,...    UID,...

$ ./john --groups=
-GID,...  GID,...

$ ./john --shells=
-SHELL,...  SHELL,...

(Pressing the [tab] key will just list these options, the command line
will not change, because I disabled expansion for --salts=-*|--salts=C*
and so on.)

3.
New expansion logic for --test, if the john version supports an optional
parameter.
(Pressing the [tab] key will just list these options, the command line
will not change, because I disabled expansion for --test=*)

$ ./john --test
--test          --test=SECONDS

(I think showing --test=SECONDS instead of --test=TIME better explains
the meaning of the optional value.)


3.
Added LIST to the list of completions for --encoding=

$ ./john --encoding=
LIST         cp1252       cp737        cp866        iso-8859-7
ansi         cp1253       cp850        iso-8859-1   koi8-r
cp1251       cp437        cp858        iso-8859-15  utf-8

Bash automatically sorts the possible options. To let LIST appear at the
beginning, I needed to temporarily set LC_ALL=C during the expansion of
--encoding=. Otherwise LIST would appear between koi8-r and utf-8.

If there are already other parameters on the command line before
--encoding=, I'll not include LIST as a completion option:

$ ./john --format=bf --encoding=
ansi         cp1253       cp850        iso-8859-1   koi8-r
cp1251       cp437        cp858        iso-8859-15  utf-8
cp1252       cp737        cp866        iso-8859-7

Even though ./john --format=bf --encoding=LIST would "work":

$ ./john --format=bf --encoding=LIST
Supported encodings within john are:
utf-8, iso-8859-1 (or ansi), iso-8859-7, iso-8859-15, koi8-r,
cp437, cp737, cp850, cp858, cp866, cp1251, cp1252, cp1253


BTW: I noticed that completion will not work (the _john function doesn't
get called) if I use
$ LC_ALL=C ./john

In this case, just the default completion logic (listing file and
directory names) works.
But this seems to be a general issue, e.g., it  also applies for
$ LC_ALL=C git


Frank

View attachment "bash_completion.john" of type "text/plain" (13586 bytes)

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ