mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
partial make style
This commit is contained in:
parent
13aa4ee6ab
commit
d88b76beda
2 changed files with 119 additions and 119 deletions
|
@ -80,22 +80,22 @@
|
||||||
#include "optimized_cipher.h"
|
#include "optimized_cipher.h"
|
||||||
|
|
||||||
static const uint8_t opt_select_LUT[256] = {
|
static const uint8_t opt_select_LUT[256] = {
|
||||||
00, 03, 02, 01, 02, 03, 00, 01, 04, 07, 07, 04, 06, 07, 05, 04,
|
00, 03, 02, 01, 02, 03, 00, 01, 04, 07, 07, 04, 06, 07, 05, 04,
|
||||||
01, 02, 03, 00, 02, 03, 00, 01, 05, 06, 06, 05, 06, 07, 05, 04,
|
01, 02, 03, 00, 02, 03, 00, 01, 05, 06, 06, 05, 06, 07, 05, 04,
|
||||||
06, 05, 04, 07, 04, 05, 06, 07, 06, 05, 05, 06, 04, 05, 07, 06,
|
06, 05, 04, 07, 04, 05, 06, 07, 06, 05, 05, 06, 04, 05, 07, 06,
|
||||||
07, 04, 05, 06, 04, 05, 06, 07, 07, 04, 04, 07, 04, 05, 07, 06,
|
07, 04, 05, 06, 04, 05, 06, 07, 07, 04, 04, 07, 04, 05, 07, 06,
|
||||||
06, 05, 04, 07, 04, 05, 06, 07, 02, 01, 01, 02, 00, 01, 03, 02,
|
06, 05, 04, 07, 04, 05, 06, 07, 02, 01, 01, 02, 00, 01, 03, 02,
|
||||||
03, 00, 01, 02, 00, 01, 02, 03, 07, 04, 04, 07, 04, 05, 07, 06,
|
03, 00, 01, 02, 00, 01, 02, 03, 07, 04, 04, 07, 04, 05, 07, 06,
|
||||||
00, 03, 02, 01, 02, 03, 00, 01, 00, 03, 03, 00, 02, 03, 01, 00,
|
00, 03, 02, 01, 02, 03, 00, 01, 00, 03, 03, 00, 02, 03, 01, 00,
|
||||||
05, 06, 07, 04, 06, 07, 04, 05, 05, 06, 06, 05, 06, 07, 05, 04,
|
05, 06, 07, 04, 06, 07, 04, 05, 05, 06, 06, 05, 06, 07, 05, 04,
|
||||||
02, 01, 00, 03, 00, 01, 02, 03, 06, 05, 05, 06, 04, 05, 07, 06,
|
02, 01, 00, 03, 00, 01, 02, 03, 06, 05, 05, 06, 04, 05, 07, 06,
|
||||||
03, 00, 01, 02, 00, 01, 02, 03, 07, 04, 04, 07, 04, 05, 07, 06,
|
03, 00, 01, 02, 00, 01, 02, 03, 07, 04, 04, 07, 04, 05, 07, 06,
|
||||||
02, 01, 00, 03, 00, 01, 02, 03, 02, 01, 01, 02, 00, 01, 03, 02,
|
02, 01, 00, 03, 00, 01, 02, 03, 02, 01, 01, 02, 00, 01, 03, 02,
|
||||||
03, 00, 01, 02, 00, 01, 02, 03, 03, 00, 00, 03, 00, 01, 03, 02,
|
03, 00, 01, 02, 00, 01, 02, 03, 03, 00, 00, 03, 00, 01, 03, 02,
|
||||||
04, 07, 06, 05, 06, 07, 04, 05, 00, 03, 03, 00, 02, 03, 01, 00,
|
04, 07, 06, 05, 06, 07, 04, 05, 00, 03, 03, 00, 02, 03, 01, 00,
|
||||||
01, 02, 03, 00, 02, 03, 00, 01, 05, 06, 06, 05, 06, 07, 05, 04,
|
01, 02, 03, 00, 02, 03, 00, 01, 05, 06, 06, 05, 06, 07, 05, 04,
|
||||||
04, 07, 06, 05, 06, 07, 04, 05, 04, 07, 07, 04, 06, 07, 05, 04,
|
04, 07, 06, 05, 06, 07, 04, 05, 04, 07, 07, 04, 06, 07, 05, 04,
|
||||||
01, 02, 03, 00, 02, 03, 00, 01, 01, 02, 02, 01, 02, 03, 01, 00
|
01, 02, 03, 00, 02, 03, 00, 01, 01, 02, 02, 01, 02, 03, 01, 00
|
||||||
};
|
};
|
||||||
|
|
||||||
/********************** the table above has been generated with this code: ********
|
/********************** the table above has been generated with this code: ********
|
||||||
|
@ -143,65 +143,65 @@ uint8_t xopt__select(bool x, bool y, uint8_t r)
|
||||||
|
|
||||||
static void opt_successor(const uint8_t *k, State *s, uint8_t y) {
|
static void opt_successor(const uint8_t *k, State *s, uint8_t y) {
|
||||||
// #define opt_T(s) (0x1 & ((s->t >> 15) ^ (s->t >> 14) ^ (s->t >> 10) ^ (s->t >> 8) ^ (s->t >> 5) ^ (s->t >> 4)^ (s->t >> 1) ^ s->t))
|
// #define opt_T(s) (0x1 & ((s->t >> 15) ^ (s->t >> 14) ^ (s->t >> 10) ^ (s->t >> 8) ^ (s->t >> 5) ^ (s->t >> 4)^ (s->t >> 1) ^ s->t))
|
||||||
// uint8_t Tt = opt_T(s);
|
// uint8_t Tt = opt_T(s);
|
||||||
uint16_t Tt = s->t & 0xc533;
|
uint16_t Tt = s->t & 0xc533;
|
||||||
Tt = Tt ^ (Tt >> 1);
|
Tt = Tt ^ (Tt >> 1);
|
||||||
Tt = Tt ^ (Tt >> 4);
|
Tt = Tt ^ (Tt >> 4);
|
||||||
Tt = Tt ^ (Tt >> 10);
|
Tt = Tt ^ (Tt >> 10);
|
||||||
Tt = Tt ^ (Tt >> 8);
|
Tt = Tt ^ (Tt >> 8);
|
||||||
|
|
||||||
s->t = (s->t >> 1);
|
s->t = (s->t >> 1);
|
||||||
s->t |= (Tt ^ (s->r >> 7) ^ (s->r >> 3)) << 15;
|
s->t |= (Tt ^ (s->r >> 7) ^ (s->r >> 3)) << 15;
|
||||||
|
|
||||||
uint8_t opt_B = s->b;
|
uint8_t opt_B = s->b;
|
||||||
opt_B ^= s->b >> 6;
|
opt_B ^= s->b >> 6;
|
||||||
opt_B ^= s->b >> 5;
|
opt_B ^= s->b >> 5;
|
||||||
opt_B ^= s->b >> 4;
|
opt_B ^= s->b >> 4;
|
||||||
|
|
||||||
s->b = s->b >> 1;
|
s->b = s->b >> 1;
|
||||||
s->b |= (opt_B ^ s->r) << 7;
|
s->b |= (opt_B ^ s->r) << 7;
|
||||||
|
|
||||||
uint8_t opt_select = opt_select_LUT[s->r] & 0x04;
|
uint8_t opt_select = opt_select_LUT[s->r] & 0x04;
|
||||||
opt_select |= (opt_select_LUT[s->r] ^ ((Tt ^ y) << 1)) & 0x02;
|
opt_select |= (opt_select_LUT[s->r] ^ ((Tt ^ y) << 1)) & 0x02;
|
||||||
opt_select |= (opt_select_LUT[s->r] ^ Tt) & 0x01;
|
opt_select |= (opt_select_LUT[s->r] ^ Tt) & 0x01;
|
||||||
|
|
||||||
uint8_t r = s->r;
|
uint8_t r = s->r;
|
||||||
s->r = (k[opt_select] ^ s->b) + s->l ;
|
s->r = (k[opt_select] ^ s->b) + s->l ;
|
||||||
s->l = s->r + r;
|
s->l = s->r + r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void opt_suc(const uint8_t *k, State *s, uint8_t *in, uint8_t length, bool add32Zeroes) {
|
static void opt_suc(const uint8_t *k, State *s, uint8_t *in, uint8_t length, bool add32Zeroes) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
uint8_t head;
|
uint8_t head;
|
||||||
head = in[i];
|
head = in[i];
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
|
|
||||||
head >>= 1;
|
head >>= 1;
|
||||||
opt_successor(k, s, head);
|
opt_successor(k, s, head);
|
||||||
}
|
}
|
||||||
//For tag MAC, an additional 32 zeroes
|
//For tag MAC, an additional 32 zeroes
|
||||||
if (add32Zeroes) {
|
if (add32Zeroes) {
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,22 +209,22 @@ static void opt_suc(const uint8_t *k, State *s, uint8_t *in, uint8_t length, boo
|
||||||
static void opt_output(const uint8_t *k, State *s, uint8_t *buffer) {
|
static void opt_output(const uint8_t *k, State *s, uint8_t *buffer) {
|
||||||
for (uint8_t times = 0; times < 4; times++) {
|
for (uint8_t times = 0; times < 4; times++) {
|
||||||
uint8_t bout = 0;
|
uint8_t bout = 0;
|
||||||
bout |= (s->r & 0x4) >> 2;
|
bout |= (s->r & 0x4) >> 2;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4) >> 1;
|
bout |= (s->r & 0x4) >> 1;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4);
|
bout |= (s->r & 0x4);
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4) << 1;
|
bout |= (s->r & 0x4) << 1;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4) << 2;
|
bout |= (s->r & 0x4) << 2;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4) << 3;
|
bout |= (s->r & 0x4) << 3;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4) << 4;
|
bout |= (s->r & 0x4) << 4;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
bout |= (s->r & 0x4) << 5;
|
bout |= (s->r & 0x4) << 5;
|
||||||
opt_successor(k, s, 0);
|
opt_successor(k, s, 0);
|
||||||
buffer[times] = bout;
|
buffer[times] = bout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,8 +243,8 @@ static void opt_MAC(uint8_t *k, uint8_t *input, uint8_t *out) {
|
||||||
|
|
||||||
void opt_doReaderMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4]) {
|
void opt_doReaderMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4]) {
|
||||||
uint8_t dest [] = {0, 0, 0, 0, 0, 0, 0, 0};
|
uint8_t dest [] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
opt_MAC(div_key_p, cc_nr_p, dest);
|
opt_MAC(div_key_p, cc_nr_p, dest);
|
||||||
memcpy(mac, dest, 4);
|
memcpy(mac, dest, 4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +255,8 @@ void opt_doTagMAC(uint8_t *cc_p, const uint8_t *div_key_p, uint8_t mac[4]) {
|
||||||
0x4c, // b
|
0x4c, // b
|
||||||
0xE012 // t
|
0xE012 // t
|
||||||
};
|
};
|
||||||
opt_suc(div_key_p, &_init, cc_p, 12, true);
|
opt_suc(div_key_p, &_init, cc_p, 12, true);
|
||||||
opt_output(div_key_p, &_init, mac);
|
opt_output(div_key_p, &_init, mac);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ State opt_doTagMAC_1(uint8_t *cc_p, const uint8_t *div_key_p) {
|
||||||
0x4c, // b
|
0x4c, // b
|
||||||
0xE012 // t
|
0xE012 // t
|
||||||
};
|
};
|
||||||
opt_suc(div_key_p, &_init, cc_p, 8, false);
|
opt_suc(div_key_p, &_init, cc_p, 8, false);
|
||||||
return _init;
|
return _init;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ State opt_doTagMAC_1(uint8_t *cc_p, const uint8_t *div_key_p) {
|
||||||
* @param div_key_p - the key to use
|
* @param div_key_p - the key to use
|
||||||
*/
|
*/
|
||||||
void opt_doTagMAC_2(State _init, uint8_t *nr, uint8_t mac[4], const uint8_t *div_key_p) {
|
void opt_doTagMAC_2(State _init, uint8_t *nr, uint8_t mac[4], const uint8_t *div_key_p) {
|
||||||
opt_suc(div_key_p, &_init, nr, 4, true);
|
opt_suc(div_key_p, &_init, nr, 4, true);
|
||||||
opt_output(div_key_p, &_init, mac);
|
opt_output(div_key_p, &_init, mac);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -752,10 +752,10 @@ static uint8_t NumBlocksPerSector(uint8_t sectorNo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static uint8_t GetSectorFromBlockNo(uint8_t blockNo) {
|
static uint8_t GetSectorFromBlockNo(uint8_t blockNo) {
|
||||||
if ( blockNo < 128 )
|
if (blockNo < 128)
|
||||||
return blockNo / 4;
|
return blockNo / 4;
|
||||||
else
|
else
|
||||||
return 32 + ((128 - blockNo) / 16);
|
return 32 + ((128 - blockNo) / 16);
|
||||||
}
|
}
|
||||||
static int CmdHF14AMfDump(const char *Cmd) {
|
static int CmdHF14AMfDump(const char *Cmd) {
|
||||||
|
|
||||||
|
@ -963,11 +963,11 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
||||||
PrintAndLogEx(SUCCESS, "\nSucceded in dumping all blocks");
|
PrintAndLogEx(SUCCESS, "\nSucceded in dumping all blocks");
|
||||||
|
|
||||||
if (strlen(dataFilename) < 1) {
|
if (strlen(dataFilename) < 1) {
|
||||||
fptr = GenerateFilename("hf-mf-", "-data");
|
fptr = GenerateFilename("hf-mf-", "-data");
|
||||||
if (fptr == NULL)
|
if (fptr == NULL)
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
|
||||||
strcpy(dataFilename, fptr);
|
strcpy(dataFilename, fptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t bytes = 16 * (FirstBlockOfSector(numSectors - 1) + NumBlocksPerSector(numSectors - 1));
|
uint16_t bytes = 16 * (FirstBlockOfSector(numSectors - 1) + NumBlocksPerSector(numSectors - 1));
|
||||||
|
@ -1229,9 +1229,9 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
||||||
e_sector = calloc(SectorsCnt, sizeof(sector_t));
|
e_sector = calloc(SectorsCnt, sizeof(sector_t));
|
||||||
if (e_sector == NULL) return PM3_EMALLOC;
|
if (e_sector == NULL) return PM3_EMALLOC;
|
||||||
|
|
||||||
// add our known key
|
// add our known key
|
||||||
e_sector[GetSectorFromBlockNo(blockNo)].foundKey[keyType] = 1;
|
e_sector[GetSectorFromBlockNo(blockNo)].foundKey[keyType] = 1;
|
||||||
e_sector[GetSectorFromBlockNo(blockNo)].Key[keyType] = key64;
|
e_sector[GetSectorFromBlockNo(blockNo)].Key[keyType] = key64;
|
||||||
|
|
||||||
//test current key and additional standard keys first
|
//test current key and additional standard keys first
|
||||||
// add parameter key
|
// add parameter key
|
||||||
|
@ -1740,7 +1740,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
blockNo,
|
blockNo,
|
||||||
keyType ? 'B' : 'A',
|
keyType ? 'B' : 'A',
|
||||||
sprint_hex(key, sizeof(key))
|
sprint_hex(key, sizeof(key))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store the key for the nested / hardnested attack (if supplied by the user)
|
// Store the key for the nested / hardnested attack (if supplied by the user)
|
||||||
e_sector[blockNo].Key[keyType] = bytes_to_num(key, 6);
|
e_sector[blockNo].Key[keyType] = bytes_to_num(key, 6);
|
||||||
|
@ -1751,7 +1751,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
blockNo,
|
blockNo,
|
||||||
keyType ? 'B' : 'A',
|
keyType ? 'B' : 'A',
|
||||||
sprint_hex(key, sizeof(key))
|
sprint_hex(key, sizeof(key))
|
||||||
);
|
);
|
||||||
PrintAndLogEx(WARNING, "Falling back to dictionary");
|
PrintAndLogEx(WARNING, "Falling back to dictionary");
|
||||||
}
|
}
|
||||||
// Check if the user supplied key is used by other sectors
|
// Check if the user supplied key is used by other sectors
|
||||||
|
@ -1765,7 +1765,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
i,
|
i,
|
||||||
j ? 'B' : 'A',
|
j ? 'B' : 'A',
|
||||||
sprint_hex(key, sizeof(key))
|
sprint_hex(key, sizeof(key))
|
||||||
);
|
);
|
||||||
|
|
||||||
// If the user supplied secctor / keytype was wrong --> just be nice and correct it ;)
|
// If the user supplied secctor / keytype was wrong --> just be nice and correct it ;)
|
||||||
if (know_target_key == false) {
|
if (know_target_key == false) {
|
||||||
|
@ -1778,7 +1778,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
blockNo,
|
blockNo,
|
||||||
keyType ? 'B' : 'A',
|
keyType ? 'B' : 'A',
|
||||||
sprint_hex(key, sizeof(key))
|
sprint_hex(key, sizeof(key))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1792,7 +1792,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
loadFileDICTIONARY(filename, keyBlock, &data_length, 6, &key_cnt);
|
loadFileDICTIONARY(filename, keyBlock, &data_length, 6, &key_cnt);
|
||||||
if ((data_length / 6) > max_dictionary_size) {
|
if ((data_length / 6) > max_dictionary_size) {
|
||||||
// This is not a good solution (loadFileDICTIONARY needs a maxdatalen)!
|
// This is not a good solution (loadFileDICTIONARY needs a maxdatalen)!
|
||||||
// loadfiledictionary will reallocate to correct size.
|
// loadfiledictionary will reallocate to correct size.
|
||||||
PrintAndLogEx(FAILED, "Dictionary is too large: %d (allowed: %d)", data_length, max_dictionary_size);
|
PrintAndLogEx(FAILED, "Dictionary is too large: %d (allowed: %d)", data_length, max_dictionary_size);
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
|
@ -1877,7 +1877,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
i,
|
i,
|
||||||
j ? 'B' : 'A',
|
j ? 'B' : 'A',
|
||||||
sprint_hex(tmp_key, sizeof(tmp_key))
|
sprint_hex(tmp_key, sizeof(tmp_key))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store valid credentials for the nested / hardnested attack if none exist
|
// Store valid credentials for the nested / hardnested attack if none exist
|
||||||
if (know_target_key == false) {
|
if (know_target_key == false) {
|
||||||
|
@ -1890,7 +1890,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
blockNo,
|
blockNo,
|
||||||
keyType ? 'B' : 'A',
|
keyType ? 'B' : 'A',
|
||||||
sprint_hex(key, sizeof(key))
|
sprint_hex(key, sizeof(key))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1931,7 +1931,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
blockNo,
|
blockNo,
|
||||||
keyType ? 'B' : 'A',
|
keyType ? 'B' : 'A',
|
||||||
sprint_hex(key, sizeof(key))
|
sprint_hex(key, sizeof(key))
|
||||||
);
|
);
|
||||||
goto noValidKeyFound;
|
goto noValidKeyFound;
|
||||||
}
|
}
|
||||||
// Store the keys
|
// Store the keys
|
||||||
|
@ -1965,17 +1965,17 @@ noValidKeyFound:
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
// Check if the sector key is already broken
|
// Check if the sector key is already broken
|
||||||
if (e_sector[i].foundKey[j])
|
if (e_sector[i].foundKey[j])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check if the key works
|
// Check if the key works
|
||||||
if (mfCheckKeys(FirstBlockOfSector(i), j, true, 1, tmp_key, &key64) == PM3_SUCCESS) {
|
if (mfCheckKeys(FirstBlockOfSector(i), j, true, 1, tmp_key, &key64) == PM3_SUCCESS) {
|
||||||
e_sector[i].Key[j] = bytes_to_num(tmp_key, 6);
|
e_sector[i].Key[j] = bytes_to_num(tmp_key, 6);
|
||||||
e_sector[i].foundKey[j] = 4;
|
e_sector[i].foundKey[j] = 4;
|
||||||
PrintAndLogEx(SUCCESS, "Found valid key: sector: %3d key type: %c key: " _YELLOW_("%s"),
|
PrintAndLogEx(SUCCESS, "Found valid key: sector: %3d key type: %c key: " _YELLOW_("%s"),
|
||||||
i,
|
i,
|
||||||
j ? 'B' : 'A',
|
j ? 'B' : 'A',
|
||||||
sprint_hex(tmp_key, sizeof(tmp_key))
|
sprint_hex(tmp_key, sizeof(tmp_key))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2063,7 +2063,7 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack
|
||||||
current_sector_i,
|
current_sector_i,
|
||||||
current_key_type_i ? 'B' : 'A',
|
current_key_type_i ? 'B' : 'A',
|
||||||
sprint_hex(tmp_key, sizeof(tmp_key))
|
sprint_hex(tmp_key, sizeof(tmp_key))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2100,11 +2100,11 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack
|
||||||
mfEmlSetMem(block, FirstBlockOfSector(current_sector_i) + NumBlocksPerSector(current_sector_i) - 1, 1);
|
mfEmlSetMem(block, FirstBlockOfSector(current_sector_i) + NumBlocksPerSector(current_sector_i) - 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// using ecfill trick, keys already in emulator mem, load data using Key A
|
// using ecfill trick, keys already in emulator mem, load data using Key A
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_MIFARE_EML_LOAD, sectors_cnt, 0, 0, NULL, 0);
|
SendCommandMIX(CMD_HF_MIFARE_EML_LOAD, sectors_cnt, 0, 0, NULL, 0);
|
||||||
|
|
||||||
// using ecfill trick, keys already in emulator mem, load data using Key B
|
// using ecfill trick, keys already in emulator mem, load data using Key B
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_MIFARE_EML_LOAD, sectors_cnt, 1, 0, NULL, 0);
|
SendCommandMIX(CMD_HF_MIFARE_EML_LOAD, sectors_cnt, 1, 0, NULL, 0);
|
||||||
|
|
||||||
|
@ -2126,12 +2126,12 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack
|
||||||
}
|
}
|
||||||
|
|
||||||
fnameptr = GenerateFilename("hf-mf-", "-data");
|
fnameptr = GenerateFilename("hf-mf-", "-data");
|
||||||
if (fnameptr == NULL) {
|
if (fnameptr == NULL) {
|
||||||
free(dump);
|
free(dump);
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
strcpy(filename, fnameptr);
|
strcpy(filename, fnameptr);
|
||||||
|
|
||||||
saveFile(filename, ".bin", dump, bytes);
|
saveFile(filename, ".bin", dump, bytes);
|
||||||
saveFileEML(filename, dump, bytes, MFBLOCK_SIZE);
|
saveFileEML(filename, dump, bytes, MFBLOCK_SIZE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue