Merge branch 'master' into fpga
* master: (27 commits) fix a bug in demodParadox() added new command "4x50_wipe" added new command "4x50_wipe" added new command "4x50_wipe" added new command "4x50_wipe" added new command "4x50_wipe" added new command "4x50_wipe" added new command "4x50_wipe" fix #833 - missing some configblocks and spelling remove verichip. chg 'lf t55xx info' - detection of t55x7 configuration blocks remove disable verichip stuff. should be inside FDX already textual lf t55 configblock detection updated textual fix: missing define on some mingw chg: hf mf decrypt - helptext (thanks @AdamLaurie) Update bt_manual_v10.md textual ...
This commit is contained in:
@@ -307,13 +307,13 @@ static int usage_hf14_decryptbytes(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf mf decrypt [h] <nt> <ar_enc> <at_enc> <data>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h this help");
|
||||
PrintAndLogEx(NORMAL, " <nt> reader nonce");
|
||||
PrintAndLogEx(NORMAL, " <nt> tag nonce");
|
||||
PrintAndLogEx(NORMAL, " <ar_enc> encrypted reader response");
|
||||
PrintAndLogEx(NORMAL, " <at_enc> encrypted tag response");
|
||||
PrintAndLogEx(NORMAL, " <data> encrypted data, taken directly after at_enc and forward");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf mf decrypt b830049b 9248314a 9280e203 41e586f9"));
|
||||
PrintAndLogEx(NORMAL, "\n this sample decrypts 41e586f9 -> 3003999a Annotated: 30 03 [99 9a] auth block 3 [crc]");
|
||||
PrintAndLogEx(NORMAL, "\n this sample decrypts 41e586f9 -> 3003999a Annotated: 30 03 [99 9a] read block 3 [crc]");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1664,14 +1664,6 @@ static inline bool bitflips_match(uint8_t byte, uint32_t state, odd_even_t odd_e
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
static uint_fast8_t reverse(uint_fast8_t b) {
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
return b;
|
||||
}
|
||||
*/
|
||||
static uint_fast8_t reverse(uint_fast8_t b) {
|
||||
return (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
|
||||
}
|
||||
|
||||
@@ -1286,6 +1286,7 @@ int CmdLFfind(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if (demodVisa2k() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Visa2000 ID") " found!"); goto out;}
|
||||
if (demodHID() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("HID Prox ID") " found!"); goto out;}
|
||||
if (demodAWID() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("AWID ID") " found!"); goto out;}
|
||||
if (demodIOProx() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("IO Prox ID") " found!"); goto out;}
|
||||
@@ -1308,8 +1309,8 @@ int CmdLFfind(const char *Cmd) {
|
||||
if (demodPyramid() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Pyramid ID") " found!"); goto out;}
|
||||
if (demodSecurakey() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Securakey ID") " found!"); goto out;}
|
||||
if (demodViking() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Viking ID") " found!"); goto out;}
|
||||
if (demodVisa2k() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Visa2000 ID") " found!"); goto out;}
|
||||
if (demodGallagher() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("GALLAGHER ID") " found!"); goto out;}
|
||||
|
||||
// if (demodTI() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Texas Instrument ID") " found!"); goto out;}
|
||||
//if (demodFermax() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Fermax ID") " found!"); goto out;}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ static int usage_lf_em4x05_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_dump");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_dump 11223344");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_dump f card1 11223344");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_dump f card1 11223344");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x05_wipe(void) {
|
||||
@@ -1395,10 +1395,12 @@ static command_t CommandTable[] = {
|
||||
{"4x05_read", CmdEM4x05Read, IfPm3Lf, "read word data from EM4x05/EM4x69"},
|
||||
{"4x05_write", CmdEM4x05Write, IfPm3Lf, "write word data to EM4x05/EM4x69"},
|
||||
{"----------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("EM 4x50") " -----------------------"},
|
||||
{"4x50_info", CmdEM4x50Info, IfPm3EM4x50, "read complete data from EM4x50"},
|
||||
{"4x50_dump", CmdEM4x50Dump, IfPm3EM4x50, "dump EM4x50 tag"},
|
||||
{"4x50_info", CmdEM4x50Info, IfPm3EM4x50, "tag information EM4x50"},
|
||||
{"4x50_write", CmdEM4x50Write, IfPm3EM4x50, "write word data to EM4x50"},
|
||||
{"4x50_write_password", CmdEM4x50WritePassword, IfPm3EM4x50, "change passwword of EM4x50 tag"},
|
||||
{"4x50_read", CmdEM4x50Read, IfPm3EM4x50, "read word data from EM4x50"},
|
||||
{"4x50_wipe", CmdEM4x50Wipe, IfPm3EM4x50, "wipe data from EM4x50"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "commonutil.h"
|
||||
#include "em4x50.h"
|
||||
|
||||
int usage_lf_em4x50_info(void) {
|
||||
static int usage_lf_em4x50_info(void) {
|
||||
PrintAndLogEx(NORMAL, "Read all information of EM4x50. Tag nust be on antenna.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_info [h] [v] [p <pwd>]");
|
||||
@@ -30,7 +30,7 @@ int usage_lf_em4x50_info(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
int usage_lf_em4x50_write(void) {
|
||||
static int usage_lf_em4x50_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Write EM4x50 word. Tag must be on antenna. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_write [h] [a <address>] [w <data>]");
|
||||
@@ -44,7 +44,7 @@ int usage_lf_em4x50_write(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
int usage_lf_em4x50_write_password(void) {
|
||||
static int usage_lf_em4x50_write_password(void) {
|
||||
PrintAndLogEx(NORMAL, "Write EM4x50 password. Tag must be on antenna. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_write_password [h] [p <pwd>] [n <pwd>]");
|
||||
@@ -57,8 +57,8 @@ int usage_lf_em4x50_write_password(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
int usage_lf_em4x50_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Read EM4x50 word(s). Tag must be on antenna. ");
|
||||
static int usage_lf_em4x50_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Read EM4x50 word(s). Tag must be on antenna.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_read [h] [a <address>] [p <pwd>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
@@ -71,6 +71,32 @@ int usage_lf_em4x50_read(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "Dump EM4x50 tag. Tag must be on antenna.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_dump [h] [f <filename prefix>] [p <pwd>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " f <filename prefix> - overide filename prefix (optional). Default is based on UID");
|
||||
PrintAndLogEx(NORMAL, " p <pwd> - password (hex) (optional)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_dump"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_dump p 11223344"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_dump f card_nnn p 11223344"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_wipe(void) {
|
||||
PrintAndLogEx(NORMAL, "Wipe data from EM4x50 tag. Tag must be on antenna. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_wipe [h] [p <pwd>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " p <pwd> - password (hex)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_wwipe p 11223344"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t *words) {
|
||||
|
||||
@@ -128,46 +154,52 @@ static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t
|
||||
}
|
||||
}
|
||||
|
||||
static void print_result(const em4x50_word_t *words, int fwr, int lwr, bool verbose) {
|
||||
static void print_result(const em4x50_word_t *words, int fwr, int lwr) {
|
||||
|
||||
// print available information for given word from fwr to lwr, i.e.
|
||||
// bit table + summary lines with hex notation of word (msb + lsb)
|
||||
|
||||
char string[NO_CHARS_MAX] = {0}, pstring[NO_CHARS_MAX] = {0};
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, " # | word (msb) | word (lsb) | desc");
|
||||
PrintAndLogEx(INFO, "----+-------------+-------------+--------------------");
|
||||
|
||||
for (int i = fwr; i <= lwr; i++) {
|
||||
|
||||
if (verbose) {
|
||||
|
||||
// final result
|
||||
string[0] = '\0';
|
||||
sprintf(pstring, "\n word[%i] msb: " _GREEN_("0x"), i);
|
||||
strcat(string, pstring);
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
sprintf(pstring, _GREEN_("%02x"), words[i].byte[j]);
|
||||
strcat(string, pstring);
|
||||
}
|
||||
|
||||
sprintf(pstring, "\n word[%i] lsb: 0x", i);
|
||||
strcat(string, pstring);
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
sprintf(pstring, "%02x", reflect8(words[i].byte[3-j]));
|
||||
strcat(string, pstring);
|
||||
}
|
||||
} else {
|
||||
string[0] = '\0';
|
||||
sprintf(pstring, "[" _GREEN_("+") "] word[%i]: " _YELLOW_("0x"), i);
|
||||
strcat(string, pstring);
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
sprintf(pstring, _YELLOW_("%02x"), words[i].byte[j]);
|
||||
strcat(string, pstring);
|
||||
}
|
||||
char s[50] = {0};
|
||||
switch(i) {
|
||||
case EM4X50_DEVICE_PASSWORD:
|
||||
sprintf(s, _YELLOW_("password, write only"));
|
||||
break;
|
||||
case EM4X50_PROTECTION:
|
||||
sprintf(s, _YELLOW_("protection cfg (locked)"));
|
||||
break;
|
||||
case EM4X50_CONTROL:
|
||||
sprintf(s, _YELLOW_("control cfg (locked)"));
|
||||
break;
|
||||
case EM4X50_DEVICE_SERIAL:
|
||||
sprintf(s, _YELLOW_("device serial number (read only)"));
|
||||
break;
|
||||
case EM4X50_DEVICE_ID:
|
||||
sprintf(s, _YELLOW_("device identification (read only)"));
|
||||
break;
|
||||
default:
|
||||
sprintf(s, "user data");
|
||||
break;
|
||||
}
|
||||
PrintAndLogEx(INFO, string);
|
||||
|
||||
char r[30] = {0};
|
||||
for (int j = 3; j >= 0; j--) {
|
||||
sprintf(r + strlen(r), "%02x ", reflect8(words[i].byte[j]));
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, " %2i | " _GREEN_("%s") "| %s| %s",
|
||||
i,
|
||||
sprint_hex(words[i].byte, 4),
|
||||
r,
|
||||
s
|
||||
);
|
||||
}
|
||||
PrintAndLogEx(INFO, "----+-------------+-------------+--------------------");
|
||||
}
|
||||
|
||||
static void print_info_result(uint8_t *data, bool verbose) {
|
||||
@@ -193,43 +225,8 @@ static void print_info_result(uint8_t *data, bool verbose) {
|
||||
// data section
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, _YELLOW_("EM4x50 data:"));
|
||||
|
||||
if (verbose) {
|
||||
print_result(words, 0, EM4X50_NO_WORDS - 1, true);
|
||||
} else {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "idx | word | desc");
|
||||
PrintAndLogEx(INFO, "----+-------------+----------------------------------");
|
||||
|
||||
// condensed data section
|
||||
for (int i = 0; i < EM4X50_NO_WORDS; i++) {
|
||||
char s[50] = {0};
|
||||
switch(i) {
|
||||
case EM4X50_DEVICE_PASSWORD:
|
||||
sprintf(s, _YELLOW_("password, write only"));
|
||||
break;
|
||||
case EM4X50_PROTECTION:
|
||||
sprintf(s, _YELLOW_("protection cfg (locked)"));
|
||||
break;
|
||||
case EM4X50_CONTROL:
|
||||
sprintf(s, _YELLOW_("control cfg (locked)"));
|
||||
break;
|
||||
case EM4X50_DEVICE_SERIAL:
|
||||
sprintf(s, _YELLOW_("device serial number (read only)"));
|
||||
break;
|
||||
case EM4X50_DEVICE_ID:
|
||||
sprintf(s, _YELLOW_("device identification (read only)"));
|
||||
break;
|
||||
default:
|
||||
sprintf(s, "user data");
|
||||
break;
|
||||
}
|
||||
PrintAndLogEx(INFO, " %2i | %s| %s", i, sprint_hex(words[i].byte, 4), s);
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(INFO, "----+-------------+----------------------------------");
|
||||
|
||||
print_result(words, 0, EM4X50_NO_WORDS - 1);
|
||||
|
||||
// configuration section
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---- " _CYAN_("Configuration") " ----");
|
||||
@@ -416,7 +413,7 @@ int CmdEM4x50Write(const char *Cmd) {
|
||||
em4x50_word_t words[EM4X50_NO_WORDS];
|
||||
|
||||
prepare_result(data, etd.address, etd.address, words);
|
||||
print_result(words, etd.address, etd.address, true);
|
||||
print_result(words, etd.address, etd.address);
|
||||
PrintAndLogEx(SUCCESS, "Successfully wrote to tag");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("lf em 4x50_read a %u") "` - to read your data", etd.address);
|
||||
return PM3_SUCCESS;
|
||||
@@ -553,9 +550,7 @@ int em4x50_read(em4x50_data_t *etd, em4x50_word_t *out, bool verbose) {
|
||||
memcpy(out, &words, sizeof(em4x50_word_t) * EM4X50_NO_WORDS);
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
print_result(words, etd->address, etd->address, true);
|
||||
}
|
||||
print_result(words, etd->address, etd->address);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -573,15 +568,6 @@ int CmdEM4x50Read(const char *Cmd) {
|
||||
case 'h': {
|
||||
return usage_lf_em4x50_read();
|
||||
}
|
||||
case 'p': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
}
|
||||
case 'a': {
|
||||
param_getdec(Cmd, cmdp + 1, &etd.address);
|
||||
|
||||
@@ -594,6 +580,15 @@ int CmdEM4x50Read(const char *Cmd) {
|
||||
cmdp += 2;
|
||||
break;
|
||||
}
|
||||
case 'p': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
PrintAndLogEx(WARNING, "\n Unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
@@ -602,8 +597,144 @@ int CmdEM4x50Read(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if (errors)
|
||||
if (errors || strlen(Cmd) == 0 || etd.addr_given == false)
|
||||
return usage_lf_em4x50_read();
|
||||
|
||||
return em4x50_read(&etd, NULL, true);
|
||||
}
|
||||
|
||||
int CmdEM4x50Dump(const char *Cmd) {
|
||||
|
||||
em4x50_data_t etd;
|
||||
etd.pwd_given = false;
|
||||
etd.addr_given = false;
|
||||
|
||||
char filename[FILE_PATH_SIZE] = {0x00};
|
||||
char *fptr = filename;
|
||||
|
||||
bool errors = false;
|
||||
uint8_t cmdp = 0;
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_lf_em4x50_dump();
|
||||
break;
|
||||
case 'f':
|
||||
param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'p': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
PrintAndLogEx(WARNING, " Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
// validation
|
||||
if (errors)
|
||||
return usage_lf_em4x50_dump();
|
||||
|
||||
PrintAndLogEx(INFO, "reading EM4x50 tag");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_INFO, (uint8_t *)&etd, sizeof(etd));
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
bool success = (resp.status & STATUS_SUCCESS) >> 1;
|
||||
if (success == false) {
|
||||
PrintAndLogEx(FAILED, "reading tag " _RED_("failed"));
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// structured format
|
||||
em4x50_word_t words[EM4X50_NO_WORDS];
|
||||
prepare_result(resp.data.asBytes, 0, EM4X50_NO_WORDS - 1, words);
|
||||
|
||||
PrintAndLogEx(INFO, _YELLOW_("EM4x50 data:"));
|
||||
print_result(words, 0, EM4X50_NO_WORDS - 1);
|
||||
|
||||
// user supplied filename?
|
||||
if (strlen(filename) == 0) {
|
||||
PrintAndLogEx(INFO, "Using UID as filename");
|
||||
fptr += sprintf(fptr, "lf-4x50-");
|
||||
FillFileNameByUID(fptr, words[EM4X50_DEVICE_SERIAL].byte, "-dump", 4);
|
||||
}
|
||||
|
||||
uint8_t data[EM4X50_NO_WORDS * 4] = {0};
|
||||
for (int i=0; i < EM4X50_NO_WORDS; i++) {
|
||||
memcpy(data + (i*4), words[i].byte, 4);
|
||||
}
|
||||
|
||||
// saveFileEML will add .eml extension to filename
|
||||
// saveFile (binary) passes in the .bin extension.
|
||||
saveFileEML(filename, data, sizeof(data), 4);
|
||||
saveFile(filename, ".bin", data, sizeof(data));
|
||||
//saveFileJSON...
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdEM4x50Wipe(const char *Cmd) {
|
||||
|
||||
// fills EM4x50 tag with zeros including password
|
||||
|
||||
bool errors = false, bpwd = false;
|
||||
uint8_t cmdp = 0;
|
||||
em4x50_data_t etd;
|
||||
PacketResponseNG resp;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_lf_em4x50_wipe();
|
||||
|
||||
case 'p':
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\npassword has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
bpwd = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "\nUnknown parameter '%c'\n", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (errors || !bpwd)
|
||||
return usage_lf_em4x50_wipe();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_WIPE, (uint8_t *)&etd, sizeof(etd));
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2*TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "\ntimeout while waiting for reply.\n");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
// print response
|
||||
bool isOK = resp.status;
|
||||
if (isOK) {
|
||||
PrintAndLogEx(SUCCESS,"\nwiping data " _GREEN_("ok") "\n");
|
||||
} else {
|
||||
PrintAndLogEx(FAILED,"\nwiping data " _RED_("failed") "\n");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
#include"common.h"
|
||||
#include "em4x50.h"
|
||||
|
||||
int usage_lf_em4x50_info(void);
|
||||
int usage_lf_em4x50_write(void);
|
||||
int usage_lf_em4x50_write_password(void);
|
||||
int usage_lf_em4x50_read(void);
|
||||
|
||||
int read_em4x50_uid(void);
|
||||
bool detect_4x50_block(void);
|
||||
int em4x50_read(em4x50_data_t *etd, em4x50_word_t *out, bool verbose);
|
||||
@@ -27,5 +22,7 @@ int CmdEM4x50Info(const char *Cmd);
|
||||
int CmdEM4x50Write(const char *Cmd);
|
||||
int CmdEM4x50WritePassword(const char *Cmd);
|
||||
int CmdEM4x50Read(const char *Cmd);
|
||||
int CmdEM4x50Dump(const char *Cmd);
|
||||
int CmdEM4x50Wipe(const char *Cmd);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -137,11 +137,16 @@ static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID
|
||||
|
||||
static int CmdKeriDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodKeri();
|
||||
}
|
||||
|
||||
int demodKeri(void) {
|
||||
|
||||
if (PSKDemod("", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - KERI: PSK1 Demod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
bool invert = false;
|
||||
size_t size = DemodBufferLen;
|
||||
int idx = detectKeri(DemodBuffer, &size, &invert);
|
||||
@@ -207,6 +212,8 @@ static int CmdKeriDemod(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int CmdKeriRead(const char *Cmd) {
|
||||
lf_read(false, 10000);
|
||||
return CmdKeriDemod(Cmd);
|
||||
@@ -382,7 +389,3 @@ int detectKeri(uint8_t *dest, size_t *size, bool *invert) {
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
int demodKeri(void) {
|
||||
return CmdKeriDemod("");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// by marshmellow
|
||||
// by danshuk
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
@@ -9,20 +11,19 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "cmdlfpac.h"
|
||||
|
||||
#include <ctype.h> //tolower
|
||||
#include <ctype.h> // tolower
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "common.h"
|
||||
#include "cmdparser.h" // command_t
|
||||
#include "cmdparser.h" // command_t
|
||||
#include "comms.h"
|
||||
#include "ui.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
#include "lfdemod.h" // preamble test
|
||||
#include "protocols.h" // t55xx defines
|
||||
#include "cmdlft55xx.h" // clone..
|
||||
#include "cmdlft55xx.h" // clone
|
||||
#include "parity.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
@@ -54,7 +55,7 @@ static int usage_lf_pac_sim(void) {
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf pac sim 12345678"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
// by danshuk
|
||||
|
||||
// PAC_8byte format: preamble (8 mark/idle bits), ascii STX (02), ascii '2' (32), ascii '0' (30), ascii bytes 0..7 (cardid), then xor checksum of cardid bytes
|
||||
// all bytes following 8 bit preamble are one start bit (0), 7 data bits (lsb first), odd parity bit, and one stop bit (1)
|
||||
static int demodbuf_to_pacid(uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_size) {
|
||||
@@ -85,7 +86,9 @@ static int demodbuf_to_pacid(uint8_t *src, const size_t src_size, uint8_t *dst,
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - PAC: Bad checksum - expected: %02X, actual: %02X", dst[dataLength - 1], checksum);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
dst[dataLength - 1] = 0; // overwrite checksum byte with null terminator
|
||||
|
||||
// overwrite checksum byte with null terminator
|
||||
dst[dataLength - 1] = 0;
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -142,9 +145,13 @@ static void pacCardIdToRaw(uint8_t *outRawBytes, const char *cardId) {
|
||||
|
||||
//see NRZDemod for what args are accepted
|
||||
static int CmdPacDemod(const char *Cmd) {
|
||||
(void)Cmd;
|
||||
return demodPac();
|
||||
}
|
||||
|
||||
int demodPac(void) {
|
||||
//NRZ
|
||||
if (NRZrawDemod(Cmd, false) != PM3_SUCCESS) {
|
||||
if (NRZrawDemod("", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - PAC: NRZ Demod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
@@ -307,7 +314,6 @@ int CmdLFPac(const char *Cmd) {
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
// by marshmellow
|
||||
// find PAC preamble in already demoded data
|
||||
int detectPac(uint8_t *dest, size_t *size) {
|
||||
if (*size < 128) return -1; //make sure buffer has data
|
||||
@@ -320,7 +326,4 @@ int detectPac(uint8_t *dest, size_t *size) {
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
int demodPac(void) {
|
||||
return CmdPacDemod("");
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ int demodParadox(void) {
|
||||
uint8_t error = 0;
|
||||
|
||||
// Remove manchester encoding from FSK bits, skip pre
|
||||
for (uint8_t i = idx + PARADOX_PREAMBLE_LEN; i < (idx + 96 - PARADOX_PREAMBLE_LEN ); i += 2) {
|
||||
for (uint8_t i = idx + PARADOX_PREAMBLE_LEN; i < (idx + 96); i += 2) {
|
||||
|
||||
// not manchester data
|
||||
if (bits[i] == bits[i + 1]) {
|
||||
|
||||
@@ -1345,17 +1345,25 @@ bool testKnownConfigBlock(uint32_t block0) {
|
||||
case T55X7_RAW_CONFIG_BLOCK:
|
||||
case T55X7_EM_UNIQUE_CONFIG_BLOCK:
|
||||
case T55X7_FDXB_CONFIG_BLOCK:
|
||||
case T55X7_FDXB_2_CONFIG_BLOCK:
|
||||
case T55X7_HID_26_CONFIG_BLOCK:
|
||||
case T55X7_PYRAMID_CONFIG_BLOCK:
|
||||
case T55X7_INDALA_64_CONFIG_BLOCK:
|
||||
case T55X7_INDALA_224_CONFIG_BLOCK:
|
||||
case T55X7_GUARDPROXII_CONFIG_BLOCK:
|
||||
case T55X7_VIKING_CONFIG_BLOCK:
|
||||
case T55X7_NORALYS_CONFIG_BLOCK:
|
||||
case T55X7_NORALSY_CONFIG_BLOCK:
|
||||
case T55X7_IOPROX_CONFIG_BLOCK:
|
||||
case T55X7_PRESCO_CONFIG_BLOCK:
|
||||
case T55X7_NEDAP_64_CONFIG_BLOCK:
|
||||
case T55X7_NEDAP_128_CONFIG_BLOCK:
|
||||
case T55X7_VISA2000_CONFIG_BLOCK:
|
||||
case T55X7_SECURAKEY_CONFIG_BLOCK:
|
||||
case T55X7_PAC_CONFIG_BLOCK:
|
||||
case T55X7_VERICHIP_CONFIG_BLOCK:
|
||||
case T55X7_KERI_CONFIG_BLOCK:
|
||||
case T55X7_NEXWATCH_CONFIG_BLOCK:
|
||||
case T55X7_JABLOTRON_CONFIG_BLOCK:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -2044,17 +2052,18 @@ static void printT5x7KnownBlock0(uint32_t b0) {
|
||||
case T55X7_EM_UNIQUE_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "EM unique, Paxton ");
|
||||
break;
|
||||
case T55X7_FDXB_2_CONFIG_BLOCK:
|
||||
case T55X7_FDXB_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "FDXB ");
|
||||
break;
|
||||
case T55X7_HID_26_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "HID 26b (ProxCard) ");
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "HID 26b (ProxCard), Paradox, AWID ");
|
||||
break;
|
||||
case T55X7_PYRAMID_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Pyramid ");
|
||||
break;
|
||||
case T55X7_INDALA_64_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 64");
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 64, Motorola");
|
||||
break;
|
||||
case T55X7_INDALA_224_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 224 ");
|
||||
@@ -2065,7 +2074,7 @@ static void printT5x7KnownBlock0(uint32_t b0) {
|
||||
case T55X7_VIKING_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Viking ");
|
||||
break;
|
||||
case T55X7_NORALYS_CONFIG_BLOCK:
|
||||
case T55X7_NORALSY_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Noralys ");
|
||||
break;
|
||||
case T55X7_IOPROX_CONFIG_BLOCK:
|
||||
@@ -2080,12 +2089,33 @@ static void printT5x7KnownBlock0(uint32_t b0) {
|
||||
case T55X7_NEDAP_128_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Nedap 128 ");
|
||||
break;
|
||||
case T55X7_PAC_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "PAC/Stanley ");
|
||||
break;
|
||||
case T55X7_VERICHIP_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Verichip ");
|
||||
break;
|
||||
case T55X7_VISA2000_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "VISA2000 ");
|
||||
break;
|
||||
case T55X7_JABLOTRON_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Jablotron ");
|
||||
break;
|
||||
case T55X7_KERI_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "KERI ");
|
||||
break;
|
||||
case T55X7_SECURAKEY_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "SecuraKey ");
|
||||
break;
|
||||
case T55X7_NEXWATCH_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "NexWatch, Quadrakey ");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen(s) > 0)
|
||||
PrintAndLogEx(NORMAL, "\n Config block match : " _YELLOW_("%s"), s);
|
||||
PrintAndLogEx(SUCCESS, "\nConfig block match : " _YELLOW_("%s"), s);
|
||||
}
|
||||
|
||||
static int CmdT55xxInfo(const char *Cmd) {
|
||||
@@ -2224,11 +2254,11 @@ static int CmdT55xxInfo(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, " POR-Delay : %s", (por) ? _GREEN_("Yes") : "No");
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(NORMAL, " Raw Data - Page 0");
|
||||
PrintAndLogEx(NORMAL, " Raw Data - Page 0, block 0");
|
||||
if (gotdata)
|
||||
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X", block0);
|
||||
PrintAndLogEx(NORMAL, " 0x" _GREEN_("%08X"), block0);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X %s", block0, sprint_bin(DemodBuffer + config.offset, 32));
|
||||
PrintAndLogEx(NORMAL, " 0x" _GREEN_("%08X") " %s", block0, sprint_bin(DemodBuffer + config.offset, 32));
|
||||
|
||||
if (((!gotdata) && (!config.Q5)) || (gotdata && (!dataasq5)))
|
||||
printT5x7KnownBlock0(block0);
|
||||
|
||||
@@ -25,28 +25,45 @@
|
||||
// config blocks
|
||||
#define T55X7_DEFAULT_CONFIG_BLOCK 0x000880E8 // ASK, compat mode, data rate 32, manchester, STT, 7 data blocks
|
||||
#define T55X7_RAW_CONFIG_BLOCK 0x000880E0 // ASK, compat mode, data rate 32, manchester, 7 data blocks
|
||||
#define T55X7_EM_UNIQUE_CONFIG_BLOCK 0x00148040 // ASK, emulate em4x02/unique - compat mode, manchester, data rate 64, 2 data blocks
|
||||
#define T55X7_EM_PAXTON_CONFIG_BLOCK 0x00148040 // ASK, emulate em4x02/paxton - compat mode, manchester, data rate 64, 2 data blocks
|
||||
#define T55X7_EM_UNIQUE_CONFIG_BLOCK 0x00148040 // ASK, EM4x02/unique - compat mode, manchester, data rate 64, 2 data blocks
|
||||
#define T55X7_EM_PAXTON_CONFIG_BLOCK 0x00148040 // ASK, EM4x02/paxton - compat mode, manchester, data rate 64, 2 data blocks
|
||||
#define T55X7_VISA2000_CONFIG_BLOCK 0x00148068 // ASK, data rate 64, 3 data blocks, STT
|
||||
#define T55X7_VIKING_CONFIG_BLOCK 0x00088040 // ASK, compat mode, data rate 32, Manchester, 2 data blocks
|
||||
#define T55X7_NORALSY_CONFIG_BLOCK 0x00088C6A // ASK, compat mode, (NORALSY - KCP3000), data rate 32, 3 data blocks
|
||||
#define T55X7_PRESCO_CONFIG_BLOCK 0x00088088 // ASK, data rate 32, Manchester, 4 data blocks, STT
|
||||
#define T55X7_SECURAKEY_CONFIG_BLOCK 0x000C8060 // ASK, Manchester, data rate 40, 3 data blocks
|
||||
|
||||
// FDXB requires data inversion and BiPhase 57 is simply BiPhase 50 inverted, so we can either do it using the modulation scheme or the inversion flag
|
||||
// we've done both below to prove that it works either way, and the modulation value for BiPhase 50 in the Atmel data sheet of binary "10001" (17) is a typo,
|
||||
// and it should actually be "10000" (16)
|
||||
// #define T55X7_FDXB_CONFIG_BLOCK 0x903F8080 // emulate fdx-b - xtended mode, BiPhase ('57), data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_CONFIG_BLOCK 0x903F0082 // emulate fdx-b - xtended mode, BiPhase ('50), invert data, data rate 32, 4 data blocks
|
||||
#define T55X7_HID_26_CONFIG_BLOCK 0x00107060 // hid 26 bit - compat mode, FSK2a, data rate 50, 3 data blocks
|
||||
#define T55X7_PYRAMID_CONFIG_BLOCK 0x00107080 // Pyramid 26 bit - compat mode, FSK2a, data rate 50, 4 data blocks
|
||||
#define T55X7_INDALA_64_CONFIG_BLOCK 0x00081040 // emulate indala 64 bit - compat mode, PSK1, psk carrier FC * 2, data rate 32, maxblock 2
|
||||
#define T55X7_INDALA_224_CONFIG_BLOCK 0x000810E0 // emulate indala 224 bit - compat mode, PSK1, psk carrier FC * 2, data rate 32, maxblock 7
|
||||
#define T55X7_GUARDPROXII_CONFIG_BLOCK 0x00150060 // bitrate 64pcb, Direct modulation, Biphase, 3 data blocks
|
||||
#define T55X7_VIKING_CONFIG_BLOCK 0x00088040 // ASK, compat mode, data rate 32, Manchester, 2 data blocks
|
||||
#define T55X7_NORALYS_CONFIG_BLOCK 0x00088C6A // ASK, compat mode, (NORALYS - KCP3000), 3 data blocks
|
||||
#define T55X7_IOPROX_CONFIG_BLOCK 0x00147040 // ioprox - FSK2a, data rate 64, 2 data blocks
|
||||
#define T55X7_PRESCO_CONFIG_BLOCK 0x00088088 // ASK, data rate 32, Manchester, 4 data blocks, STT
|
||||
#define T55X7_NEDAP_64_CONFIG_BLOCK 0x907f0042 // BiPhase, data rate 64, 2 data blocks
|
||||
#define T55X7_NEDAP_128_CONFIG_BLOCK 0x907f0082 // BiPhase, data rate 64, 4 data blocks
|
||||
// #define T55X7_FDXB_CONFIG_BLOCK 0x903F8080 // BiPhase, fdx-b - xtended mode, BiPhase ('57), data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_CONFIG_BLOCK 0x903F0082 // BiPhase, fdx-b - xtended mode, BiPhase ('50), invert data, data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_2_CONFIG_BLOCK 0x00098080 //
|
||||
|
||||
#define T55X7_HID_26_CONFIG_BLOCK 0x00107060 // FSK2a, hid 26 bit - compat mode, data rate 50, 3 data blocks
|
||||
#define T55X7_PARADOX_CONFIG_BLOCK 0x00107060 // FSK2a, hid 26 bit - compat mode, data rate 50, 3 data blocks
|
||||
#define T55X7_AWID_CONFIG_BLOCK 0x00107060 // FSK2a, hid 26 bit - compat mode, data rate 50, 3 data blocks
|
||||
#define T55X7_PYRAMID_CONFIG_BLOCK 0x00107080 // FSK2a, Pyramid 26 bit - compat mode, data rate 50, 4 data blocks
|
||||
#define T55X7_IOPROX_CONFIG_BLOCK 0x00147040 // FSK2a, data rate 64, 2 data blocks
|
||||
|
||||
#define T55X7_INDALA_64_CONFIG_BLOCK 0x00081040 // PSK1, indala 64 bit - compat mode, psk carrier FC * 2, data rate 32, maxblock 2
|
||||
#define T55X7_INDALA_224_CONFIG_BLOCK 0x000810E0 // PSK1, indala 224 bit - compat mode, psk carrier FC * 2, data rate 32, maxblock 7
|
||||
#define T55X7_MOTOROLA_CONFIG_BLOCK 0x00081040 // PSK1, data rate 32, 2 data blocks
|
||||
#define T55X7_NEXWATCH_CONFIG_BLOCK 0x00081060 // PSK1 data rate 16, psk carrier FC * 2, 3 data blocks
|
||||
#define T55X7_KERI_CONFIG_BLOCK 0x603E1040 // PSK1, 2 data blocks
|
||||
|
||||
#define T55X7_JABLOTRON_CONFIG_BLOCK 0x00158040 // Biphase, data rate 64, 2 data blocks
|
||||
#define T55X7_GUARDPROXII_CONFIG_BLOCK 0x00150060 // Biphase, data rate 64, Direct modulation, 3 data blocks
|
||||
#define T55X7_NEDAP_64_CONFIG_BLOCK 0x907f0042 // BiPhase, data rate 64, 2 data blocks
|
||||
#define T55X7_NEDAP_128_CONFIG_BLOCK 0x907f0082 // BiPhase, data rate 64, 4 data blocks
|
||||
|
||||
#define T55X7_PAC_CONFIG_BLOCK 0x00080080 // NRZ, data rate 32, 4 data blocks
|
||||
#define T55X7_VERICHIP_CONFIG_BLOCK 0x000C0080 // NRZ, data rate 40, 4 data blocks
|
||||
#define T55X7_bin 0b0010
|
||||
|
||||
#define T5555_DEFAULT_CONFIG_BLOCK 0x6001F004 // data rate 64 , ask, manchester, 2 data blocks?
|
||||
// Q5 / Termic / T5555
|
||||
#define T5555_DEFAULT_CONFIG_BLOCK 0x6001F004 // ASK, data rate 64, manchester, 2 data blocks?
|
||||
|
||||
typedef enum {
|
||||
T55x7_RAW = 0x00,
|
||||
T55x7_DEFAULT = 0x00,
|
||||
|
||||
@@ -39,9 +39,13 @@ static int usage_lf_verichip_clone(void) {
|
||||
|
||||
//see NRZDemod for what args are accepted
|
||||
static int CmdVerichipDemod(const char *Cmd) {
|
||||
(void)Cmd;
|
||||
return demodVerichip();
|
||||
}
|
||||
|
||||
int demodVerichip(void) {
|
||||
//NRZ
|
||||
if (NRZrawDemod(Cmd, false) != PM3_SUCCESS) {
|
||||
if (NRZrawDemod("", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - VERICHIP: NRZ Demod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
@@ -154,20 +158,15 @@ int CmdLFVerichip(const char *Cmd) {
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
// by marshmellow
|
||||
// find PAC preamble in already demoded data
|
||||
// find VERICHIP preamble in already demoded data
|
||||
int detectVerichip(uint8_t *dest, size_t *size) {
|
||||
if (*size < 128) return -1; //make sure buffer has data
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -2; //preamble not found
|
||||
if (*size != 128) return -3; //wrong demoded size
|
||||
if (*size < 128) return -3; //wrong demoded size
|
||||
//return start position
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
int demodVerichip(void) {
|
||||
return CmdVerichipDemod("");
|
||||
}
|
||||
|
||||
@@ -128,24 +128,17 @@ uint64_t x_bytes_to_num(uint8_t *src, size_t len) {
|
||||
return num;
|
||||
}
|
||||
|
||||
uint8_t reversebytes(uint8_t b) {
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
return b;
|
||||
}
|
||||
|
||||
void reverse_arraybytes(uint8_t *arr, size_t len) {
|
||||
uint8_t i;
|
||||
for (i = 0; i < len ; i++) {
|
||||
arr[i] = reversebytes(arr[i]);
|
||||
arr[i] = reflect8(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void reverse_arraycopy(uint8_t *arr, uint8_t *dest, size_t len) {
|
||||
uint8_t i;
|
||||
for (i = 0; i < len ; i++) {
|
||||
dest[i] = reversebytes(arr[i]);
|
||||
dest[i] = reflect8(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -727,6 +727,10 @@ static bool DetectWindowsAnsiSupport(void) {
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
||||
#endif
|
||||
|
||||
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD dwMode = 0;
|
||||
GetConsoleMode(hOut, &dwMode);
|
||||
|
||||
@@ -791,15 +791,6 @@ uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bits) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
uint8_t pw_rev_A(uint8_t b) {
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
return b;
|
||||
}
|
||||
*/
|
||||
|
||||
uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor) {
|
||||
uint64_t remaind = 0, quotient = 0, result = 0;
|
||||
remaind = num % divider;
|
||||
|
||||
@@ -54,9 +54,12 @@ void print_blocks(uint32_t *data, size_t len);
|
||||
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen);
|
||||
void num_to_bytebits(uint64_t n, size_t len, uint8_t *dest);
|
||||
void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest);
|
||||
|
||||
// Swap endian on arrays up to 64bytes.
|
||||
uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize);
|
||||
void SwapEndian64ex(const uint8_t *src, const size_t len, const uint8_t blockSize, uint8_t *dest);
|
||||
|
||||
// parameter helper functions
|
||||
int param_getlength(const char *line, int paramnum);
|
||||
char param_getchar(const char *line, int paramnum);
|
||||
char param_getchar_indx(const char *line, int indx, int paramnum);
|
||||
|
||||
Reference in New Issue
Block a user