All pastes #1795540 Raw Edit

Someone

public c v1 · immutable
#1795540 ·published 2010-02-13 19:26 UTC
rendered paste body
#include <stdlib.h>#include <stdio.h>#include <inttypes.h>#include <signal.h>#include <gcrypt.h>// compile with:// gcc -O3 -lgcrypt findguid.c -o findguid// run as:// ./findguid [<starting-counter-value>]uint32_t interesting[] = {/*0x13371337,0xcafebabe,0x12345678,0x1337babe,0xdeadbeef,0x1337cafe,0xcafe1337,*///0xb00bb00b,0xb00b1355,//0x01011010,//0x00011000,//0x10100101,//0xC0CAC01A,//0x00100100,/*0x2FA66075,0x3FA66075,0x4FA66075,0x5FA66075,0x6FA66075,0x7FA66075,0x8FA66075,0x9FA66075,*///0xBA775EC5,//0x600D600D,0xB00BCAFE,0xB16B00B5,0xB00BFACE,0x00000000};typedef int counter_type_t;counter_type_t counter;uint32_t byteswap4321(uint32_t x) {	return (x<<24) | ((x<<8) & 0x00ff0000) |		((x>>8) & 0x0000ff00) | (x>>24);}voidleave(int sig) {	printf("\nInterrupted; counter=%u.\n", counter);	exit(sig);}int main(int argc, char **argv) {		(void) signal(SIGINT,leave);		gcry_md_hd_t initial;		gcry_md_open(&initial, GCRY_MD_MD5, 0);		char *v = malloc(2048-sizeof(counter_type_t));		memset(v, 0x00, 2048-sizeof(counter_type_t));		// increment here if you scanned everything and didn't find shit	v[0] = 5;			gcry_md_write(initial, v, 2048-sizeof(counter_type_t));				counter = 0;		if (argv[1]) // you can resume by doing ./execname <counter-value>		counter = atoi(argv[1]);			while (counter != -1) {				gcry_md_hd_t copy;		gcry_md_copy(&copy, initial);				gcry_md_write(copy, &counter, sizeof(counter_type_t));						unsigned char *digest = gcry_md_read(copy, 0);				uint32_t last32 = *((uint32_t *)(digest+(16-4)));				last32 = byteswap4321(last32);				uint32_t *p = interesting;				p--;		do {			p++;			if (last32 == *p) {								printf("Found %08x at counter=%u.\n", last32, counter);								char *filename = NULL;								asprintf(&filename, "qkey-%08x-%u", last32, counter);								FILE *f = fopen(filename, "w");								free(filename);								fwrite(v, 2048-sizeof(counter_type_t), 1, f);								fwrite(&counter, sizeof(counter_type_t), 1, f);								fclose(f);							}								} while (*p);						//printf("%08x\n", last32);				gcry_md_close(copy);				counter++;	}		free(v);		gcry_md_close(initial);			return 0;	}