magnumripper/JohnTheRipper — pull request #558 by frank-dittrich (2014-04-09 14:56:51+00:00)
Title: First revision of testing for different tunable costs among hashes

The following functionality is supported:
-listing format specific tunable cost parameters
in --list=format-details and --list=format-all-details
-format specific functions to calculate tunable costs per salt
-check loaded hashes for differences in tunable cost values,
print warning messages to stdout and to log file if such
differences are found
-filter salts based on --costs= (works similar to --salts=,
except that values or ranges for cost parameters can be
specified in a comma separated list:
--cost=-2 (cost of first cost parameter must be smaller than 2)
--cost=2,10:20 (cost of 1st parameter is >= 2, of 2nd between 10 and 20)
--cost=:,10:20 (first cost parameter ignored, 2nd between 10 and 20)
--cost=:,-3 (first cost parameter ignored, 2nd smaller than 3)

Currently, up to 2 tunable cost parameters are supported.
This can easily be adjusted by increasing FMT_TUNABLE_COSTS.
Cost values are unsigned int.

Format version bumped to 12, but just reverting it to 11
disables all the changes.

All formats have been adjusted so that they work with
FMT_MAIN_VERSION 11 and with FMT_MAIN_VERSION 12.

But most formats don't yet report tunable cost parameter and their
values per salt.
The only exceptions so far are:
Format label bcrypt
Tunable cost parameters iteration count

Format label crypt
Tunable cost parameters algorithm [1:descrypt/2:md5crypt/3:sunmd5/4:bcrypt/5:sha256crypt/6:sha512crypt]
algorithm specific tunable cost

So, since --format=crypt --subformat=... only works for --test,
you an use --format=crypt --costs=2 to pick md5crypt hashes.
The 2nd tunable cost for --format=crypt currently is a dummy,
always returning exactly the same ost as the 1st parameter.
My intension is to return the subformat specific tunable cost parameter
(i.e., iteration count) in a later revision.

$ ./john --format=bcrypt bcrypt.hashes
Loaded 13 password hashes with 9 different salts (bcrypt [Blowfish 32/64 X2])
Remaining 12 password hashes with 8 different salts
Loaded hashes with cost 1 (iteration count) varying from 16 to 256
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:05 70.79% 1/3 (ETA: 16:35:21) 0g/s 553.5p/s 553.5c/s 1203C/s #3#..$3$
Session aborted

The "Loaded hashes with cost 1 (iteration count) varying from 16 to 256" line
appears only if the remaining loaded hashes differ in their tunable cost.
E.g., if there are only 2 different cost values, and all hashes of the lower
cost value have already been cracked, the line doesn't appear.