This commit is contained in:
iceman1001 2020-01-12 17:28:12 +01:00
commit ed67936892
11 changed files with 177 additions and 177 deletions

View file

@ -107,7 +107,7 @@ void HfPlotDownload(void) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_GET_TRACE); // let FPGA transfer its internal Block-RAM FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_GET_TRACE); // let FPGA transfer its internal Block-RAM
LED_B_ON(); LED_B_ON();
for(size_t i = 0; i < FPGA_TRACE_SIZE; i += PM3_CMD_DATA_SIZE) { for (size_t i = 0; i < FPGA_TRACE_SIZE; i += PM3_CMD_DATA_SIZE) {
// prepare next DMA transfer: // prepare next DMA transfer:
uint8_t *next_buf = buf + ((i + PM3_CMD_DATA_SIZE) % (2 * PM3_CMD_DATA_SIZE)); uint8_t *next_buf = buf + ((i + PM3_CMD_DATA_SIZE) % (2 * PM3_CMD_DATA_SIZE));

View file

@ -3675,7 +3675,7 @@ void arg_register_error(struct arg_end *end,
* Return index of first table entry with a matching short option * Return index of first table entry with a matching short option
* or -1 if no match was found. * or -1 if no match was found.
*/ */
static int find_shortoption(struct arg_hdr** table, char shortopt) { static int find_shortoption(struct arg_hdr **table, char shortopt) {
int tabindex; int tabindex;
for (tabindex = 0; !(table[tabindex]->flag & ARG_TERMINATOR); tabindex++) { for (tabindex = 0; !(table[tabindex]->flag & ARG_TERMINATOR); tabindex++) {
if (table[tabindex]->shortopts && if (table[tabindex]->shortopts &&
@ -3708,7 +3708,7 @@ void dump_longoptions(struct longoptions *longoptions) {
} }
#endif #endif
static struct longoptions* alloc_longoptions(struct arg_hdr** table) { static struct longoptions *alloc_longoptions(struct arg_hdr **table) {
struct longoptions *result; struct longoptions *result;
size_t nbytes; size_t nbytes;
int noptions = 1; int noptions = 1;
@ -3790,7 +3790,7 @@ static struct longoptions* alloc_longoptions(struct arg_hdr** table) {
return result; return result;
} }
static char* alloc_shortoptions(struct arg_hdr** table) { static char *alloc_shortoptions(struct arg_hdr **table) {
char *result; char *result;
size_t len = 2; size_t len = 2;
int tabindex; int tabindex;
@ -3830,7 +3830,7 @@ static char* alloc_shortoptions(struct arg_hdr** table) {
/* return index of the table terminator entry */ /* return index of the table terminator entry */
static int arg_endindex(struct arg_hdr** table) { static int arg_endindex(struct arg_hdr **table) {
int tabindex = 0; int tabindex = 0;
while (!(table[tabindex]->flag & ARG_TERMINATOR)) while (!(table[tabindex]->flag & ARG_TERMINATOR))
tabindex++; tabindex++;

View file

@ -234,7 +234,7 @@ int CmdHFPlot(const char *Cmd) {
"Plots HF signal after RF signal path and A/D conversion.", "Plots HF signal after RF signal path and A/D conversion.",
"This can be used after any hf command and will show the last few milliseconds of the HF signal.\n" "This can be used after any hf command and will show the last few milliseconds of the HF signal.\n"
"Note: If the last hf command terminated because of a timeout you will most probably see nothing.\n"); "Note: If the last hf command terminated because of a timeout you will most probably see nothing.\n");
void* argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
}; };

View file

@ -2469,12 +2469,12 @@ static int CmdHF14AMfUGenDiverseKeys(const char *Cmd) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(WARNING, "iso14443a card select failed");
return PM3_ESOFT; return PM3_ESOFT;
} }
/* /*
if (card.uidlen != 4) { if (card.uidlen != 4) {
PrintAndLogEx(WARNING, "Wrong sized UID, expected 4bytes got %d", card.uidlen); PrintAndLogEx(WARNING, "Wrong sized UID, expected 4bytes got %d", card.uidlen);
return PM3_ESOFT; return PM3_ESOFT;
} }
*/ */
memcpy(uid, card.uid, card.uidlen); memcpy(uid, card.uid, card.uidlen);
} else { } else {
if (param_gethex(Cmd, 0, uid, 8)) return usage_hf_mfu_gendiverse(); if (param_gethex(Cmd, 0, uid, 8)) return usage_hf_mfu_gendiverse();

View file

@ -73,14 +73,14 @@ static int usage_lf_indala_sim(void) {
static void encodeHeden2L(uint8_t *dest, uint32_t cardnumber) { static void encodeHeden2L(uint8_t *dest, uint32_t cardnumber) {
uint8_t template[] = { uint8_t template[] = {
1,0,1,0,0,0,0,0, 1, 0, 1, 0, 0, 0, 0, 0,
0,0,0,0,0,0,0,0, 0, 0, 0, 0, 0, 0, 0, 0,
0,0,0,0,0,0,0,0, 0, 0, 0, 0, 0, 0, 0, 0,
0,0,0,0,0,0,0,0, 0, 0, 0, 0, 0, 0, 0, 0,
1,0,0,0,1,0,0,0, 1, 0, 0, 0, 1, 0, 0, 0,
1,0,0,0,0,0,0,0, 1, 0, 0, 0, 0, 0, 0, 0,
0,0,0,0,1,0,0,1, 0, 0, 0, 0, 1, 0, 0, 1,
0,0,0,0,0,0,1,0 0, 0, 0, 0, 0, 0, 1, 0
}; };
uint8_t cardbits[32]; uint8_t cardbits[32];
@ -105,14 +105,14 @@ static void encodeHeden2L(uint8_t *dest, uint32_t cardnumber) {
// Parity // Parity
uint8_t counter = 0; uint8_t counter = 0;
for (int i=0; i< sizeof(template) - HEDEN2L_OFFSET; i++) { for (int i = 0; i < sizeof(template) - HEDEN2L_OFFSET; i++) {
if (template[i]) if (template[i])
counter++; counter++;
} }
template[63] = (counter & 0x1); template[63] = (counter & 0x1);
for (int i = 0; i< sizeof(template); i += 8) { for (int i = 0; i < sizeof(template); i += 8) {
dest[i/8] = bytebits_to_byte(template + i, 8); dest[i / 8] = bytebits_to_byte(template + i, 8);
} }
PrintAndLogEx(INFO, "Heden-2L card number %u", cardnumber); PrintAndLogEx(INFO, "Heden-2L card number %u", cardnumber);
@ -123,22 +123,22 @@ static void decodeHeden2L(uint8_t *bits) {
uint32_t cardnumber = 0; uint32_t cardnumber = 0;
uint8_t offset = HEDEN2L_OFFSET; uint8_t offset = HEDEN2L_OFFSET;
if ( bits[offset + 8] ) cardnumber += 1; if (bits[offset + 8]) cardnumber += 1;
if ( bits[offset + 10] ) cardnumber += 2; if (bits[offset + 10]) cardnumber += 2;
if ( bits[offset + 14] ) cardnumber += 4; if (bits[offset + 14]) cardnumber += 4;
if ( bits[offset + 15] ) cardnumber += 8; if (bits[offset + 15]) cardnumber += 8;
if ( bits[offset + 12] ) cardnumber += 16; if (bits[offset + 12]) cardnumber += 16;
if ( bits[offset + 28] ) cardnumber += 32; if (bits[offset + 28]) cardnumber += 32;
if ( bits[offset + 3] ) cardnumber += 64; if (bits[offset + 3]) cardnumber += 64;
if ( bits[offset + 11] ) cardnumber += 128; if (bits[offset + 11]) cardnumber += 128;
if ( bits[offset + 19] ) cardnumber += 256; if (bits[offset + 19]) cardnumber += 256;
if ( bits[offset + 26] ) cardnumber += 512; if (bits[offset + 26]) cardnumber += 512;
if ( bits[offset + 17] ) cardnumber += 1024; if (bits[offset + 17]) cardnumber += 1024;
if ( bits[offset + 18] ) cardnumber += 2048; if (bits[offset + 18]) cardnumber += 2048;
if ( bits[offset + 20] ) cardnumber += 4096; if (bits[offset + 20]) cardnumber += 4096;
if ( bits[offset + 13] ) cardnumber += 8192; if (bits[offset + 13]) cardnumber += 8192;
if ( bits[offset + 7] ) cardnumber += 16384; if (bits[offset + 7]) cardnumber += 16384;
if ( bits[offset + 23] ) cardnumber += 32768; if (bits[offset + 23]) cardnumber += 32768;
PrintAndLogEx(SUCCESS, "\tHeden-2L | %u", cardnumber); PrintAndLogEx(SUCCESS, "\tHeden-2L | %u", cardnumber);
} }

View file

@ -36,13 +36,13 @@
//------------------------------------ //------------------------------------
static void transform_D(uint8_t *ru) { static void transform_D(uint8_t *ru) {
const uint32_t c_D[] = { const uint32_t c_D[] = {
0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8, 0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8,
0xD1CC8B4E, 0xE8873E6F, 0x61399BBB, 0xF1B91926, 0xAC661520, 0xA21A31C9, 0xD1CC8B4E, 0xE8873E6F, 0x61399BBB, 0xF1B91926, 0xAC661520, 0xA21A31C9,
0xD424808D, 0xFE118E07, 0xD18E728D, 0xABAC9E17, 0x18066433, 0x00E18E79, 0xD424808D, 0xFE118E07, 0xD18E728D, 0xABAC9E17, 0x18066433, 0x00E18E79,
0x65A77305, 0x5AE9E297, 0x11FC628C, 0x7BB3431F, 0x942A8308, 0xB2F8FD20, 0x65A77305, 0x5AE9E297, 0x11FC628C, 0x7BB3431F, 0x942A8308, 0xB2F8FD20,
0x5728B869, 0x30726D5A 0x5728B869, 0x30726D5A
}; };
//Transform //Transform
uint8_t i; uint8_t i;
@ -197,9 +197,9 @@ int mfc_algo_ving_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *k
int mfc_algo_ving_all(uint8_t *uid, uint8_t *keys) { int mfc_algo_ving_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG; if (keys == NULL) return PM3_EINVARG;
for (int keytype = 0; keytype < 2; keytype++) { for (int keytype = 0; keytype < 2; keytype++) {
for (int sector = 0; sector < 16; sector++){ for (int sector = 0; sector < 16; sector++) {
uint64_t key = 0; uint64_t key = 0;
mfc_algo_ving_one(uid, sector, keytype, &key ); mfc_algo_ving_one(uid, sector, keytype, &key);
num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6)); num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6));
} }
} }
@ -216,9 +216,9 @@ int mfc_algo_yale_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *k
int mfc_algo_yale_all(uint8_t *uid, uint8_t *keys) { int mfc_algo_yale_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG; if (keys == NULL) return PM3_EINVARG;
for (int keytype = 0; keytype < 2; keytype++) { for (int keytype = 0; keytype < 2; keytype++) {
for (int sector = 0; sector < 16; sector++){ for (int sector = 0; sector < 16; sector++) {
uint64_t key = 0; uint64_t key = 0;
mfc_algo_yale_one(uid, sector, keytype, &key ); mfc_algo_yale_one(uid, sector, keytype, &key);
num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6)); num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6));
} }
} }
@ -236,9 +236,9 @@ int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG; if (keys == NULL) return PM3_EINVARG;
for (int keytype = 0; keytype < 2; keytype++) { for (int keytype = 0; keytype < 2; keytype++) {
for (int sector = 0; sector < 16; sector++){ for (int sector = 0; sector < 16; sector++) {
uint64_t key = 0; uint64_t key = 0;
mfc_algo_saflok_one(uid, sector, keytype, &key ); mfc_algo_saflok_one(uid, sector, keytype, &key);
num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6)); num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6));
} }
} }
@ -261,7 +261,7 @@ int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *
uint8_t xor[6]; uint8_t xor[6];
if ( keytype == 0 ) { if (keytype == 0) {
uint64_t xor_tbl_a[] = { uint64_t xor_tbl_a[] = {
0x09125a2589e5, 0x09125a2589e5,
@ -273,7 +273,7 @@ int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *
num_to_bytes(xor_tbl_a[sector - 1], 6, xor); num_to_bytes(xor_tbl_a[sector - 1], 6, xor);
*key = *key =
(uint64_t)(uid[0] ^ xor[0] ) << 40 | (uint64_t)(uid[0] ^ xor[0]) << 40 |
(uint64_t)(uid[1] ^ xor[1]) << 32 | (uint64_t)(uid[1] ^ xor[1]) << 32 |
(uint64_t)(uid[2] ^ xor[2]) << 24 | (uint64_t)(uid[2] ^ xor[2]) << 24 |
(uint64_t)(uid[3] ^ xor[3]) << 16 | (uint64_t)(uid[3] ^ xor[3]) << 16 |
@ -311,7 +311,7 @@ int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG; if (keys == NULL) return PM3_EINVARG;
for (int keytype = 0; keytype < 2; keytype++) { for (int keytype = 0; keytype < 2; keytype++) {
for (int sector = 0; sector < 5; sector++){ for (int sector = 0; sector < 5; sector++) {
uint64_t key = 0; uint64_t key = 0;
mfc_algo_mizip_one(uid, sector, keytype, &key); mfc_algo_mizip_one(uid, sector, keytype, &key);
num_to_bytes(key, 6, keys + (keytype * 5 * 6) + (sector * 6)); num_to_bytes(key, 6, keys + (keytype * 5 * 6) + (sector * 6));
@ -350,7 +350,7 @@ int mfc_algo_di_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key
int mfc_algo_di_all(uint8_t *uid, uint8_t *keys) { int mfc_algo_di_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG; if (keys == NULL) return PM3_EINVARG;
for (int keytype = 0; keytype < 2; keytype++) { for (int keytype = 0; keytype < 2; keytype++) {
for (int sector = 0; sector < 5; sector++){ for (int sector = 0; sector < 5; sector++) {
uint64_t key = 0; uint64_t key = 0;
mfc_algo_di_one(uid, sector, keytype, &key); mfc_algo_di_one(uid, sector, keytype, &key);
num_to_bytes(key, 6, keys + (keytype * 5 * 6) + (sector * 6)); num_to_bytes(key, 6, keys + (keytype * 5 * 6) + (sector * 6));
@ -361,10 +361,10 @@ int mfc_algo_di_all(uint8_t *uid, uint8_t *keys) {
// Skylanders // Skylanders
static uint64_t sky_crc64_like(uint64_t result, uint8_t sector) { static uint64_t sky_crc64_like(uint64_t result, uint8_t sector) {
#define SKY_POLY UINT64_C(0x42f0e1eba9ea3693) #define SKY_POLY UINT64_C(0x42f0e1eba9ea3693)
#define SKY_TOP UINT64_C(0x800000000000) #define SKY_TOP UINT64_C(0x800000000000)
result ^= (uint64_t)sector << 40; result ^= (uint64_t)sector << 40;
for(int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
result = (result & SKY_TOP) ? (result << 1) ^ SKY_POLY : result << 1; result = (result & SKY_TOP) ? (result << 1) ^ SKY_POLY : result << 1;
} }
return result; return result;
@ -387,7 +387,7 @@ int mfc_algo_sky_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *ke
// hash UID // hash UID
uint64_t hash = 0x9AE903260CC4; uint64_t hash = 0x9AE903260CC4;
for(int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
hash = sky_crc64_like(hash, uid[i]); hash = sky_crc64_like(hash, uid[i]);
} }
@ -398,7 +398,7 @@ int mfc_algo_sky_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *ke
int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys) { int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG; if (keys == NULL) return PM3_EINVARG;
for (int keytype = 0; keytype < 2; keytype++) { for (int keytype = 0; keytype < 2; keytype++) {
for (int sector = 0; sector < 16; sector++){ for (int sector = 0; sector < 16; sector++) {
uint64_t key = 0; uint64_t key = 0;
mfc_algo_sky_one(uid, sector, keytype, &key); mfc_algo_sky_one(uid, sector, keytype, &key);
num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6)); num_to_bytes(key, 6, keys + (keytype * 16 * 6) + (sector * 6));

View file

@ -113,7 +113,7 @@ static const int Iso15693FrameSOF[] = {
-1, -1, -1, -1, -1, -1, -1, -1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1 1, 1, 1, 1
}; };
static const int Iso15693Logic0[] = { static const int Iso15693Logic0[] = {
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
@ -125,7 +125,7 @@ static const int Iso15693Logic1[] = {
-1, -1, -1, -1, -1, -1, -1, -1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1 1, 1, 1, 1
}; };
// EOF defined as // EOF defined as
// 1) logic '0' (8 pulses of 423.75kHz followed by unmodulated for 18.88us) // 1) logic '0' (8 pulses of 423.75kHz followed by unmodulated for 18.88us)