Files
john/john-MD5_std.c.diff

106 lines
2.8 KiB
Diff

diff -Naur john-1.6.37/src/MD5_std.c john-1.6.37-apache-md5/src/MD5_std.c
--- john-1.6.37/src/MD5_std.c 2003-12-03 11:16:26.000000000 +0100
+++ john-1.6.37-apache-md5/src/MD5_std.c 2004-07-26 10:55:08.000000000 +0200
@@ -1,4 +1,14 @@
/*
+ Modified by Sun-Zero <sun-zero@freemail.hu>
+ 2004. 07. 26.
+
+ Now, its work with md5 hash of apache.
+ The original john patch came from
+ http://lists.jammed.com/pen-test/2001/11/0134.html by
+ Kostas Evangelinos (kos@bastard.net)
+*/
+
+/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-2001,2003 by Solar Designer
*
@@ -400,7 +410,7 @@
order[19][index].length = current->l.pp;
}
-void MD5_std_crypt(void)
+void MD5_std_crypt(int md5_type)
{
int length, index, mask;
MD5_pattern *line;
@@ -482,12 +492,21 @@
#if MD5_X2
for (index = 0, key = pool; index < MD5_N; index++, key++) {
#endif
+
memcpy(&block[index], key->o.p.b, key->l.p);
+ if (md5_type == MD5_TYPE_APACHE) {
+ memcpy(&block[index].b[key->l.p], "$apr1$", 6);
+ memcpy(&block[index].b[key->l.p + 6], key->s, key->l.s);
+ memcpy(&block[index].b[key->l.ps + 6],
+ MD5_out[index], key->l.p);
+ length = key->l.psp + 6;
+ } else {
memcpy(&block[index].b[key->l.p], "$1$", 3);
memcpy(&block[index].b[key->l.p + 3], key->s, key->l.s);
memcpy(&block[index].b[key->l.ps + 3],
MD5_out[index], key->l.p);
length = key->l.psp + 3;
+ }
if ((mask = key->l.p))
do {
block[index].b[length++] =
@@ -853,13 +872,26 @@
#endif
-char *MD5_std_get_salt(char *ciphertext)
+char *MD5_std_get_salt(char *ciphertext, int md5_type)
{
static char out[9];
int length;
+ char *pos;
+ char *start;
- for (length = 0; length < 8; length++)
- if ((out[length] = ciphertext[3 + length]) == '$') break;
+ start = &ciphertext[1];
+ if (md5_type == MD5_TYPE_APACHE) {
+ for (pos = start; *pos && *pos != '$'; pos++);
+ start = ++pos;
+ }
+
+ for (length = 0; length < 8; length++) {
+ if (md5_type == MD5_TYPE_APACHE) {
+ if ((out[length] = start[length]) == '$') break;
+ } else {
+ if ((out[length] = ciphertext[3 + length]) == '$') break;
+ }
+ }
out[length] = 0;
return out;
@@ -876,7 +908,7 @@
out.b[b2] = value >> 8; \
out.b[b3] = value;
-MD5_word *MD5_std_get_binary(char *ciphertext)
+MD5_word *MD5_std_get_binary(char *ciphertext, int md5_type)
{
static union {
MD5_binary w;
@@ -885,7 +917,16 @@
char *pos;
MD5_word value;
+ char *start;
+ if (md5_type == MD5_TYPE_APACHE) {
+ start = &ciphertext[1];
+ for (pos = start; *pos && *pos != '$'; pos++);
+ if (!*pos || pos < start+1 || pos > start+MD5_MAGIC_LENGTH+1) return 0;
+ pos++;
+ while (*pos++ != '$');
+ } else {
pos = ciphertext + 3; while (*pos++ != '$');
+ }
TO_BINARY(0, 6, 12);
TO_BINARY(1, 7, 13);