-
Notifications
You must be signed in to change notification settings - Fork 0
/
crackkey.c
84 lines (74 loc) · 2.93 KB
/
crackkey.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* this is a block of example code I used to test the system early on no longer in use */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include "hmac_sha2.h"
#include <ctype.h>
#define FNV_PRIME_32 16777619
#define MASK_24 (((uint32_t)1<<24)-1) /* i.e., (u_int32_t)0xffffff */
uint32_t fnv_hasher(uint8_t *str)
{
uint32_t hval = 0;
/*
* FNV-1 hash each octet in the buffer
*/
int i = 0;
for (i = 0; i < 32; i++) {
/* multiply by the 32 bit FNV magic prime mod 2^32 */
hval *= FNV_PRIME_32;
/* xor the bottom with the current octet */
hval ^= (uint32_t)str[i];
}
/* return our new hash value */
return hval;
}
int main(int argc, char **argv)
{
uint8_t digest[SHA256_DIGEST_SIZE];
uint8_t ihatebuffers[4] = {0};
uint32_t fnv_hash,fnv_hash2;
uint32_t crack = 0xdd955f;
uint32_t time = 1296579900;
memset(digest, 0, sizeof(digest));
int i,j,k,l;
uint8_t hmacKey[]={
0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,
0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,
0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a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] = (uint8_t)(time >> 8);
ihatebuffers[1] = (uint8_t)(time >> 16);
ihatebuffers[0] = (uint8_t)(time >> 24);
for(l = 0; l <256; l++) {
for(k = 0; k < 256; k++) {
for(j = 0; j < 256; j++) {
for(i = 0; i < 256; i++) {
hmacKey[252] = l;
hmacKey[253] = k;
hmacKey[254] = j;
hmacKey[255] = i;
hmac_sha256(hmacKey, 256, ihatebuffers,4, digest, SHA256_DIGEST_SIZE);
fnv_hash = fnv_hasher(digest);
fnv_hash2 = (fnv_hash>>24) ^ (fnv_hash & MASK_24);
if(fnv_hash2 == crack)
printf("24 byte hash:%02X\n", fnv_hash2);
}
}
}
}
return EXIT_SUCCESS;
}