]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/loclass/hash1_brute.c
Merge branch 'master' of https://github.com/Proxmark/proxmark3
[proxmark3-svn] / client / loclass / hash1_brute.c
1 #include <stdio.h>
2 #include "cipherutils.h"
3 #include <stdint.h>
4 #include <stdbool.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <ctype.h>
8 #include "elite_crack.h"
9
10 void calc_score(uint8_t* csn, uint8_t* k)
11 {
12 uint8_t score =0 ;
13 uint8_t i;
14 uint8_t goodvals[16] = {0};
15 uint8_t uniq_vals[8] = {0};
16 memset(goodvals, 0x00, 16);
17 memset(uniq_vals, 0x00, 8);
18 uint8_t badval = 0;
19 int badscore =0;
20 for(i=0; i < 8 ; i++)
21 {
22 if(k[i] == 0x01) continue;
23 if(k[i] == 0x00) continue;
24 if(k[i] == 0x45) continue;
25 if(k[i] < 16){
26 goodvals[k[i]] = 1;
27 }
28 // if(k[i] ==9 || k[i]==2){
29 // goodvals[k[i]] = 1;
30 // }
31
32 else if(k[i]>=16){
33 badscore++;
34 badval = k[i];
35 }
36 }
37 for(i =0; i < 16; i++)
38 {
39 if(goodvals[i])
40 {
41 uniq_vals[score] = i;
42 score +=1;
43 }
44 }
45 if(score >=2 && badscore < 2)
46 {
47 printf("CSN\t%02x%02x%02x%02x%02x%02x%02x%02x\t%02x %02x %02x %02x %02x %02x %02x %02x\t"
48 ,csn[0],csn[1],csn[2],csn[3],csn[4],csn[5],csn[6],csn[7]
49 ,k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7]
50 );
51 for(i =0 ; i < score; i++)
52 {
53 printf("%d,", uniq_vals[i]);
54 }
55 printf("\tbadscore: %d (%02x)", badscore, badval);
56 printf("\r\n");
57
58 }
59
60 }
61
62 void brute_hash1(){
63 uint8_t csn[8] = {0,0,0,0,0xf7,0xff,0x12,0xe0};
64 uint8_t k[8]= {0,0,0,0,0,0,0,0};
65 uint16_t a,b,c,d;
66 uint8_t testcsn[8] ={0x00,0x0d,0x0f,0xfd,0xf7,0xff,0x12,0xe0} ;
67 uint8_t testkey[8] ={0x05 ,0x01 ,0x00 ,0x10 ,0x45 ,0x08 ,0x45,0x56} ;
68 calc_score(testcsn,testkey);
69 printf("Brute forcing hashones\n");
70 //exit(1);
71 for(a=0;a < 256;a++)
72 {
73 //if(a > 0)printf("%d/256 done...\n", a);
74 for(b=0;b < 256 ; b++)
75 for(c=0;c < 256;c++)
76 for(d=0;d < 256;d++)
77 {
78 csn[0] = a;
79 csn[1] = b;
80 csn[2] = c;
81 csn[3] = d;
82 csn[4] = 0xf7;
83 csn[5] = 0xff;
84 csn[6] = 0x12;
85 csn[7] = 0xe0;
86 hash1(csn, k);
87 calc_score(csn,k);
88 }
89 }
90
91 }
92
Impressum, Datenschutz