From 3c67e0054ce78178245ba9b1aeae6d625d0b6e17 Mon Sep 17 00:00:00 2001 From: DoZ10 Date: Sat, 6 May 2017 20:40:10 -0400 Subject: [PATCH] Implemented Perl test and fixed issues. Now have a working base. --- OpenCL/inc_types.cl | 2 +- OpenCL/m00670_a0.cl | 18 +++++++++--------- chachaTest.dict | 1 - chachaTest.hash | 1 - chachaTest.sh | 1 - docs/changes.txt | 1 + docs/readme.txt | 1 + include/interface.h | 4 ++-- src/interface.c | 4 ++-- src/usage.c | 1 + tools/test.pl | 23 ++++++++++++++++++++--- tools/test.sh | 2 +- 12 files changed, 38 insertions(+), 21 deletions(-) delete mode 100644 chachaTest.dict delete mode 100644 chachaTest.hash delete mode 100755 chachaTest.sh diff --git a/OpenCL/inc_types.cl b/OpenCL/inc_types.cl index b5d7daad6..4211ab691 100644 --- a/OpenCL/inc_types.cl +++ b/OpenCL/inc_types.cl @@ -782,7 +782,7 @@ typedef struct luks_tmp typedef struct chacha20 { u32 iv[2]; - u8 plain[64]; + u32 plain[2]; u32 plain_length; u32 position; diff --git a/OpenCL/m00670_a0.cl b/OpenCL/m00670_a0.cl index c378944ad..2d9c78d0a 100644 --- a/OpenCL/m00670_a0.cl +++ b/OpenCL/m00670_a0.cl @@ -71,7 +71,7 @@ void chacha20_transform (const u32x w0[4], const u32x w1[4], const u32 position, x[14] = ctx[14]; x[15] = ctx[15]; - for (int i = 0; i < 10; ++i) { + for (u8 i = 0; i < 10; ++i) { /* Column round */ QR(0, 4, 8, 12); @@ -103,10 +103,10 @@ void chacha20_transform (const u32x w0[4], const u32x w1[4], const u32 position, x[14] += ctx[14]; x[15] += ctx[15]; - digest[0] = plain[0] ^ x[0]; - digest[1] = plain[1] ^ x[1]; - digest[2] = plain[2] ^ x[2]; - digest[3] = plain[3] ^ x[3]; + digest[1] = plain[0] ^ x[0]; + digest[0] = plain[1] ^ x[1]; + digest[3] = plain[2] ^ x[2]; + digest[2] = plain[3] ^ x[3]; } __kernel void m00670_m04 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const comb_t *combs_buf, __global const bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const chacha20_t *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) @@ -231,10 +231,10 @@ __kernel void m00670_s04 (__global pw_t *pws, __global const kernel_rule_t *rule chacha20_transform (w0, w1, position, iv, plain, digest); - const u32x r0 = digest[1]; - const u32x r1 = digest[0]; - const u32x r2 = digest[3]; - const u32x r3 = digest[2]; + const u32x r0 = digest[0]; + const u32x r1 = digest[1]; + const u32x r2 = digest[2]; + const u32x r3 = digest[3]; COMPARE_S_SIMD(r0, r1, r2, r3); } diff --git a/chachaTest.dict b/chachaTest.dict deleted file mode 100644 index 9f358a4ad..000000000 --- a/chachaTest.dict +++ /dev/null @@ -1 +0,0 @@ -123456 diff --git a/chachaTest.hash b/chachaTest.hash deleted file mode 100644 index 0223dbbf4..000000000 --- a/chachaTest.hash +++ /dev/null @@ -1 +0,0 @@ -$Chacha20$*0*0001020304050607*00000000000000000000000000000000*8c697432d1159fede2a9c8c4a0002f10 diff --git a/chachaTest.sh b/chachaTest.sh deleted file mode 100755 index 253f5f357..000000000 --- a/chachaTest.sh +++ /dev/null @@ -1 +0,0 @@ -./hashcat -m 670 -a 0 chachaTest.hash chachaTest.dict -u1 -n1 --force --weak-hash-threshold=0 --potfile-disable diff --git a/docs/changes.txt b/docs/changes.txt index 7acfae9e8..57fdd1825 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -5,6 +5,7 @@ ## - Added hash-mode 600 = Blake2-512 +- Added hash-mode 670 = Chacha20 - Added hash-mode 15200 = Blockchain, My Wallet, V2 ## diff --git a/docs/readme.txt b/docs/readme.txt index d128e38e6..4c22baecb 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -53,6 +53,7 @@ NVIDIA GPUs require "NVIDIA Driver" (367.x or later) - Whirlpool - DES (PT = $salt, key = $pass) - 3DES (PT = $salt, key = $pass) +- Chacha20 - GOST R 34.11-94 - GOST R 34.11-2012 (Streebog) 256-bit - GOST R 34.11-2012 (Streebog) 512-bit diff --git a/include/interface.h b/include/interface.h index 92fb4b88c..ce72309ed 100644 --- a/include/interface.h +++ b/include/interface.h @@ -912,8 +912,8 @@ typedef enum display_len DISPLAY_LEN_MAX_501 = 104, DISPLAY_LEN_MIN_600 = 8 + 128, DISPLAY_LEN_MAX_600 = 8 + 128, - DISPLAY_LEN_MIN_670 = 10 + 1 + 1 + 1 + 16 + 1 + 32 + 1 + 32, - DISPLAY_LEN_MAX_670 = 10 + 1 + 5 + 1 + 16 + 1 + 32 + 1 + 32, + DISPLAY_LEN_MIN_670 = 10 + 1 + 1 + 1 + 16 + 1 + 16 + 1 + 16, + DISPLAY_LEN_MAX_670 = 10 + 1 + 5 + 1 + 16 + 1 + 64 + 1 + 64, DISPLAY_LEN_MIN_900 = 32, DISPLAY_LEN_MAX_900 = 32, DISPLAY_LEN_MIN_910 = 32 + 1 + 0, diff --git a/src/interface.c b/src/interface.c index 72fd80079..27feec16f 100644 --- a/src/interface.c +++ b/src/interface.c @@ -18546,8 +18546,8 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le byte_swap_32(chacha20->iv[0]), byte_swap_32(chacha20->plain[1]), byte_swap_32(chacha20->plain[0]), - byte_swap_32(ptr[1]), - byte_swap_32(ptr[0])); + ptr[1], + ptr[0]); } else if (hash_type == HASH_TYPE_RIPEMD160) { diff --git a/src/usage.c b/src/usage.c index 7f44abfeb..69a0126ef 100644 --- a/src/usage.c +++ b/src/usage.c @@ -172,6 +172,7 @@ static const char *USAGE_BIG[] = " 14000 | DES (PT = $salt, key = $pass) | Raw Cipher, Known-Plaintext attack", " 14100 | 3DES (PT = $salt, key = $pass) | Raw Cipher, Known-Plaintext attack", " 14900 | Skip32 (PT = $salt, key = $pass) | Raw Cipher, Known-Plaintext attack", + " 670 | Chacha20 | Raw Cipher, Known-Plaintext attack", " 400 | phpass | Generic KDF", " 8900 | scrypt | Generic KDF", " 11900 | PBKDF2-HMAC-MD5 | Generic KDF", diff --git a/tools/test.pl b/tools/test.pl index 9a9565daf..a6429a62a 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -31,6 +31,7 @@ use Crypt::Twofish; use Crypt::Mode::ECB; use Crypt::UnixCrypt_XS qw (crypt_rounds fold_password base64_to_int24 block_to_base64 int24_to_base64); use Crypt::Skip32; +use Crypt::OpenSSH::ChachaPoly; use MIME::Base64; use Authen::Passphrase::NTHash; use Authen::Passphrase::MySQL323; @@ -47,7 +48,7 @@ my $hashcat = "./hashcat"; my $MAX_LEN = 55; -my @modes = (0, 10, 11, 12, 20, 21, 22, 23, 30, 40, 50, 60, 100, 101, 110, 111, 112, 120, 121, 122, 125, 130, 131, 132, 133, 140, 141, 150, 160, 200, 300, 400, 500, 600, 900, 1000, 1100, 1300, 1400, 1410, 1411, 1420, 1430, 1440, 1441, 1450, 1460, 1500, 1600, 1700, 1710, 1711, 1720, 1730, 1740, 1722, 1731, 1750, 1760, 1800, 2100, 2400, 2410, 2500, 2600, 2611, 2612, 2711, 2811, 3000, 3100, 3200, 3710, 3711, 3300, 3500, 3610, 3720, 3800, 3910, 4010, 4110, 4210, 4300, 4400, 4500, 4520, 4521, 4522, 4600, 4700, 4800, 4900, 5000, 5100, 5300, 5400, 5500, 5600, 5700, 5800, 6000, 6100, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7100, 7200, 7300, 7400, 7500, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8900, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200, 11300, 11400, 11500, 11600, 11900, 12000, 12001, 12100, 12200, 12300, 12400, 12600, 12700, 12800, 12900, 13000, 13100, 13200, 13300, 13400, 13500, 13600, 13800, 13900, 14000, 14100, 14400, 14700, 14800, 14900, 15000, 15100, 15200, 99999); +my @modes = (0, 10, 11, 12, 20, 21, 22, 23, 30, 40, 50, 60, 100, 101, 110, 111, 112, 120, 121, 122, 125, 130, 131, 132, 133, 140, 141, 150, 160, 200, 300, 400, 500, 600, 670, 900, 1000, 1100, 1300, 1400, 1410, 1411, 1420, 1430, 1440, 1441, 1450, 1460, 1500, 1600, 1700, 1710, 1711, 1720, 1730, 1740, 1722, 1731, 1750, 1760, 1800, 2100, 2400, 2410, 2500, 2600, 2611, 2612, 2711, 2811, 3000, 3100, 3200, 3710, 3711, 3300, 3500, 3610, 3720, 3800, 3910, 4010, 4110, 4210, 4300, 4400, 4500, 4520, 4521, 4522, 4600, 4700, 4800, 4900, 5000, 5100, 5300, 5400, 5500, 5600, 5700, 5800, 6000, 6100, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7100, 7200, 7300, 7400, 7500, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8900, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200, 11300, 11400, 11500, 11600, 11900, 12000, 12001, 12100, 12200, 12300, 12400, 12600, 12700, 12800, 12900, 13000, 13100, 13200, 13300, 13400, 13500, 13600, 13800, 13900, 14000, 14100, 14400, 14700, 14800, 14900, 15000, 15100, 15200, 99999); my %is_unicode = map { $_ => 1 } qw(30 40 130 131 132 133 140 141 1000 1100 1430 1440 1441 1730 1740 1731 5500 5600 8000 9400 9500 9600 9700 9800 11600 13500 13800); my %less_fifteen = map { $_ => 1 } qw(500 1600 1800 2400 2410 3200 6300 7400 10500 10700); @@ -3075,7 +3076,7 @@ sub passthrough my $tmp_hash; - if ($mode == 0 || $mode == 100 || $mode == 101 || $mode == 133 || $mode == 200 || $mode == 300 || $mode == 600 || $mode == 900 || $mode == 1000 || $mode == 1300 || $mode == 1400 || $mode == 1700 || $mode == 2400 || $mode == 2600 || $mode == 3500 || $mode == 4300 || $mode == 4400 || $mode == 4500 || $mode == 4600 || $mode == 4700 || $mode == 5000 || $mode == 5100 || $mode == 6000 || $mode == 6100 || $mode == 6900 || $mode == 5700 || $mode == 9900 || $mode == 10800 || $mode == 11500 || $mode == 13300 || $mode == 99999) + if ($mode == 0 || $mode == 100 || $mode == 101 || $mode == 133 || $mode == 200 || $mode == 300 || $mode == 600 || $mode == 670 || $mode == 900 || $mode == 1000 || $mode == 1300 || $mode == 1400 || $mode == 1700 || $mode == 2400 || $mode == 2600 || $mode == 3500 || $mode == 4300 || $mode == 4400 || $mode == 4500 || $mode == 4600 || $mode == 4700 || $mode == 5000 || $mode == 5100 || $mode == 6000 || $mode == 6100 || $mode == 6900 || $mode == 5700 || $mode == 9900 || $mode == 10800 || $mode == 11500 || $mode == 13300 || $mode == 99999) { $tmp_hash = gen_hash ($mode, $word_buf, ""); } @@ -3534,7 +3535,7 @@ sub single { my $mode = $modes[$j]; - if ($mode == 0 || $mode == 100 || $mode == 101 || $mode == 133 || $mode == 200 || $mode == 300 || $mode == 600 || $mode == 900 || $mode == 1000 || $mode == 1300 || $mode == 1400 || $mode == 1700 || $mode == 2400 || $mode == 2600 || $mode == 3500 || $mode == 4300 || $mode == 4400 || $mode == 4500 || $mode == 4600 || $mode == 4700 || $mode == 5000 || $mode == 5100 || $mode == 5300 || $mode == 5400 || $mode == 6000 || $mode == 6100 || $mode == 6600 || $mode == 6900 || $mode == 5700 || $mode == 8200 || $mode == 8300 || $mode == 9900 || $mode == 10800 || $mode == 11500 || $mode == 13300 || $mode == 99999) + if ($mode == 0 || $mode == 100 || $mode == 101 || $mode == 133 || $mode == 200 || $mode == 300 || $mode == 600 || $mode == 670 || $mode == 900 || $mode == 1000 || $mode == 1300 || $mode == 1400 || $mode == 1700 || $mode == 2400 || $mode == 2600 || $mode == 3500 || $mode == 4300 || $mode == 4400 || $mode == 4500 || $mode == 4600 || $mode == 4700 || $mode == 5000 || $mode == 5100 || $mode == 5300 || $mode == 5400 || $mode == 6000 || $mode == 6100 || $mode == 6600 || $mode == 6900 || $mode == 5700 || $mode == 8200 || $mode == 8300 || $mode == 9900 || $mode == 10800 || $mode == 11500 || $mode == 13300 || $mode == 99999) { for (my $i = 1; $i < 32; $i++) { @@ -4783,6 +4784,22 @@ sub gen_hash $hash_buf = lc blake2b_hex($word_buf); $tmp_hash = sprintf ("\$BLAKE2\$" . $hash_buf); } + elsif ($mode == 670) + { + my $eight_byte_iv = pack("H*", "0000000000000000"); + my $eight_byte_counter = pack("H*", "0000000000000000"); # little endian + + my $pad_len = 32 - length $word_buf; + my $key = $word_buf . "\0" x $pad_len; + my $cipher = Crypt::OpenSSH::ChachaPoly->new($key); + + $cipher->ivsetup($eight_byte_iv, $eight_byte_counter); + + my $enc = $cipher->encrypt("AAAAAAAA"); + $hash_buf = $enc; + + $tmp_hash = sprintf ("\$Chacha20\$\*0\*0000000000000000\*4141414141414141\*%s", unpack("H*", $enc)); + } elsif ($mode == 900) { $hash_buf = md4_hex ($word_buf); diff --git a/tools/test.sh b/tools/test.sh index ea7893239..146cafc0e 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -9,7 +9,7 @@ TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # missing hash types: 5200,6251,6261,6271,6281 -HASH_TYPES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 125 130 131 132 133 140 141 150 160 200 300 400 500 600 900 1000 1100 1300 1400 1410 1411 1420 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 3910 4010 4110 4300 4400 4500 4520 4521 4522 4700 4800 4900 5000 5100 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8900 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 10100 10200 10300 10400 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11900 12000 12001 12100 12200 12300 12400 12600 12700 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800 14000 14100 14400 14600 14700 14800 14900 15000 15100 15200 99999" +HASH_TYPES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 125 130 131 132 133 140 141 150 160 200 300 400 500 600 670 900 1000 1100 1300 1400 1410 1411 1420 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 3910 4010 4110 4300 4400 4500 4520 4521 4522 4700 4800 4900 5000 5100 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8900 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 10100 10200 10300 10400 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11900 12000 12001 12100 12200 12300 12400 12600 12700 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800 14000 14100 14400 14600 14700 14800 14900 15000 15100 15200 99999" #ATTACK_MODES="0 1 3 6 7" ATTACK_MODES="0 1 3 7"