mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-23 06:35:38 -07:00
no printf
This commit is contained in:
parent
110a173e6d
commit
cccee38597
2 changed files with 46 additions and 56 deletions
|
@ -41,34 +41,33 @@ static void calc_score(uint8_t *csn, uint8_t *k) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (score >= 2 && badscore < 2) {
|
if (score >= 2 && badscore < 2) {
|
||||||
printf("CSN\t%02x%02x%02x%02x%02x%02x%02x%02x\t%02x %02x %02x %02x %02x %02x %02x %02x\t"
|
PrintAndLogEx(NORMAL, "CSN\t%02x%02x%02x%02x%02x%02x%02x%02x\t%02x %02x %02x %02x %02x %02x %02x %02x\t" NOLF
|
||||||
, csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]
|
, csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]
|
||||||
, k[0], k[1], k[2], k[3], k[4], k[5], k[6], k[7]
|
, k[0], k[1], k[2], k[3], k[4], k[5], k[6], k[7]
|
||||||
);
|
);
|
||||||
|
|
||||||
for (i = 0 ; i < score; i++) {
|
for (i = 0 ; i < score; i++) {
|
||||||
printf("%d,", uniq_vals[i]);
|
PrintAndLogEx(NORMAL, "%d," NOLF, uniq_vals[i]);
|
||||||
}
|
}
|
||||||
printf("\tbadscore: %d (%02x)", badscore, badval);
|
PrintAndLogEx(NORMAL, "\tbadscore: %d (%02x)" NOLF, badscore, badval);
|
||||||
printf("\r\n");
|
PrintAndLogEx(NORMAL, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void brute_hash1(void) {
|
void brute_hash1(void) {
|
||||||
uint16_t a, b, c, d;
|
|
||||||
uint8_t csn[8] = {0, 0, 0, 0, 0xf7, 0xff, 0x12, 0xe0};
|
uint8_t csn[8] = {0, 0, 0, 0, 0xf7, 0xff, 0x12, 0xe0};
|
||||||
uint8_t k[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
uint8_t k[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
uint8_t testcsn[8] = {0x00, 0x0d, 0x0f, 0xfd, 0xf7, 0xff, 0x12, 0xe0} ;
|
uint8_t testcsn[8] = {0x00, 0x0d, 0x0f, 0xfd, 0xf7, 0xff, 0x12, 0xe0} ;
|
||||||
uint8_t testkey[8] = {0x05, 0x01, 0x00, 0x10, 0x45, 0x08, 0x45, 0x56} ;
|
uint8_t testkey[8] = {0x05, 0x01, 0x00, 0x10, 0x45, 0x08, 0x45, 0x56} ;
|
||||||
calc_score(testcsn, testkey);
|
calc_score(testcsn, testkey);
|
||||||
printf("Brute forcing hashones\n");
|
|
||||||
//exit(1);
|
|
||||||
|
|
||||||
for (a = 0; a < 256; a++) {
|
PrintAndLogEx(INFO, "Brute forcing hashones");
|
||||||
//if(a > 0)printf("%d/256 done...\n", a);
|
|
||||||
for (b = 0; b < 256; b++)
|
for (uint16_t a = 0; a < 256; a++) {
|
||||||
for (c = 0; c < 256; c++)
|
for (uint16_t b = 0; b < 256; b++) {
|
||||||
for (d = 0; d < 256; d++) {
|
for (uint16_t c = 0; c < 256; c++) {
|
||||||
|
for (uint16_t d = 0; d < 256; d++) {
|
||||||
csn[0] = a;
|
csn[0] = a;
|
||||||
csn[1] = b;
|
csn[1] = b;
|
||||||
csn[2] = c;
|
csn[2] = c;
|
||||||
|
@ -82,4 +81,6 @@ void brute_hash1(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
|
||||||
uint8_t p_i = p >> i & 0x1;
|
uint8_t p_i = p >> i & 0x1;
|
||||||
|
|
||||||
if (k[i]) { // yi = 1
|
if (k[i]) { // yi = 1
|
||||||
//printf("k[%d] +1\n", i);
|
// PrintAndLogEx(NORMAL, "k[%d] + 1", i);
|
||||||
k[i] |= ~zTilde_i & 0x7E;
|
k[i] |= ~zTilde_i & 0x7E;
|
||||||
k[i] |= p_i & 1;
|
k[i] |= p_i & 1;
|
||||||
k[i] += 1;
|
k[i] += 1;
|
||||||
|
@ -399,7 +399,7 @@ static void testPermute(void) {
|
||||||
permute(&p_in, x, 0, 4, &out);
|
permute(&p_in, x, 0, 4, &out);
|
||||||
|
|
||||||
uint64_t permuted = x_bytes_to_num(outbuffer, 8);
|
uint64_t permuted = x_bytes_to_num(outbuffer, 8);
|
||||||
//printf("zTilde 0x%"PRIX64"\n", zTilde);
|
// PrintAndLogEx(NORMAL, "zTilde 0x%"PRIX64, zTilde);
|
||||||
permuted >>= 16;
|
permuted >>= 16;
|
||||||
|
|
||||||
uint8_t res[8] = { getSixBitByte(permuted, 0),
|
uint8_t res[8] = { getSixBitByte(permuted, 0),
|
||||||
|
@ -694,28 +694,21 @@ int doKeyTests(void) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
void checkParity2(uint8_t* key)
|
void checkParity2(uint8_t* key) {
|
||||||
{
|
|
||||||
|
|
||||||
uint8_t stored_parity = key[7];
|
uint8_t stored_parity = key[7];
|
||||||
printf("Parity byte: 0x%02x\n", stored_parity);
|
PrintAndLogEx(NORMAL, "Parity byte: 0x%02x", stored_parity);
|
||||||
int i;
|
int i, byte, fails = 0;
|
||||||
int byte;
|
|
||||||
int fails =0;
|
|
||||||
BitstreamIn bits = {key, 56, 0};
|
BitstreamIn bits = {key, 56, 0};
|
||||||
|
|
||||||
bool parity = 0;
|
bool parity = 0;
|
||||||
|
|
||||||
for(i =0 ; i < 56; i++)
|
for (i = 0; i < 56; i++) {
|
||||||
{
|
|
||||||
|
|
||||||
if ( i > 0 && i % 7 == 0)
|
if ( i > 0 && i % 7 == 0){
|
||||||
{
|
|
||||||
parity = !parity;
|
parity = !parity;
|
||||||
bool pbit = stored_parity & (0x80 >> (byte));
|
bool pbit = stored_parity & (0x80 >> (byte));
|
||||||
if(parity != pbit)
|
if (parity != pbit) {
|
||||||
{
|
PrintAndLogEx(NORMAL, "parity2 fail byte %d, should be %d, was %d", (i / 7), parity, pbit);
|
||||||
printf("parity2 fail byte %d, should be %d, was %d\n", (i / 7), parity, pbit);
|
|
||||||
fails++;
|
fails++;
|
||||||
}
|
}
|
||||||
parity =0 ;
|
parity =0 ;
|
||||||
|
@ -723,24 +716,21 @@ void checkParity2(uint8_t* key)
|
||||||
}
|
}
|
||||||
parity = parity ^ headBit(&bits);
|
parity = parity ^ headBit(&bits);
|
||||||
}
|
}
|
||||||
if(fails)
|
if (fails) {
|
||||||
{
|
PrintAndLogEx(FAILED, "parity2 fails: %d", fails);
|
||||||
printf("parity2 fails: %d\n", fails);
|
} else {
|
||||||
}else
|
PrintAndLogEx(INFO, "Key syntax is with parity bits grouped in the last byte!");
|
||||||
{
|
|
||||||
printf("Key syntax is with parity bits grouped in the last byte!\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void modifyKey_put_parity_last(uint8_t * key, uint8_t* output)
|
|
||||||
{
|
void modifyKey_put_parity_last(uint8_t * key, uint8_t* output) {
|
||||||
|
|
||||||
uint8_t paritybits = 0;
|
uint8_t paritybits = 0;
|
||||||
bool parity =0;
|
bool parity =0;
|
||||||
BitstreamOut out = { output, 0, 0};
|
BitstreamOut out = { output, 0, 0};
|
||||||
unsigned int bbyte, bbit;
|
unsigned int bbyte, bbit;
|
||||||
for(bbyte=0; bbyte <8 ; bbyte++ )
|
for (bbyte = 0; bbyte <8; bbyte++ ) {
|
||||||
{
|
for(bbit = 0; bbit < 7; bbit++) {
|
||||||
for(bbit =0 ; bbit< 7 ; bbit++)
|
|
||||||
{
|
|
||||||
bool bit = *(key + bbyte) & (1 << (7 - bbit));
|
bool bit = *(key + bbyte) & (1 << (7 - bbit));
|
||||||
pushBit(&out, bit);
|
pushBit(&out, bit);
|
||||||
parity ^= bit;
|
parity ^= bit;
|
||||||
|
@ -751,7 +741,7 @@ void modifyKey_put_parity_last(uint8_t * key, uint8_t* output)
|
||||||
|
|
||||||
}
|
}
|
||||||
output[7] = paritybits;
|
output[7] = paritybits;
|
||||||
printf("Parity byte: %02x\n", paritybits);
|
PrintAndLogEx(INFO, "Parity byte: %02x", paritybits);
|
||||||
}
|
}
|
||||||
|
|
||||||
* @brief Modifies a key with parity bits last, so that it is formed with parity
|
* @brief Modifies a key with parity bits last, so that it is formed with parity
|
||||||
|
@ -759,8 +749,7 @@ void modifyKey_put_parity_last(uint8_t * key, uint8_t* output)
|
||||||
* @param key
|
* @param key
|
||||||
* @param output
|
* @param output
|
||||||
|
|
||||||
void modifyKey_put_parity_allover(uint8_t * key, uint8_t* output)
|
void modifyKey_put_parity_allover(uint8_t * key, uint8_t* output) {
|
||||||
{
|
|
||||||
bool parity =0;
|
bool parity =0;
|
||||||
BitstreamOut out = {output, 0, 0};
|
BitstreamOut out = {output, 0, 0};
|
||||||
BitstreamIn in = {key, 0, 0};
|
BitstreamIn in = {key, 0, 0};
|
||||||
|
@ -777,7 +766,7 @@ void modifyKey_put_parity_allover(uint8_t * key, uint8_t* output)
|
||||||
pushBit(&out, !parity);
|
pushBit(&out, !parity);
|
||||||
|
|
||||||
if (des_key_check_key_parity(output))
|
if (des_key_check_key_parity(output))
|
||||||
printf("modifyKey_put_parity_allover fail, DES key invalid parity!");
|
PrintAndLogEx(FAILED, "modifyKey_put_parity_allover fail, DES key invalid parity!");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue