Fixes #1538: Added -m 22500 = MultiBit Classic .key (MD5)

pull/2306/head
philsmd 4 years ago
parent dbfd8d949e
commit b51273fb0b
No known key found for this signature in database
GPG Key ID: 4F25D016D9D6A8AF

File diff suppressed because it is too large Load Diff

@ -0,0 +1,622 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_rp.h"
#include "inc_rp.cl"
#include "inc_scalar.cl"
#include "inc_hash_md5.cl"
#include "inc_cipher_aes.cl"
#endif
DECLSPEC int is_valid_bitcoinj_8 (const u8 v)
{
// .abcdefghijklmnopqrstuvwxyz
if (v > (u8) 'z') return 0;
if (v < (u8) '.') return 0;
if ((v > (u8) '.') && (v < (u8) 'a')) return 0;
return 1;
}
KERNEL_FQ void m22500_mxx (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
COPY_PW (pws[gid]);
/**
* salt
*/
u32 s[64] = { 0 };
s[0] = salt_bufs[salt_pos].salt_buf[0];
s[1] = salt_bufs[salt_pos].salt_buf[1];
u32 data[8];
data[0] = salt_bufs[salt_pos].salt_buf[2];
data[1] = salt_bufs[salt_pos].salt_buf[3];
data[2] = salt_bufs[salt_pos].salt_buf[4];
data[3] = salt_bufs[salt_pos].salt_buf[5];
data[4] = salt_bufs[salt_pos].salt_buf[6];
data[5] = salt_bufs[salt_pos].salt_buf[7];
data[6] = salt_bufs[salt_pos].salt_buf[8];
data[7] = salt_bufs[salt_pos].salt_buf[9];
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
pw_t tmp = PASTE_PW;
tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len);
/**
* key1 = md5 ($pass . $salt):
*/
md5_ctx_t ctx;
md5_init (&ctx);
md5_update (&ctx, tmp.i, tmp.pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 ukey[8];
ukey[0] = ctx.h[0];
ukey[1] = ctx.h[1];
ukey[2] = ctx.h[2];
ukey[3] = ctx.h[3];
/**
* key2 = md5 ($key1 . $pass . $salt):
*/
u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update ()
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update (&ctx, tmp.i, tmp.pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
ukey[4] = ctx.h[0];
ukey[5] = ctx.h[1];
ukey[6] = ctx.h[2];
ukey[7] = ctx.h[3];
/**
* iv = md5 ($key2 . $pass . $salt):
*/
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update (&ctx, tmp.i, tmp.pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 iv[4];
iv[0] = ctx.h[0];
iv[1] = ctx.h[1];
iv[2] = ctx.h[2];
iv[3] = ctx.h[3];
/**
* AES-256-CBC:
*/
#define KEYLEN 60
u32 ks[KEYLEN];
aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
u32 encrypted[4];
encrypted[0] = data[0];
encrypted[1] = data[1];
encrypted[2] = data[2];
encrypted[3] = data[3];
u32 out[4];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
// first char of decrypted wallet data must be K, L, Q, 5, # or \n
const u32 first_byte = out[0] & 0xff;
if ((first_byte != 0x4b) && // K
(first_byte != 0x4c) && // L
(first_byte != 0x51) && // Q
(first_byte != 0x35) && // 5
(first_byte != 0x23) && // #
(first_byte != 0x0a)) // \n
{
continue;
}
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet
(first_byte == 0x4c) || // L
(first_byte == 0x51) || // Q
(first_byte == 0x35)) // 5
{
// base58 check:
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
}
else if (first_byte == 0x0a) // \n => bitcoinj
{
if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte
// check for "org." substring:
if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped)
if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g"
if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0)
if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7
if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8
if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9
if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10
if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11
if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12
if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13
}
else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet
{
// Full string would be:
// "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
// check for "# KEEP YOUR PRIV" substring:
if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped)
if (out[1] != 0x59205045) continue; // "Y PE"
if (out[2] != 0x2052554f) continue; // " RUO"
if (out[3] != 0x56495250) continue; // "VIRP"
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
// check for "ATE KEYS SAFE! A" substring:
if (out[0] != 0x20455441) continue; // " ETA" (byte swapped)
if (out[1] != 0x5359454b) continue; // "SYEK"
if (out[2] != 0x46415320) continue; // "FAS "
if (out[3] != 0x41202145) continue; // "A !E"
}
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
}
}
}
KERNEL_FQ void m22500_sxx (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
COPY_PW (pws[gid]);
/**
* salt
*/
u32 s[64] = { 0 };
s[0] = salt_bufs[salt_pos].salt_buf[0];
s[1] = salt_bufs[salt_pos].salt_buf[1];
u32 data[8];
data[0] = salt_bufs[salt_pos].salt_buf[2];
data[1] = salt_bufs[salt_pos].salt_buf[3];
data[2] = salt_bufs[salt_pos].salt_buf[4];
data[3] = salt_bufs[salt_pos].salt_buf[5];
data[4] = salt_bufs[salt_pos].salt_buf[6];
data[5] = salt_bufs[salt_pos].salt_buf[7];
data[6] = salt_bufs[salt_pos].salt_buf[8];
data[7] = salt_bufs[salt_pos].salt_buf[9];
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
pw_t tmp = PASTE_PW;
tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len);
/**
* key1 = md5 ($pass . $salt):
*/
md5_ctx_t ctx;
md5_init (&ctx);
md5_update (&ctx, tmp.i, tmp.pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 ukey[8];
ukey[0] = ctx.h[0];
ukey[1] = ctx.h[1];
ukey[2] = ctx.h[2];
ukey[3] = ctx.h[3];
/**
* key2 = md5 ($key1 . $pass . $salt):
*/
u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update ()
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update (&ctx, tmp.i, tmp.pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
ukey[4] = ctx.h[0];
ukey[5] = ctx.h[1];
ukey[6] = ctx.h[2];
ukey[7] = ctx.h[3];
/**
* iv = md5 ($key2 . $pass . $salt):
*/
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update (&ctx, tmp.i, tmp.pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 iv[4];
iv[0] = ctx.h[0];
iv[1] = ctx.h[1];
iv[2] = ctx.h[2];
iv[3] = ctx.h[3];
/**
* AES-256-CBC:
*/
#define KEYLEN 60
u32 ks[KEYLEN];
aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
u32 encrypted[4];
encrypted[0] = data[0];
encrypted[1] = data[1];
encrypted[2] = data[2];
encrypted[3] = data[3];
u32 out[4];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
// first char of decrypted wallet data must be K, L, Q, 5, # or \n
const u32 first_byte = out[0] & 0xff;
if ((first_byte != 0x4b) && // K
(first_byte != 0x4c) && // L
(first_byte != 0x51) && // Q
(first_byte != 0x35) && // 5
(first_byte != 0x23) && // #
(first_byte != 0x0a)) // \n
{
continue;
}
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet
(first_byte == 0x4c) || // L
(first_byte == 0x51) || // Q
(first_byte == 0x35)) // 5
{
// base58 check:
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
}
else if (first_byte == 0x0a) // \n => bitcoinj
{
if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte
// check for "org." substring:
if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped)
if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g"
if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0)
if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7
if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8
if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9
if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10
if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11
if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12
if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13
}
else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet
{
// Full string would be:
// "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
// check for "# KEEP YOUR PRIV" substring:
if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped)
if (out[1] != 0x59205045) continue; // "Y PE"
if (out[2] != 0x2052554f) continue; // " RUO"
if (out[3] != 0x56495250) continue; // "VIRP"
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
// check for "ATE KEYS SAFE! A" substring:
if (out[0] != 0x20455441) continue; // " ETA" (byte swapped)
if (out[1] != 0x5359454b) continue; // "SYEK"
if (out[2] != 0x46415320) continue; // "FAS "
if (out[3] != 0x41202145) continue; // "A !E"
}
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,632 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_scalar.cl"
#include "inc_hash_md5.cl"
#include "inc_cipher_aes.cl"
#endif
DECLSPEC int is_valid_bitcoinj_8 (const u8 v)
{
// .abcdefghijklmnopqrstuvwxyz
if (v > (u8) 'z') return 0;
if (v < (u8) '.') return 0;
if ((v > (u8) '.') && (v < (u8) 'a')) return 0;
return 1;
}
KERNEL_FQ void m22500_mxx (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
/**
* salt
*/
u32 s[64] = { 0 };
s[0] = salt_bufs[salt_pos].salt_buf[0];
s[1] = salt_bufs[salt_pos].salt_buf[1];
u32 data[8];
data[0] = salt_bufs[salt_pos].salt_buf[2];
data[1] = salt_bufs[salt_pos].salt_buf[3];
data[2] = salt_bufs[salt_pos].salt_buf[4];
data[3] = salt_bufs[salt_pos].salt_buf[5];
data[4] = salt_bufs[salt_pos].salt_buf[6];
data[5] = salt_bufs[salt_pos].salt_buf[7];
data[6] = salt_bufs[salt_pos].salt_buf[8];
data[7] = salt_bufs[salt_pos].salt_buf[9];
md5_ctx_t ctx0;
md5_init (&ctx0);
md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
/**
* key1 = md5 ($pass . $salt):
*/
md5_ctx_t ctx = ctx0;
md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 ukey[8];
ukey[0] = ctx.h[0];
ukey[1] = ctx.h[1];
ukey[2] = ctx.h[2];
ukey[3] = ctx.h[3];
/**
* key2 = md5 ($key1 . $pass . $salt):
*/
u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update ()
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len);
md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
ukey[4] = ctx.h[0];
ukey[5] = ctx.h[1];
ukey[6] = ctx.h[2];
ukey[7] = ctx.h[3];
/**
* iv = md5 ($key2 . $pass . $salt):
*/
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len);
md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 iv[4];
iv[0] = ctx.h[0];
iv[1] = ctx.h[1];
iv[2] = ctx.h[2];
iv[3] = ctx.h[3];
/**
* AES-256-CBC:
*/
#define KEYLEN 60
u32 ks[KEYLEN];
aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
u32 encrypted[4];
encrypted[0] = data[0];
encrypted[1] = data[1];
encrypted[2] = data[2];
encrypted[3] = data[3];
u32 out[4];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
// first char of decrypted wallet data must be K, L, Q, 5, # or \n
const u32 first_byte = out[0] & 0xff;
if ((first_byte != 0x4b) && // K
(first_byte != 0x4c) && // L
(first_byte != 0x51) && // Q
(first_byte != 0x35) && // 5
(first_byte != 0x23) && // #
(first_byte != 0x0a)) // \n
{
continue;
}
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet
(first_byte == 0x4c) || // L
(first_byte == 0x51) || // Q
(first_byte == 0x35)) // 5
{
// base58 check:
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
}
else if (first_byte == 0x0a) // \n => bitcoinj
{
if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte
// check for "org." substring:
if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped)
if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g"
if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0)
if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7
if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8
if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9
if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10
if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11
if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12
if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13
}
else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet
{
// Full string would be:
// "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
// check for "# KEEP YOUR PRIV" substring:
if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped)
if (out[1] != 0x59205045) continue; // "Y PE"
if (out[2] != 0x2052554f) continue; // " RUO"
if (out[3] != 0x56495250) continue; // "VIRP"
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
// check for "ATE KEYS SAFE! A" substring:
if (out[0] != 0x20455441) continue; // " ETA" (byte swapped)
if (out[1] != 0x5359454b) continue; // "SYEK"
if (out[2] != 0x46415320) continue; // "FAS "
if (out[3] != 0x41202145) continue; // "A !E"
}
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
}
}
}
KERNEL_FQ void m22500_sxx (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
/**
* salt
*/
u32 s[64] = { 0 };
s[0] = salt_bufs[salt_pos].salt_buf[0];
s[1] = salt_bufs[salt_pos].salt_buf[1];
u32 data[8];
data[0] = salt_bufs[salt_pos].salt_buf[2];
data[1] = salt_bufs[salt_pos].salt_buf[3];
data[2] = salt_bufs[salt_pos].salt_buf[4];
data[3] = salt_bufs[salt_pos].salt_buf[5];
data[4] = salt_bufs[salt_pos].salt_buf[6];
data[5] = salt_bufs[salt_pos].salt_buf[7];
data[6] = salt_bufs[salt_pos].salt_buf[8];
data[7] = salt_bufs[salt_pos].salt_buf[9];
md5_ctx_t ctx0;
md5_init (&ctx0);
md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
/**
* key1 = md5 ($pass . $salt):
*/
md5_ctx_t ctx = ctx0;
md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 ukey[8];
ukey[0] = ctx.h[0];
ukey[1] = ctx.h[1];
ukey[2] = ctx.h[2];
ukey[3] = ctx.h[3];
/**
* key2 = md5 ($key1 . $pass . $salt):
*/
u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update ()
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len);
md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
ukey[4] = ctx.h[0];
ukey[5] = ctx.h[1];
ukey[6] = ctx.h[2];
ukey[7] = ctx.h[3];
/**
* iv = md5 ($key2 . $pass . $salt):
*/
w[0] = ctx.h[0];
w[1] = ctx.h[1];
w[2] = ctx.h[2];
w[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, w, 16);
md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len);
md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 iv[4];
iv[0] = ctx.h[0];
iv[1] = ctx.h[1];
iv[2] = ctx.h[2];
iv[3] = ctx.h[3];
/**
* AES-256-CBC:
*/
#define KEYLEN 60
u32 ks[KEYLEN];
aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
u32 encrypted[4];
encrypted[0] = data[0];
encrypted[1] = data[1];
encrypted[2] = data[2];
encrypted[3] = data[3];
u32 out[4];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
// first char of decrypted wallet data must be K, L, Q, 5, # or \n
const u32 first_byte = out[0] & 0xff;
if ((first_byte != 0x4b) && // K
(first_byte != 0x4c) && // L
(first_byte != 0x51) && // Q
(first_byte != 0x35) && // 5
(first_byte != 0x23) && // #
(first_byte != 0x0a)) // \n
{
continue;
}
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet
(first_byte == 0x4c) || // L
(first_byte == 0x51) || // Q
(first_byte == 0x35)) // 5
{
// base58 check:
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
}
else if (first_byte == 0x0a) // \n => bitcoinj
{
if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte
// check for "org." substring:
if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped)
if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g"
if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0)
if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7
if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8
if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9
if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10
if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11
if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12
if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13
}
else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet
{
// Full string would be:
// "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
// check for "# KEEP YOUR PRIV" substring:
if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped)
if (out[1] != 0x59205045) continue; // "Y PE"
if (out[2] != 0x2052554f) continue; // " RUO"
if (out[3] != 0x56495250) continue; // "VIRP"
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
// check for "ATE KEYS SAFE! A" substring:
if (out[0] != 0x20455441) continue; // " ETA" (byte swapped)
if (out[1] != 0x5359454b) continue; // "SYEK"
if (out[2] != 0x46415320) continue; // "FAS "
if (out[3] != 0x41202145) continue; // "A !E"
}
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,650 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_simd.cl"
#include "inc_hash_md5.cl"
#include "inc_cipher_aes.cl"
#endif
DECLSPEC int is_valid_bitcoinj_8 (const u8 v)
{
// .abcdefghijklmnopqrstuvwxyz
if (v > (u8) 'z') return 0;
if (v < (u8) '.') return 0;
if ((v > (u8) '.') && (v < (u8) 'a')) return 0;
return 1;
}
KERNEL_FQ void m22500_mxx (KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
/**
* base
*/
const u32 pw_len = pws[gid].pw_len;
u32x w[64] = { 0 };
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
{
w[idx] = pws[gid].i[idx];
}
/**
* salt
*/
u32 s[64] = { 0 };
s[0] = salt_bufs[salt_pos].salt_buf[0];
s[1] = salt_bufs[salt_pos].salt_buf[1];
u32 data[8];
data[0] = salt_bufs[salt_pos].salt_buf[2];
data[1] = salt_bufs[salt_pos].salt_buf[3];
data[2] = salt_bufs[salt_pos].salt_buf[4];
data[3] = salt_bufs[salt_pos].salt_buf[5];
data[4] = salt_bufs[salt_pos].salt_buf[6];
data[5] = salt_bufs[salt_pos].salt_buf[7];
data[6] = salt_bufs[salt_pos].salt_buf[8];
data[7] = salt_bufs[salt_pos].salt_buf[9];
/**
* loop
*/
u32x w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
w[0] = w0;
/**
* key1 = md5 ($pass . $salt):
*/
md5_ctx_t ctx;
md5_init (&ctx);
md5_update (&ctx, w, pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 ukey[8];
ukey[0] = ctx.h[0];
ukey[1] = ctx.h[1];
ukey[2] = ctx.h[2];
ukey[3] = ctx.h[3];
/**
* key2 = md5 ($key1 . $pass . $salt):
*/
u32 h[16] = { 0 }; // we need 64-bit alignment for md5_update ()
h[0] = ctx.h[0];
h[1] = ctx.h[1];
h[2] = ctx.h[2];
h[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, h, 16);
md5_update (&ctx, w, pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
ukey[4] = ctx.h[0];
ukey[5] = ctx.h[1];
ukey[6] = ctx.h[2];
ukey[7] = ctx.h[3];
/**
* iv = md5 ($key2 . $pass . $salt):
*/
h[0] = ctx.h[0];
h[1] = ctx.h[1];
h[2] = ctx.h[2];
h[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, h, 16);
md5_update (&ctx, w, pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 iv[4];
iv[0] = ctx.h[0];
iv[1] = ctx.h[1];
iv[2] = ctx.h[2];
iv[3] = ctx.h[3];
/**
* AES-256-CBC:
*/
#define KEYLEN 60
u32 ks[KEYLEN];
aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
u32 encrypted[4];
encrypted[0] = data[0];
encrypted[1] = data[1];
encrypted[2] = data[2];
encrypted[3] = data[3];
u32 out[4];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
// first char of decrypted wallet data must be K, L, Q, 5, # or \n
const u32 first_byte = out[0] & 0xff;
if ((first_byte != 0x4b) && // K
(first_byte != 0x4c) && // L
(first_byte != 0x51) && // Q
(first_byte != 0x35) && // 5
(first_byte != 0x23) && // #
(first_byte != 0x0a)) // \n
{
continue;
}
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet
(first_byte == 0x4c) || // L
(first_byte == 0x51) || // Q
(first_byte == 0x35)) // 5
{
// base58 check:
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
}
else if (first_byte == 0x0a) // \n => bitcoinj
{
if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte
// check for "org." substring:
if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped)
if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g"
if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0)
if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7
if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8
if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9
if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10
if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11
if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12
if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13
}
else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet
{
// Full string would be:
// "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
// check for "# KEEP YOUR PRIV" substring:
if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped)
if (out[1] != 0x59205045) continue; // "Y PE"
if (out[2] != 0x2052554f) continue; // " RUO"
if (out[3] != 0x56495250) continue; // "VIRP"
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
// check for "ATE KEYS SAFE! A" substring:
if (out[0] != 0x20455441) continue; // " ETA" (byte swapped)
if (out[1] != 0x5359454b) continue; // "SYEK"
if (out[2] != 0x46415320) continue; // "FAS "
if (out[3] != 0x41202145) continue; // "A !E"
}
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
}
}
}
KERNEL_FQ void m22500_sxx (KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
/**
* base
*/
const u32 pw_len = pws[gid].pw_len;
u32x w[64] = { 0 };
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
{
w[idx] = pws[gid].i[idx];
}
/**
* salt
*/
u32 s[64] = { 0 };
s[0] = salt_bufs[salt_pos].salt_buf[0];
s[1] = salt_bufs[salt_pos].salt_buf[1];
u32 data[8];
data[0] = salt_bufs[salt_pos].salt_buf[2];
data[1] = salt_bufs[salt_pos].salt_buf[3];
data[2] = salt_bufs[salt_pos].salt_buf[4];
data[3] = salt_bufs[salt_pos].salt_buf[5];
data[4] = salt_bufs[salt_pos].salt_buf[6];
data[5] = salt_bufs[salt_pos].salt_buf[7];
data[6] = salt_bufs[salt_pos].salt_buf[8];
data[7] = salt_bufs[salt_pos].salt_buf[9];
/**
* loop
*/
u32x w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
w[0] = w0;
/**
* key1 = md5 ($pass . $salt):
*/
md5_ctx_t ctx;
md5_init (&ctx);
md5_update (&ctx, w, pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 ukey[8];
ukey[0] = ctx.h[0];
ukey[1] = ctx.h[1];
ukey[2] = ctx.h[2];
ukey[3] = ctx.h[3];
/**
* key2 = md5 ($key1 . $pass . $salt):
*/
u32 h[16] = { 0 }; // we need 64-bit alignment for md5_update ()
h[0] = ctx.h[0];
h[1] = ctx.h[1];
h[2] = ctx.h[2];
h[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, h, 16);
md5_update (&ctx, w, pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
ukey[4] = ctx.h[0];
ukey[5] = ctx.h[1];
ukey[6] = ctx.h[2];
ukey[7] = ctx.h[3];
/**
* iv = md5 ($key2 . $pass . $salt):
*/
h[0] = ctx.h[0];
h[1] = ctx.h[1];
h[2] = ctx.h[2];
h[3] = ctx.h[3];
md5_init (&ctx);
md5_update (&ctx, h, 16);
md5_update (&ctx, w, pw_len);
md5_update (&ctx, s, 8);
md5_final (&ctx);
u32 iv[4];
iv[0] = ctx.h[0];
iv[1] = ctx.h[1];
iv[2] = ctx.h[2];
iv[3] = ctx.h[3];
/**
* AES-256-CBC:
*/
#define KEYLEN 60
u32 ks[KEYLEN];
aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
u32 encrypted[4];
encrypted[0] = data[0];
encrypted[1] = data[1];
encrypted[2] = data[2];
encrypted[3] = data[3];
u32 out[4];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
// first char of decrypted wallet data must be K, L, Q, 5, # or \n
const u32 first_byte = out[0] & 0xff;
if ((first_byte != 0x4b) && // K
(first_byte != 0x4c) && // L
(first_byte != 0x51) && // Q
(first_byte != 0x35) && // 5
(first_byte != 0x23) && // #
(first_byte != 0x0a)) // \n
{
continue;
}
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet
(first_byte == 0x4c) || // L
(first_byte == 0x51) || // Q
(first_byte == 0x35)) // 5
{
// base58 check:
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
if (is_valid_base58_32 (out[0]) == 0) continue;
if (is_valid_base58_32 (out[1]) == 0) continue;
if (is_valid_base58_32 (out[2]) == 0) continue;
if (is_valid_base58_32 (out[3]) == 0) continue;
}
else if (first_byte == 0x0a) // \n => bitcoinj
{
if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte
// check for "org." substring:
if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped)
if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g"
if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0)
if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7
if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8
if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9
if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10
if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11
if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12
if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13
}
else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet
{
// Full string would be:
// "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
// check for "# KEEP YOUR PRIV" substring:
if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped)
if (out[1] != 0x59205045) continue; // "Y PE"
if (out[2] != 0x2052554f) continue; // " RUO"
if (out[3] != 0x56495250) continue; // "VIRP"
iv[0] = encrypted[0];
iv[1] = encrypted[1];
iv[2] = encrypted[2];
iv[3] = encrypted[3];
encrypted[0] = data[4];
encrypted[1] = data[5];
encrypted[2] = data[6];
encrypted[3] = data[7];
aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
out[2] ^= iv[2];
out[3] ^= iv[3];
// check for "ATE KEYS SAFE! A" substring:
if (out[0] != 0x20455441) continue; // " ETA" (byte swapped)
if (out[1] != 0x5359454b) continue; // "SYEK"
if (out[2] != 0x46415320) continue; // "FAS "
if (out[3] != 0x41202145) continue; // "A !E"
}
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
}
}
}

@ -40,6 +40,7 @@
- Added hash-mode: md5($salt.sha1($salt.$pass))
- Added hash-mode: md5(sha1($pass).md5($pass).sha1($pass))
- Added hash-mode: md5(sha1($salt).md5($pass))
- Added hash-mode: MultiBit Classic .key (MD5)
- Added hash-mode: Open Document Format (ODF) 1.1 (SHA-1, Blowfish)
- Added hash-mode: Open Document Format (ODF) 1.2 (SHA-256, AES)
- Added hash-mode: Oracle Transportation Management (SHA256)

@ -284,6 +284,7 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (9.0 or
- Ethereum Pre-Sale Wallet, PBKDF2-HMAC-SHA256
- Ethereum Wallet, PBKDF2-HMAC-SHA256
- Ethereum Wallet, SCRYPT
- MultiBit Classic .key (MD5)
- 7-Zip
- RAR3-hp
- RAR5

@ -0,0 +1,236 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "modules.h"
#include "bitops.h"
#include "convert.h"
#include "shared.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
static const u32 DGST_POS1 = 1;
static const u32 DGST_POS2 = 2;
static const u32 DGST_POS3 = 3;
static const u32 DGST_SIZE = DGST_SIZE_4_4;
static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER;
static const char *HASH_NAME = "MultiBit Classic .key (MD5)";
static const u64 KERN_TYPE = 22500;
static const u32 OPTI_TYPE = OPTI_TYPE_EARLY_SKIP;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$multibit$1*e5912fe5c84af3d5*5f0391c219e8ef62c06505b1f6232858f5bcaa739c2b471d45dd0bd8345334de";
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; }
u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; }
u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; }
u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; }
u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; }
const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; }
u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; }
u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; }
u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; }
u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; }
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
static const char *SIGNATURE_MULTIBIT = "$multibit$";
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL);
u32 pw_max = PW_MAX;
if (optimized_kernel == true)
{
pw_max = 31; // 55 - 8 (salt) - 16 (key1/key2)
}
return pw_max;
}
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
{
u32 *digest = (u32 *) digest_buf;
token_t token;
token.token_cnt = 4;
token.signatures_cnt = 1;
token.signatures_buf[0] = SIGNATURE_MULTIBIT;
token.len[0] = 10;
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
| TOKEN_ATTR_VERIFY_SIGNATURE;
token.sep[1] = '*';
token.len_min[1] = 1;
token.len_max[1] = 1;
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[2] = '*';
token.len_min[2] = 16;
token.len_max[2] = 16;
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[3] = '*';
token.len_min[3] = 64;
token.len_max[3] = 64;
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
// version
const u8 *version_pos = token.buf[1];
const u32 version = hc_strtoul ((const char *) version_pos, NULL, 10);
if (version != 1) return PARSER_SALT_VALUE;
// salt
const u8 *salt_pos = token.buf[2];
salt->salt_buf[0] = hex_to_u32 (salt_pos + 0);
salt->salt_buf[1] = hex_to_u32 (salt_pos + 8);
// data
const u8 *data_pos = token.buf[3];
salt->salt_buf[2] = hex_to_u32 (data_pos + 0);
salt->salt_buf[3] = hex_to_u32 (data_pos + 8);
salt->salt_buf[4] = hex_to_u32 (data_pos + 16);
salt->salt_buf[5] = hex_to_u32 (data_pos + 24);
salt->salt_buf[6] = hex_to_u32 (data_pos + 32);
salt->salt_buf[7] = hex_to_u32 (data_pos + 40);
salt->salt_buf[8] = hex_to_u32 (data_pos + 48);
salt->salt_buf[9] = hex_to_u32 (data_pos + 56);
// TODO remove ?
// salt->salt_buf[2] = byte_swap_32 (salt->salt_buf[2]);
// salt->salt_buf[3] = byte_swap_32 (salt->salt_buf[3]);
// salt->salt_buf[4] = byte_swap_32 (salt->salt_buf[4]);
// salt->salt_buf[5] = byte_swap_32 (salt->salt_buf[5]);
// salt->salt_buf[6] = byte_swap_32 (salt->salt_buf[6]);
// salt->salt_buf[7] = byte_swap_32 (salt->salt_buf[7]);
// salt->salt_buf[8] = byte_swap_32 (salt->salt_buf[8]);
// salt->salt_buf[9] = byte_swap_32 (salt->salt_buf[9]);
salt->salt_len = 40; // 8 + 32;
// fake hash
digest[0] = salt->salt_buf[2];
digest[1] = salt->salt_buf[3];
digest[2] = salt->salt_buf[4];
digest[3] = salt->salt_buf[5];
return (PARSER_OK);
}
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
{
int line_len = snprintf (line_buf, line_size, "%s%i*%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x",
SIGNATURE_MULTIBIT,
1,
byte_swap_32 (salt->salt_buf[0]),
byte_swap_32 (salt->salt_buf[1]),
byte_swap_32 (salt->salt_buf[2]),
byte_swap_32 (salt->salt_buf[3]),
byte_swap_32 (salt->salt_buf[4]),
byte_swap_32 (salt->salt_buf[5]),
byte_swap_32 (salt->salt_buf[6]),
byte_swap_32 (salt->salt_buf[7]),
byte_swap_32 (salt->salt_buf[8]),
byte_swap_32 (salt->salt_buf[9]));
return line_len;
}
void module_init (module_ctx_t *module_ctx)
{
module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT;
module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT;
module_ctx->module_attack_exec = module_attack_exec;
module_ctx->module_benchmark_esalt = MODULE_DEFAULT;
module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT;
module_ctx->module_benchmark_mask = MODULE_DEFAULT;
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
module_ctx->module_dgst_pos0 = module_dgst_pos0;
module_ctx->module_dgst_pos1 = module_dgst_pos1;
module_ctx->module_dgst_pos2 = module_dgst_pos2;
module_ctx->module_dgst_pos3 = module_dgst_pos3;
module_ctx->module_dgst_size = module_dgst_size;
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
module_ctx->module_esalt_size = MODULE_DEFAULT;
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
module_ctx->module_hash_binary_save = MODULE_DEFAULT;
module_ctx->module_hash_decode_potfile = MODULE_DEFAULT;
module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT;
module_ctx->module_hash_decode = module_hash_decode;
module_ctx->module_hash_encode_status = MODULE_DEFAULT;
module_ctx->module_hash_encode_potfile = MODULE_DEFAULT;
module_ctx->module_hash_encode = module_hash_encode;
module_ctx->module_hash_init_selftest = MODULE_DEFAULT;
module_ctx->module_hash_mode = MODULE_DEFAULT;
module_ctx->module_hash_category = module_hash_category;
module_ctx->module_hash_name = module_hash_name;
module_ctx->module_hashes_count_min = MODULE_DEFAULT;
module_ctx->module_hashes_count_max = MODULE_DEFAULT;
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
module_ctx->module_hook12 = MODULE_DEFAULT;
module_ctx->module_hook23 = MODULE_DEFAULT;
module_ctx->module_hook_salt_size = MODULE_DEFAULT;
module_ctx->module_hook_size = MODULE_DEFAULT;
module_ctx->module_jit_build_options = MODULE_DEFAULT;
module_ctx->module_jit_cache_disable = MODULE_DEFAULT;
module_ctx->module_kernel_accel_max = MODULE_DEFAULT;
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;
module_ctx->module_kernel_loops_max = MODULE_DEFAULT;
module_ctx->module_kernel_loops_min = MODULE_DEFAULT;
module_ctx->module_kernel_threads_max = MODULE_DEFAULT;
module_ctx->module_kernel_threads_min = MODULE_DEFAULT;
module_ctx->module_kern_type = module_kern_type;
module_ctx->module_kern_type_dynamic = MODULE_DEFAULT;
module_ctx->module_opti_type = module_opti_type;
module_ctx->module_opts_type = module_opts_type;
module_ctx->module_outfile_check_disable = MODULE_DEFAULT;
module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT;
module_ctx->module_potfile_custom_check = MODULE_DEFAULT;
module_ctx->module_potfile_disable = MODULE_DEFAULT;
module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT;
module_ctx->module_pwdump_column = MODULE_DEFAULT;
module_ctx->module_pw_max = module_pw_max;
module_ctx->module_pw_min = MODULE_DEFAULT;
module_ctx->module_salt_max = MODULE_DEFAULT;
module_ctx->module_salt_min = MODULE_DEFAULT;
module_ctx->module_salt_type = module_salt_type;
module_ctx->module_separator = MODULE_DEFAULT;
module_ctx->module_st_hash = module_st_hash;
module_ctx->module_st_pass = module_st_pass;
module_ctx->module_tmp_size = MODULE_DEFAULT;
module_ctx->module_unstable_warning = MODULE_DEFAULT;
module_ctx->module_warmup_disable = MODULE_DEFAULT;
}

@ -0,0 +1,192 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::MD5 qw (md5);
use Crypt::CBC;
sub module_constraints { [[0, 256], [8, 8], [0, 31], [8, 8], [-1, -1]] }
my $BASE58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
my $BITCOINJ_CHARS = ".abcdefghijklmnopqrstuvwxyz";
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $data = shift;
my $word_salt = $word . $salt;
my $key1 = md5 ( $word_salt);
my $key2 = md5 ($key1 . $word_salt);
my $iv = md5 ($key2 . $word_salt);
my $aes_cbc = Crypt::CBC->new ({
cipher => "Crypt::Rijndael",
iv => $iv,
key => $key1 . $key2,
keysize => 32,
literal_key => 1,
header => "none",
padding => "none"
});
my $type = 0; # 0: MultiBit Classic MD5, 1: KnCGroup Bitcoin Wallet, 2: bitcoinj
my $key = "";
if (! defined ($data))
{
$type = random_number (0, 2);
if ($type == 0)
{
my @chars_at_start = ('K', 'L', 'Q', '5');
$data = $chars_at_start[random_number (0, scalar (@chars_at_start) - 1)];
for (my $i = 1; $i < 32; $i++)
{
$data .= substr ($BASE58_CHARS, random_number (0, length ($BASE58_CHARS) - 1), 1);
}
}
elsif ($type == 1)
{
$data = "\n";
$data .= chr (random_number (0, 127));
$data .= "org.";
for (my $i = 6; $i < 32; $i++)
{
$data .= substr ($BITCOINJ_CHARS, random_number (0, length ($BITCOINJ_CHARS) - 1), 1);
}
}
elsif ($type == 2)
{
# Full string would be:
# "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins."
$data = '# KEEP YOUR PRIVATE KEYS SAFE! A';
}
$key = $aes_cbc->encrypt ($data);
}
else
{
$key = $aes_cbc->decrypt ($data);
# verification step:
# first char of $key must be K, L, Q, 5, # or \n
my $char_at_start = substr ($key, 0, 1);
if (($char_at_start eq 'K') ||
($char_at_start eq 'L') ||
($char_at_start eq 'Q') ||
($char_at_start eq '5'))
{
my $error = 0;
for (my $i = 1; $i < 32; $i++) # start with 1 (we already checked first char)
{
my $c = substr ($key, $i, 1);
my $idx = index ($BASE58_CHARS, $c);
next if ($idx >= 0);
$error = 1;
last;
}
if ($error == 0)
{
$key = $data;
}
}
elsif ($char_at_start eq "\n") # bitcoinj
{
my $second_char = substr ($key, 1, 1);
if (ord ($second_char) < 128)
{
if (substr ($key, 2, 4) eq "org.")
{
my $error = 0;
for (my $i = 6; $i < 14; $i++) # start with 6 (we already checked first chars)
{
my $c = substr ($key, $i, 1);
my $idx = index ($BITCOINJ_CHARS, $c);
next if ($idx >= 0);
$error = 1;
last;
}
if ($error == 0)
{
$key = $data;
}
}
}
}
elsif ($char_at_start eq '#') # KnCGroup Bitcoin Wallet
{
if (substr ($key, 0, 16) eq '# KEEP YOUR PRIV')
{
$key = $data;
}
}
}
my $hash = sprintf ("\$multibit\$1*%s*%s", unpack ("H*", $salt), unpack ("H*", $key));
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my $idx = index ($line, ':');
return unless $idx >= 0;
my $hash = substr ($line, 0, $idx);
my $word = substr ($line, $idx + 1);
return unless substr ($hash, 0, 12) eq '$multibit$1*';
$idx = index ($hash, '*', 12);
return unless $idx == 28;
my $salt_hex = substr ($hash, 12, 16); # 28 - 12 = 16
my $data_hex = substr ($hash, 29);
return unless length ($salt_hex) == 16;
return unless length ($data_hex) == 64;
my $salt = pack ("H*", $salt_hex);
my $data = pack ("H*", $data_hex);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt, $data);
return ($new_hash, $word);
}
1;
Loading…
Cancel
Save