Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 7 Jun 2012 18:05:59 +0200
From: Frank Dittrich <frank_dittrich@...mail.com>
To: john-dev@...ts.openwall.com
Subject: Re: ./john --test --format=crypt --subformat=BF (usage
 problem)

On 06/06/2012 11:32 PM, magnum wrote:
> On 06/06/2012 11:24 PM, Frank Dittrich wrote:
>> I would make listing and checking subformat names similar to format
>> names. Than means, now that the list of formats in the usage output is
>> written in lower case, I would use lower case subformats in the stderr
>> output. I'd also allow using upper case subformat names, since
>> --format=DES also works.
>> I wouldn't list all the different ways to specify a particular
>> subformat, just listing bf instead of bf, bcrypt and blowfish is OK.
>> Sould we also use raw-sha256 and raw-sha512 as subformat names instead,
>> to match the format names?
>>
>> What do you think?
> 
> All these are valid concerns and I probably meant to use strcasecmp().
> I'll have a look some time. Or would you like to submit a patch?

OK, done.

I even invested a little time studying basic git usage.
See the attached patch file.
I hope I got this right. If not, please let me know what I'm doing wrong.

I implemented all the suggested changes.

You can now use upper and lower case subformat names.
In addition to the subformat names that were previously allowed I added
raw-sga256 and raw-sha512.
I didn't remove sha256, sha-256, sha512 and sha-512, bcrypt and
blowfish, because I don't know which script might rely on the old
subformat names.

$ ./john --test --format=crypt --subformat=?
Subformat unknown to John. Currently supported: des, md5, bf,
raw-sha256, raw-sha512

So, bash completion will list these options:

$ ./john --test --format=crypt --subformat=[tab][tab]
bf          des         md5         raw-sha256  raw-sha512


Unfortunately, I forgot to support bash completion for upper case
subformats.

So, this will currently not work:

$ ./john --test --format=crypt --subformat=D[tab]

I'll send a separate patch for john.bash completion which completes
$ ./john --test --format=crypt --subformat=D[tab]
to
$ ./john --test --format=crypt --subformat=des


Frank

>From 1daa68ec8f69855fdd8351ed4b241083148639aa Mon Sep 17 00:00:00 2001
From: Frank Dittrich <frank_dittrich@...mail.com>
Date: Thu, 7 Jun 2012 17:49:24 +0200
Subject: [PATCH] c3_fmt.c: improve --subformat= handling

---
 src/c3_fmt.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/c3_fmt.c b/src/c3_fmt.c
index fcdd502..a190417 100644
--- a/src/c3_fmt.c
+++ b/src/c3_fmt.c
@@ -71,40 +71,42 @@ struct fmt_main fmt_crypt;
 static void init(struct fmt_main *pFmt)
 {
 	if (options.subformat) {
-		if (strncmp(options.subformat, "md5", 4)==0) {
+		if (strcasecmp(options.subformat, "md5")==0) {
 			fmt_crypt.params.benchmark_comment = " MD5";
 			tests[0].ciphertext = "$1$dXc3I7Rw$ctlgjDdWJLMT.qwHsWhXR1";
 			tests[1].ciphertext = "$1$dXc3I7Rw$94JPyQc/eAgQ3MFMCoMF.0";
 			tests[2].ciphertext = "$1$dXc3I7Rw$is1mVIAEtAhIzSdfn5JOO0";
 			tests[3].ciphertext = "$1$eQT9Hwbt$XtuElNJD.eW5MN5UCWyTQ0";
 			tests[4].ciphertext = "$1$Eu.GHtia$CFkL/nE1BYTlEPiVx1VWX0";
-		} else if ((strncmp(options.subformat, "sha-256", 8)==0) ||
-		           (strncmp(options.subformat, "sha256", 7)==0)) {
+		} else if ((strcasecmp(options.subformat, "raw-sha256")==0) ||
+		           (strcasecmp(options.subformat, "sha-256")==0) ||
+		           (strcasecmp(options.subformat, "sha256")==0)) {
 			fmt_crypt.params.benchmark_comment = " SHA-256 rounds=5000";
 			tests[0].ciphertext = "$5$LKO/Ute40T3FNF95$U0prpBQd4PloSGU0pnpM4z9wKn4vZ1.jsrzQfPqxph9";
 			tests[1].ciphertext = "$5$LKO/Ute40T3FNF95$fdgfoJEBoMajNxCv3Ru9LyQ0xZgv0OBMQoq80LQ/Qd.";
 			tests[2].ciphertext = "$5$LKO/Ute40T3FNF95$8Ry82xGnnPI/6HtFYnvPBTYgOL23sdMXn8C29aO.x/A";
 			tests[3].ciphertext = "$5$9mx1HkCz7G1xho50$O7V7YgleJKLUhcfk9pgzdh3RapEaWqMtEp9UUBAKIPA";
 			tests[4].ciphertext = "$5$kc7lRD1fpYg0g.IP$d7CMTcEqJyTXyeq8hTdu/jB/I6DGkoo62NXbHIR7S43";
-		} else if ((strncmp(options.subformat, "sha-512", 8)==0) ||
-	            (strncmp(options.subformat, "sha512", 7)==0)) {
+		} else if ((strcasecmp(options.subformat, "raw-sha512")==0) ||
+		           (strcasecmp(options.subformat, "sha-512")==0) ||
+		           (strcasecmp(options.subformat, "sha512")==0)) {
 			fmt_crypt.params.benchmark_comment = " SHA-512 rounds=5000";
 			tests[0].ciphertext = "$6$LKO/Ute40T3FNF95$6S/6T2YuOIHY0N3XpLKABJ3soYcXD9mB7uVbtEZDj/LNscVhZoZ9DEH.sBciDrMsHOWOoASbNLTypH/5X26gN0";
 			tests[1].ciphertext = "$6$LKO/Ute40T3FNF95$wK80cNqkiAUzFuVGxW6eFe8J.fSVI65MD5yEm8EjYMaJuDrhwe5XXpHDJpwF/kY.afsUs1LlgQAaOapVNbggZ1";
 			tests[2].ciphertext = "$6$LKO/Ute40T3FNF95$YS81pp1uhOHTgKLhSMtQCr2cDiUiN03Ud3gyD4ameviK1Zqz.w3oXsMgO6LrqmIEcG3hiqaUqHi/WEE2zrZqa/";
 			tests[3].ciphertext = "$6$OmBOuxFYBZCYAadG$WCckkSZok9xhp4U1shIZEV7CCVwQUwMVea7L3A77th6SaE9jOPupEMJB.z0vIWCDiN9WLh2m9Oszrj5G.gt330";
 			tests[4].ciphertext = "$6$ojWH1AiTee9x1peC$QVEnTvRVlPRhcLQCk/HnHaZmlGAAjCfrAN0FtOsOnUk5K5Bn/9eLHHiRzrTzaIKjW9NTLNIBUCtNVOowWS2mN.";
-		} else if ((strncmp(options.subformat, "bf", 3)==0) ||
-	            (strncmp(options.subformat, "blowfish", 9)==0) ||
-	            (strncmp(options.subformat, "bcrypt", 7)==0)) {
+		} else if ((strcasecmp(options.subformat, "bf")==0) ||
+		           (strcasecmp(options.subformat, "blowfish")==0) ||
+		           (strcasecmp(options.subformat, "bcrypt")==0)) {
 			fmt_crypt.params.benchmark_comment = " BF x32";
 			tests[0].ciphertext = "$2a$05$c92SVSfjeiCD6F2nAD6y0uBpJDjdRkt0EgeC4/31Rf2LUZbDRDE.O";
 			tests[1].ciphertext = "$2a$05$WY62Xk2TXZ7EvVDQ5fmjNu7b0GEzSzUXUh2cllxJwhtOeMtWV3Ujq";
 			tests[2].ciphertext = "$2a$05$Fa0iKV3E2SYVUlMknirWU.CFYGvJ67UwVKI1E2FP6XeLiZGcH3MJi";
 			tests[3].ciphertext = "$2a$05$.WRrXibc1zPgIdRXYfv.4uu6TD1KWf0VnHzq/0imhUhuxSxCyeBs2";
 			tests[4].ciphertext = "$2a$05$Otz9agnajgrAe0.kFVF9V.tzaStZ2s1s4ZWi/LY4sw2k/MTVFj/IO";
-		} else if (strncmp(options.subformat, "des", 4)) {
-			fprintf(stderr, "Subformat unknown to John. Currently supported: DES, MD5, BF, SHA-256, SHA-512\n\n");
+		} else if (strcasecmp(options.subformat, "des")) {
+			fprintf(stderr, "Subformat unknown to John. Currently supported: des, md5, bf, raw-sha256, raw-sha512\n\n");
 			error();
 		}
 	}
-- 
1.7.7.6


Powered by blists - more mailing lists

Your e-mail address:

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