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

📄 lm_fmt.c

📁 解Unix密码的程序john1.
💻 C
字号:
/* * This file is part of John the Ripper password cracker, * Copyright (c) 1996-2000 by Solar Designer */#include <string.h>#include "arch.h"#include "memory.h"#include "DES_bs.h"#include "common.h"#include "formats.h"#define FORMAT_LABEL			"lm"#define FORMAT_NAME			"NT LM DES"#define BENCHMARK_COMMENT		""#define BENCHMARK_LENGTH		-1#define PLAINTEXT_LENGTH		7#define CIPHERTEXT_LENGTH		32#define LM_EMPTY			"AAD3B435B51404EE"static struct fmt_tests tests[] = {	{"$LM$1C3A2B6D939A1021", "AAA"},	{"$LM$CBC501A4D2227783", "AAAAAAA"},	{"$LM$CE045FF77F9D89E2", "ZZZZ"},	{LM_EMPTY LM_EMPTY, ""},	{"$LM$7584248B8D2C9F9E", "A"},	{NULL}};#define ALGORITHM_NAME			DES_BS_ALGORITHM_NAME#define BINARY_SIZE			ARCH_SIZE#define SALT_SIZE			0#define MIN_KEYS_PER_CRYPT		DES_BS_DEPTH#define MAX_KEYS_PER_CRYPT		DES_BS_DEPTHstatic struct {	char keys[MAX_KEYS_PER_CRYPT][PLAINTEXT_LENGTH + 1];	char upcase[0x100];} *buffer;static void init(void){	int c;	DES_bs_init(1);	if (sizeof(*buffer) <= sizeof(DES_bs_all.E))		buffer = (void *)DES_bs_all.E;	else		buffer = mem_alloc_tiny(sizeof(*buffer), MEM_ALIGN_CACHE);	for (c = 0; c < 0x100; c++)	if (c >= 'a' && c <= 'z')		buffer->upcase[c] = c & ~0x20;	else		buffer->upcase[c] = c;}static int valid(char *ciphertext){	char *pos;	for (pos = ciphertext; atoi16[ARCH_INDEX(*pos)] != 0x7F; pos++);	if (!*pos && pos - ciphertext == CIPHERTEXT_LENGTH) {		if (strcmp(&ciphertext[16], LM_EMPTY))			return 2;		else			return 1;	}	if (strncmp(ciphertext, "$LM$", 4)) return 0;	for (pos = &ciphertext[4]; atoi16[ARCH_INDEX(*pos)] != 0x7F; pos++);	if (*pos || pos - ciphertext != 20) return 0;	return 1;}static char *split(char *ciphertext, int index){	static char out[21];	if (!strncmp(ciphertext, "$LM$", 4)) return ciphertext;	out[0] = '$';	out[1] = 'L';	out[2] = 'M';	out[3] = '$';	if (index)		memcpy(&out[4], &ciphertext[16], 16);	else		memcpy(&out[4], ciphertext, 16);	out[20] = 0;	return out;}static void *get_binary(char *ciphertext){	return DES_bs_get_binary_LM(ciphertext + 4);}static int binary_hash_0(void *binary){	return *(int *)binary & 0xF;}static int binary_hash_1(void *binary){	return *(int *)binary & 0xFF;}static int binary_hash_2(void *binary){	return *(int *)binary & 0xFFF;}static int get_hash_0(int index){	return DES_bs_get_hash(index, 4);}static int get_hash_1(int index){	return DES_bs_get_hash(index, 8);}static int get_hash_2(int index){	return DES_bs_get_hash(index, 12);}static void set_salt(void *salt){}static void crypt_all(int count){	int index;	DES_bs_clear_keys();	for (index = 0; index < count; index++)		DES_bs_set_key_LM(buffer->keys[index], index);	DES_bs_crypt_LM();}static int cmp_all(void *binary, int count){	return DES_bs_cmp_all((ARCH_WORD *)binary);}static int cmp_one(void *binary, int index){	return DES_bs_cmp_one((ARCH_WORD *)binary, 32, index);}static int cmp_exact(char *source, int index){	return DES_bs_cmp_one(get_binary(source), 64, index);}static void set_key(char *key, int index){	char *dst = buffer->keys[index];	char *src = key;	int count = PLAINTEXT_LENGTH;	do {		if (!(*dst++ = buffer->upcase[ARCH_INDEX(*src++)])) return;	} while (--count);	*dst = 0;}static char *get_key(int index){	return buffer->keys[index];}struct fmt_main fmt_LM = {	{		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_8_BIT | FMT_BS,		tests	}, {		init,		valid,		split,		get_binary,		fmt_default_salt,		{			binary_hash_0,			binary_hash_1,			binary_hash_2		},		fmt_default_salt_hash,		set_salt,		set_key,		get_key,		crypt_all,		{			get_hash_0,			get_hash_1,			get_hash_2		},		cmp_all,		cmp_one,		cmp_exact	}};

⌨️ 快捷键说明

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