⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 md5_std.c

📁 unix密码破解软件John the Ripper
💻 C
📖 第 1 页 / 共 2 页
字号:
	HH (b, c, d, a, x[10], S34, AC40);		/* 40 */	HH (a, b, c, d, x[13], S31, AC41);		/* 41 */	HH (d, a, b, c, x[ 0], S32, AC42);		/* 42 */	HH (c, d, a, b, x[ 3], S33, AC43);		/* 43 */	HH (b, c, d, a, x[ 6], S34, AC44);		/* 44 */	HH (a, b, c, d, x[ 9], S31, AC45);		/* 45 */	HH (d, a, b, c, x[12], S32, AC46);		/* 46 */	c += H (d, a, b) + AC47;	ROTATE_LEFT (c, S33); c += d;			/* 47 */	HH (b, c, d, a, x[ 2], S34, AC48);		/* 48 *//* Round 4 */	II (a, b, c, d, x[ 0], S41, AC49);		/* 49 */	II (d, a, b, c, x[ 7], S42, AC50);		/* 50 */	II (c, d, a, b, x[14], S43, AC51);		/* 51 */	II (b, c, d, a, x[ 5], S44, AC52);		/* 52 */	II (a, b, c, d, x[12], S41, AC53);		/* 53 */	II (d, a, b, c, x[ 3], S42, AC54);		/* 54 */	II (c, d, a, b, x[10], S43, AC55);		/* 55 */	II (b, c, d, a, x[ 1], S44, AC56);		/* 56 */	II (a, b, c, d, x[ 8], S41, AC57);		/* 57 */	d += I (a, b, c) + AC58;	ROTATE_LEFT (d, S42); d += a;			/* 58 */	II (c, d, a, b, x[ 6], S43, AC59);		/* 59 */	II (b, c, d, a, x[13], S44, AC60);		/* 60 */	II (a, b, c, d, x[ 4], S41, AC61);		/* 61 */	II (d, a, b, c, x[11], S42, AC62);		/* 62 */	II (c, d, a, b, x[ 2], S43, AC63);		/* 63 */	II (b, c, d, a, x[ 9], S44, AC64);		/* 64 */	out[0] = Ca + a;	out[1] = Cb + b;	out[2] = Cc + c;	out[3] = Cd + d;}#elseextern void MD5_body(MD5_word x[15], MD5_word out[4]);#endif#if ARCH_LITTLE_ENDIAN#define MD5_swap(x, y, count)#elsestatic void MD5_swap(MD5_word *x, MD5_word *y, int count){	MD5_word tmp;	do {		tmp = *x++;		ROTATE_LEFT(tmp, 16);		*y++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);	} while (--count);}#endifstatic unsigned char PADDING[56] = {	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};static struct {	char s[8];	struct {		int p, s, ps, pp, psp;	} l;	struct {		MD5_block p, sp, pp, spp;	} e;	struct {		MD5_block p, ps, pp, psp;	} o;} patterns;struct pattern {	int length;	MD5_block *even, *odd;};static struct pattern order[21] = {	{0, &patterns.e.p, &patterns.o.psp},	{0, &patterns.e.spp, &patterns.o.pp},	{0, &patterns.e.spp, &patterns.o.psp},	{0, &patterns.e.pp, &patterns.o.ps},	{0, &patterns.e.spp, &patterns.o.pp},	{0, &patterns.e.spp, &patterns.o.psp},	{0, &patterns.e.pp, &patterns.o.psp},	{0, &patterns.e.sp, &patterns.o.pp},	{0, &patterns.e.spp, &patterns.o.psp},	{0, &patterns.e.pp, &patterns.o.psp},	{0, &patterns.e.spp, &patterns.o.p},	{0, &patterns.e.spp, &patterns.o.psp},	{0, &patterns.e.pp, &patterns.o.psp},	{0, &patterns.e.spp, &patterns.o.pp},	{0, &patterns.e.sp, &patterns.o.psp},	{0, &patterns.e.pp, &patterns.o.psp},	{0, &patterns.e.spp, &patterns.o.pp},	{0, &patterns.e.spp, &patterns.o.ps},	{0, &patterns.e.pp, &patterns.o.psp},	{0, &patterns.e.spp, &patterns.o.pp},	{0, &patterns.e.spp, &patterns.o.psp},};void MD5_std_set_salt(char *salt){	int length;	for (length = 0; salt[length] && length < 8; length++);	memcpy(patterns.s, salt, patterns.l.s = length);}void MD5_std_set_key(char *key){	int length;	for (length = 0; key[length] && length < 15; length++);	memcpy(patterns.o.p.b, key, patterns.l.p = length);	memcpy(&patterns.o.p.b[length + 16], PADDING, 40 - length);	patterns.o.p.w[14] = (length + 16) << 3;	memcpy(patterns.o.pp.b, key, length);	memcpy(&patterns.o.pp.b[length], key, length);	patterns.l.pp = length << 1;	memcpy(&patterns.o.pp.b[patterns.l.pp + 16], PADDING,		40 - patterns.l.pp);	patterns.o.pp.w[14] = (patterns.l.pp + 16) << 3;	memcpy(&patterns.e.p.b[16], key, length);	memcpy(&patterns.e.p.b[16 + length], PADDING, 40 - length);	patterns.e.p.w[14] = (length + 16) << 3;	MD5_swap(patterns.e.p.w, patterns.e.p.w, 14);	memcpy(&patterns.e.pp.b[16], patterns.o.pp.b, patterns.l.pp);	memcpy(&patterns.e.pp.b[16 + patterns.l.pp], PADDING,		40 - patterns.l.pp);	patterns.e.pp.w[14] = (patterns.l.pp + 16) << 3;	MD5_swap(patterns.e.pp.w, patterns.e.pp.w, 14);	order[1].length = patterns.l.pp;	order[4].length = patterns.l.pp;	order[7].length = patterns.l.pp;	order[10].length = length;	order[13].length = patterns.l.pp;	order[16].length = patterns.l.pp;	order[19].length = patterns.l.pp;}void MD5_std_crypt(){	MD5_block block;	int length, index;	struct pattern *line;#if ARCH_LITTLE_ENDIAN	MD5_word *last;#endif	memcpy(patterns.o.ps.b, patterns.o.p.b, patterns.l.p);	memcpy(&patterns.o.ps.b[patterns.l.p], patterns.s, patterns.l.s);	patterns.l.ps = patterns.l.p + patterns.l.s;	memcpy(&patterns.o.ps.b[patterns.l.ps + 16], PADDING,		40 - patterns.l.ps);	patterns.o.ps.w[14] = (patterns.l.ps + 16) << 3;	memcpy(patterns.o.psp.b, patterns.o.ps.b, patterns.l.ps);	memcpy(&patterns.o.psp.b[patterns.l.ps], patterns.o.p.b, patterns.l.p);	patterns.l.psp = patterns.l.ps + patterns.l.p;	memcpy(&patterns.o.psp.b[patterns.l.psp + 16], PADDING,		40 - patterns.l.psp);	patterns.o.psp.w[14] = (patterns.l.psp + 16) << 3;	memcpy(&patterns.e.sp.b[16], patterns.s, patterns.l.s);	memcpy(&patterns.e.sp.b[16 + patterns.l.s], patterns.o.p.b,		patterns.l.p);	memcpy(&patterns.e.sp.b[16 + patterns.l.ps], PADDING,		40 - patterns.l.ps);	patterns.e.sp.w[14] = (patterns.l.ps + 16) << 3;	MD5_swap(patterns.e.sp.w, patterns.e.sp.w, 14);	memcpy(&patterns.e.spp.b[16], patterns.s, patterns.l.s);	memcpy(&patterns.e.spp.b[16 + patterns.l.s], patterns.o.pp.b,		patterns.l.pp);	memcpy(&patterns.e.spp.b[16 + patterns.l.psp], PADDING,		40 - patterns.l.psp);	patterns.e.spp.w[14] = (patterns.l.psp + 16) << 3;	MD5_swap(patterns.e.spp.w, patterns.e.spp.w, 14);	order[0].length = patterns.l.psp;	order[2].length = patterns.l.psp;	order[3].length = patterns.l.ps;	order[5].length = patterns.l.psp;	order[6].length = patterns.l.psp;	order[8].length = patterns.l.psp;	order[9].length = patterns.l.psp;	order[11].length = patterns.l.psp;	order[12].length = patterns.l.psp;	order[14].length = patterns.l.psp;	order[15].length = patterns.l.psp;	order[17].length = patterns.l.ps;	order[18].length = patterns.l.psp;	order[20].length = patterns.l.psp;	memcpy(&block, patterns.o.psp.b, patterns.l.psp);	memcpy(&block.b[patterns.l.psp], PADDING, 56 - patterns.l.psp);	block.w[14] = patterns.l.psp << 3;	MD5_swap(block.w, block.w, 14);	MD5_body(block.w, MD5_out);	MD5_swap(MD5_out, MD5_out, 4);	memcpy(&block, patterns.o.p.b, patterns.l.p);	memcpy(&block.b[patterns.l.p], "$1$", 3);	memcpy(&block.b[patterns.l.p + 3], patterns.s, patterns.l.s);	memcpy(&block.b[patterns.l.ps + 3], MD5_out, patterns.l.p);	length = patterns.l.psp + 3;	if ((index = patterns.l.p))	do {		block.b[length++] = (index & 1) ? 0 : patterns.o.p.b[0];	} while (index >>= 1);	memcpy(&block.b[length], PADDING, 56 - length);	block.w[14] = length << 3;	MD5_swap(block.w, block.w, 14);	MD5_body(block.w, order[0].even->w);	index = 500; line = order;	do {#if ARCH_LITTLE_ENDIAN#if ARCH_ALLOWS_UNALIGNED		MD5_body(line->even->w,			(MD5_word *)&line->odd->b[line->length]);#else		MD5_body(line->even->w, MD5_out);		memcpy(&line->odd->b[line->length], MD5_out, 16);#endif		last = line->odd->w;		if (++line >= order + 21) line = order;		MD5_body(last, line->even->w);#else		MD5_body(line->even->w, MD5_out);		MD5_swap(MD5_out, MD5_out, 4);		memcpy(&line->odd->b[line->length], MD5_out, 16);		MD5_swap(line->odd->w, block.w, 14);		block.w[14] = line->odd->w[14];		if (++line >= order + 21) line = order;		MD5_body(block.w, line->even->w);#endif	} while (--index);	memcpy(MD5_out, line->even, 16);}char *MD5_std_get_salt(char *ciphertext){	static char out[9];	int length;	for (length = 0; length < 8; length++)	if ((out[length] = ciphertext[3 + length]) == '$') break;	out[length] = 0;	return out;}#define TO_BINARY(b1, b2, b3) \	value = \		(MD5_word)atoi64[(ARCH_INDEX)pos[0]] | \		((MD5_word)atoi64[(ARCH_INDEX)pos[1]] << 6) | \		((MD5_word)atoi64[(ARCH_INDEX)pos[2]] << 12) | \		((MD5_word)atoi64[(ARCH_INDEX)pos[3]] << 18); \	pos += 4; \	out.b[b1] = value >> 16; \	out.b[b2] = value >> 8; \	out.b[b3] = value;MD5_word *MD5_std_get_binary(char *ciphertext){	static union {		MD5_binary w;		char b[16];	} out;	char *pos;	MD5_word value;	pos = ciphertext + 3; while (*pos++ != '$');	TO_BINARY(0, 6, 12);	TO_BINARY(1, 7, 13);	TO_BINARY(2, 8, 14);	TO_BINARY(3, 9, 15);	TO_BINARY(4, 10, 5);	out.b[11] =		(MD5_word)atoi64[(ARCH_INDEX)pos[0]] |		((MD5_word)atoi64[(ARCH_INDEX)pos[1]] << 6);	MD5_swap(out.w, out.w, 4);	return out.w;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -