Openwall wordlists collection for password cracking (20+ languages)
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 19 Dec 2010 16:42:54 -0600
From: James Nobis <quel@...lrod.net>
To: john-users@...ts.openwall.com
Subject: hmailserver patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi all,

I wrote a quick patch to support http://www.hmailserver.com/ password
hashes and it is already available on the wiki
http://openwall.info/wiki/john/patches.  The format is straight forward
enough as noted at
http://www.hmailserver.com/forum/viewtopic.php?p=97515#p97515.  A fairly
simple salt format concatenated with the password and a single sha256 of
the result.  The patch just uses openssl/sha.h so there are not any
optimizations.

I do not even know who uses this mail server but a friend of mine
apparently encounters enough to have it setup in his lab for testing and
security auditing.  I had some free time waiting for a server to be
moved and this is the product.  It passes -test and I tried a few short
runs successfully.

Per the notes about how to post your patches I'm attaching the ascii
diff as well.

James Nobis
quel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCgAGBQJNDopuAAoJEGUWgJyjXssuB/IQAI/uudH2UQzR580hiDtaYvPp
Aoicuqu01EpWlg9e4wWdBaJ+8YeQvhBgvyKHGF/sBl+og8QX0Ti8mOjX1wl13d5A
0qpzHSwwvK31y11azGJG20Ar/p3dpKWIe6chxbXjaVv3nk24HyibH4VH68TMH6Pw
CTvLzaIGkOAm2XZtZQrlaORjEAYeW54X2tODs1H6BvPumjpYhOx94OApuoshimQQ
/6smB5pPh7O7dF4Wj0Q71Irm6HAWhrvYGrIHTblPHutqyhshJTkVqBcazpGYexrq
VRx83xMVbCnaEjiauedE4HfrA06aVy+WSdsFrDuWoh4gVMsOKJypQmyUQcP9lIWG
jPH4nLNbU0TATQqdGvMlokaX7euz2c9cCRDKgZ6AEXaeQQhGkJuD11lPEWZ41fcx
5qDlNnhj7XchcQIdDFFA3MT3oK4Y+t3SnumCph9qo9PvdeKzqFGcXC/l1xGii4gn
KITpY1/NAj9a9vQ5r9fZH+pttz8eviwdWIxU7CrGIUerho/+SOp5kWTRKgh/+jWm
sgac6v8cApLnyzl8Rt0W5kJUggVH/mlFxdCgU6nnNmONExxB45rfp+D5gBnsGimS
4NdRBQRFFlRyAqQRpoo3Q/+zynSYBm+4e+VHEzse+DI7IY/WtJzPM2Kkti1Zc3MT
mGWJ14o/dZT8hj8VqH5j
=QjB3
-----END PGP SIGNATURE-----

diff -urpN john-1.7.6.orig/src/hmailserver_fmt.c john-1.7.6/src/hmailserver_fmt.c
--- john-1.7.6.orig/src/hmailserver_fmt.c	1970-01-01 00:00:00.000000000 +0000
+++ john-1.7.6/src/hmailserver_fmt.c	2010-12-19 22:07:19.000000000 +0000
@@ -0,0 +1,248 @@
+/*
+ * This patch Copyright (C) 2010 by James Nobis - quel
+ * - quel NOSPAM quelrod NOSPAM net, and it is herby released to the general
+ * public under the follow terms:
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * format specification
+ * http://www.hmailserver.com/forum/viewtopic.php?p=97515&sid=b2c1c6ba1e10c2f0654ca9421b2059e8#p97515
+ * inspiration from the generic sha-1 and md5
+ * Copyright (c) 2010 by Solar Designer
+ */
+
+#include <string.h>
+#include <openssl/sha.h>
+
+#include "arch.h"
+#include "params.h"
+#include "common.h"
+#include "formats.h"
+
+#define FORMAT_LABEL			"hmailserver"
+#define FORMAT_NAME			"hmailserver"
+
+#define ALGORITHM_NAME			"32/" ARCH_BITS_STR
+
+#define BENCHMARK_COMMENT		""
+#define BENCHMARK_LENGTH		0
+
+#define PLAINTEXT_LENGTH		70
+#define CIPHERTEXT_LENGTH		64
+
+#define BINARY_SIZE			32
+#define SALT_SIZE			6
+
+#define MIN_KEYS_PER_CRYPT		1
+#define MAX_KEYS_PER_CRYPT		1
+
+static struct fmt_tests hmailserver_tests[] = {
+	{"cc06fa688a64cdeea43d3c0fb761fede7e3ccf00a9daea9c79f7d458e06f88327f16dd", "password"},
+	{"fee4fd4446aebcb3332aa5c61845b7bcbe5a3126fedf51a6359663d61b87d4f6ee87df", "12345678"},
+	{"2d7b784370c488b6548394ba11513e159220c83e2458ed01d8c7cdadd6bf486b433703", "1234"},
+	{"0926aadc8d49682c3f091af2dbf7f16f1cc7130b8e6dc86978d3f1bef914ce0096d4b3", "0123456789ABCDE"},
+	{NULL}
+};
+
+static char saved_salt[SALT_SIZE];
+static int saved_key_length;
+static char saved_key[PLAINTEXT_LENGTH + 1];
+static SHA_CTX ctx;
+static ARCH_WORD_32 crypt_out[8] = {0}; // 8 * 32 = 256
+
+static int valid(char *ciphertext)
+{
+	int i;
+
+	if ( ciphertext == NULL )
+		return 0;
+
+	if ( strnlen( ciphertext, PLAINTEXT_LENGTH ) != PLAINTEXT_LENGTH )
+		return 0;
+
+	for ( i = 0; i < PLAINTEXT_LENGTH - 1; i++ )
+		if (!( (('0' <= ciphertext[i] ) && ( ciphertext[i] <= '9' ))
+				|| (('a' <= ciphertext[i] ) && ( ciphertext[i] <= 'f' )) ))
+			return 0;
+
+	return 1;
+}
+
+static void *get_binary(char *ciphertext)
+{
+	static unsigned char out[BINARY_SIZE];
+	char *p;
+	int i;
+
+	p = ciphertext + SALT_SIZE;
+	for (i = 0; i < sizeof(out); i++) {
+		out[i] =
+		    (atoi16[ARCH_INDEX(*p)] << 4) |
+		    atoi16[ARCH_INDEX(p[1])];
+		p += 2;
+	}
+
+	return out;
+}
+
+static void *salt(char *ciphertext)
+{
+	static unsigned char out[SALT_SIZE];
+
+	memcpy(out, ciphertext, SALT_SIZE);
+
+	return out;
+}
+
+static int binary_hash_0(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xF;
+}
+
+static int binary_hash_1(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFF;
+}
+
+static int binary_hash_2(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFF;
+}
+
+static int binary_hash_3(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFF;
+}
+
+static int binary_hash_4(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
+}
+
+static int get_hash_0(int index)
+{
+	return crypt_out[0] & 0xF;
+}
+
+static int get_hash_1(int index)
+{
+	return crypt_out[0] & 0xFF;
+}
+
+static int get_hash_2(int index)
+{
+	return crypt_out[0] & 0xFFF;
+}
+
+static int get_hash_3(int index)
+{
+	return crypt_out[0] & 0xFFFF;
+}
+
+static int get_hash_4(int index)
+{
+	return crypt_out[0] & 0xFFFFF;
+}
+
+static int salt_hash(void *salt)
+{
+	int x, y;
+	x = ((ARCH_WORD_32)(ARCH_INDEX(((unsigned char *)salt)[0])-' '));
+	y = (((ARCH_WORD_32)(ARCH_INDEX(((unsigned char *)salt)[1])-' ')<<4));
+	return (x+y) & 0x3FF;
+}
+
+static void set_salt(void *salt)
+{
+	memcpy(saved_salt, salt, SALT_SIZE);
+}
+
+static void set_key(char *key, int index)
+{
+	saved_key_length = strlen(key);
+	if (saved_key_length > PLAINTEXT_LENGTH)
+		saved_key_length = PLAINTEXT_LENGTH;
+	memcpy(saved_key, key, saved_key_length);
+}
+
+static char *get_key(int index)
+{
+	saved_key[saved_key_length] = 0;
+	return saved_key;
+}
+
+static void crypt_all(int count)
+{
+	SHA256_Init(&ctx);
+	SHA256_Update(&ctx, &saved_salt, SALT_SIZE);
+	SHA256_Update(&ctx, saved_key, saved_key_length);
+	SHA256_Final((unsigned char *)crypt_out, &ctx);
+}
+
+static int cmp_all(void *binary, int count)
+{
+	return !memcmp(binary, crypt_out, BINARY_SIZE);
+}
+
+static int cmp_exact(char *source, int index)
+{
+	return 1;
+}
+
+struct fmt_main fmt_hmailserver = {
+	{
+		FORMAT_LABEL,
+		FORMAT_NAME,
+		ALGORITHM_NAME,
+		BENCHMARK_COMMENT,
+		BENCHMARK_LENGTH,
+		PLAINTEXT_LENGTH,
+		BINARY_SIZE,
+		SALT_SIZE,
+		MIN_KEYS_PER_CRYPT,
+		MAX_KEYS_PER_CRYPT,
+		FMT_CASE | FMT_8_BIT,
+		hmailserver_tests
+	}, {
+		fmt_default_init,
+		valid,
+		fmt_default_split,
+		get_binary,
+		salt,
+		{
+			binary_hash_0,
+			binary_hash_1,
+			binary_hash_2,
+			binary_hash_3,
+			binary_hash_4
+		},
+		salt_hash,
+		set_salt,
+		set_key,
+		get_key,
+		fmt_default_clear_keys,
+		crypt_all,
+		{
+			get_hash_0,
+			get_hash_1,
+			get_hash_2,
+			get_hash_3,
+			get_hash_4
+		},
+		cmp_all,
+		cmp_all,
+		cmp_exact
+	}
+};
diff -urpN john-1.7.6.orig/src/john.c john-1.7.6/src/john.c
--- john-1.7.6.orig/src/john.c	2010-12-19 18:35:24.000000000 +0000
+++ john-1.7.6/src/john.c	2010-12-18 19:58:46.000000000 +0000
@@ -52,6 +52,7 @@ extern struct fmt_main fmt_PO;
 extern struct fmt_main fmt_rawMD5go;
 extern struct fmt_main fmt_MD5gen;
 extern struct fmt_main fmt_hmacMD5;
+extern struct fmt_main fmt_hmailserver;
 extern struct fmt_main fmt_IPB2;
 extern struct fmt_main fmt_phpassmd5;
 extern struct fmt_main fmt_DMD5;
@@ -141,6 +142,7 @@ static void john_register_all(void)
 	john_register_one(&fmt_md4_gen);
 	john_register_one(&fmt_KRB4);
 	john_register_one(&fmt_KRB5);
+	john_register_one(&fmt_hmailserver);
 	john_register_one(&fmt_NSLDAP);
 	john_register_one(&fmt_NSLDAPS);
 	john_register_one(&fmt_OPENLDAPS);
diff -urpN john-1.7.6.orig/src/Makefile john-1.7.6/src/Makefile
--- john-1.7.6.orig/src/Makefile	2010-12-19 18:35:24.000000000 +0000
+++ john-1.7.6/src/Makefile	2010-12-19 18:35:51.000000000 +0000
@@ -43,6 +43,7 @@ JOHN_OBJS = \
 	NT_fmt.o \
 	XSHA_fmt.o \
 	DOMINOSEC_fmt.o \
+	hmailserver_fmt.o \
 	lotus5_fmt.o \
 	oracle_fmt.o \
 	oracle11_fmt.o \
diff -urpN john-1.7.6.orig/src/options.c john-1.7.6/src/options.c
--- john-1.7.6.orig/src/options.c	2010-12-19 18:35:24.000000000 +0000
+++ john-1.7.6/src/options.c	2010-12-18 19:55:26.000000000 +0000
@@ -140,7 +140,7 @@ static struct opt_entry opt_list[] = {
 "--format=NAME              force hash type NAME:\n" \
 "                           DES/BSDI/MD5/BF/AFS/LM/NT/XSHA/PO/raw-MD5/MD5-gen/\n" \
 "                           IPB2/raw-sha1/md5a/hmac-md5/phpass-md5/KRB5/bfegg/\n" \
-"                           nsldap/ssha/openssha/oracle/oracle11/MYSQL/\n" \
+"                           hmailserver/nsldap/ssha/openssha/oracle/oracle11/MYSQL/\n" \
 "                           mysql-sha1/mscash/lotus5/DOMINOSEC/\n" \
 "                           NETLM/NETNTLM/NETLMv2/NETNTLMv2/NETHALFLM/MSCHAPv2/\n" \
 "                           mssql/mssql05/epi/phps/mysql-fast/pix-md5/sapG/\n" \

Powered by blists - more mailing lists

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