Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120509173617.GA19228@debian>
Date: Wed, 9 May 2012 21:36:17 +0400
From: Aleksey Cherepanov <aleksey.4erepanov@...il.com>
To: john-dev@...ts.openwall.com
Subject: Re: Fwd: bash auto-completion for john

On Wed, May 09, 2012 at 03:39:55PM +0200, Frank Dittrich wrote:
> On 05/08/2012 09:35 AM, Aleksey Cherepanov wrote:
> > On Tue, May 08, 2012 at 08:58:48AM +0200, magnum wrote:
> >> Of course, we should also support dynamic completion of --format. I
> >> suppose this wont need any hidden option, we already get a parsable list
> >> from john with no options.
> > 
> > Yes, it is parsable. I used
> > john | perl -nle '$f = 0 if /^--/; $f = 1 if /^--format/; print $1 while m!([-\w\(\)]+)(/|$)!g && $f'
> > to get list from John's output for Johnny. It watches for --format key, then
> > it prints all words (with dashes and digits, and even braces) followed by
> > slash or end of line until it reaches any other key.
> 
> For magnumripper-magnum-jumbo-46dd1ae, this command
...
> As we all know, perl is a write-only language, that's why I'll not look
> for the error.
> But there are many more formats:
> 
> --format=NAME             force hash type NAME: afs bf bfegg bsdi crc32
> crypt
...

Yes, it does not work. Because this version of john uses space as a delimiter
while my code expects slash. That is why I check output manually.

> I replaced dynamic_n with dynamic, because I think --format=dynamic is
> valid, but --format=dynamic_n isn't.
...
> In my bash completion script, I use something like
> 
> ./john|grep -A 100 '^--format='|sed 's#^--format=[ A-Za-z]*:##'|grep -v
> '^--'|sed 's#^ *##'|sed 's#[/ ]#\n#g'|sed 's#^dynamic_n$#dynamic#'

I simplified it a bit:

john | sed -n '/^--format/,$ { s#^--format=[ A-Za-z]*:##; /^--/ q; s#^ *##; s#\<dynamic_n\>#dynamic#; s#[/ ]#\n#g; p }'

/^--/ q stops script on the next key after --format so there is no need for
magic numbers like 100. \< and \> shows that dynamic_n should be a whole word
(not part). It seems to work with magnum-jumbo.

Regards,
Aleksey Cherepanov

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.