Por favor, identifícate o regístrate.
Moderadores: jamonazo2000, comepiedras
#include <stdio.h>
#include <stdlib.h>
#include <openssl/md5.h>
#define KEY_SIZE 16
/* MD5 hashes */
#define COMMON_KEY "\x8d\x1a\x2e\xbc\xd8\x2a\x34\x69\xb7\x7f\xac\xf1\x5d\x9c\x8e\x50"
#define MD5_BLANKER "\x45\x82\x41\x7d\x62\x3c\x81\xfc\xa0\x7a\x46\xa5\x70\xc8\x96\x9e"
#define SD_IV "\xd9\xf2\xb2\xe0\x45\xd2\x2d\x38\x05\xa6\x7f\xe0\xc3\x40\xcc\xd2"
#define SD_KEY "\xef\x33\xe2\x24\xe4\x5c\x8d\x8c\x35\xce\x32\xd8\xa8\x10\xb6\x03"
void print_hex(unsigned char *c, unsigned int n)
{
int i;
for (i = 0; i < n; i++)
printf("%.2x", c[i]);
}
int hexcmp(unsigned char *c1, char *c2, int n)
{
int i;
for (i = 0; i < n; i++)
if ((char)c1[i] != c2[i])
return 1;
return 0;
}
char *find_key(unsigned char *c)
{
unsigned char hash[KEY_SIZE];
/* Get MD5 hash of the first 16 bytes */
MD5(c, sizeof(hash), hash);
/* Compare hashes */
if (!hexcmp(hash, COMMON_KEY, sizeof(hash)))
return "common-key";
else if (!hexcmp(hash, MD5_BLANKER, sizeof(hash)))
return "md5-blanker";
else if (!hexcmp(hash, SD_IV, sizeof(hash)))
return "sd-iv";
else if (!hexcmp(hash, SD_KEY, sizeof(hash)))
return "sd-key";
return NULL;
}
int main(int argc, char **argv)
{
FILE *fp;
unsigned char buf[KEY_SIZE];
char *ret;
off_t offset;
/* Enough arguments? */
if (argc < 2) {
printf("Usage: %s <file>\n", argv[0]);
return 0;
}
/* Open file as read-only */
fp = fopen(argv[1], "rb");
if (!fp) {
printf("ERROR: Couldn't open \"%s\"\n", argv[1]);
return 1;
}
/* Find keys */
for (offset = 0; fread(&buf, sizeof(buf), 1, fp) == 1; offset++) {
ret = find_key(buf);
if (ret)
printf("\"%s\" key found at offset 0x%.8lx!!\n", ret, offset);
fseeko(fp, offset+1, SEEK_SET);
}
/* Close file */
fclose(fp);
return 0;
}

Usuarios navegando por este foro: No hay usuarios registrados visitando el foro y 0 invitados