Merge branch 'master' of github.com:merlokk/proxmark3i into emv_vsdc
This commit is contained in:
commit
bebfcab7b9
84 files changed
+3694
-923
No files matched your search
+8
-8
@@ -299,29 +299,29 @@ lualibs/mf_default_keys.lua : default_keys.dic
|
||||
|
||||
clean:
|
||||
$(RM) $(CLEAN)
|
||||
cd ../liblua && make clean
|
||||
cd $(JANSSONLIBPATH) && make clean
|
||||
cd $(MBEDTLSLIBPATH) && make clean
|
||||
cd $(CBORLIBPATH) && make clean
|
||||
cd ../liblua && $(MAKE) clean
|
||||
cd $(JANSSONLIBPATH) && $(MAKE) clean
|
||||
cd $(MBEDTLSLIBPATH) && $(MAKE) clean
|
||||
cd $(CBORLIBPATH) && $(MAKE) clean
|
||||
|
||||
tarbin: $(BINS)
|
||||
$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
|
||||
|
||||
lua_build:
|
||||
@echo Compiling liblua, using platform $(LUAPLATFORM)
|
||||
cd ../liblua && make $(LUAPLATFORM)
|
||||
cd ../liblua && $(MAKE) $(LUAPLATFORM)
|
||||
|
||||
jansson_build:
|
||||
@echo Compiling jansson
|
||||
cd $(JANSSONLIBPATH) && make all
|
||||
cd $(JANSSONLIBPATH) && $(MAKE) all
|
||||
|
||||
mbedtls_build:
|
||||
@echo Compiling mbedtls
|
||||
cd $(MBEDTLSLIBPATH) && make all
|
||||
cd $(MBEDTLSLIBPATH) && $(MAKE) all
|
||||
|
||||
cbor_build:
|
||||
@echo Compiling tinycbor
|
||||
cd $(CBORLIBPATH) && make all
|
||||
cd $(CBORLIBPATH) && $(MAKE) all
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
||||
+1
-1
@@ -1786,7 +1786,7 @@ int Cmdbin2hex(const char *Cmd) {
|
||||
//Number of digits supplied as argument
|
||||
size_t length = en - bg + 1;
|
||||
size_t bytelen = (length+7) / 8;
|
||||
uint8_t* arr = (uint8_t *) malloc(bytelen);
|
||||
uint8_t* arr = (uint8_t *) calloc(bytelen, sizeof(uint8_t));
|
||||
memset(arr, 0, bytelen);
|
||||
BitstreamOut bout = { arr, 0, 0 };
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Proxmark3 RDV40 Flash memory commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef WITH_FLASH
|
||||
|
||||
#include "cmdflashmem.h"
|
||||
|
||||
#include "mbedtls/rsa.h"
|
||||
@@ -604,3 +606,5 @@ int CmdHelp(const char *Cmd) {
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,8 @@
|
||||
// Proxmark3 RDV40 Flash memory commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef WITH_FLASH
|
||||
|
||||
#ifndef CMDFLASHMEM_H__
|
||||
#define CMDFLASHMEM_H__
|
||||
|
||||
@@ -38,4 +40,6 @@ extern int CmdFlashMemLoad(const char* cmd);
|
||||
extern int CmdFlashMemSave(const char* cmd);
|
||||
extern int CmdFlashMemWipe(const char *Cmd);
|
||||
extern int CmdFlashMemInfo(const char *Cmd);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+180
-30
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>, Hagen Fritsch
|
||||
// 2011, 2017 Merlok
|
||||
// 2011, 2017 - 2019 Merlok
|
||||
// 2014, Peter Fillmore
|
||||
// 2015, 2016, 2017 Iceman
|
||||
//
|
||||
@@ -12,6 +12,8 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "cmdhf14a.h"
|
||||
|
||||
bool APDUInFramingEnable = true;
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static int waitCmd(uint8_t iLen);
|
||||
|
||||
@@ -147,6 +149,10 @@ char* getTagInfo(uint8_t uid) {
|
||||
return manufactureMapping[len-1].desc;
|
||||
}
|
||||
|
||||
// iso14a apdu input frame length
|
||||
static uint16_t frameLength = 0;
|
||||
uint16_t atsFSC[] = {16, 24, 32, 40, 48, 64, 96, 128, 256};
|
||||
|
||||
int usage_hf_14a_sim(void) {
|
||||
// PrintAndLogEx(NORMAL, "\n Emulating ISO/IEC 14443 type A tag with 4,7 or 10 byte UID\n");
|
||||
PrintAndLogEx(NORMAL, "\n Emulating ISO/IEC 14443 type A tag with 4,7 byte UID\n");
|
||||
@@ -486,10 +492,7 @@ int CmdHF14AInfo(const char *Cmd) {
|
||||
(tb1 ? "" : " NOT"),
|
||||
(tc1 ? "" : " NOT"),
|
||||
fsci,
|
||||
fsci < 5 ? (fsci - 2) * 8 :
|
||||
fsci < 8 ? (fsci - 3) * 32 :
|
||||
fsci == 8 ? 256 :
|
||||
-1
|
||||
fsci < sizeof(atsFSC) ? atsFSC[fsci] : -1
|
||||
);
|
||||
}
|
||||
pos = 2;
|
||||
@@ -836,15 +839,90 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdExchangeAPDU(uint8_t *datain, int datainlen, bool activateField, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, bool *chaining) {
|
||||
uint16_t cmdc = 0;
|
||||
int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
||||
UsbCommand resp;
|
||||
|
||||
*chaining = false;
|
||||
frameLength = 0;
|
||||
|
||||
if (card)
|
||||
memset(card, 0, sizeof(iso14a_card_select_t));
|
||||
|
||||
if (activateField) {
|
||||
cmdc |= ISO14A_CONNECT;
|
||||
DropField();
|
||||
|
||||
// Anticollision + SELECT card
|
||||
UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}};
|
||||
SendCommand(&ca);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "Proxmark connection timeout.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check result
|
||||
if (resp.arg[0] == 0) {
|
||||
PrintAndLogEx(ERR, "No card in field.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] != 1 && resp.arg[0] != 2) {
|
||||
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.arg[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
// get ATS
|
||||
UsbCommand cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
memcpy(cr.d.asBytes, rats, 2);
|
||||
SendCommand(&cr);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "Proxmark connection timeout.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] <= 0) { // ats_len
|
||||
PrintAndLogEx(ERR, "Can't get ATS.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get frame length from ATS in data field
|
||||
if (resp.arg[0] > 1) {
|
||||
uint8_t fsci = resp.d.asBytes[1] & 0x0f;
|
||||
if (fsci < sizeof(atsFSC))
|
||||
frameLength = atsFSC[fsci];
|
||||
}
|
||||
} else {
|
||||
// get frame length from ATS in card data structure
|
||||
iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.d.asBytes;
|
||||
if (vcard->ats_len > 1) {
|
||||
uint8_t fsci = vcard->ats[1] & 0x0f;
|
||||
if (fsci < sizeof(atsFSC))
|
||||
frameLength = atsFSC[fsci];
|
||||
}
|
||||
|
||||
if (card)
|
||||
memcpy(card, vcard, sizeof(iso14a_card_select_t));
|
||||
}
|
||||
|
||||
if (disconnect)
|
||||
DropField();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool activateField, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, bool *chainingout) {
|
||||
*chainingout = false;
|
||||
|
||||
if (activateField) {
|
||||
// select with no disconnect and set frameLength
|
||||
int selres = SelectCard14443_4(false, NULL);
|
||||
if (selres)
|
||||
return selres;
|
||||
}
|
||||
|
||||
uint16_t cmdc = 0;
|
||||
if (chainingin)
|
||||
cmdc = ISO14A_SEND_CHAINING;
|
||||
|
||||
// "Command APDU" length should be 5+255+1, but javacard's APDU buffer might be smaller - 133 bytes
|
||||
// https://stackoverflow.com/questions/32994936/safe-max-java-card-apdu-data-command-and-respond-size
|
||||
// here length USB_CMD_DATA_SIZE=512
|
||||
@@ -856,18 +934,6 @@ int CmdExchangeAPDU(uint8_t *datain, int datainlen, bool activateField, uint8_t
|
||||
uint8_t *recv;
|
||||
UsbCommand resp;
|
||||
|
||||
if (activateField) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "APDU: Proxmark connection timeout.");
|
||||
return 1;
|
||||
}
|
||||
if (resp.arg[0] != 1) {
|
||||
PrintAndLogEx(ERR, "APDU: Proxmark error %d.", resp.arg[0]);
|
||||
DropField();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
recv = resp.d.asBytes;
|
||||
int iLen = resp.arg[0];
|
||||
@@ -883,13 +949,20 @@ int CmdExchangeAPDU(uint8_t *datain, int datainlen, bool activateField, uint8_t
|
||||
return 2;
|
||||
}
|
||||
|
||||
// I-block ACK
|
||||
if ((res & 0xf2) == 0xa2) {
|
||||
*dataoutlen = 0;
|
||||
*chainingout = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!iLen) {
|
||||
PrintAndLogEx(ERR, "APDU: No APDU response.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check apdu length
|
||||
if (iLen < 4 && iLen >= 0) {
|
||||
if (iLen < 2 && iLen >= 0) {
|
||||
PrintAndLogEx(ERR, "APDU: Small APDU response. Len=%d", iLen);
|
||||
return 2;
|
||||
}
|
||||
@@ -904,7 +977,7 @@ int CmdExchangeAPDU(uint8_t *datain, int datainlen, bool activateField, uint8_t
|
||||
|
||||
// chaining
|
||||
if ((res & 0x10) != 0) {
|
||||
*chaining = true;
|
||||
*chainingout = true;
|
||||
}
|
||||
|
||||
// CRC Check
|
||||
@@ -923,12 +996,57 @@ int CmdExchangeAPDU(uint8_t *datain, int datainlen, bool activateField, uint8_t
|
||||
int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen) {
|
||||
*dataoutlen = 0;
|
||||
bool chaining = false;
|
||||
|
||||
int res = CmdExchangeAPDU(datain, datainlen, activateField, dataout, maxdataoutlen, dataoutlen, &chaining);
|
||||
int res;
|
||||
|
||||
// 3 byte here - 1b framing header, 2b crc16
|
||||
if (APDUInFramingEnable &&
|
||||
( (frameLength && (datainlen > frameLength - 3)) || (datainlen > USB_CMD_DATA_SIZE - 3)) ) {
|
||||
int clen = 0;
|
||||
|
||||
bool vActivateField = activateField;
|
||||
|
||||
do {
|
||||
int vlen = MIN(frameLength - 3, datainlen - clen);
|
||||
bool chainBlockNotLast = ((clen + vlen) < datainlen);
|
||||
|
||||
*dataoutlen = 0;
|
||||
res = CmdExchangeAPDU(chainBlockNotLast, &datain[clen], vlen, vActivateField, dataout, maxdataoutlen, dataoutlen, &chaining);
|
||||
if (res) {
|
||||
if (!leaveSignalON)
|
||||
DropField();
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
// check R-block ACK
|
||||
if ((*dataoutlen == 0) && (*dataoutlen != 0 || chaining != chainBlockNotLast)) {
|
||||
if (!leaveSignalON)
|
||||
DropField();
|
||||
|
||||
return 201;
|
||||
}
|
||||
|
||||
clen += vlen;
|
||||
vActivateField = false;
|
||||
if (*dataoutlen) {
|
||||
if (clen != datainlen)
|
||||
PrintAndLogEx(WARNING, "APDU: I-block/R-block sequence error. Data len=%d, Sent=%d, Last packet len=%d", datainlen, clen, *dataoutlen);
|
||||
break;
|
||||
}
|
||||
} while (clen < datainlen);
|
||||
} else {
|
||||
res = CmdExchangeAPDU(false, datain, datainlen, activateField, dataout, maxdataoutlen, dataoutlen, &chaining);
|
||||
if (res) {
|
||||
if (!leaveSignalON)
|
||||
DropField();
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
while (chaining) {
|
||||
// I-block with chaining
|
||||
res = CmdExchangeAPDU(NULL, 0, false, &dataout[*dataoutlen], maxdataoutlen, dataoutlen, &chaining);
|
||||
res = CmdExchangeAPDU(false, NULL, 0, false, &dataout[*dataoutlen], maxdataoutlen, dataoutlen, &chaining);
|
||||
|
||||
if (res) {
|
||||
if (!leaveSignalON)
|
||||
@@ -1205,16 +1323,48 @@ int CmdHF14AAntiFuzz(const char *cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHF14AChaining(const char *cmd) {
|
||||
|
||||
CLIParserInit("hf 14a chaining",
|
||||
"Enable/Disable ISO14443a input chaining. Maximum input length goes from ATS.",
|
||||
"Usage:\n"
|
||||
"\thf 14a chaining disable -> disable chaining\n"
|
||||
"\thf 14a chaining -> show chaining enable/disable state\n");
|
||||
|
||||
void* argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str0(NULL, NULL, "<enable/disable or 0/1>", NULL),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(cmd, argtable, true);
|
||||
|
||||
struct arg_str *str = arg_get_str(1);
|
||||
int len = arg_get_str_len(1);
|
||||
|
||||
if (len && (!strcmp(str->sval[0], "enable") || !strcmp(str->sval[0], "1")))
|
||||
APDUInFramingEnable = true;
|
||||
|
||||
if (len && (!strcmp(str->sval[0], "disable") || !strcmp(str->sval[0], "0")))
|
||||
APDUInFramingEnable = false;
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
PrintAndLogEx(INFO, "\nISO 14443-4 input chaining %s.\n", APDUInFramingEnable ? "enabled" : "disabled");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"list", CmdHF14AList, 0, "[Deprecated] List ISO 14443-a history"},
|
||||
{"info", CmdHF14AInfo, 0, "Tag information"},
|
||||
{"reader", CmdHF14AReader, 0, "Act like an ISO14443-a reader"},
|
||||
{"reader", CmdHF14AReader, 0, "Act like an ISO14443-a reader"},
|
||||
{"cuids", CmdHF14ACUIDs, 0, "<n> Collect n>0 ISO14443-a UIDs in one go"},
|
||||
{"sim", CmdHF14ASim, 0, "<UID> -- Simulate ISO 14443-a tag"},
|
||||
{"sim", CmdHF14ASim, 0, "<UID> -- Simulate ISO 14443-a tag"},
|
||||
{"sniff", CmdHF14ASniff, 0, "sniff ISO 14443-a traffic"},
|
||||
{"apdu", CmdHF14AAPDU, 0, "Send ISO 14443-4 APDU to tag"},
|
||||
{"raw", CmdHF14ACmdRaw, 0, "Send raw hex data to tag"},
|
||||
{"chaining", CmdHF14AChaining, 0, "Control ISO 14443-4 input chaining"},
|
||||
{"raw", CmdHF14ACmdRaw, 0, "Send raw hex data to tag"},
|
||||
{"antifuzz", CmdHF14AAntiFuzz, 0, "Fuzzing the anticollision phase. Warning! Readers may react strange"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
+46
-42
@@ -519,21 +519,21 @@ int CmdHF15Info(const char *Cmd) {
|
||||
SendCommand(&c);
|
||||
|
||||
if ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) {
|
||||
PrintAndLogEx(NORMAL, "iso15693 card select failed");
|
||||
PrintAndLogEx(WARNING, "iso15693 card select failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t status = resp.arg[0];
|
||||
|
||||
if ( status < 2 ) {
|
||||
PrintAndLogEx(NORMAL, "iso15693 card doesn't answer to systeminfo command");
|
||||
PrintAndLogEx(WARNING, "iso15693 card doesn't answer to systeminfo command");
|
||||
return 1;
|
||||
}
|
||||
|
||||
recv = resp.d.asBytes;
|
||||
|
||||
if ( recv[0] & ISO15_RES_ERROR ) {
|
||||
PrintAndLogEx(NORMAL, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
PrintAndLogEx(WARNING, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -575,8 +575,8 @@ int CmdHF15Info(const char *Cmd) {
|
||||
// Record Activity without enabeling carrier
|
||||
//helptext
|
||||
int CmdHF15Record(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (cmdp == 'h' || cmdp == 'H') return usage_15_record();
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_15_record();
|
||||
|
||||
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693, {0,0,0}};
|
||||
clearCommandBuffer();
|
||||
@@ -598,8 +598,8 @@ int HF15Reader(const char *Cmd, bool verbose) {
|
||||
}
|
||||
|
||||
int CmdHF15Reader(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (cmdp == 'h' || cmdp == 'H') return usage_15_reader();
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_15_reader();
|
||||
|
||||
HF15Reader(Cmd, true);
|
||||
return 0;
|
||||
@@ -608,16 +608,16 @@ int CmdHF15Reader(const char *Cmd) {
|
||||
// Simulation is still not working very good
|
||||
// helptext
|
||||
int CmdHF15Sim(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') return usage_15_sim();
|
||||
char cmdp =tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 1 || cmdp == 'h') return usage_15_sim();
|
||||
|
||||
uint8_t uid[8] = {0,0,0,0,0,0,0,0};
|
||||
if (param_gethex(Cmd, 0, uid, 16)) {
|
||||
PrintAndLogEx(NORMAL, "UID must include 16 HEX symbols");
|
||||
PrintAndLogEx(WARNING, "UID must include 16 HEX symbols");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Starting simulating UID %s", sprint_hex(uid, sizeof(uid)) );
|
||||
PrintAndLogEx(SUCCESS, "Starting simulating UID %s", sprint_hex(uid, sizeof(uid)) );
|
||||
|
||||
UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}};
|
||||
memcpy(c.d.asBytes, uid, 8);
|
||||
@@ -630,10 +630,10 @@ int CmdHF15Sim(const char *Cmd) {
|
||||
// (There is no standard way of reading the AFI, allthough some tags support this)
|
||||
// helptext
|
||||
int CmdHF15Afi(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (cmdp == 'h' || cmdp == 'H') return usage_15_findafi();
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_15_findafi();
|
||||
|
||||
PrintAndLogEx(NORMAL, "press pm3-button to cancel");
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button to cancel");
|
||||
|
||||
UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}};
|
||||
clearCommandBuffer();
|
||||
@@ -689,7 +689,7 @@ int CmdHF15Dump(const char*Cmd) {
|
||||
}
|
||||
// detect blocksize from card :)
|
||||
|
||||
PrintAndLogEx(NORMAL, "Reading memory from tag UID %s", sprintUID(NULL, uid));
|
||||
PrintAndLogEx(NORMAL, "Reading memory from tag UID " _YELLOW_(%s), sprintUID(NULL, uid));
|
||||
|
||||
int blocknum = 0;
|
||||
uint8_t *recv = NULL;
|
||||
@@ -764,7 +764,7 @@ int CmdHF15Dump(const char*Cmd) {
|
||||
}
|
||||
|
||||
int CmdHF15Restore(const char*Cmd) {
|
||||
FILE *file;
|
||||
FILE *f;
|
||||
|
||||
uint8_t uid[8]={0x00};
|
||||
char filename[FILE_PATH_SIZE] = {0x00};
|
||||
@@ -774,10 +774,10 @@ int CmdHF15Restore(const char*Cmd) {
|
||||
char newCmdPrefix[255] = {0x00}, tmpCmd[255] = {0x00};
|
||||
char param[FILE_PATH_SIZE]="";
|
||||
char hex[255]="";
|
||||
uint8_t retries = 3, tried = 0;
|
||||
uint8_t retries = 3, tried = 0, i = 0;
|
||||
int retval=0;
|
||||
size_t bytes_read;
|
||||
uint8_t i=0;
|
||||
|
||||
while(param_getchar(Cmd, cmdp) != 0x00) {
|
||||
switch(tolower(param_getchar(Cmd, cmdp))) {
|
||||
case '-':
|
||||
@@ -785,7 +785,8 @@ int CmdHF15Restore(const char*Cmd) {
|
||||
switch(param[1])
|
||||
{
|
||||
case '2':
|
||||
case 'o': strncpy(newCmdPrefix, " ",sizeof(newCmdPrefix)-1);
|
||||
case 'o':
|
||||
strncpy(newCmdPrefix, " ", sizeof(newCmdPrefix)-1);
|
||||
strncat(newCmdPrefix, param, sizeof(newCmdPrefix)-1);
|
||||
break;
|
||||
default:
|
||||
@@ -815,18 +816,18 @@ int CmdHF15Restore(const char*Cmd) {
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
return usage_15_restore();
|
||||
break;
|
||||
}
|
||||
cmdp++;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO,"Blocksize: %u",blocksize);
|
||||
if(filename[0]=='\0')
|
||||
{
|
||||
|
||||
if ( !strlen(filename)) {
|
||||
PrintAndLogEx(WARNING,"Please provide a filename");
|
||||
return 1;
|
||||
return usage_15_restore();
|
||||
}
|
||||
|
||||
if ((file = fopen(filename,"rb")) == NULL) {
|
||||
if ((f = fopen(filename, "rb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not find file %s", filename);
|
||||
return 2;
|
||||
}
|
||||
@@ -835,40 +836,43 @@ int CmdHF15Restore(const char*Cmd) {
|
||||
PrintAndLogEx(WARNING, "No tag found");
|
||||
return 3;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
tried=0;
|
||||
hex[0]=0x00;
|
||||
tmpCmd[0]=0x00;
|
||||
tried = 0;
|
||||
hex[0] = 0x00;
|
||||
tmpCmd[0] = 0x00;
|
||||
|
||||
bytes_read = fread( buff, 1, blocksize, file );
|
||||
bytes_read = fread( buff, 1, blocksize, f );
|
||||
if ( bytes_read == 0) {
|
||||
PrintAndLogEx(SUCCESS, "File reading done (%s).", filename);
|
||||
fclose(file);
|
||||
PrintAndLogEx(SUCCESS, "File reading done `%s`", filename);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
else if ( bytes_read != blocksize) {
|
||||
} else if ( bytes_read != blocksize) {
|
||||
PrintAndLogEx(WARNING, "File reading error (%s), %u bytes read instead of %u bytes.", filename, bytes_read, blocksize);
|
||||
fclose(file);
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
for(int j=0;j<blocksize;j++)
|
||||
snprintf(hex+j*2,3,"%02X", (unsigned char)buff[j]);
|
||||
for(int j=0;j<sizeof(uid)/sizeof(uid[0]);j++)
|
||||
|
||||
for(int j=0; j < blocksize; j++)
|
||||
snprintf(hex+j*2, 3, "%02X", buff[j]);
|
||||
|
||||
for(int j=0; j < sizeof(uid)/sizeof(uid[0]); j++)
|
||||
snprintf(buff+j*2,3,"%02X", uid[j]);
|
||||
|
||||
//TODO: Addressed mode currently not work
|
||||
//snprintf(tmpCmd, sizeof(tmpCmd), "%s %s %d %s", newCmdPrefix, buff, i, hex);
|
||||
snprintf(tmpCmd, sizeof(tmpCmd), "%s u %d %s", newCmdPrefix, i, hex);
|
||||
PrintAndLogEx(DEBUG, "Command to be sent: %s", tmpCmd);
|
||||
snprintf(tmpCmd, sizeof(tmpCmd), "%s u %u %s", newCmdPrefix, i, hex);
|
||||
PrintAndLogEx(DEBUG, "Command to be sent| %s", tmpCmd);
|
||||
|
||||
for(tried=0;tried<retries;tried++)
|
||||
if(!(retval=CmdHF15Write(tmpCmd)))
|
||||
for(tried=0; tried < retries; tried++)
|
||||
if(!(retval = CmdHF15Write(tmpCmd)))
|
||||
break;
|
||||
if(tried >= retries)
|
||||
return retval;
|
||||
|
||||
i++;
|
||||
}
|
||||
fclose(file);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int CmdHF15List(const char *Cmd) {
|
||||
@@ -1241,7 +1245,7 @@ int CmdHF15Write(const char *Cmd) {
|
||||
AddCrc(req, reqlen);
|
||||
c.arg[0] = reqlen+2;
|
||||
|
||||
PrintAndLogEx(NORMAL, "iso15693 writing to page %02d (0x&02X) | data ", pagenum, pagenum);
|
||||
PrintAndLogEx(NORMAL, "iso15693 writing to page %02d (0x%02X) | data ", pagenum, pagenum);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
||||
PrintAndLogEx(FAILED, "Error in step %d, Return code: %d",resp.arg[0],(int)resp.arg[1]);
|
||||
} else {
|
||||
size_t nonce_length = resp.arg[1];
|
||||
char *nonce = (char *) malloc(2 * nonce_length + 1);
|
||||
char *nonce = (char *) calloc(2 * nonce_length + 1, sizeof(uint8_t));
|
||||
for(int j = 0; j < nonce_length; j++) {
|
||||
sprintf(nonce + (2 * j), "%02X", resp.d.asBytes[j]);
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ int CmdHFiClassSim(const char *Cmd) {
|
||||
break;
|
||||
|
||||
size_t datalen = NUM_CSNS * 24;
|
||||
void* dump = malloc(datalen);
|
||||
void* dump = calloc(datalen, sizeof(uint8_t));
|
||||
if ( !dump ) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return 2;
|
||||
@@ -456,7 +456,7 @@ int CmdHFiClassSim(const char *Cmd) {
|
||||
break;
|
||||
|
||||
size_t datalen = NUM_CSNS * 24;
|
||||
void* dump = malloc(datalen);
|
||||
void* dump = calloc(datalen, sizeof(uint8_t));
|
||||
if ( !dump ) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return 2;
|
||||
@@ -2463,7 +2463,7 @@ static void shave(uint8_t *data, uint8_t len){
|
||||
data[i] &= 0xFE;
|
||||
}
|
||||
static void generate_rev(uint8_t *data, uint8_t len) {
|
||||
uint8_t *key = calloc(len,1);
|
||||
uint8_t *key = calloc(len, sizeof(uint8_t));
|
||||
PrintAndLogEx(SUCCESS, "input permuted key | %s \n", sprint_hex(data, len));
|
||||
permute_rev(data, len, key);
|
||||
PrintAndLogEx(SUCCESS, " unpermuted key | %s \n", sprint_hex(key, len));
|
||||
@@ -2472,8 +2472,8 @@ static void generate_rev(uint8_t *data, uint8_t len) {
|
||||
free(key);
|
||||
}
|
||||
static void generate(uint8_t *data, uint8_t len) {
|
||||
uint8_t *key = calloc(len,1);
|
||||
uint8_t *pkey = calloc(len,1);
|
||||
uint8_t *key = calloc(len, sizeof(uint8_t));
|
||||
uint8_t *pkey = calloc(len, sizeof(uint8_t));
|
||||
PrintAndLogEx(SUCCESS, " input key | %s \n", sprint_hex(data, len));
|
||||
permute(data, len, pkey);
|
||||
PrintAndLogEx(SUCCESS, "permuted key | %s \n", sprint_hex(pkey, len));
|
||||
|
||||
+108
-73
@@ -180,15 +180,14 @@ int CmdLegicInfo(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Reading tag memory %d b...", card.cardsize);
|
||||
PrintAndLogEx(SUCCESS, "Reading tag memory %d b...", card.cardsize);
|
||||
|
||||
// allocate receiver buffer
|
||||
uint8_t *data = malloc(card.cardsize);
|
||||
uint8_t *data = calloc(card.cardsize, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Cannot allocate memory");
|
||||
return 2;
|
||||
}
|
||||
memset(data, 0, card.cardsize);
|
||||
|
||||
int status = legic_read_mem(0, card.cardsize, 0x55, data, &datalen);
|
||||
if ( status > 0 ) {
|
||||
@@ -480,15 +479,20 @@ int CmdLegicRdmem(const char *Cmd) {
|
||||
uint16_t datalen = 0;
|
||||
sscanf(Cmd, "%x %x %x", &offset, &len, &iv);
|
||||
|
||||
PrintAndLogEx(NORMAL, "Reading %d bytes, from offset %d", len, offset);
|
||||
// sanity checks
|
||||
if ( len + offset >= MAX_LENGTH ) {
|
||||
PrintAndLogEx(WARNING, "Out-of-bounds, Cardsize = %d, [offset+len = %d ]", MAX_LENGTH, len + offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Reading %d bytes, from offset %d", len, offset);
|
||||
|
||||
// allocate receiver buffer
|
||||
uint8_t *data = malloc(len);
|
||||
uint8_t *data = calloc(len, sizeof(uint8_t));
|
||||
if ( !data ){
|
||||
PrintAndLogEx(WARNING, "Cannot allocate memory");
|
||||
return 2;
|
||||
return -2;
|
||||
}
|
||||
memset(data, 0, len);
|
||||
|
||||
int status = legic_read_mem(offset, len, iv, data, &datalen);
|
||||
if ( status == 0 ) {
|
||||
@@ -540,9 +544,9 @@ int CmdLegicRfWrite(const char *Cmd) {
|
||||
}
|
||||
|
||||
// limit number of bytes to write. This is not a 'restore' command.
|
||||
if ( (len>>1) > 100 ){
|
||||
PrintAndLogEx(NORMAL, "Max bound on 100bytes to write a one time.");
|
||||
PrintAndLogEx(NORMAL, "Use the 'hf legic restore' command if you want to write the whole tag at once");
|
||||
if ( (len >> 1) > 100 ){
|
||||
PrintAndLogEx(WARNING, "Max bound on 100bytes to write a one time.");
|
||||
PrintAndLogEx(WARNING, "Use the 'hf legic restore' command if you want to write the whole tag at once");
|
||||
errors = true;
|
||||
}
|
||||
|
||||
@@ -551,7 +555,7 @@ int CmdLegicRfWrite(const char *Cmd) {
|
||||
if (data)
|
||||
free(data);
|
||||
|
||||
data = malloc(len >> 1);
|
||||
data = calloc(len >> 1, sizeof(uint8_t));
|
||||
if ( data == NULL ) {
|
||||
PrintAndLogEx(WARNING, "Can't allocate memory. exiting");
|
||||
errors = true;
|
||||
@@ -598,12 +602,12 @@ int CmdLegicRfWrite(const char *Cmd) {
|
||||
// OUT-OF-BOUNDS checks
|
||||
// UID 4+1 bytes can't be written to.
|
||||
if ( offset < 5 ) {
|
||||
PrintAndLogEx(NORMAL, "Out-of-bounds, bytes 0-1-2-3-4 can't be written to. Offset = %d", offset);
|
||||
PrintAndLogEx(WARNING, "Out-of-bounds, bytes 0-1-2-3-4 can't be written to. Offset = %d", offset);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if ( len + offset >= card.cardsize ) {
|
||||
PrintAndLogEx(NORMAL, "Out-of-bounds, Cardsize = %d, [offset+len = %d ]", card.cardsize, len + offset);
|
||||
PrintAndLogEx(WARNING, "Out-of-bounds, Cardsize = %d, [offset+len = %d ]", card.cardsize, len + offset);
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -622,7 +626,7 @@ int CmdLegicRfWrite(const char *Cmd) {
|
||||
|
||||
legic_chk_iv(&IV);
|
||||
|
||||
PrintAndLogEx(NORMAL, "Writing to tag");
|
||||
PrintAndLogEx(SUCCESS, "Writing to tag");
|
||||
|
||||
UsbCommand c = {CMD_WRITER_LEGIC_RF, {offset, len, IV}};
|
||||
memcpy(c.d.asBytes, data, len);
|
||||
@@ -630,10 +634,18 @@ int CmdLegicRfWrite(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
++timeout;
|
||||
printf("."); fflush(stdout);
|
||||
if (timeout > 7) {
|
||||
PrintAndLogEx(WARNING, "\ncommand execution time out");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
if ( !isOK ) {
|
||||
PrintAndLogEx(WARNING, "Failed writing tag");
|
||||
@@ -673,7 +685,7 @@ int CmdLegicCalcCrc(const char *Cmd){
|
||||
// it's possible for user to accidentally enter "b" parameter
|
||||
// more than once - we have to clean previous malloc
|
||||
if (data) free(data);
|
||||
data = malloc(len >> 1);
|
||||
data = calloc(len >> 1, sizeof(uint8_t) );
|
||||
if ( data == NULL ) {
|
||||
PrintAndLogEx(WARNING, "Can't allocate memory. exiting");
|
||||
errors = true;
|
||||
@@ -714,10 +726,10 @@ int CmdLegicCalcCrc(const char *Cmd){
|
||||
switch (type){
|
||||
case 16:
|
||||
init_table(CRC_LEGIC);
|
||||
PrintAndLogEx(NORMAL, "Legic crc16: %X", crc16_legic(data, len, uidcrc));
|
||||
PrintAndLogEx(SUCCESS, "Legic crc16: %X", crc16_legic(data, len, uidcrc));
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(NORMAL, "Legic crc8: %X", CRC8Legic(data, len) );
|
||||
PrintAndLogEx(SUCCESS, "Legic crc8: %X", CRC8Legic(data, len) );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -733,11 +745,18 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
if ( !WaitForResponseTimeout(CMD_ACK, &resp, 3000) ) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
++timeout;
|
||||
printf("."); fflush(stdout);
|
||||
if (timeout > 7) {
|
||||
PrintAndLogEx(WARNING, "\ncommand execution time out");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
*outlen = resp.arg[1];
|
||||
if ( !isOK ) {
|
||||
@@ -762,13 +781,13 @@ int legic_print_type(uint32_t tagtype, uint8_t spaces){
|
||||
char *spacer = spc + (10-spaces);
|
||||
|
||||
if ( tagtype == 22 )
|
||||
PrintAndLogEx(NORMAL, "%sTYPE : MIM%d card (outdated)", spacer, tagtype);
|
||||
PrintAndLogEx(SUCCESS, "%sTYPE : MIM%d card (outdated)", spacer, tagtype);
|
||||
else if ( tagtype == 256 )
|
||||
PrintAndLogEx(NORMAL, "%sTYPE : MIM%d card (234 bytes)", spacer, tagtype);
|
||||
PrintAndLogEx(SUCCESS, "%sTYPE : MIM%d card (234 bytes)", spacer, tagtype);
|
||||
else if ( tagtype == 1024 )
|
||||
PrintAndLogEx(NORMAL, "%sTYPE : MIM%d card (1002 bytes)", spacer, tagtype);
|
||||
PrintAndLogEx(SUCCESS, "%sTYPE : MIM%d card (1002 bytes)", spacer, tagtype);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "%sTYPE : Unknown %06x", spacer, tagtype);
|
||||
PrintAndLogEx(INFO, "%sTYPE : Unknown %06x", spacer, tagtype);
|
||||
return 0;
|
||||
}
|
||||
int legic_get_type(legic_card_select_t *card){
|
||||
@@ -792,12 +811,12 @@ int legic_get_type(legic_card_select_t *card){
|
||||
void legic_chk_iv(uint32_t *iv){
|
||||
if ( (*iv & 0x7F) != *iv ){
|
||||
*iv &= 0x7F;
|
||||
PrintAndLogEx(NORMAL, "Truncating IV to 7bits, %u", *iv);
|
||||
PrintAndLogEx(INFO, "Truncating IV to 7bits, %u", *iv);
|
||||
}
|
||||
// IV must be odd
|
||||
if ( (*iv & 1) == 0 ){
|
||||
*iv |= 0x01;
|
||||
PrintAndLogEx(NORMAL, "LSB of IV must be SET %u", *iv);
|
||||
PrintAndLogEx(INFO, "LSB of IV must be SET %u", *iv);
|
||||
}
|
||||
}
|
||||
void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
||||
@@ -828,11 +847,11 @@ int HFLegicReader(const char *Cmd, bool verbose) {
|
||||
if ( verbose ) PrintAndLogEx(WARNING, "command execution time out");
|
||||
return 1;
|
||||
case 3:
|
||||
if ( verbose ) PrintAndLogEx(NORMAL, "legic card select failed");
|
||||
if ( verbose ) PrintAndLogEx(WARNING, "legic card select failed");
|
||||
return 2;
|
||||
default: break;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, " UID : %s", sprint_hex(card.uid, sizeof(card.uid)));
|
||||
PrintAndLogEx(SUCCESS, " UID : %s", sprint_hex(card.uid, sizeof(card.uid)));
|
||||
legic_print_type(card.cardsize, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -882,16 +901,23 @@ int CmdLegicDump(const char *Cmd){
|
||||
dumplen = card.cardsize;
|
||||
|
||||
legic_print_type(dumplen, 0);
|
||||
PrintAndLogEx(NORMAL, "Reading tag memory %d b...", dumplen);
|
||||
PrintAndLogEx(SUCCESS, "Reading tag memory %d b...", dumplen);
|
||||
|
||||
UsbCommand c = {CMD_READER_LEGIC_RF, {0x00, dumplen, 0x55}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) {
|
||||
PrintAndLogEx(NORMAL, "Command execute time-out");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
++timeout;
|
||||
printf("."); fflush(stdout);
|
||||
if (timeout > 7) {
|
||||
PrintAndLogEx(WARNING, "\ncommand execution time out");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
if ( !isOK ) {
|
||||
@@ -900,12 +926,11 @@ int CmdLegicDump(const char *Cmd){
|
||||
}
|
||||
|
||||
uint16_t readlen = resp.arg[1];
|
||||
uint8_t *data = malloc(readlen);
|
||||
uint8_t *data = calloc(readlen, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 3;
|
||||
}
|
||||
memset(data, 0, readlen);
|
||||
|
||||
if ( readlen != dumplen )
|
||||
PrintAndLogEx(WARNING, "Fail, only managed to read 0x%02X bytes of 0x%02X", readlen, dumplen);
|
||||
@@ -923,7 +948,7 @@ int CmdLegicDump(const char *Cmd){
|
||||
else
|
||||
sprintf(fnameptr + fileNlen,".bin");
|
||||
|
||||
f = fopen(filename,"wb");
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
PrintAndLogEx(WARNING, "Could not create file name %s", filename);
|
||||
if (data)
|
||||
@@ -934,7 +959,7 @@ int CmdLegicDump(const char *Cmd){
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
free(data);
|
||||
PrintAndLogEx(NORMAL, "Wrote %d bytes to %s", readlen, filename);
|
||||
PrintAndLogEx(SUCCESS, "Wrote %d bytes to %s", readlen, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -982,12 +1007,11 @@ int CmdLegicRestore(const char *Cmd){
|
||||
numofbytes = card.cardsize;
|
||||
|
||||
// set up buffer
|
||||
uint8_t *data = malloc(numofbytes);
|
||||
uint8_t *data = calloc(numofbytes, sizeof(uint8_t) );
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 2;
|
||||
}
|
||||
memset(data, 0, numofbytes);
|
||||
|
||||
legic_print_type(numofbytes, 0);
|
||||
|
||||
@@ -997,7 +1021,7 @@ int CmdLegicRestore(const char *Cmd){
|
||||
|
||||
f = fopen(filename,"rb");
|
||||
if (!f) {
|
||||
PrintAndLogEx(NORMAL, "File %s not found or locked", filename);
|
||||
PrintAndLogEx(WARNING, "File %s not found or locked", filename);
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -1018,12 +1042,12 @@ int CmdLegicRestore(const char *Cmd){
|
||||
fclose(f);
|
||||
|
||||
if ( bytes_read == 0){
|
||||
PrintAndLogEx(NORMAL, "File reading error");
|
||||
PrintAndLogEx(WARNING, "File reading error");
|
||||
free(data);
|
||||
return 2;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Restoring to card");
|
||||
PrintAndLogEx(SUCCESS, "Restoring to card");
|
||||
|
||||
// transfer to device
|
||||
size_t len = 0;
|
||||
@@ -1038,22 +1062,29 @@ int CmdLegicRestore(const char *Cmd){
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
++timeout;
|
||||
printf("."); fflush(stdout);
|
||||
if (timeout > 7) {
|
||||
PrintAndLogEx(WARNING, "\ncommand execution time out");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
if ( !isOK ) {
|
||||
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.arg[1] & 0xFF);
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Wrote chunk [offset %d | len %d | total %d", i, len, i+len);
|
||||
PrintAndLogEx(SUCCESS, "Wrote chunk [offset %d | len %d | total %d", i, len, i+len);
|
||||
}
|
||||
|
||||
free(data);
|
||||
PrintAndLogEx(NORMAL, "\nWrote %d bytes to card from file %s", numofbytes, filename);
|
||||
PrintAndLogEx(SUCCESS, "\nWrote %d bytes to card from file %s", numofbytes, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1077,12 +1108,11 @@ int CmdLegicELoad(const char *Cmd) {
|
||||
}
|
||||
|
||||
// set up buffer
|
||||
uint8_t *data = malloc(numofbytes);
|
||||
uint8_t *data = calloc(numofbytes, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 3;
|
||||
}
|
||||
memset(data, 0, numofbytes);
|
||||
|
||||
// set up file
|
||||
len = param_getstr(Cmd, nameParamNo, filename, FILE_PATH_SIZE);
|
||||
@@ -1094,7 +1124,7 @@ int CmdLegicELoad(const char *Cmd) {
|
||||
// open file
|
||||
f = fopen(filename,"rb");
|
||||
if (!f) {
|
||||
PrintAndLogEx(NORMAL, "File %s not found or locked", filename);
|
||||
PrintAndLogEx(WARNING, "File %s not found or locked", filename);
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
@@ -1102,7 +1132,7 @@ int CmdLegicELoad(const char *Cmd) {
|
||||
// load file
|
||||
size_t bytes_read = fread(data, 1, numofbytes, f);
|
||||
if ( bytes_read == 0){
|
||||
PrintAndLogEx(NORMAL, "File reading error");
|
||||
PrintAndLogEx(WARNING, "File reading error");
|
||||
free(data);
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
@@ -1115,7 +1145,7 @@ int CmdLegicELoad(const char *Cmd) {
|
||||
legic_seteml(data, 0, numofbytes);
|
||||
|
||||
free(data);
|
||||
PrintAndLogEx(NORMAL, "\nLoaded %d bytes from file: %s to emulator memory", numofbytes, filename);
|
||||
PrintAndLogEx(SUCCESS, "\nLoaded %d bytes from file: %s to emulator memory", numofbytes, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1146,15 +1176,14 @@ int CmdLegicESave(const char *Cmd) {
|
||||
fileNlen = FILE_PATH_SIZE - 5;
|
||||
|
||||
// set up buffer
|
||||
uint8_t *data = malloc(numofbytes);
|
||||
uint8_t *data = calloc(numofbytes, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 3;
|
||||
}
|
||||
memset(data, 0, numofbytes);
|
||||
|
||||
// download emulator memory
|
||||
PrintAndLogEx(NORMAL, "Reading emulator memory...");
|
||||
PrintAndLogEx(SUCCESS, "Reading emulator memory...");
|
||||
if (!GetFromDevice( BIG_BUF_EML, data, numofbytes, 0, NULL, 2500, false)) {
|
||||
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
||||
free(data);
|
||||
@@ -1185,16 +1214,15 @@ int CmdLegicWipe(const char *Cmd){
|
||||
}
|
||||
|
||||
// set up buffer
|
||||
uint8_t *data = malloc(card.cardsize);
|
||||
uint8_t *data = calloc(card.cardsize, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 2;
|
||||
}
|
||||
memset(data, 0, card.cardsize);
|
||||
|
||||
legic_print_type(card.cardsize, 0);
|
||||
|
||||
PrintAndLogEx(NORMAL, "Erasing");
|
||||
PrintAndLogEx(SUCCESS, "Erasing");
|
||||
|
||||
// transfer to device
|
||||
size_t len = 0;
|
||||
@@ -1210,11 +1238,18 @@ int CmdLegicWipe(const char *Cmd){
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
free(data);
|
||||
return 3;
|
||||
}
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
++timeout;
|
||||
printf("."); fflush(stdout);
|
||||
if (timeout > 7) {
|
||||
PrintAndLogEx(WARNING, "\ncommand execution time out");
|
||||
free(data);
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
if ( !isOK ) {
|
||||
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.arg[1] & 0xFF);
|
||||
@@ -1222,7 +1257,7 @@ int CmdLegicWipe(const char *Cmd){
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "ok\n");
|
||||
PrintAndLogEx(SUCCESS, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1236,7 +1271,7 @@ static command_t CommandTable[] = {
|
||||
{"reader", CmdLegicReader, 1, "LEGIC Prime Reader UID and tag info"},
|
||||
{"info", CmdLegicInfo, 0, "Display deobfuscated and decoded LEGIC Prime tag data"},
|
||||
{"dump", CmdLegicDump, 0, "Dump LEGIC Prime tag to binary file"},
|
||||
{"restore", CmdLegicRestore, 0, "Restore a dump onto a LEGIC Prime tag"},
|
||||
{"restore", CmdLegicRestore, 0, "Restore a dump file onto a LEGIC Prime tag"},
|
||||
{"rdmem", CmdLegicRdmem, 0, "Read bytes from a LEGIC Prime tag"},
|
||||
{"sim", CmdLegicRfSim, 0, "Start tag simulator"},
|
||||
{"write", CmdLegicRfWrite, 0, "Write data to a LEGIC Prime tag"},
|
||||
|
||||
+1
-1
@@ -357,7 +357,7 @@ void annotateIso7816(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize){
|
||||
case ISO7816_EXTERNAL_AUTHENTICATION :snprintf(exp, size, "EXTERNAL AUTH");break;
|
||||
case ISO7816_GET_CHALLENGE :snprintf(exp, size, "GET CHALLENGE");break;
|
||||
case ISO7816_MANAGE_CHANNEL :snprintf(exp, size, "MANAGE CHANNEL");break;
|
||||
case ISO7816_GETSTATUS :snprintf(exp, size, "GET RESPONSE");break;
|
||||
case ISO7816_GET_RESPONSE :snprintf(exp, size, "GET RESPONSE");break;
|
||||
default :snprintf(exp,size,"?"); break;
|
||||
}
|
||||
}
|
||||
|
||||
+149
-130
@@ -11,11 +11,16 @@
|
||||
#include "cmdhfmf.h"
|
||||
#include "mifare4.h"
|
||||
|
||||
#define MIFARE_4K_MAXBLOCK 255
|
||||
#define MIFARE_4K_MAXBLOCK 256
|
||||
#define MIFARE_2K_MAXBLOCK 128
|
||||
#define MIFARE_1K_MAXBLOCK 64
|
||||
#define MIFARE_MINI_MAXBLOCK 20
|
||||
|
||||
#define MIFARE_MINI_MAXSECTOR 5
|
||||
#define MIFARE_1K_MAXSECTOR 16
|
||||
#define MIFARE_2K_MAXSECTOR 32
|
||||
#define MIFARE_4K_MAXSECTOR 40
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int usage_hf14_ice(void){
|
||||
@@ -415,7 +420,7 @@ int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
|
||||
char * GenerateFilename(const char *prefix, const char *suffix){
|
||||
uint8_t uid[10] = {0,0,0,0,0,0,0,0,0,0};
|
||||
int uidlen=0;
|
||||
char * fptr = malloc (sizeof (char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid)*2 + 1);
|
||||
char * fptr = calloc (sizeof (char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid)*2 + 1, sizeof(uint8_t));
|
||||
|
||||
GetHFMF14AUID(uid, &uidlen);
|
||||
if (!uidlen) {
|
||||
@@ -591,7 +596,7 @@ int CmdHF14AMfRdSc(const char *Cmd) {
|
||||
}
|
||||
|
||||
sectorNo = param_get8(Cmd, 0);
|
||||
if (sectorNo > 39) {
|
||||
if (sectorNo > MIFARE_4K_MAXSECTOR ) {
|
||||
PrintAndLogEx(NORMAL, "Sector number must be less than 40");
|
||||
return 1;
|
||||
}
|
||||
@@ -645,7 +650,7 @@ int CmdHF14AMfRdSc(const char *Cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t NumOfBlocks(char card){
|
||||
uint16_t NumOfBlocks(char card){
|
||||
switch(card){
|
||||
case '0' : return MIFARE_MINI_MAXBLOCK;
|
||||
case '1' : return MIFARE_1K_MAXBLOCK;
|
||||
@@ -656,11 +661,11 @@ uint8_t NumOfBlocks(char card){
|
||||
}
|
||||
uint8_t NumOfSectors(char card){
|
||||
switch(card){
|
||||
case '0' : return 5;
|
||||
case '1' : return 16;
|
||||
case '2' : return 32;
|
||||
case '4' : return 40;
|
||||
default : return 16;
|
||||
case '0' : return MIFARE_MINI_MAXSECTOR;
|
||||
case '1' : return MIFARE_1K_MAXSECTOR;
|
||||
case '2' : return MIFARE_2K_MAXSECTOR;
|
||||
case '4' : return MIFARE_4K_MAXSECTOR;
|
||||
default : return MIFARE_1K_MAXSECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +734,7 @@ int CmdHF14AMfDump(const char *Cmd) {
|
||||
}
|
||||
|
||||
if ((fin = fopen(keyFilename, "rb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not find file %s", keyFilename);
|
||||
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_(%s), keyFilename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -738,7 +743,7 @@ int CmdHF14AMfDump(const char *Cmd) {
|
||||
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
||||
bytes_read = fread( keyA[sectorNo], 1, 6, fin );
|
||||
if ( bytes_read != 6) {
|
||||
PrintAndLogEx(NORMAL, "File reading error.");
|
||||
PrintAndLogEx(WARNING, "File reading error.");
|
||||
fclose(fin);
|
||||
return 2;
|
||||
}
|
||||
@@ -748,7 +753,7 @@ int CmdHF14AMfDump(const char *Cmd) {
|
||||
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
||||
bytes_read = fread( keyB[sectorNo], 1, 6, fin );
|
||||
if ( bytes_read != 6) {
|
||||
PrintAndLogEx(NORMAL, "File reading error.");
|
||||
PrintAndLogEx(WARNING, "File reading error.");
|
||||
fclose(fin);
|
||||
return 2;
|
||||
}
|
||||
@@ -874,13 +879,13 @@ int CmdHF14AMfDump(const char *Cmd) {
|
||||
}
|
||||
|
||||
if ((fout = fopen(dataFilename,"wb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "could not create file name %s", dataFilename);
|
||||
PrintAndLogEx(WARNING, "could not create file name " _YELLOW_(%s), dataFilename);
|
||||
return 1;
|
||||
}
|
||||
uint16_t numblocks = FirstBlockOfSector(numSectors - 1) + NumBlocksPerSector(numSectors - 1);
|
||||
fwrite(carddata, 1, 16*numblocks, fout);
|
||||
fclose(fout);
|
||||
PrintAndLogEx(SUCCESS, "dumped %d blocks (%d bytes) to file %s", numblocks, 16*numblocks, dataFilename);
|
||||
PrintAndLogEx(SUCCESS, "dumped %d blocks (%d bytes) to file " _YELLOW_(%s), numblocks, 16*numblocks, dataFilename);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -940,7 +945,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||
}
|
||||
|
||||
if ((fkeys = fopen(keyFilename, "rb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not find file %s", keyFilename);
|
||||
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_(%s), keyFilename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -948,7 +953,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
bytes_read = fread( keyA[sectorNo], 1, 6, fkeys );
|
||||
if ( bytes_read != 6 ) {
|
||||
PrintAndLogEx(NORMAL, "File reading error (%s).", keyFilename);
|
||||
PrintAndLogEx(WARNING, "File reading error " _YELLOW_(%s), keyFilename);
|
||||
fclose(fkeys);
|
||||
return 2;
|
||||
}
|
||||
@@ -957,7 +962,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
bytes_read = fread( keyB[sectorNo], 1, 6, fkeys );
|
||||
if ( bytes_read != 6 ) {
|
||||
PrintAndLogEx(NORMAL, "File reading error (%s).", keyFilename);
|
||||
PrintAndLogEx(WARNING, "File reading error " _YELLOW_(%s), keyFilename);
|
||||
fclose(fkeys);
|
||||
return 2;
|
||||
}
|
||||
@@ -974,10 +979,10 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||
}
|
||||
|
||||
if ((fdump = fopen(dataFilename, "rb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not find file %s", dataFilename);
|
||||
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_(%s), dataFilename);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Restoring %s to card", dataFilename);
|
||||
PrintAndLogEx(INFO, "Restoring " _YELLOW_(%s)" to card", dataFilename);
|
||||
|
||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
for (blockNo = 0; blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
|
||||
@@ -985,7 +990,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
bytes_read = fread(bldata, 1, 16, fdump);
|
||||
if ( bytes_read != 16) {
|
||||
PrintAndLogEx(NORMAL, "File reading error (%s).", dataFilename);
|
||||
PrintAndLogEx(WARNING, "File reading error " _YELLOW_(%s), dataFilename);
|
||||
fclose(fdump);
|
||||
fdump = NULL;
|
||||
return 2;
|
||||
@@ -1015,9 +1020,9 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||
UsbCommand resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "Command execute timeout");
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1187,7 +1192,7 @@ int CmdHF14AMfNested(const char *Cmd) {
|
||||
|
||||
|
||||
// 20160116 If Sector A is found, but not Sector B, try just reading it of the tag?
|
||||
PrintAndLogEx(SUCCESS, "trying to read key B...");
|
||||
PrintAndLogEx(INFO, "trying to read key B...");
|
||||
for (i = 0; i < SectorsCnt; i++) {
|
||||
// KEY A but not KEY B
|
||||
if ( e_sector[i].foundKey[0] && !e_sector[i].foundKey[1] ) {
|
||||
@@ -1230,8 +1235,8 @@ int CmdHF14AMfNested(const char *Cmd) {
|
||||
if (e_sector[i].foundKey[1])
|
||||
num_to_bytes(e_sector[i].Key[1], 6, &keyBlock[10]);
|
||||
mfEmlSetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
PrintAndLogEx(SUCCESS, "key transferred to emulator memory.");
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "key transferred to emulator memory.");
|
||||
}
|
||||
|
||||
// Create dump file
|
||||
@@ -1241,12 +1246,12 @@ int CmdHF14AMfNested(const char *Cmd) {
|
||||
return 1;
|
||||
|
||||
if ((fkeys = fopen(fptr, "wb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "could not create file %s", fptr);
|
||||
PrintAndLogEx(WARNING, "could not create file " _YELLOW_(%s), fptr);
|
||||
free(e_sector);
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "saving keys to binary file %s...", fptr);
|
||||
PrintAndLogEx(SUCCESS, "saving keys to binary file " _YELLOW_(%s), fptr);
|
||||
for (i=0; i<SectorsCnt; i++) {
|
||||
if (e_sector[i].foundKey[0]){
|
||||
num_to_bytes(e_sector[i].Key[0], 6, tempkey);
|
||||
@@ -1314,14 +1319,14 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
default:
|
||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||
{
|
||||
PrintAndLogEx(NORMAL, "Block number is missing");
|
||||
PrintAndLogEx(WARNING, "Block number is missing");
|
||||
return 1;
|
||||
|
||||
}
|
||||
blockNo = param_get8(Cmd, cmdp);
|
||||
ctmp = tolower(param_getchar(Cmd, cmdp+1));
|
||||
if (ctmp != 'a' && ctmp != 'b') {
|
||||
PrintAndLogEx(NORMAL, "Key type must be A or B");
|
||||
PrintAndLogEx(WARNING, "Key type must be A or B");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1330,13 +1335,13 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (param_gethex(Cmd, cmdp+2, key, 12)) {
|
||||
PrintAndLogEx(NORMAL, "Key must include 12 HEX symbols");
|
||||
PrintAndLogEx(WARNING, "Key must include 12 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (param_getchar(Cmd, cmdp+3) == 0x00)
|
||||
{
|
||||
PrintAndLogEx(NORMAL, "Target block number is missing");
|
||||
PrintAndLogEx(WARNING, "Target block number is missing");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1344,7 +1349,7 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
|
||||
ctmp = tolower(param_getchar(Cmd, cmdp+4));
|
||||
if (ctmp != 'a' && ctmp != 'b') {
|
||||
PrintAndLogEx(NORMAL, "Target key type must be A or B");
|
||||
PrintAndLogEx(WARNING, "Target key type must be A or B");
|
||||
return 1;
|
||||
}
|
||||
if (ctmp != 'a') {
|
||||
@@ -1402,7 +1407,7 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
SetSIMDInstr(SIMD_NONE);
|
||||
break;
|
||||
default:
|
||||
PrintAndLog("Unknown SIMD type. %c", ctmp);
|
||||
PrintAndLogEx(WARNING, "Unknown SIMD type. %c", ctmp);
|
||||
return 1;
|
||||
}
|
||||
cmdp += 2;
|
||||
@@ -1420,7 +1425,7 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
// check if we can authenticate to sector
|
||||
int res = mfCheckKeys(blockNo, keyType, true, 1, key, &key64);
|
||||
if (res) {
|
||||
PrintAndLogEx(NORMAL, "Key is wrong. Can't authenticate to block:%3d key type:%c", blockNo, keyType ? 'B' : 'A');
|
||||
PrintAndLogEx(WARNING, "Key is wrong. Can't authenticate to block:%3d key type:%c", blockNo, keyType ? 'B' : 'A');
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -1497,11 +1502,11 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
|
||||
// sectors
|
||||
switch(ctmp) {
|
||||
case '0': sectorsCnt = 5; break;
|
||||
case '1': sectorsCnt = 16; break;
|
||||
case '2': sectorsCnt = 32; break;
|
||||
case '4': sectorsCnt = 40; break;
|
||||
default: sectorsCnt = 16;
|
||||
case '0': sectorsCnt = MIFARE_MINI_MAXSECTOR; break;
|
||||
case '1': sectorsCnt = MIFARE_1K_MAXSECTOR; break;
|
||||
case '2': sectorsCnt = MIFARE_2K_MAXSECTOR; break;
|
||||
case '4': sectorsCnt = MIFARE_4K_MAXSECTOR; break;
|
||||
default: sectorsCnt = MIFARE_1K_MAXSECTOR;
|
||||
}
|
||||
|
||||
for (i = 1; param_getchar(Cmd, i); i++) {
|
||||
@@ -1542,7 +1547,7 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
|
||||
f = fopen( filename, "r");
|
||||
if ( !f ){
|
||||
PrintAndLogEx(FAILED, "File: %s: not found or locked.", filename);
|
||||
PrintAndLogEx(FAILED, "File: " _YELLOW_(%s) ": not found or locked.", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1556,7 +1561,7 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
if( buf[0]=='#' ) continue; //The line start with # is comment, skip
|
||||
|
||||
if (!isxdigit(buf[0])){
|
||||
PrintAndLogEx(FAILED, "File content error. '%s' must include 12 HEX symbols",buf);
|
||||
PrintAndLogEx(FAILED, "File content error. '" _YELLOW_(%s)"' must include 12 HEX symbols", buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1578,7 +1583,7 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
}
|
||||
fclose(f);
|
||||
PrintAndLogEx(SUCCESS, "Loaded %2d keys from %s", keycnt, filename);
|
||||
PrintAndLogEx(SUCCESS, "Loaded %2d keys from " _YELLOW_(%s), keycnt, filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1617,7 +1622,7 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar(); (void)gc;
|
||||
PrintAndLogEx(NORMAL, "\naborted via keyboard!\n");
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1644,47 +1649,63 @@ out:
|
||||
t1 = msclock() - t1;
|
||||
PrintAndLogEx(SUCCESS, "Time in checkkeys (fast): %.1fs\n", (float)(t1/1000.0));
|
||||
|
||||
printKeyTable( sectorsCnt, e_sector );
|
||||
|
||||
if (transferToEml) {
|
||||
uint8_t block[16] = {0x00};
|
||||
for (uint8_t i = 0; i < sectorsCnt; ++i ) {
|
||||
mfEmlGetMem(block, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
if (e_sector[i].foundKey[0])
|
||||
num_to_bytes(e_sector[i].Key[0], 6, block);
|
||||
if (e_sector[i].foundKey[1])
|
||||
num_to_bytes(e_sector[i].Key[1], 6, block+10);
|
||||
mfEmlSetMem(block, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Found keys have been transferred to the emulator memory");
|
||||
// check..
|
||||
uint8_t found_keys = 0;
|
||||
for (uint8_t i = 0; i < sectorsCnt; ++i) {
|
||||
|
||||
if ( e_sector[i].foundKey[0] )
|
||||
found_keys++;
|
||||
|
||||
if ( e_sector[i].foundKey[1] )
|
||||
found_keys++;
|
||||
}
|
||||
|
||||
if (createDumpFile) {
|
||||
fptr = GenerateFilename("hf-mf-", "-key.bin");
|
||||
if (fptr == NULL)
|
||||
return 1;
|
||||
|
||||
FILE *fkeys = fopen(fptr, "wb");
|
||||
if (fkeys == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not create file %s", fptr);
|
||||
free(keyBlock);
|
||||
free(e_sector);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Printing keys to binary file %s...", fptr);
|
||||
if ( found_keys == 0 ) {
|
||||
PrintAndLogEx(WARNING, "No keys found");
|
||||
} else {
|
||||
|
||||
for (i=0; i<sectorsCnt; i++) {
|
||||
num_to_bytes(e_sector[i].Key[0], 6, tempkey);
|
||||
fwrite (tempkey, 1, 6, fkeys);
|
||||
}
|
||||
printKeyTable( sectorsCnt, e_sector );
|
||||
|
||||
for (i=0; i<sectorsCnt; i++) {
|
||||
num_to_bytes(e_sector[i].Key[1], 6, tempkey);
|
||||
fwrite (tempkey, 1, 6, fkeys );
|
||||
if (transferToEml) {
|
||||
uint8_t block[16] = {0x00};
|
||||
for (uint8_t i = 0; i < sectorsCnt; ++i ) {
|
||||
mfEmlGetMem(block, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
if (e_sector[i].foundKey[0])
|
||||
num_to_bytes(e_sector[i].Key[0], 6, block);
|
||||
if (e_sector[i].foundKey[1])
|
||||
num_to_bytes(e_sector[i].Key[1], 6, block+10);
|
||||
mfEmlSetMem(block, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Found keys have been transferred to the emulator memory");
|
||||
}
|
||||
|
||||
if (createDumpFile) {
|
||||
fptr = GenerateFilename("hf-mf-", "-key.bin");
|
||||
if (fptr == NULL)
|
||||
return 1;
|
||||
|
||||
fclose(fkeys);
|
||||
PrintAndLogEx(NORMAL, "Found keys have been dumped to %s --> 0xffffffffffff has been inserted for unknown keys.", fptr);
|
||||
FILE *fkeys = fopen(fptr, "wb");
|
||||
if (fkeys == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not create file " _YELLOW_(%s), fptr);
|
||||
free(keyBlock);
|
||||
free(e_sector);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Printing keys to binary file " _YELLOW_(%s)"...", fptr);
|
||||
|
||||
for (i=0; i<sectorsCnt; i++) {
|
||||
num_to_bytes(e_sector[i].Key[0], 6, tempkey);
|
||||
fwrite (tempkey, 1, 6, fkeys);
|
||||
}
|
||||
|
||||
for (i=0; i<sectorsCnt; i++) {
|
||||
num_to_bytes(e_sector[i].Key[1], 6, tempkey);
|
||||
fwrite (tempkey, 1, 6, fkeys );
|
||||
}
|
||||
|
||||
fclose(fkeys);
|
||||
PrintAndLogEx(SUCCESS, "Found keys have been dumped to " _YELLOW_(%s)" --> 0xffffffffffff has been inserted for unknown keys.", fptr);
|
||||
}
|
||||
}
|
||||
|
||||
free(keyBlock);
|
||||
@@ -1695,8 +1716,8 @@ out:
|
||||
|
||||
int CmdHF14AMfChk(const char *Cmd) {
|
||||
|
||||
char ctmp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || ctmp == 'h' || ctmp == 'H') return usage_hf14_chk();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 3 || ctmp == 'h') return usage_hf14_chk();
|
||||
|
||||
FILE * f;
|
||||
char filename[FILE_PATH_SIZE]={0};
|
||||
@@ -1729,23 +1750,21 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
blockNo = param_get8(Cmd, 0);
|
||||
}
|
||||
|
||||
ctmp = param_getchar(Cmd, 1);
|
||||
ctmp = tolower(param_getchar(Cmd, 1));
|
||||
clen = param_getlength(Cmd, 1);
|
||||
if (clen == 1) {
|
||||
switch (ctmp) {
|
||||
case 'a':
|
||||
case 'A':
|
||||
keyType = 0;
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
keyType = 1;
|
||||
break;
|
||||
case '?':
|
||||
keyType = 2;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(NORMAL, "Key type must be A , B or ?");
|
||||
PrintAndLogEx(FAILED, "Key type must be A , B or ?");
|
||||
free(keyBlock);
|
||||
return 1;
|
||||
};
|
||||
@@ -1753,7 +1772,7 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
|
||||
for (i = 2; param_getchar(Cmd, i); i++) {
|
||||
|
||||
ctmp = param_getchar(Cmd, i);
|
||||
ctmp = tolower(param_getchar(Cmd, i));
|
||||
clen = param_getlength(Cmd, i);
|
||||
|
||||
if (clen == 12) {
|
||||
@@ -1775,8 +1794,8 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "[%2d] key %s", keycnt, sprint_hex( (keyBlock + 6*keycnt), 6 ) );;
|
||||
keycnt++;
|
||||
} else if ( clen == 1 ) {
|
||||
if (ctmp == 't' || ctmp == 'T') { transferToEml = 1; continue; }
|
||||
if (ctmp == 'd' || ctmp == 'D') { createDumpFile = 1; continue; }
|
||||
if (ctmp == 't' ) { transferToEml = 1; continue; }
|
||||
if (ctmp == 'd' ) { createDumpFile = 1; continue; }
|
||||
} else {
|
||||
// May be a dic file
|
||||
if ( param_getstr(Cmd, i, filename, sizeof(filename)) >= FILE_PATH_SIZE ) {
|
||||
@@ -1786,7 +1805,7 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
|
||||
f = fopen( filename , "r");
|
||||
if ( !f ) {
|
||||
PrintAndLogEx(FAILED, "File: %s: not found or locked.", filename);
|
||||
PrintAndLogEx(FAILED, "File: " _YELLOW_(%s)": not found or locked.", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1801,7 +1820,7 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
|
||||
// codesmell, only checks first char?
|
||||
if (!isxdigit(buf[0])){
|
||||
PrintAndLogEx(FAILED, "File content error. '%s' must include 12 HEX symbols",buf);
|
||||
PrintAndLogEx(FAILED, "File content error. '" _YELLOW_(%s)"' must include 12 HEX symbols",buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1824,12 +1843,12 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
}
|
||||
fclose(f);
|
||||
PrintAndLogEx(SUCCESS, "Loaded %2d keys from %s", keycnt, filename);
|
||||
PrintAndLogEx(SUCCESS, "Loaded %2d keys from " _YELLOW_(%s), keycnt, filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (keycnt == 0) {
|
||||
PrintAndLogEx(NORMAL, "No key specified, trying default keys");
|
||||
PrintAndLogEx(INFO, "No key specified, trying default keys");
|
||||
for (;keycnt < MIFARE_DEFAULTKEYS_SIZE; keycnt++)
|
||||
PrintAndLogEx(NORMAL, "[%2d] %02x%02x%02x%02x%02x%02x", keycnt,
|
||||
(keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],
|
||||
@@ -1873,7 +1892,7 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
printf("."); fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar(); (void)gc;
|
||||
PrintAndLogEx(NORMAL, "\naborted via keyboard!\n");
|
||||
PrintAndLogEx(INFO, "\naborted via keyboard!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1892,12 +1911,12 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
t1 = msclock() - t1;
|
||||
PrintAndLogEx(NORMAL, "\nTime in checkkeys: %.0f seconds\n", (float)t1/1000.0);
|
||||
PrintAndLogEx(SUCCESS, "\nTime in checkkeys: %.0f seconds\n", (float)t1/1000.0);
|
||||
|
||||
|
||||
// 20160116 If Sector A is found, but not Sector B, try just reading it of the tag?
|
||||
if ( keyType != 1 ) {
|
||||
PrintAndLogEx(NORMAL, "testing to read key B...");
|
||||
PrintAndLogEx(INFO, "testing to read key B...");
|
||||
for (i = 0; i < SectorsCnt; i++) {
|
||||
// KEY A but not KEY B
|
||||
if ( e_sector[i].foundKey[0] && !e_sector[i].foundKey[1] ) {
|
||||
@@ -1943,7 +1962,7 @@ out:
|
||||
num_to_bytes(e_sector[i].Key[1], 6, block+10);
|
||||
mfEmlSetMem(block, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Found keys have been transferred to the emulator memory");
|
||||
PrintAndLogEx(SUCCESS, "Found keys have been transferred to the emulator memory");
|
||||
}
|
||||
|
||||
if (createDumpFile) {
|
||||
@@ -1953,12 +1972,12 @@ out:
|
||||
|
||||
FILE *fkeys = fopen(fptr, "wb");
|
||||
if (fkeys == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not create file %s", fptr);
|
||||
PrintAndLogEx(WARNING, "Could not create file " _YELLOW_(%s), fptr);
|
||||
free(keyBlock);
|
||||
free(e_sector);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Printing keys to binary file %s...", fptr);
|
||||
PrintAndLogEx(INFO, "Printing keys to binary file " _YELLOW_(%s)"...", fptr);
|
||||
|
||||
for( i=0; i<SectorsCnt; i++) {
|
||||
num_to_bytes(e_sector[i].Key[0], 6, tempkey);
|
||||
@@ -1969,7 +1988,7 @@ out:
|
||||
fwrite ( tempkey, 1, 6, fkeys );
|
||||
}
|
||||
fclose(fkeys);
|
||||
PrintAndLogEx(NORMAL, "Found keys have been dumped to file %s. 0xffffffffffff has been inserted for unknown keys.", fptr);
|
||||
PrintAndLogEx(SUCCESS, "Found keys have been dumped to file " _YELLOW_(%s)". 0xffffffffffff has been inserted for unknown keys.", fptr);
|
||||
}
|
||||
|
||||
free(keyBlock);
|
||||
@@ -2018,7 +2037,7 @@ void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose) {
|
||||
uint8_t sector = data.sector;
|
||||
uint8_t keytype = data.keytype;
|
||||
|
||||
PrintAndLogEx(NORMAL, "Reader is trying authenticate with: Key %s, sector %02d: [%012" PRIx64 "]"
|
||||
PrintAndLogEx(INFO, "Reader is trying authenticate with: Key %s, sector %02d: [%012" PRIx64 "]"
|
||||
, keytype ? "B" : "A"
|
||||
, sector
|
||||
, key
|
||||
@@ -2033,7 +2052,7 @@ void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose) {
|
||||
num_to_bytes( k_sector[sector].Key[0], 6, memBlock);
|
||||
num_to_bytes( k_sector[sector].Key[1], 6, memBlock+10);
|
||||
//iceman, guessing this will not work so well for 4K tags.
|
||||
PrintAndLogEx(NORMAL, "Setting Emulator Memory Block %02d: [%s]"
|
||||
PrintAndLogEx(INFO, "Setting Emulator Memory Block %02d: [%s]"
|
||||
, (sector*4) + 3
|
||||
, sprint_hex( memBlock, sizeof(memBlock))
|
||||
);
|
||||
@@ -2108,7 +2127,7 @@ int CmdHF14AMf1kSim(const char *Cmd) {
|
||||
UsbCommand resp;
|
||||
|
||||
if(flags & FLAG_INTERACTIVE) {
|
||||
PrintAndLogEx(NORMAL, "Press pm3-button or send another cmd to abort simulation");
|
||||
PrintAndLogEx(INFO, "Press pm3-button or send another cmd to abort simulation");
|
||||
|
||||
while( !ukbhit() ){
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500) ) continue;
|
||||
@@ -2144,8 +2163,8 @@ int CmdHF14AMfSniff(const char *Cmd){
|
||||
|
||||
memset(uid, 0x00, sizeof(uid));
|
||||
|
||||
char ctmp = param_getchar(Cmd, 0);
|
||||
if ( ctmp == 'h' || ctmp == 'H' ) return usage_hf14_sniff();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if ( ctmp == 'h') return usage_hf14_sniff();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ctmp = tolower(param_getchar(Cmd, i));
|
||||
@@ -2172,7 +2191,7 @@ int CmdHF14AMfSniff(const char *Cmd){
|
||||
printf("."); fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar(); (void)gc;
|
||||
PrintAndLogEx(NORMAL, "\n[!] aborted via keyboard!\n");
|
||||
PrintAndLogEx(INFO, "\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2195,7 +2214,7 @@ int CmdHF14AMfSniff(const char *Cmd){
|
||||
if (traceLen > bufsize || buf == NULL) {
|
||||
uint8_t *p;
|
||||
if (buf == NULL) // not yet allocated
|
||||
p = malloc(traceLen);
|
||||
p = calloc(traceLen, sizeof(uint8_t));
|
||||
else // need more memory
|
||||
p = realloc(buf, traceLen);
|
||||
|
||||
@@ -2412,14 +2431,14 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
return usage_hf14_eload();
|
||||
|
||||
switch (c) {
|
||||
case '0' : numBlocks = 5*4; break;
|
||||
case '0' : numBlocks = MIFARE_MINI_MAXBLOCK; break;
|
||||
case '1' :
|
||||
case '\0': numBlocks = 16*4; break;
|
||||
case '2' : numBlocks = 32*4; break;
|
||||
case '4' : numBlocks = 256; break;
|
||||
case '\0': numBlocks = MIFARE_1K_MAXBLOCK; break;
|
||||
case '2' : numBlocks = MIFARE_2K_MAXBLOCK; break;
|
||||
case '4' : numBlocks = MIFARE_4K_MAXBLOCK; break;
|
||||
case 'u' : numBlocks = 255; blockWidth = 4; break;
|
||||
default: {
|
||||
numBlocks = 16*4;
|
||||
numBlocks = MIFARE_1K_MAXBLOCK;
|
||||
nameParamNo = 0;
|
||||
}
|
||||
}
|
||||
@@ -2475,7 +2494,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Loaded %d blocks from file: %s", blockNum, filename);
|
||||
PrintAndLogEx(SUCCESS, "Loaded %d blocks from file: " _YELLOW_(%s), blockNum, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2496,14 +2515,14 @@ int CmdHF14AMfESave(const char *Cmd) {
|
||||
blocks = NumOfBlocks(c);
|
||||
bytes = blocks * MFBLOCK_SIZE;
|
||||
|
||||
dump = calloc(sizeof(uint8_t), bytes);
|
||||
dump = calloc(bytes, sizeof(uint8_t));
|
||||
if (!dump) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 1;
|
||||
}
|
||||
memset(dump, 0, bytes);
|
||||
|
||||
PrintAndLogEx(INFO, "dowingloading from emulator memory");
|
||||
PrintAndLogEx(INFO, "downloading from emulator memory");
|
||||
if (!GetFromDevice( BIG_BUF_EML, dump, bytes, 0, NULL, 2500, false)) {
|
||||
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
||||
free(dump);
|
||||
@@ -2761,7 +2780,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
||||
blockNum++;
|
||||
|
||||
// magic card type - mifare 1K
|
||||
if (blockNum >= 16 * 4) break;
|
||||
if (blockNum >= MIFARE_1K_MAXBLOCK ) break;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
@@ -2783,8 +2802,8 @@ int CmdHF14AMfCGetBlk(const char *Cmd) {
|
||||
int res;
|
||||
memset(data, 0x00, sizeof(data));
|
||||
|
||||
char ctmp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h' || ctmp == 'H') return usage_hf14_cgetblk();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h') return usage_hf14_cgetblk();
|
||||
|
||||
blockNo = param_get8(Cmd, 0);
|
||||
|
||||
@@ -2819,8 +2838,8 @@ int CmdHF14AMfCGetSc(const char *Cmd) {
|
||||
uint8_t sector = 0;
|
||||
int i, res, flags;
|
||||
|
||||
char ctmp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h' || ctmp == 'H') return usage_hf14_cgetsc();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h') return usage_hf14_cgetsc();
|
||||
|
||||
sector = param_get8(Cmd, 0);
|
||||
if (sector > 39) {
|
||||
@@ -2912,7 +2931,7 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
||||
|
||||
if (errors || cmdp == 0) return usage_hf14_csave();
|
||||
|
||||
dump = malloc(bytes);
|
||||
dump = calloc(bytes, sizeof(uint8_t));
|
||||
if (!dump) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 1;
|
||||
@@ -2958,8 +2977,8 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
||||
//needs nt, ar, at, Data to decrypt
|
||||
int CmdHf14AMfDecryptBytes(const char *Cmd){
|
||||
|
||||
char ctmp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h' || ctmp == 'H') return usage_hf14_decryptbytes();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h') return usage_hf14_decryptbytes();
|
||||
|
||||
uint32_t nt = param_get32ex(Cmd,0,0,16);
|
||||
uint32_t ar_enc = param_get32ex(Cmd,1,0,16);
|
||||
@@ -3010,7 +3029,7 @@ int CmdHf14AMfSetMod(const char *Cmd) {
|
||||
UsbCommand resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t ok = resp.arg[0] & 0xff;
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", ok);
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", ok);
|
||||
if (!ok)
|
||||
PrintAndLogEx(FAILED, "Failed.");
|
||||
} else {
|
||||
@@ -3023,12 +3042,12 @@ int CmdHf14AMfSetMod(const char *Cmd) {
|
||||
int CmdHf14AMfNack(const char *Cmd) {
|
||||
|
||||
bool verbose = false;
|
||||
char ctmp = param_getchar(Cmd, 0);
|
||||
if ( ctmp == 'h' || ctmp == 'H' ) return usage_hf14_nack();
|
||||
if ( ctmp == 'v' || ctmp == 'V' ) verbose = true;
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if ( ctmp == 'h' ) return usage_hf14_nack();
|
||||
if ( ctmp == 'v' ) verbose = true;
|
||||
|
||||
if ( verbose )
|
||||
PrintAndLogEx(NORMAL, "Started testing card for NACK bug. Press key to abort");
|
||||
PrintAndLogEx(INFO, "Started testing card for NACK bug. Press key to abort");
|
||||
|
||||
detect_classic_nackbug(verbose);
|
||||
return 0;
|
||||
@@ -3086,7 +3105,7 @@ int CmdHF14AMfice(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "Collecting %u nonces \n", limit);
|
||||
|
||||
if ((fnonces = fopen(filename,"wb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not create file %s",filename);
|
||||
PrintAndLogEx(WARNING, "Could not create file " _YELLOW_(%s),filename);
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -3097,7 +3116,7 @@ int CmdHF14AMfice(const char *Cmd) {
|
||||
do {
|
||||
if (ukbhit()) {
|
||||
int gc = getchar(); (void)gc;
|
||||
PrintAndLogEx(NORMAL, "\naborted via keyboard!\n");
|
||||
PrintAndLogEx(INFO, "\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3119,7 +3138,7 @@ int CmdHF14AMfice(const char *Cmd) {
|
||||
|
||||
total_num_nonces += items;
|
||||
if ( total_num_nonces > part_limit ) {
|
||||
PrintAndLogEx(NORMAL, "Total nonces %u\n", total_num_nonces);
|
||||
PrintAndLogEx(INFO, "Total nonces %u\n", total_num_nonces);
|
||||
part_limit += 3000;
|
||||
}
|
||||
|
||||
@@ -3130,7 +3149,7 @@ int CmdHF14AMfice(const char *Cmd) {
|
||||
} while (!acquisition_completed);
|
||||
|
||||
out:
|
||||
PrintAndLogEx(NORMAL, "time: %" PRIu64 " seconds\n", (msclock()-t1)/1000);
|
||||
PrintAndLogEx(SUCCESS, "time: %" PRIu64 " seconds\n", (msclock()-t1)/1000);
|
||||
|
||||
if ( fnonces ) {
|
||||
fflush(fnonces);
|
||||
|
||||
@@ -209,7 +209,7 @@ static int compare_count_bitflip_bitarrays(const void *b1, const void *b2)
|
||||
|
||||
static voidpf inflate_malloc(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
return malloc(items*size);
|
||||
return calloc(items*size, sizeof(uint8_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -1038,8 +1038,11 @@ static bool shrink_key_space(float *brute_forces)
|
||||
}
|
||||
*brute_forces = MIN(brute_forces1, brute_forces2);
|
||||
float reduction_rate = update_reduction_rate(*brute_forces, false);
|
||||
return ((hardnested_stage & CHECK_2ND_BYTES)
|
||||
&& reduction_rate >= 0.0 && reduction_rate < brute_force_per_second * sample_period / 1000.0);
|
||||
|
||||
//iceman 2018
|
||||
return ((hardnested_stage & CHECK_2ND_BYTES) &&
|
||||
reduction_rate >= 0.0 &&
|
||||
( reduction_rate < brute_force_per_second * (float)sample_period / 1000.0 || *brute_forces < 0x1F000000000));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+28
-35
@@ -980,11 +980,11 @@ int CmdHF14AMfUInfo(const char *Cmd){
|
||||
if ( hasAuthKey ) return 1;
|
||||
|
||||
// also try to diversify default keys.. look into CmdHF14AMfuGenDiverseKeys
|
||||
PrintAndLogEx(NORMAL, "Trying some default 3des keys");
|
||||
PrintAndLogEx(INFO, "Trying some default 3des keys");
|
||||
for (uint8_t i = 0; i < KEYS_3DES_COUNT; ++i ) {
|
||||
key = default_3des_keys[i];
|
||||
if (ulc_authentication(key, true)) {
|
||||
PrintAndLogEx(NORMAL, "Found default 3des key: ");
|
||||
PrintAndLogEx(SUCCESS, "Found default 3des key: ");
|
||||
uint8_t keySwap[16];
|
||||
memcpy(keySwap, SwapEndian64(key,16,8), 16);
|
||||
ulc_print_3deskey(keySwap);
|
||||
@@ -1079,7 +1079,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
|
||||
num_to_bytes( ul_ev1_pwdgenA(card.uid), 4, key);
|
||||
len = ulev1_requestAuthentication(key, pack, sizeof(pack));
|
||||
if (len > -1) {
|
||||
PrintAndLogEx(NORMAL, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
PrintAndLogEx(SUCCESS, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1089,7 +1089,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
|
||||
num_to_bytes( ul_ev1_pwdgenB(card.uid), 4, key);
|
||||
len = ulev1_requestAuthentication(key, pack, sizeof(pack));
|
||||
if (len > -1) {
|
||||
PrintAndLogEx(NORMAL, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
PrintAndLogEx(SUCCESS, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
|
||||
num_to_bytes( ul_ev1_pwdgenC(card.uid), 4, key);
|
||||
len = ulev1_requestAuthentication(key, pack, sizeof(pack));
|
||||
if (len > -1) {
|
||||
PrintAndLogEx(NORMAL, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
PrintAndLogEx(SUCCESS, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1109,7 +1109,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
|
||||
num_to_bytes( ul_ev1_pwdgenD(card.uid), 4, key);
|
||||
len = ulev1_requestAuthentication(key, pack, sizeof(pack));
|
||||
if (len > -1) {
|
||||
PrintAndLogEx(NORMAL, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
PrintAndLogEx(SUCCESS, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1119,13 +1119,13 @@ int CmdHF14AMfUInfo(const char *Cmd){
|
||||
key = default_pwd_pack[i];
|
||||
len = ulev1_requestAuthentication(key, pack, sizeof(pack));
|
||||
if (len > -1) {
|
||||
PrintAndLogEx(NORMAL, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
PrintAndLogEx(SUCCESS, "Found a default password: %s || Pack: %02X %02X",sprint_hex(key, 4), pack[0], pack[1]);
|
||||
break;
|
||||
} else {
|
||||
if (!ul_auth_select( &card, tagtype, hasAuthKey, authkeyptr, pack, sizeof(pack))) return -1;
|
||||
}
|
||||
}
|
||||
if (len < 1) PrintAndLogEx(NORMAL, "password not known");
|
||||
if (len < 1) PrintAndLogEx(WARNING, "password not known");
|
||||
}
|
||||
}
|
||||
out:
|
||||
@@ -1250,7 +1250,7 @@ int CmdHF14AMfUWrBl(const char *Cmd){
|
||||
UsbCommand resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ int CmdHF14AMfURdBl(const char *Cmd){
|
||||
PrintAndLogEx(WARNING, "Failed reading block: (%02x)", isOK);
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "Command execute time-out");
|
||||
PrintAndLogEx(WARNING, "Command execute time-out");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1743,7 +1743,7 @@ int CmdHF14AMfUDump(const char *Cmd){
|
||||
}
|
||||
}
|
||||
ul_print_type(tagtype, 0);
|
||||
PrintAndLogEx(NORMAL, "Reading tag memory...");
|
||||
PrintAndLogEx(SUCCESS, "Reading tag memory...");
|
||||
UsbCommand c = {CMD_MIFAREU_READCARD, {startPage, pages}};
|
||||
if ( hasAuthKey ) {
|
||||
if (tagtype & UL_C)
|
||||
@@ -1912,12 +1912,10 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
memset(authkey, 0x00, sizeof(authkey));
|
||||
|
||||
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch(param_getchar(Cmd, cmdp)) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
return usage_hf_mfu_restore();
|
||||
case 'k':
|
||||
case 'K':
|
||||
keylen = param_getstr(Cmd, cmdp+1, tempStr, sizeof(tempStr));
|
||||
if (keylen == 32 || keylen == 8) { //ul-c or ev1/ntag key length
|
||||
errors = param_gethex(tempStr, 0, authkey, keylen);
|
||||
@@ -1930,12 +1928,10 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
hasKey = true;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
swapEndian = true;
|
||||
cmdp++;
|
||||
break;
|
||||
case 'f':
|
||||
case 'F':
|
||||
filelen = param_getstr(Cmd, cmdp+1, filename, FILE_PATH_SIZE);
|
||||
|
||||
if (filelen > FILE_PATH_SIZE-5)
|
||||
@@ -1947,17 +1943,14 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
cmdp++;
|
||||
write_special = true;
|
||||
break;
|
||||
case 'e':
|
||||
case 'E':
|
||||
cmdp++;
|
||||
write_extra = true;
|
||||
break;
|
||||
case 'r':
|
||||
case 'R':
|
||||
cmdp++;
|
||||
read_key = true;
|
||||
break;
|
||||
@@ -1972,7 +1965,7 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
if (errors || cmdp == 0) return usage_hf_mfu_restore();
|
||||
|
||||
if ((f = fopen(filename,"rb")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Could not find file %s", filename);
|
||||
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_(%s), filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2000,7 +1993,7 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Restoring %s to card", filename);
|
||||
PrintAndLogEx(INFO, "Restoring " _YELLOW_(%s)" to card", filename);
|
||||
|
||||
mfu_dump_t *mem = (mfu_dump_t*)dump;
|
||||
uint8_t pages = (bytes_read-48)/4;
|
||||
@@ -2084,7 +2077,7 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Restoring data blocks.");
|
||||
PrintAndLogEx(INFO, "Restoring data blocks.");
|
||||
// write all other data
|
||||
// Skip block 0,1,2,3 (only magic tags can write to them)
|
||||
// Skip last 5 blocks usually is configuration
|
||||
@@ -2103,7 +2096,7 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
// write special data last
|
||||
if (write_special) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "Restoring configuration blocks.\n");
|
||||
PrintAndLogEx(INFO, "Restoring configuration blocks.\n");
|
||||
|
||||
PrintAndLogEx(NORMAL, "authentication with keytype[%x] %s\n", (uint8_t)(c.arg[1] & 0xff), sprint_hex(p_authkey,4));
|
||||
|
||||
@@ -2128,16 +2121,16 @@ int CmdHF14AMfURestore(const char *Cmd){
|
||||
// Load emulator with dump file
|
||||
//
|
||||
int CmdHF14AMfUeLoad(const char *Cmd){
|
||||
char c = param_getchar(Cmd, 0);
|
||||
if ( c == 'h' || c == 'H' || c == 0x00) return usage_hf_mfu_eload();
|
||||
char c = tolower(param_getchar(Cmd, 0));
|
||||
if ( c == 'h' || c == 0x00) return usage_hf_mfu_eload();
|
||||
return CmdHF14AMfELoad(Cmd);
|
||||
}
|
||||
//
|
||||
// Simulate tag
|
||||
//
|
||||
int CmdHF14AMfUSim(const char *Cmd){
|
||||
char c = param_getchar(Cmd, 0);
|
||||
if ( c == 'h' || c == 'H' || c == 0x00) return usage_hf_mfu_sim();
|
||||
char c = tolower(param_getchar(Cmd, 0));
|
||||
if ( c == 'h' || c == 0x00) return usage_hf_mfu_sim();
|
||||
return CmdHF14ASim(Cmd);
|
||||
}
|
||||
|
||||
@@ -2153,16 +2146,16 @@ int CmdHF14AMfucAuth(const char *Cmd){
|
||||
uint8_t keyNo = 3;
|
||||
bool errors = false;
|
||||
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
|
||||
//Change key to user defined one
|
||||
if (cmdp == 'k' || cmdp == 'K'){
|
||||
if (cmdp == 'k'){
|
||||
keyNo = param_get8(Cmd, 1);
|
||||
if(keyNo >= KEYS_3DES_COUNT)
|
||||
errors = true;
|
||||
}
|
||||
|
||||
if (cmdp == 'h' || cmdp == 'H') errors = true;
|
||||
if (cmdp == 'h') errors = true;
|
||||
|
||||
if (errors) return usage_hf_mfu_ucauth();
|
||||
|
||||
@@ -2278,9 +2271,9 @@ int CmdTestDES(const char * cmd)
|
||||
int CmdHF14AMfucSetPwd(const char *Cmd){
|
||||
|
||||
uint8_t pwd[16] = {0x00};
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_hf_mfu_ucsetpwd();
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_hf_mfu_ucsetpwd();
|
||||
|
||||
if (param_gethex(Cmd, 0, pwd, 32)) {
|
||||
PrintAndLogEx(WARNING, "Password must include 32 HEX symbols");
|
||||
@@ -2295,7 +2288,7 @@ int CmdHF14AMfucSetPwd(const char *Cmd){
|
||||
UsbCommand resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1500) ) {
|
||||
if ( (resp.arg[0] & 0xff) == 1) {
|
||||
PrintAndLogEx(NORMAL, "Ultralight-C new password: %s", sprint_hex(pwd,16));
|
||||
PrintAndLogEx(INFO, "Ultralight-C new password: %s", sprint_hex(pwd,16));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Failed writing at block %d", resp.arg[1] & 0xff);
|
||||
return 1;
|
||||
@@ -2315,9 +2308,9 @@ int CmdHF14AMfucSetUid(const char *Cmd){
|
||||
UsbCommand c = {CMD_MIFAREU_READBL};
|
||||
UsbCommand resp;
|
||||
uint8_t uid[7] = {0x00};
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_hf_mfu_ucsetuid();
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_hf_mfu_ucsetuid();
|
||||
|
||||
if (param_gethex(Cmd, 0, uid, 14)) {
|
||||
PrintAndLogEx(WARNING, "UID must include 14 HEX symbols");
|
||||
|
||||
+3
-3
@@ -194,7 +194,7 @@ static int topaz_print_CC(uint8_t *data) {
|
||||
PrintAndLogEx(NORMAL, " %02x: version %d.%d supported by tag", data[1], (data[1] & 0xF0) >> 4, data[1] & 0x0f);
|
||||
uint16_t memsize = (data[2] + 1) * 8;
|
||||
topaz_tag.size = memsize;
|
||||
topaz_tag.dynamic_memory = malloc(memsize - TOPAZ_STATIC_MEMORY);
|
||||
topaz_tag.dynamic_memory = calloc(memsize - TOPAZ_STATIC_MEMORY, sizeof(uint8_t));
|
||||
PrintAndLogEx(NORMAL, " %02x: Physical Memory Size of this tag: %d bytes", data[2], memsize);
|
||||
PrintAndLogEx(NORMAL, " %02x: %s / %s", data[3],
|
||||
(data[3] & 0xF0) ? "(RFU)" : "Read access granted without any security",
|
||||
@@ -278,12 +278,12 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
|
||||
dynamic_lock_area_t *old = topaz_tag.dynamic_lock_areas;
|
||||
dynamic_lock_area_t *new = topaz_tag.dynamic_lock_areas;
|
||||
if (old == NULL) {
|
||||
new = topaz_tag.dynamic_lock_areas = (dynamic_lock_area_t *)malloc(sizeof(dynamic_lock_area_t));
|
||||
new = topaz_tag.dynamic_lock_areas = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t) , sizeof(uint8_t));
|
||||
} else {
|
||||
while(old->next != NULL) {
|
||||
old = old->next;
|
||||
}
|
||||
new = old->next = (dynamic_lock_area_t *)malloc(sizeof(dynamic_lock_area_t));
|
||||
new = old->next = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t), sizeof(uint8_t));
|
||||
}
|
||||
new->next = NULL;
|
||||
if (area_start <= next_lockable_byte) {
|
||||
|
||||
+3
-3
@@ -257,9 +257,9 @@ int CmdVersion(const char *Cmd) {
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
|
||||
#ifdef __WIN32
|
||||
PrintAndLogEx(NORMAL, "\nProxmark3 RFID instrument\n");
|
||||
PrintAndLogEx(NORMAL, "\n [ Proxmark3 RFID instrument ]\n");
|
||||
#else
|
||||
PrintAndLogEx(NORMAL, "\n\e[34mProxmark3 RFID instrument\e[0m\n");
|
||||
PrintAndLogEx(NORMAL, "\n\e[34m [ Proxmark3 RFID instrument ]\e[0m\n");
|
||||
#endif
|
||||
char s[50] = {0};
|
||||
#if defined(WITH_FLASH) || defined(WITH_SMARTCARD) || defined(WITH_FPC)
|
||||
@@ -275,7 +275,7 @@ int CmdVersion(const char *Cmd) {
|
||||
strncat(s, "fpc; ", sizeof(s) - strlen(s) - 1);
|
||||
#endif
|
||||
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
|
||||
PrintAndLogEx(NORMAL, " client: iceman %s \n", s);
|
||||
PrintAndLogEx(NORMAL, " client: iceman %s \n", s);
|
||||
|
||||
PrintAndLogEx(NORMAL, (char*)resp.d.asBytes);
|
||||
lookupChipID(resp.arg[0], resp.arg[1]);
|
||||
|
||||
+121
-52
@@ -141,21 +141,33 @@ int usage_t55xx_wakup(){
|
||||
PrintAndLogEx(NORMAL, " lf t55xx wakeup p 11223344 - send wakeup password");
|
||||
return 0;
|
||||
}
|
||||
int usage_t55xx_bruteforce(){
|
||||
PrintAndLogEx(NORMAL, "This command uses A) bruteforce to scan a number range");
|
||||
PrintAndLogEx(NORMAL, " B) a dictionary attack");
|
||||
int usage_t55xx_chk(){
|
||||
PrintAndLogEx(NORMAL, "This command uses a dictionary attack");
|
||||
PrintAndLogEx(NORMAL, "press 'enter' to cancel the command");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx bruteforce [h] <start password> <end password> [i <*.dic>]");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx bruteforce [h] <m> [i <*.dic>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " m - use dictionary from flashmemory\n");
|
||||
PrintAndLogEx(NORMAL, " i <*.dic> - loads a default keys dictionary file <*.dic>");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx bruteforce m");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx bruteforce i default_pwd.dic");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return 0;
|
||||
}
|
||||
int usage_t55xx_bruteforce(){
|
||||
PrintAndLogEx(NORMAL, "This command uses bruteforce to scan a number range");
|
||||
PrintAndLogEx(NORMAL, "press 'enter' to cancel the command");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx bruteforce [h] <start password> <end password>");
|
||||
PrintAndLogEx(NORMAL, " password must be 4 bytes (8 hex symbols)");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " <start_pwd> - 4 byte hex value to start pwd search at");
|
||||
PrintAndLogEx(NORMAL, " <end_pwd> - 4 byte hex value to end pwd search at");
|
||||
PrintAndLogEx(NORMAL, " i <*.dic> - loads a default keys dictionary file <*.dic>");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx bruteforce aaaaaaaa bbbbbbbb");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx bruteforce i default_pwd.dic");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return 0;
|
||||
}
|
||||
@@ -224,10 +236,9 @@ int CmdT55xxSetConfig(const char *Cmd) {
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
tmp = param_getchar(Cmd, cmdp);
|
||||
tmp = tolower(param_getchar(Cmd, cmdp));
|
||||
switch(tmp) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
return usage_t55xx_config();
|
||||
case 'b':
|
||||
errors |= param_getdec(Cmd, cmdp+1, &bitRate);
|
||||
@@ -292,12 +303,10 @@ int CmdT55xxSetConfig(const char *Cmd) {
|
||||
config.offset = offset;
|
||||
cmdp+=2;
|
||||
break;
|
||||
case 'Q':
|
||||
case 'q':
|
||||
config.Q5 = true;
|
||||
cmdp++;
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
config.ST = true;
|
||||
cmdp++;
|
||||
@@ -343,8 +352,8 @@ int T55xxReadBlock(uint8_t block, bool page1, bool usepwd, bool override, uint32
|
||||
if (!AquireData(page1, block, usepwd, password) ) return 0;
|
||||
if (!DecodeT55xxBlock()) return 0;
|
||||
|
||||
char blk[10]={0};
|
||||
sprintf(blk,"%02d", block);
|
||||
char blk[10] = {0};
|
||||
sprintf(blk, "%02d", block);
|
||||
printT55xxBlock(blk);
|
||||
return 1;
|
||||
}
|
||||
@@ -358,22 +367,18 @@ int CmdT55xxReadBlock(const char *Cmd) {
|
||||
bool errors = false;
|
||||
uint8_t cmdp = 0;
|
||||
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch(param_getchar(Cmd, cmdp)) {
|
||||
switch ( tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
return usage_t55xx_read();
|
||||
case 'b':
|
||||
case 'B':
|
||||
errors |= param_getdec(Cmd, cmdp+1, &block);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'o':
|
||||
case 'O':
|
||||
override = true;
|
||||
cmdp++;
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
password = param_get32ex(Cmd, cmdp+1, 0, 16);
|
||||
usepwd = true;
|
||||
cmdp += 2;
|
||||
@@ -1503,23 +1508,68 @@ bool IsCancelled(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int CmdT55xxBruteForce(const char *Cmd) {
|
||||
|
||||
int CmdT55xxChkPwds(const char *Cmd) {
|
||||
// load a default pwd file.
|
||||
char line[9];
|
||||
char filename[FILE_PATH_SIZE] = {0};
|
||||
int keycnt = 0;
|
||||
uint8_t stKeyBlock = 20;
|
||||
uint8_t *keyBlock = NULL, *p = NULL;
|
||||
uint32_t start_password = 0x00000000; //start password
|
||||
uint32_t end_password = 0xFFFFFFFF; //end password
|
||||
bool found = false;
|
||||
uint8_t timeout = 0;
|
||||
|
||||
memset(line, 0, sizeof(line));
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_t55xx_bruteforce();
|
||||
if (cmdp == 'h') return usage_t55xx_chk();
|
||||
|
||||
/*
|
||||
if ( T55xxReadBlock(7, 0, 0, 0, 0) ) {
|
||||
|
||||
// now try to validate it..
|
||||
PrintAndLogEx(WARNING, "\n Block 7 was readable");
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
if ( cmdp == 'm' ) {
|
||||
UsbCommand c = {CMD_T55XX_CHKPWDS, {0,0,0} };
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
|
||||
while ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) {
|
||||
timeout++;
|
||||
printf("."); fflush(stdout);
|
||||
if (timeout > 180) {
|
||||
PrintAndLogEx(WARNING, "\nno response from Proxmark. Aborting...");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ( resp.arg[0] ) {
|
||||
PrintAndLogEx(SUCCESS, "\nFound a candidate [ %08X ]. Trying to validate", resp.arg[1]);
|
||||
|
||||
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, resp.arg[1])) {
|
||||
PrintAndLogEx(INFO, "Aquireing data from device failed. Quitting");
|
||||
return 2;
|
||||
}
|
||||
|
||||
found = tryDetectModulation();
|
||||
if (found) {
|
||||
PrintAndLogEx(SUCCESS, "Found valid password: [ %08X ]", resp.arg[1]);
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Password NOT found.");
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Password NOT found.");
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
keyBlock = calloc(stKeyBlock, 4);
|
||||
if (keyBlock == NULL) return 1;
|
||||
|
||||
@@ -1531,7 +1581,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
|
||||
|
||||
FILE * f = fopen( filename , "r");
|
||||
if ( !f ) {
|
||||
PrintAndLogEx(NORMAL, "File: %s: not found or locked.", filename);
|
||||
PrintAndLogEx(WARNING, "File: %s: not found or locked.", filename);
|
||||
free(keyBlock);
|
||||
return 1;
|
||||
}
|
||||
@@ -1546,7 +1596,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
|
||||
if( line[0]=='#' ) continue;
|
||||
|
||||
if (!isxdigit(line[0])) {
|
||||
PrintAndLogEx(NORMAL, "File content error. '%s' must include 8 HEX symbols", line);
|
||||
PrintAndLogEx(WARNING, "File content error. '%s' must include 8 HEX symbols", line);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1569,7 +1619,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
|
||||
|
||||
num_to_bytes( strtoll(line, NULL, 16), 4, keyBlock + 4*keycnt);
|
||||
|
||||
PrintAndLogEx(NORMAL, "chk custom pwd[%2d] %08X", keycnt, bytes_to_num(keyBlock + 4 * keycnt, 4) );
|
||||
// PrintAndLogEx(NORMAL, "chk custom pwd[%2d] %08X", keycnt, bytes_to_num(keyBlock + 4 * keycnt, 4) );
|
||||
keycnt++;
|
||||
memset(line, 0, sizeof(line));
|
||||
}
|
||||
@@ -1577,11 +1627,11 @@ int CmdT55xxBruteForce(const char *Cmd) {
|
||||
fclose(f);
|
||||
|
||||
if (keycnt == 0) {
|
||||
PrintAndLogEx(NORMAL, "No keys found in file");
|
||||
PrintAndLogEx(WARNING, "No keys found in file");
|
||||
free(keyBlock);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Loaded %d keys", keycnt);
|
||||
PrintAndLogEx(SUCCESS, "Loaded %d keys", keycnt);
|
||||
|
||||
// loop
|
||||
uint64_t testpwd = 0x00;
|
||||
@@ -1600,69 +1650,87 @@ int CmdT55xxBruteForce(const char *Cmd) {
|
||||
|
||||
testpwd = bytes_to_num(keyBlock + 4*c, 4);
|
||||
|
||||
PrintAndLogEx(NORMAL, "Testing %08X", testpwd);
|
||||
PrintAndLogEx(INFO, "Testing %08X", testpwd);
|
||||
|
||||
if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, testpwd)) {
|
||||
PrintAndLogEx(NORMAL, "Aquireing data from device failed. Quitting");
|
||||
PrintAndLogEx(INFO, "Aquireing data from device failed. Quitting");
|
||||
free(keyBlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
found = tryDetectModulation();
|
||||
if ( found ) {
|
||||
PrintAndLogEx(NORMAL, "Found valid password: [%08X]", testpwd);
|
||||
//free(keyBlock);
|
||||
//return 0;
|
||||
}
|
||||
if ( found )
|
||||
break;
|
||||
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Password NOT found.");
|
||||
free(keyBlock);
|
||||
return 0;
|
||||
if ( found )
|
||||
PrintAndLogEx(SUCCESS, "Found valid password: [ %08X ]", testpwd);
|
||||
else
|
||||
PrintAndLogEx(WARNING, "Password NOT found.");
|
||||
}
|
||||
|
||||
free(keyBlock);
|
||||
|
||||
out:
|
||||
t1 = msclock() - t1;
|
||||
PrintAndLogEx(SUCCESS, "\nTime in bruteforce: %.0f seconds\n", (float)t1/1000.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdT55xxBruteForce(const char *Cmd) {
|
||||
|
||||
uint32_t start_password = 0x00000000; //start password
|
||||
uint32_t end_password = 0xFFFFFFFF; //end password
|
||||
uint32_t curr = 0;
|
||||
bool found = false;
|
||||
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_t55xx_bruteforce();
|
||||
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
// Try to read Block 7, first :)
|
||||
|
||||
// incremental pwd range search
|
||||
start_password = param_get32ex(Cmd, 0, 0, 16);
|
||||
end_password = param_get32ex(Cmd, 1, 0, 16);
|
||||
|
||||
curr = start_password;
|
||||
|
||||
if ( start_password >= end_password ) {
|
||||
free(keyBlock);
|
||||
return usage_t55xx_bruteforce();
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Search password range [%08X -> %08X]", start_password, end_password);
|
||||
|
||||
uint32_t i = start_password;
|
||||
PrintAndLogEx(INFO, "Search password range [%08X -> %08X]", start_password, end_password);
|
||||
|
||||
while ((!found) && (i <= end_password)){
|
||||
while ((!found) || (curr <= end_password)){
|
||||
|
||||
printf("."); fflush(stdout);
|
||||
|
||||
if (IsCancelled()) {
|
||||
free(keyBlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, i)) {
|
||||
PrintAndLogEx(NORMAL, "Aquireing data from device failed. Quitting");
|
||||
free(keyBlock);
|
||||
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, curr)) {
|
||||
PrintAndLogEx(WARNING, "Aquireing data from device failed. Quitting");
|
||||
return 0;
|
||||
}
|
||||
found = tryDetectModulation();
|
||||
|
||||
if (found) break;
|
||||
i++;
|
||||
++curr;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
if (found)
|
||||
PrintAndLogEx(NORMAL, "Found valid password: [%08x]", i);
|
||||
PrintAndLogEx(SUCCESS, "Found valid password: [ %08X ]", curr);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "Password NOT found. Last tried: [%08x]", --i);
|
||||
PrintAndLogEx(WARNING, "Password NOT found. Last tried: [ %08X ]", --curr);
|
||||
|
||||
free(keyBlock);
|
||||
t1 = msclock() - t1;
|
||||
PrintAndLogEx(SUCCESS, "\nTime in bruteforce: %.0f seconds\n", (float)t1/1000.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1746,9 +1814,9 @@ int CmdT55xxRecoverPW(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
if (found == 1)
|
||||
PrintAndLogEx(NORMAL, "Found valid password: [%08x]", curr_password);
|
||||
PrintAndLogEx(SUCCESS, "Found valid password: [%08x]", curr_password);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "Password NOT found.");
|
||||
PrintAndLogEx(WARNING, "Password NOT found.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1959,6 +2027,7 @@ static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"bruteforce", CmdT55xxBruteForce,0, "<start password> <end password> [i <*.dic>] Simple bruteforce attack to find password"},
|
||||
{"config", CmdT55xxSetConfig, 1, "Set/Get T55XX configuration (modulation, inverted, offset, rate)"},
|
||||
{"chk", CmdT55xxChkPwds, 1, "Check passwords"},
|
||||
{"detect", CmdT55xxDetect, 1, "[1] Try detecting the tag modulation from reading the configuration block."},
|
||||
{"deviceconfig", CmdT55xxSetDeviceConfig, 1, "Set/Get T55XX device configuration (startgap, writegap, write0, write1, readgap"},
|
||||
{"p1detect", CmdT55xxDetectPage1,1, "[1] Try detecting if this is a t55xx tag by reading page 1"},
|
||||
|
||||
@@ -133,6 +133,7 @@ t55xx_conf_block_t Get_t55xx_Config(void);
|
||||
void Set_t55xx_Config(t55xx_conf_block_t conf);
|
||||
|
||||
extern int CmdLFT55XX(const char *Cmd);
|
||||
extern int CmdT55xxChk(const char *Cmd);
|
||||
extern int CmdT55xxBruteForce(const char *Cmd);
|
||||
extern int CmdT55xxSetConfig(const char *Cmd);
|
||||
extern int CmdT55xxReadBlock(const char *Cmd);
|
||||
|
||||
@@ -356,7 +356,7 @@ static int smart_responseEx(uint8_t *data, bool silent) {
|
||||
if (needGetData) {
|
||||
int len = data[datalen - 1];
|
||||
if (!silent) PrintAndLogEx(INFO, "Requesting 0x%02X bytes response", len);
|
||||
uint8_t getstatus[] = {0x00, ISO7816_GETSTATUS, 0x00, 0x00, len};
|
||||
uint8_t getstatus[] = {0x00, ISO7816_GET_RESPONSE, 0x00, 0x00, len};
|
||||
UsbCommand cStatus = {CMD_SMART_RAW, {SC_RAW, sizeof(getstatus), 0}};
|
||||
memcpy(cStatus.d.asBytes, getstatus, sizeof(getstatus) );
|
||||
clearCommandBuffer();
|
||||
@@ -372,7 +372,7 @@ static int smart_responseEx(uint8_t *data, bool silent) {
|
||||
if (datalen != len + 2) {
|
||||
// data with ACK
|
||||
if (datalen == len + 2 + 1) { // 2 - response, 1 - ACK
|
||||
if (data[0] != ISO7816_GETSTATUS) {
|
||||
if (data[0] != ISO7816_GET_RESPONSE) {
|
||||
if (!silent) {
|
||||
PrintAndLogEx(ERR, "GetResponse ACK error. len 0x%x | data[0] %02X", len, data[0]);
|
||||
}
|
||||
@@ -1012,7 +1012,7 @@ int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||
json_t *root = NULL;
|
||||
smart_loadjson("aidlist", "json", &root);
|
||||
|
||||
uint8_t* buf = malloc(USB_CMD_DATA_SIZE);
|
||||
uint8_t* buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||
if ( !buf )
|
||||
return 1;
|
||||
|
||||
|
||||
+44
-1
@@ -711,4 +711,47 @@ FD8705E721B0,
|
||||
00ada2cd516d,
|
||||
#
|
||||
#
|
||||
D3F7D3F7D3F7
|
||||
D3F7D3F7D3F7
|
||||
##
|
||||
237a4d0d9119,
|
||||
0ed7846c2bc9,
|
||||
FFFFD06F83E3,
|
||||
FFFFAE82366C,
|
||||
F89C86B2A961,
|
||||
F83466888612,
|
||||
ED3A7EFBFF56,
|
||||
E96246531342,
|
||||
E1DD284379D4,
|
||||
DFED39FFBB76,
|
||||
DB5181C92CBE,
|
||||
CFC738403AB0,
|
||||
BCFE01BCFE01,
|
||||
BA28CFD15EE8,
|
||||
B0699AD03D17,
|
||||
AABBCC660429,
|
||||
A4EF6C3BB692,
|
||||
A2B2C9D187FB,
|
||||
9B1DD7C030A1,
|
||||
9AEDF9931EC1,
|
||||
8F9B229047AC,
|
||||
872B71F9D15A,
|
||||
833FBD3CFE51,
|
||||
5D293AFC8D7E,
|
||||
5554AAA96321,
|
||||
474249437569,
|
||||
435330666666,
|
||||
1A2B3C4D5E6F,
|
||||
123456ABCDEF,
|
||||
83BAB5ACAD62,
|
||||
64E2283FCF5E,
|
||||
64A2EE93B12B,
|
||||
46868F6D5677,
|
||||
40E5EA1EFC00,
|
||||
37D4DCA92451,
|
||||
2012053082AD,
|
||||
2011092119F1,
|
||||
200306202033,
|
||||
1795902DBAF9,
|
||||
17505586EF02,
|
||||
022FE48B3072,
|
||||
013940233313,
|
||||
@@ -96,6 +96,7 @@ FABADA11, //china?
|
||||
69696969,
|
||||
12121212,
|
||||
12344321,
|
||||
1234ABCD,
|
||||
11112222,
|
||||
13131313,
|
||||
10041004,
|
||||
@@ -104,8 +105,8 @@ FABADA11, //china?
|
||||
abcd1234,
|
||||
20002000,
|
||||
19721972,
|
||||
aa55aa55, //amiboo
|
||||
55aa55aa, //rev amiboo
|
||||
aa55aa55, // amiboo
|
||||
55aa55aa, // rev amiboo
|
||||
4f271149, // seeds ul-ev1
|
||||
07d7bb0b, // seeds ul-ev1
|
||||
9636ef8f, // seeds ul-ev1
|
||||
@@ -113,4 +114,4 @@ b5f44686, // seeds ul-ev1
|
||||
9E3779B9, // TEA
|
||||
C6EF3720, // TEA
|
||||
7854794A, // xbox tea constant :)
|
||||
F1EA5EED, //burtle
|
||||
F1EA5EED, // burtle
|
||||
@@ -0,0 +1,1000 @@
|
||||
002DE0301481,
|
||||
004173272D18,
|
||||
0058A4884CA5,
|
||||
00BAC32761D8,
|
||||
00BB79731B00,
|
||||
00E8C85DB172,
|
||||
02096124DA70,
|
||||
024988BC4D5E,
|
||||
0271B7C4B015,
|
||||
028137A705DB,
|
||||
02827C286AB4,
|
||||
02C10DA600D0,
|
||||
0340643D5E27,
|
||||
037A5DA4682B,
|
||||
037AC43CBD9D,
|
||||
037B9B8AA219,
|
||||
037EE3DE21B7,
|
||||
0380A9A3CBDE,
|
||||
03D10A75B56A,
|
||||
03E8CD22E691,
|
||||
04109ED8EA79,
|
||||
04361330B35C,
|
||||
043D8B66D569,
|
||||
045E5588845C,
|
||||
048DE5148DE7,
|
||||
0490921D0194,
|
||||
04B717BD92EB,
|
||||
04D49C76623B,
|
||||
051518B3301E,
|
||||
0529E8827A52,
|
||||
052B16064085,
|
||||
05DC4016B500,
|
||||
06124317A9A6,
|
||||
06147D199266,
|
||||
0670AEB833CE,
|
||||
0686A9E6D6E0,
|
||||
06A34E5E6639,
|
||||
06B78AD0C4BB,
|
||||
0710E7818AB8,
|
||||
07121B8C633A,
|
||||
07176713C0ED,
|
||||
0793533A5087,
|
||||
081D1B1C3110,
|
||||
0849495E1CCA,
|
||||
09429512046E,
|
||||
0966C3B28E04,
|
||||
098A92C3660A,
|
||||
098B48278122,
|
||||
099672009EEA,
|
||||
0A7632943926,
|
||||
0AEE126549DA,
|
||||
0B3B8C2833BC,
|
||||
0B733C13E2C9,
|
||||
0B764247D00E,
|
||||
0BE811559D69,
|
||||
0C208AD4E4B3,
|
||||
0C270BC0BDDC,
|
||||
0C5D782CB183,
|
||||
0C82C94EB11B,
|
||||
0CCDE948878A,
|
||||
0CCE39820AAE,
|
||||
0CDE3E716B32,
|
||||
0CE06C96DB4C,
|
||||
0CE87813E389,
|
||||
0D3385CEA152,
|
||||
0D5C5B8BCC5B,
|
||||
0DB0A87AB882,
|
||||
0DE247593B93,
|
||||
0E0AD1796003,
|
||||
0E62E6CAC3D3,
|
||||
106E2D6E55E6,
|
||||
1096A7830C82,
|
||||
11549C141AD9,
|
||||
116A92C793D6,
|
||||
116C31526819,
|
||||
11C68052AAE9,
|
||||
1234B5BE8E78,
|
||||
1268C7D104E1,
|
||||
12A21B5671A8,
|
||||
13359D5AE9A5,
|
||||
1426EC62BB6C,
|
||||
144489B1056E,
|
||||
14A22C112090,
|
||||
14C9BBB5361B,
|
||||
14EB6286AC57,
|
||||
14EE72B27223,
|
||||
153BB53ACE71,
|
||||
157B03405B38,
|
||||
15A45083D24E,
|
||||
15DACCE8D5EC,
|
||||
16124677BBC5,
|
||||
16373A44D5D7,
|
||||
1663659384DC,
|
||||
167828B6105C,
|
||||
16B25A453093,
|
||||
1706B1BE25C7,
|
||||
171B15888483,
|
||||
17BC8EED9A0C,
|
||||
17C6299D5A37,
|
||||
17E9C4C416EB,
|
||||
1804087C7166,
|
||||
1841CC4E3E79,
|
||||
18AB05761CC5,
|
||||
18ADAAC2B08B,
|
||||
18E566417E5C,
|
||||
191390328752,
|
||||
1A47959E7DB4,
|
||||
1A9A970CC370,
|
||||
1B095E78BB33,
|
||||
1B1717043D2B,
|
||||
1B1A054566D9,
|
||||
1B4654AE9454,
|
||||
1B9CD1ED3420,
|
||||
1B9E00780953,
|
||||
1BB6A9CE71E2,
|
||||
1C1250A36A13,
|
||||
1C2316079532,
|
||||
1C2855ED7A10,
|
||||
1CD1AE73CA8C,
|
||||
1CD3D4E690B7,
|
||||
1D0322005969,
|
||||
1D09B23EB116,
|
||||
1D67A32045ED,
|
||||
1D89D900968A,
|
||||
1DAE8D2CEA5C,
|
||||
1E1873799CD7,
|
||||
1E60CE7C5179,
|
||||
1E6A67909B8D,
|
||||
1E8516585792,
|
||||
1EB0864E9134,
|
||||
1ECE3D04A020,
|
||||
2009828E4A21,
|
||||
200A6A3AA65D,
|
||||
20188A599582,
|
||||
20267CB20256,
|
||||
20628CA7D92D,
|
||||
2077C980EB2E,
|
||||
2089B5D68B27,
|
||||
209481EC6256,
|
||||
20B6691C64B1,
|
||||
20CC5A00C677,
|
||||
211473555436,
|
||||
2170E9D0D448,
|
||||
219529A90EDD,
|
||||
21A5B6481B7D,
|
||||
224A308017D1,
|
||||
227D16EA455A,
|
||||
22A1245CA266,
|
||||
22A95CB798DC,
|
||||
230E26964171,
|
||||
231173B68E46,
|
||||
2332BB9A2452,
|
||||
234323BC2992,
|
||||
234E50256146,
|
||||
235C9338D5B6,
|
||||
23789D9ADD0D,
|
||||
23997DD240AB,
|
||||
23A5BA53AD4D,
|
||||
23BB58853461,
|
||||
24CAD4153036,
|
||||
24CE79506842,
|
||||
25228ED714BC,
|
||||
257377227B34,
|
||||
2584287A0174,
|
||||
2616192EEB22,
|
||||
265C03B50877,
|
||||
26D641E834DC,
|
||||
27073B57132B,
|
||||
279060E3DEE9,
|
||||
284BA0A0A29C,
|
||||
285C6604C5B4,
|
||||
28B20331245A,
|
||||
28D042242A83,
|
||||
28DDD4C3E9C4,
|
||||
292C2CCD157E,
|
||||
299ABB519354,
|
||||
2A41BE015C1D,
|
||||
2A4A55052A51,
|
||||
2A94CBCD7A6E,
|
||||
2AB6536187C7,
|
||||
2B2D2DC3D319,
|
||||
2BD607CA70B2,
|
||||
2C6C7957EB3E,
|
||||
2C9E9E4D0895,
|
||||
2D2A97DD45E3,
|
||||
2D41850A8AA6,
|
||||
2DAC030D1AB9,
|
||||
2E12426D8847,
|
||||
2E25AD1D6D8D,
|
||||
2E2E85E0E6C9,
|
||||
2E4340CC1C63,
|
||||
2E6803BE2E11,
|
||||
2EB24B573DCD,
|
||||
2EC6450A47C7,
|
||||
2ECDA9A5EA96,
|
||||
2EDE1C155023,
|
||||
302D5D37342B,
|
||||
303645E47667,
|
||||
303B30A460E8,
|
||||
3048EBB8A18E,
|
||||
30BD652BED24,
|
||||
30CCE5ECB397,
|
||||
310241E1CB36,
|
||||
312670228372,
|
||||
319E8895EAB5,
|
||||
31E3A933BC4A,
|
||||
3250D2E661DA,
|
||||
32560224418D,
|
||||
32589E221D10,
|
||||
326657A8E9C0,
|
||||
329AC7C59311,
|
||||
32A091B89995,
|
||||
3312C094BD20,
|
||||
336C8CBA5AE2,
|
||||
34240649314A,
|
||||
3493D84E6317,
|
||||
349A347186D7,
|
||||
349BEAC5210E,
|
||||
34A939B49EDC,
|
||||
34CC7E36C8C4,
|
||||
34D71347877E,
|
||||
34DC25B4D0CE,
|
||||
35895EB472C4,
|
||||
358A6A398211,
|
||||
360A08C66042,
|
||||
36306A9CA571,
|
||||
37284428A250,
|
||||
377EC8A78B8D,
|
||||
37BD90A68613,
|
||||
37E602347133,
|
||||
382DE6AB2D1A,
|
||||
385D498B5390,
|
||||
38B67589E47D,
|
||||
393CCCCCDA4A,
|
||||
39682B3E10B5,
|
||||
397619525709,
|
||||
39A83A32909B,
|
||||
3A5834C46513,
|
||||
3A70C7A4BCE4,
|
||||
3A818D01E093,
|
||||
3AA5AC1CDC21,
|
||||
3AAE07339954,
|
||||
3B4497052B42,
|
||||
3B784087DB2D,
|
||||
3B86A20C16EA,
|
||||
3B8E321AB1B4,
|
||||
3BC4A3099B0D,
|
||||
3BC741376E71,
|
||||
3C4C95D0A0C7,
|
||||
3C84B55A5E54,
|
||||
3C888A88C59D,
|
||||
3D5C8240B2D2,
|
||||
3DB004172BE7,
|
||||
3E23271C1C15,
|
||||
3E3188294ED1,
|
||||
3E84144A770E,
|
||||
3EA227893101,
|
||||
3EB914E70076,
|
||||
3EE6D4A85643,
|
||||
40DABA780B41,
|
||||
4119340759A2,
|
||||
415210E0C6BB,
|
||||
416D21717779,
|
||||
41B1839829A9,
|
||||
4201A36DE766,
|
||||
4261A795D5A7,
|
||||
42AA0B29626E,
|
||||
430265958BEB,
|
||||
4317C5C16EAD,
|
||||
431D799E0C89,
|
||||
4342794AD7BB,
|
||||
4387ADE263DB,
|
||||
43982124C310,
|
||||
4436CB060568,
|
||||
44449507B736,
|
||||
44E858C82975,
|
||||
459BC12982B1,
|
||||
45AE5DDA9830,
|
||||
45C414CDC347,
|
||||
45CE4E504C06,
|
||||
461744C8EABD,
|
||||
46D012CA3BEC,
|
||||
47170BD112B6,
|
||||
47C43D5DD234,
|
||||
47CD4AC26271,
|
||||
47D410D1C7C4,
|
||||
4808C5AD0115,
|
||||
485BEEDBC293,
|
||||
486001404A80,
|
||||
488CCC60B70A,
|
||||
49204E3CA169,
|
||||
495657C78147,
|
||||
4970714D53D9,
|
||||
4AA715A0BBB4,
|
||||
4B9901AEC16E,
|
||||
4BE0B912A5A3,
|
||||
4CBC34D10D83,
|
||||
4CD3ACABC6A3,
|
||||
4CE00134DE1E,
|
||||
4CEB27151C49,
|
||||
4D02A3D7CE48,
|
||||
4D13683C7960,
|
||||
4D1A263BA48B,
|
||||
4D23919463A3,
|
||||
4D9763C083D9,
|
||||
4DAC8EE52C68,
|
||||
4DCB89C7B2E6,
|
||||
4DD9D9B637C4,
|
||||
4DE6CB63A920,
|
||||
4DEBA10CC85D,
|
||||
4E232A8C2E30,
|
||||
4E2879A411E7,
|
||||
4EA7B0BED74B,
|
||||
4EB8761372EA,
|
||||
4EC2B23135AB,
|
||||
4EC71DB088DE,
|
||||
4EC9AB4B5519,
|
||||
50179E461EE6,
|
||||
50265ED9D468,
|
||||
5047DC2975BE,
|
||||
508357498162,
|
||||
508BE54D326E,
|
||||
510A8C52AAC4,
|
||||
511335CC92CD,
|
||||
518229589A81,
|
||||
5184D04315D7,
|
||||
51B4AE31B246,
|
||||
526EDB918BEE,
|
||||
529CE44BEBCC,
|
||||
52A843082BB3,
|
||||
52AE9A909674,
|
||||
5313E9079489,
|
||||
532DE5E7E0E9,
|
||||
535508AA6C91,
|
||||
53691569B669,
|
||||
540A5B789761,
|
||||
547B86E57596,
|
||||
54C649075B57,
|
||||
552249203848,
|
||||
55430B5318E9,
|
||||
5570D22DC66B,
|
||||
55710879E113,
|
||||
55D2E4AC0446,
|
||||
56207539825A,
|
||||
564664475726,
|
||||
566441C5C28C,
|
||||
56A7930913C3,
|
||||
56C944B04618,
|
||||
56D455A8BBEA,
|
||||
5726991C8C28,
|
||||
5726AA3BE37B,
|
||||
573314090BA5,
|
||||
577C31903867,
|
||||
577C528E786C,
|
||||
57AD9604ED24,
|
||||
580C377283C7,
|
||||
587329CE3EBE,
|
||||
587C34557B36,
|
||||
58B11E803B58,
|
||||
5902E4DCC95D,
|
||||
5A060A64C535,
|
||||
5A36898CA7C5,
|
||||
5A4740D952EC,
|
||||
5A6ED7966868,
|
||||
5A99578CAA13,
|
||||
5AAD6814E68B,
|
||||
5B065568048A,
|
||||
5B6CE0B3AD0A,
|
||||
5B70E0B11758,
|
||||
5B926E3751EB,
|
||||
5B9CA63C4267,
|
||||
5BDC1391B289,
|
||||
5C1D3898D537,
|
||||
5C34B8E4A456,
|
||||
5C36456EA1E5,
|
||||
5C43A75C65A0,
|
||||
5C5752328A47,
|
||||
5C9D20250D74,
|
||||
5CBA3CEE351A,
|
||||
5CD5E98A2864,
|
||||
5CE0EB9C01B6,
|
||||
5D384E6A4145,
|
||||
5D9DB8445155,
|
||||
5DE8717BB640,
|
||||
5E1A4EE98748,
|
||||
5E45A227B391,
|
||||
5E8E50B3048B,
|
||||
5EB0EA0A9412,
|
||||
6032C47B7676,
|
||||
60E0C84ADDEE,
|
||||
612A447A2149,
|
||||
612D81821854,
|
||||
616B820EAD01,
|
||||
616D75A4A022,
|
||||
61DE2B085AC9,
|
||||
62312EC272A0,
|
||||
6232C5262CC6,
|
||||
62B7C7C9B0D0,
|
||||
62C531C6E29C,
|
||||
63E6AAAB4433,
|
||||
644ABCC3DD12,
|
||||
64AE7BEA1784,
|
||||
6515B38077D6,
|
||||
65972038CC25,
|
||||
65E120DE5E55,
|
||||
66141DDE8320,
|
||||
66718BD91332,
|
||||
668082242328,
|
||||
668920AEE063,
|
||||
6696C4332D46,
|
||||
66C9880D1DC2,
|
||||
67150CB11E95,
|
||||
671737BA0054,
|
||||
673551D0A99E,
|
||||
676D682C4336,
|
||||
678B98AA2E86,
|
||||
6847808E63EE,
|
||||
6887A122AA62,
|
||||
6888C514DEAD,
|
||||
688BD5B7B4E9,
|
||||
68A99E258692,
|
||||
68C312391560,
|
||||
68C9D33E3735,
|
||||
6900A069E3D7,
|
||||
690155BE8D8E,
|
||||
69174742042D,
|
||||
69B9CE233517,
|
||||
6A0B123D7595,
|
||||
6AB8E2B49E25,
|
||||
6ABD4C4A72D9,
|
||||
6B1CC539A1B2,
|
||||
6B30B6B0925D,
|
||||
6B638C1C950D,
|
||||
6BAAAB1D4589,
|
||||
6BAD01EBE736,
|
||||
6BB4ED5E1682,
|
||||
6CA178E036DA,
|
||||
6CE210B529C4,
|
||||
6D23D505D2B1,
|
||||
6D3CBD12BC6D,
|
||||
6D83563EB521,
|
||||
6D98AB9CCC71,
|
||||
6E3D7366E78C,
|
||||
6E5582237608,
|
||||
6E6602904925,
|
||||
6E77B8EB6444,
|
||||
6E978A7B16C6,
|
||||
6EEC05EB651C,
|
||||
70284824B26C,
|
||||
702CDACE0C14,
|
||||
704E1B85BED8,
|
||||
70BB123776D6,
|
||||
70CCC3A2D7C0,
|
||||
716A747CB931,
|
||||
7173E199A420,
|
||||
71BC9C9E31E4,
|
||||
71CAEEA3B771,
|
||||
71D8BA423D55,
|
||||
72253C7DD951,
|
||||
7260377CD286,
|
||||
7280858E8B20,
|
||||
72913BDAB647,
|
||||
72B5B87BBC6E,
|
||||
72C83B1D098A,
|
||||
72DA8050A38E,
|
||||
735C2AB60A97,
|
||||
736B602A93D9,
|
||||
738D7833E7DE,
|
||||
73E7B22D6E54,
|
||||
74133B1E2DED,
|
||||
74A929877793,
|
||||
74E3670C045A,
|
||||
7531E3E2A41C,
|
||||
7542A9B65EB4,
|
||||
7564993C91C7,
|
||||
760ED0AB626E,
|
||||
762E0E021E38,
|
||||
763D7E6BB40E,
|
||||
764B38E2903D,
|
||||
768016001C8D,
|
||||
76A616C3D42C,
|
||||
76AE99D9A294,
|
||||
76BAAA710D25,
|
||||
76E3B23696BC,
|
||||
77322DD2E184,
|
||||
77B40902B6D9,
|
||||
77C0AC14972D,
|
||||
77C1CE0E7674,
|
||||
77D7B7E2C8BA,
|
||||
78279397A68E,
|
||||
7836593AB838,
|
||||
783859EB51A6,
|
||||
78CCDB50C193,
|
||||
7932684154AE,
|
||||
79604362370E,
|
||||
796630ED27B3,
|
||||
799E4E270953,
|
||||
79A00573947A,
|
||||
79B798D66B01,
|
||||
7A0455D0A7EC,
|
||||
7A33D19B7248,
|
||||
7B0A8AE18817,
|
||||
7B0BA045AB35,
|
||||
7B0DE8504D57,
|
||||
7B21781EC649,
|
||||
7B7224C1AB79,
|
||||
7B90C2BA9B23,
|
||||
7BB90D382672,
|
||||
7BBC9DC92836,
|
||||
7C09DC408C47,
|
||||
7C418B493454,
|
||||
7C491D518242,
|
||||
7C7A86CC727C,
|
||||
7CE836EBD228,
|
||||
7D49042C530D,
|
||||
7E5744EC286C,
|
||||
7E680A48C383,
|
||||
7EC45CCEC35A,
|
||||
7EDADA19EB57,
|
||||
8005BD088847,
|
||||
8022E705B640,
|
||||
8031E3565825,
|
||||
80499BAA5959,
|
||||
807466CCBAB5,
|
||||
810518578380,
|
||||
810D24CB13CC,
|
||||
812B02C34A64,
|
||||
8163A5DDE1CD,
|
||||
8186CE2B363E,
|
||||
81DE6062B9D7,
|
||||
822017D8929A,
|
||||
8247C78188C5,
|
||||
8270D538D5E8,
|
||||
82D8E8DDE296,
|
||||
831207CA6E8A,
|
||||
83378A077357,
|
||||
83A05B477535,
|
||||
840160379EEE,
|
||||
84044BAB78A7,
|
||||
84366C6D7781,
|
||||
8442CC9AA777,
|
||||
8470AAD30447,
|
||||
8498740493BB,
|
||||
84A35A698E93,
|
||||
84ABDE484425,
|
||||
84B24DBB9A67,
|
||||
84B723B2A237,
|
||||
852BEB133D74,
|
||||
854501E98239,
|
||||
854A0ED2E77D,
|
||||
85A066D39785,
|
||||
8619557091AA,
|
||||
86228C3742A4,
|
||||
8637BB3BA795,
|
||||
8642D9310B46,
|
||||
86538085966D,
|
||||
86EE9C410811,
|
||||
870A042C1B34,
|
||||
873B47C457E6,
|
||||
873CE44DDC6B,
|
||||
874D123262E7,
|
||||
87513C960770,
|
||||
877641436923,
|
||||
878A091B74B7,
|
||||
87927467808B,
|
||||
88C2E39B5990,
|
||||
88D252AC1A8A,
|
||||
891EDA20BDEA,
|
||||
89267DEE07ED,
|
||||
892CB89ACCC6,
|
||||
8A2423E9D100,
|
||||
8A6BC2E3811B,
|
||||
8A8EB5771EE9,
|
||||
8A906B4B3211,
|
||||
8AB21B524C5C,
|
||||
8AB823BDC2AE,
|
||||
8AC3B2ADE77B,
|
||||
8AC4317D049B,
|
||||
8ACD6B86EC44,
|
||||
8AD966CA3B4D,
|
||||
8B0A3B3DCDD4,
|
||||
8B1B6C705C1A,
|
||||
8B1C75E27153,
|
||||
8B2A5E0332A1,
|
||||
8B6216E412DB,
|
||||
8B7CCA9DB004,
|
||||
8B9999AE9703,
|
||||
8BABAD9A65C6,
|
||||
8C32D0AE3DB7,
|
||||
8C99807368A5,
|
||||
8CC1133D7D5B,
|
||||
8CD2C872187A,
|
||||
8D0563B86DD4,
|
||||
8D43D81E37B4,
|
||||
8D96A800B21A,
|
||||
8D97B475C957,
|
||||
8DA62EC0C524,
|
||||
8DACA1BC0636,
|
||||
8DE3B131D728,
|
||||
8E55316D3B3D,
|
||||
8EE497C9A869,
|
||||
90210DDAB57D,
|
||||
9026977EB8A6,
|
||||
903AA4305025,
|
||||
9083158A49A1,
|
||||
9092D12E7967,
|
||||
90D8713352D1,
|
||||
911E097A27A9,
|
||||
9140EC087241,
|
||||
918A67D05479,
|
||||
919B1D357E91,
|
||||
9210BBA2AB26,
|
||||
9224B6555E30,
|
||||
9226D4D1236A,
|
||||
922E7955CC67,
|
||||
929CC86B1B26,
|
||||
929E1556110E,
|
||||
9302DEB79C5A,
|
||||
9384841B4702,
|
||||
93B4BD1CB47C,
|
||||
93D985D55712,
|
||||
940B37939AC6,
|
||||
94673AE73823,
|
||||
947A8147E0AE,
|
||||
94CD6A4B6391,
|
||||
94CEEAC5A8D7,
|
||||
95ABD3A7C631,
|
||||
95E1C233EDE2,
|
||||
9607AE17AD09,
|
||||
960C98566E52,
|
||||
96435BD1D29B,
|
||||
965D66E19245,
|
||||
965D72659982,
|
||||
9695167B4149,
|
||||
96D0C3996714,
|
||||
97274C21BD6C,
|
||||
973186B345BB,
|
||||
973A28C983A3,
|
||||
979686C51AB6,
|
||||
97992CE2DD31,
|
||||
97E9D0C89DA8,
|
||||
97EB8A44C49D,
|
||||
98314DC363C5,
|
||||
9860DC044565,
|
||||
988D023C15A5,
|
||||
9917BDA7B4D7,
|
||||
9996A233442A,
|
||||
9A2132B5B625,
|
||||
9A694755A978,
|
||||
9A7911ECC275,
|
||||
9AA1E6CE588C,
|
||||
9ABCCD2AE7C7,
|
||||
9B39A60D3841,
|
||||
9C0630361CC5,
|
||||
9C4E19AB64B1,
|
||||
9CE96BADE4D8,
|
||||
9D442B28BD11,
|
||||
9D4C35AE1A08,
|
||||
9E02910C691A,
|
||||
9E46407C9024,
|
||||
9E74D104ACEA,
|
||||
9EDD416A7912,
|
||||
A026642D13AD,
|
||||
A12908B38536,
|
||||
A16EE9666D5A,
|
||||
A199132A4043,
|
||||
A1AEC2B58BBA,
|
||||
A1BE42A15EDE,
|
||||
A1D0844C2C63,
|
||||
A1E0103A1879,
|
||||
A253602B9445,
|
||||
A2B019B46CB9,
|
||||
A2BBCC3B546C,
|
||||
A2C325A73A9C,
|
||||
A2CB60E815A0,
|
||||
A314B97C1A6A,
|
||||
A3647146C335,
|
||||
A3A580799BB4,
|
||||
A3D30CC8EB97,
|
||||
A402B5137D86,
|
||||
A42158CC74B5,
|
||||
A435DD64AD17,
|
||||
A4693D21013B,
|
||||
A479A91EED49,
|
||||
A4B30D146A01,
|
||||
A5142D626200,
|
||||
A54056E87CBB,
|
||||
A57DBD287491,
|
||||
A588C918E327,
|
||||
A593071D4758,
|
||||
A5CC0EE7B9E3,
|
||||
A6375E98A5B5,
|
||||
A666347B3B4B,
|
||||
A6A203994202,
|
||||
A6BAE1A1520D,
|
||||
A6E9885AA49D,
|
||||
A705087E89A8,
|
||||
A7072D4324C7,
|
||||
A745AD7D6789,
|
||||
A750456E7C5E,
|
||||
A783A8774651,
|
||||
A787C822020C,
|
||||
A78BB575EAC5,
|
||||
A7905680A254,
|
||||
A805534D84E9,
|
||||
A86C2595A1C3,
|
||||
A89903B6ADDB,
|
||||
A9182707A219,
|
||||
A9391782A846,
|
||||
A96B08E3A50B,
|
||||
A98DEB0733C9,
|
||||
A9C37CE71D23,
|
||||
AA2D69C757D9,
|
||||
AA4E4558A9EE,
|
||||
AA6C835C9124,
|
||||
AAC0C35C43EB,
|
||||
AB30CB2CB354,
|
||||
AB6191DB240A,
|
||||
AB8953D3560C,
|
||||
ABBB521319E6,
|
||||
AC47461358D7,
|
||||
AC58C25A1559,
|
||||
AC7D4B201D92,
|
||||
AD061A23287D,
|
||||
AD105D52DB36,
|
||||
AD4EA84D7185,
|
||||
AD5038D15490,
|
||||
AD97523144B2,
|
||||
ADB24E78784B,
|
||||
ADCBD453B232,
|
||||
AE516A187825,
|
||||
AE52116C234C,
|
||||
AE817239CAB5,
|
||||
AEA5A5A0E46B,
|
||||
AECC93678543,
|
||||
B0452769A83C,
|
||||
B04D71906C60,
|
||||
B0805C191424,
|
||||
B09172DDBE43,
|
||||
B13AE369390C,
|
||||
B14080E570D1,
|
||||
B1419B62772C,
|
||||
B14775DEA2E2,
|
||||
B188BA649EA1,
|
||||
B1BB0DB95C67,
|
||||
B1BB19BDD424,
|
||||
B1E8B5054DAD,
|
||||
B1EBB537CC0D,
|
||||
B2174092CDC5,
|
||||
B2554CC8AD6E,
|
||||
B2C5A2E88304,
|
||||
B312E56ED250,
|
||||
B37B48D8C1C5,
|
||||
B39C699CD208,
|
||||
B3B121208E34,
|
||||
B3C3C6E4395B,
|
||||
B410B958C3B8,
|
||||
B4204546A74E,
|
||||
B45171C5A67D,
|
||||
B4B103E693ED,
|
||||
B4DACABCAB07,
|
||||
B506567A2B84,
|
||||
B51083D5C2BD,
|
||||
B54D7674CB90,
|
||||
B570E5EA1DA3,
|
||||
B598984AD584,
|
||||
B5D7E1135821,
|
||||
B60D053A36D9,
|
||||
B63957593E23,
|
||||
B64558CAC0C9,
|
||||
B68175BCA864,
|
||||
B6CD1A3EC5BC,
|
||||
B72468A7710D,
|
||||
B75176C82A8B,
|
||||
B7AA0CA5D94A,
|
||||
B7B9D7E523B8,
|
||||
B808D87AB75C,
|
||||
B93A6432E51A,
|
||||
B941A9D99B6C,
|
||||
B9DA40920237,
|
||||
BA6C2E10086A,
|
||||
BA7384AB949E,
|
||||
BA8DEEE045E8,
|
||||
BADC2149EC42,
|
||||
BB1924266B36,
|
||||
BB41640E6340,
|
||||
BBB475DB2B03,
|
||||
BBD4C4699719,
|
||||
BC0B2C897267,
|
||||
BC7BEE6B71C4,
|
||||
BC8B21AD8802,
|
||||
BCA2D8118631,
|
||||
BCB7A7006400,
|
||||
BCBC6637499B,
|
||||
BCBD2B8BE4B3,
|
||||
BD213E28C568,
|
||||
BD32E4EC7080,
|
||||
BD401D63C3E9,
|
||||
BD463C3693A4,
|
||||
BD749E85586A,
|
||||
BD7CA11B9551,
|
||||
BD96355CBE36,
|
||||
BD9E6EB7B524,
|
||||
BDADE6111218,
|
||||
BDB576D1E88C,
|
||||
BDB5DC09C522,
|
||||
BE19C75D6B7E,
|
||||
BE5B3ED935AC,
|
||||
BEA20C972E70,
|
||||
BEEB4A159B37,
|
||||
C01E8740DE38,
|
||||
C0411C28857D,
|
||||
C045544AD1E4,
|
||||
C04660B76831,
|
||||
C0C4CA21B876,
|
||||
C0E0E092C8B4,
|
||||
C0EE394D3D95,
|
||||
C14601C6B411,
|
||||
C16EBAE928B2,
|
||||
C189A791A85B,
|
||||
C1ACDB8C1890,
|
||||
C1C55A7A99EA,
|
||||
C1D72A47755A,
|
||||
C1D8B91D65AA,
|
||||
C1E6149B386D,
|
||||
C22D8E2B1E37,
|
||||
C23E999B6298,
|
||||
C314E31A670D,
|
||||
C3D275A9B8C7,
|
||||
C3EE19B61C89,
|
||||
C427B93DC2ED,
|
||||
C443EEC4330D,
|
||||
C477B966D328,
|
||||
C4C6CAE4784C,
|
||||
C55875BCB82C,
|
||||
C581CA998910,
|
||||
C5ABC0A455C5,
|
||||
C5BE33E6B1E2,
|
||||
C629E0D34581,
|
||||
C65194543D6B,
|
||||
C67B8E869D90,
|
||||
C6BC3B9CCB41,
|
||||
C7034BC581A6,
|
||||
C748500B6947,
|
||||
C757C15E9E0D,
|
||||
C798A8465ACB,
|
||||
C7B6702AC17B,
|
||||
C849133B7CCC,
|
||||
C870C98A4E91,
|
||||
C90B7AD266D3,
|
||||
C90D996C3A2D,
|
||||
C953797CCE61,
|
||||
C9639352EEC8,
|
||||
C983685AA86B,
|
||||
C9CCA6D095A3,
|
||||
C9CE81D47EDB,
|
||||
C9D449AD9970,
|
||||
CA0D9CCC4C38,
|
||||
CA277AC09859,
|
||||
CA56EB045188,
|
||||
CAB92B865BAD,
|
||||
CAE8572C2657,
|
||||
CB1CE185575C,
|
||||
CB2ECC3D9C22,
|
||||
CB642A081A89,
|
||||
CBBAD2DA0EC5,
|
||||
CC1B5BD45315,
|
||||
CC2C02300D34,
|
||||
CC559969D0CC,
|
||||
CC5646BD7AEB,
|
||||
CC6A93BD93D1,
|
||||
CC726DD08765,
|
||||
CCBBAB6504A4,
|
||||
CCC1EA3E27B8,
|
||||
CD16EAB946E9,
|
||||
CDB4EEE02E14,
|
||||
CDC21E1E1EC7,
|
||||
CE09B3870EA2,
|
||||
CE5AA0C8B5A8,
|
||||
CE63DE29E069,
|
||||
D0368B24CA49,
|
||||
D0489010A72C,
|
||||
D075379A21A6,
|
||||
D09893B4EE04,
|
||||
D0A7A2787570,
|
||||
D0B8C06C02E4,
|
||||
D106E94A4C3B,
|
||||
D11E7D1BBEEA,
|
||||
D12B25B8DDE2,
|
||||
D1972D6CE2C3,
|
||||
D1B91D224946,
|
||||
D2752E53679D,
|
||||
D35B2B75CC52,
|
||||
D40E935117A2,
|
||||
D4C37528DC05,
|
||||
D4C818A5455E,
|
||||
D4CD56DB8AEB,
|
||||
D5190BD5CED6,
|
||||
D55E5AA3406D,
|
||||
D576E9D856D9,
|
||||
D5E444E9D82D,
|
||||
D61A3231790D,
|
||||
D669B3AE1E11,
|
||||
D6C075899D06,
|
||||
D6C3503456C4,
|
||||
D7AC70A05A0C,
|
||||
D80A37B6D7ED,
|
||||
D82E6938C58C,
|
||||
D85E51344EB6,
|
||||
D8809EB9BA7D,
|
||||
D8913C2D48E9,
|
||||
D9109460D912,
|
||||
D94E36427E20,
|
||||
D97E55B1816A,
|
||||
D99425130C1A,
|
||||
D99C3222A190,
|
||||
D9A207103ED7,
|
||||
D9C70CC5818A,
|
||||
DA3379D12773,
|
||||
DA705702248C,
|
||||
DA818C56CE43,
|
||||
DAE1888DCC0B,
|
||||
DBA0A2DCA8E0,
|
||||
DBD9799E15B1,
|
||||
DC242193D7E3,
|
||||
DCB5AC62946C,
|
||||
DCB75AEC61A0,
|
||||
DD6E0587A821,
|
||||
DD7B1A7C6A82,
|
||||
DDA22A189095,
|
||||
DDDAE53AA711,
|
||||
DDE7304E78B6,
|
||||
DE1B4DA681B9,
|
||||
DEAC67E2D7C1,
|
||||
DEB7D7E4C62B,
|
||||
E127434AB3B7,
|
||||
E1ACC6742AB7,
|
||||
E1E59574ADBC,
|
||||
E1EA6BAA03D9,
|
||||
E222553A59A2,
|
||||
E2230B8E84C9,
|
||||
E33E807EC3BA,
|
||||
E341574B2E32,
|
||||
E42868808B70,
|
||||
E43562C624B0,
|
||||
E43D54DC3511,
|
||||
E466090D2123,
|
||||
E47069DA0C44,
|
||||
E49DD6062901,
|
||||
E4ACA0ADBA0D,
|
||||
E4B976AD6687,
|
||||
E526BB7888DB,
|
||||
E53354B71B10,
|
||||
E57581CE8617,
|
||||
E61A1DA5A60E,
|
||||
E6293BDA5EDC,
|
||||
E64C2A07CA9B,
|
||||
E6600C4D6A44,
|
||||
E6655B6425DC,
|
||||
E6BADC631036,
|
||||
E70143BE0091,
|
||||
E75E07A010D1,
|
||||
E76962E3B8B4,
|
||||
E8028A6DCC90,
|
||||
E80C5E3E8227,
|
||||
E8779E40450E,
|
||||
E8A9E2D87D36,
|
||||
E8B5A0BDD993,
|
||||
E933DA9735C4,
|
||||
E93A2E63189D,
|
||||
E9447637E40D,
|
||||
E94836269887,
|
||||
E94D82A564BA,
|
||||
E98DC3B561B5,
|
||||
E9EB2DE57AE9,
|
||||
EA490920877D,
|
||||
EA4C494C9353,
|
||||
EA9B1695DD91,
|
||||
EAD0E31A6834,
|
||||
EB16B6462B66,
|
||||
EB276C9AB68D,
|
||||
EB3C9732C3BA,
|
||||
EB44DDC408CE,
|
||||
EB8536C958B2,
|
||||
EBC825C186B3,
|
||||
EC1A55BB58EB,
|
||||
EC2B12107313,
|
||||
EC8CB5758097,
|
||||
ECD4C42EA3D1,
|
||||
ED22B7115435,
|
||||
ED2CE17A590C,
|
||||
ED65A9B6469C,
|
||||
ED6748113E0D,
|
||||
ED8CEB8B7102,
|
||||
EDCE0890472D,
|
||||
EDD4A2EA7493,
|
||||
EE17C426D25E,
|
||||
EE487A4C806E,
|
||||
EE5931913A8D,
|
||||
EED56840AEBA,
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,57 @@
|
||||
010203040506,
|
||||
013940233313,
|
||||
022FE48B3072,
|
||||
123456789ABC,
|
||||
123456ABCDEF,
|
||||
17505586EF02,
|
||||
1795902DBAF9,
|
||||
1A2B3C4D5E6F,
|
||||
1A982C7E459A,
|
||||
200306202033,
|
||||
2011092119F1,
|
||||
2012053082AD,
|
||||
37D4DCA92451,
|
||||
40E5EA1EFC00,
|
||||
435330666666,
|
||||
46868F6D5677,
|
||||
474249437569,
|
||||
4D3A99C351DD,
|
||||
533CB6C723F6,
|
||||
5554AAA96321,
|
||||
587EE5F9350F,
|
||||
5A1B85FCE20A,
|
||||
5D293AFC8D7E,
|
||||
64A2EE93B12B,
|
||||
64E2283FCF5E,
|
||||
714C5C886E97,
|
||||
833FBD3CFE51,
|
||||
83BAB5ACAD62,
|
||||
872B71F9D15A,
|
||||
8F9B229047AC,
|
||||
8FD0A4F256E9,
|
||||
9AEDF9931EC1,
|
||||
9B1DD7C030A1,
|
||||
A0478CC39091,
|
||||
A0A1A2A3A4A5,
|
||||
A2B2C9D187FB,
|
||||
A4EF6C3BB692,
|
||||
AABBCC660429,
|
||||
AABBCCDDEEFF,
|
||||
ABCDEF123456,
|
||||
B0699AD03D17,
|
||||
B0B1B2B3B4B5,
|
||||
BA28CFD15EE8,
|
||||
BCFE01BCFE01,
|
||||
C0C1C2C3C4C5,
|
||||
CFC738403AB0,
|
||||
D0D1D2D3D4D5,
|
||||
D3F7D3F7D3F7,
|
||||
DB5181C92CBE,
|
||||
DFED39FFBB76,
|
||||
E1DD284379D4,
|
||||
E96246531342,
|
||||
ED3A7EFBFF56,
|
||||
F83466888612,
|
||||
F89C86B2A961,
|
||||
FFFFAE82366C,
|
||||
FFFFD06F83E3,
|
||||
+25
-21
@@ -623,7 +623,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define dreturn(n) {free(pdol_data_tlv);tlvdb_free(tlvSelect);tlvdb_free(tlvRoot);DropField();return n;}
|
||||
#define dreturn(n) {free(pdol_data_tlv); tlvdb_free(tlvSelect); tlvdb_free(tlvRoot); DropFieldEx( channel ); return n;}
|
||||
|
||||
void InitTransactionParameters(struct tlvdb *tlvRoot, bool paramLoadJSON, enum TransactionType TrType, bool GenACGPO) {
|
||||
|
||||
@@ -1244,7 +1244,7 @@ int CmdEMVExec(const char *cmd) {
|
||||
|
||||
}
|
||||
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
|
||||
// Destroy TLV's
|
||||
free(pdol_data_tlv);
|
||||
@@ -1346,7 +1346,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
}
|
||||
|
||||
// drop field at start
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
|
||||
// iso 14443 select
|
||||
PrintAndLogEx(NORMAL, "--> GET UID, ATS.");
|
||||
@@ -1399,7 +1399,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
if (EMVSearch(channel, false, true, decodeTLV, tlvSelect)) {
|
||||
PrintAndLogEx(ERR, "Can't found any of EMV AID. Exit...");
|
||||
tlvdb_free(tlvSelect);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -1415,7 +1415,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
|
||||
if (!AIDlen) {
|
||||
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -1434,7 +1434,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Can't select AID (%d). Exit...", res);
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 5;
|
||||
}
|
||||
|
||||
@@ -1462,7 +1462,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
if (!pdol_data_tlv){
|
||||
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 6;
|
||||
}
|
||||
|
||||
@@ -1471,7 +1471,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
if (!pdol_data_tlv_data) {
|
||||
PrintAndLogEx(ERR, "Can't create PDOL data.");
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 6;
|
||||
}
|
||||
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
||||
@@ -1485,7 +1485,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 7;
|
||||
}
|
||||
ProcessGPOResponseFormat1(tlvRoot, buf, len, decodeTLV);
|
||||
@@ -1577,8 +1577,7 @@ int CmdEMVScan(const char *cmd) {
|
||||
// free tlv object
|
||||
tlvdb_free(tlvRoot);
|
||||
|
||||
// DropField
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
|
||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||
if (res) {
|
||||
@@ -1631,6 +1630,14 @@ int CmdEMVRoca(const char *cmd) {
|
||||
if (arg_get_lit(2))
|
||||
channel = ECC_CONTACT;
|
||||
PrintChannel(channel);
|
||||
|
||||
#ifndef WITH_SMARTCARD
|
||||
// not compiled with smartcard functionality, we need to exit
|
||||
if ( channel == ECC_CONTACT ) {
|
||||
PrintAndLogEx(WARNING, "PM3 Client is not compiled with support for SMARTCARD. Exiting.");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// select card
|
||||
uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2;
|
||||
@@ -1654,7 +1661,7 @@ int CmdEMVRoca(const char *cmd) {
|
||||
if (EMVSearch(channel, false, true, false, tlvSelect)) {
|
||||
PrintAndLogEx(ERR, "Can't found any of EMV AID. Exit...");
|
||||
tlvdb_free(tlvSelect);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -1670,7 +1677,7 @@ int CmdEMVRoca(const char *cmd) {
|
||||
|
||||
if (!AIDlen) {
|
||||
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -1685,7 +1692,7 @@ int CmdEMVRoca(const char *cmd) {
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Can't select AID (%d). Exit...", res);
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 5;
|
||||
}
|
||||
|
||||
@@ -1697,7 +1704,7 @@ int CmdEMVRoca(const char *cmd) {
|
||||
if (!pdol_data_tlv){
|
||||
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 6;
|
||||
}
|
||||
|
||||
@@ -1706,7 +1713,7 @@ int CmdEMVRoca(const char *cmd) {
|
||||
if (!pdol_data_tlv_data) {
|
||||
PrintAndLogEx(ERR, "Can't create PDOL data.");
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 6;
|
||||
}
|
||||
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
||||
@@ -1720,7 +1727,7 @@ int CmdEMVRoca(const char *cmd) {
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
|
||||
tlvdb_free(tlvRoot);
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
return 7;
|
||||
}
|
||||
ProcessGPOResponseFormat1(tlvRoot, buf, len, false);
|
||||
@@ -1818,10 +1825,7 @@ out:
|
||||
// free tlv object
|
||||
tlvdb_free(tlvRoot);
|
||||
|
||||
if ( channel == ECC_CONTACTLESS)
|
||||
DropField();
|
||||
|
||||
|
||||
DropFieldEx( channel );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveField
|
||||
int res = 0;
|
||||
|
||||
if (ActivateField) {
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
msleep(50);
|
||||
}
|
||||
|
||||
@@ -262,8 +262,12 @@ int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveField
|
||||
}
|
||||
break;
|
||||
case ECC_CONTACT:
|
||||
#ifdef WITH_SMARTCARD
|
||||
//int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
||||
res = ExchangeAPDUSC(data, (IncludeLe?6:5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||
#else
|
||||
res = 1;
|
||||
#endif
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
@@ -480,7 +484,7 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
||||
}
|
||||
|
||||
if(!LeaveFieldON)
|
||||
DropField();
|
||||
DropFieldEx( channel );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,23 @@
|
||||
"U9psmyPzK+Vsgw2jeRQ5JlKDyqE0hebfC1tvFu0CCrJFcw==\r\n" \
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
|
||||
// Name: SoloKey U2F Root CA Serial 14143382635911888524 (0xc44763928ff4be8c)
|
||||
// Issued: 2018-11-11
|
||||
#define SOLOKEY_CA \
|
||||
"-----BEGIN CERTIFICATE-----\r\n" \
|
||||
"MIIB9DCCAZoCCQDER2OSj/S+jDAKBggqhkjOPQQDAjCBgDELMAkGA1UEBhMCVVMx\r\n" \
|
||||
"ETAPBgNVBAgMCE1hcnlsYW5kMRIwEAYDVQQKDAlTb2xvIEtleXMxEDAOBgNVBAsM\r\n" \
|
||||
"B1Jvb3QgQ0ExFTATBgNVBAMMDHNvbG9rZXlzLmNvbTEhMB8GCSqGSIb3DQEJARYS\r\n" \
|
||||
"aGVsbG9Ac29sb2tleXMuY29tMCAXDTE4MTExMTEyNTE0MloYDzIwNjgxMDI5MTI1\r\n" \
|
||||
"MTQyWjCBgDELMAkGA1UEBhMCVVMxETAPBgNVBAgMCE1hcnlsYW5kMRIwEAYDVQQK\r\n" \
|
||||
"DAlTb2xvIEtleXMxEDAOBgNVBAsMB1Jvb3QgQ0ExFTATBgNVBAMMDHNvbG9rZXlz\r\n" \
|
||||
"LmNvbTEhMB8GCSqGSIb3DQEJARYSaGVsbG9Ac29sb2tleXMuY29tMFkwEwYHKoZI\r\n" \
|
||||
"zj0CAQYIKoZIzj0DAQcDQgAEWHAN0CCJVZdMs0oktZ5m93uxmB1iyq8ELRLtqVFL\r\n" \
|
||||
"SOiHQEab56qRTB/QzrpGAY++Y2mw+vRuQMNhBiU0KzwjBjAKBggqhkjOPQQDAgNI\r\n" \
|
||||
"ADBFAiEAz9SlrAXIlEu87vra54rICPs+4b0qhp3PdzcTg7rvnP0CIGjxzlteQQx+\r\n" \
|
||||
"jQGd7rwSZuE5RWUPVygYhUstQO9zNUOs\r\n" \
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
|
||||
/* Concatenation of all additional CA certificates in PEM format if available */
|
||||
const char additional_ca_pem[] = GLOBALSIGN_CA YUBICO_CA;
|
||||
const char additional_ca_pem[] = GLOBALSIGN_CA YUBICO_CA SOLOKEY_CA;
|
||||
const size_t additional_ca_pem_len = sizeof(additional_ca_pem);
|
||||
@@ -250,9 +250,9 @@ int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *pu
|
||||
uint32_t verifyflags = 0;
|
||||
res = mbedtls_x509_crt_verify(&cert, &cacert, NULL, NULL, &verifyflags, NULL, NULL);
|
||||
if (res) {
|
||||
PrintAndLog("ERROR: DER verify returned 0x%x - %s", (res<0)?-res:res, ecdsa_get_error(res));
|
||||
PrintAndLog("ERROR: DER verify returned 0x%x - %s\n", (res<0)?-res:res, ecdsa_get_error(res));
|
||||
} else {
|
||||
PrintAndLog("Certificate OK.");
|
||||
PrintAndLog("Certificate OK.\n");
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
||||
flash_seg_t *seg;
|
||||
uint32_t last_end = 0;
|
||||
|
||||
ctx->segments = malloc(sizeof(flash_seg_t) * num_phdrs);
|
||||
ctx->segments = calloc(sizeof(flash_seg_t) * num_phdrs, sizeof(uint8_t));
|
||||
if (!ctx->segments) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
return -1;
|
||||
@@ -88,7 +88,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
||||
|
||||
uint8_t *data;
|
||||
// make extra space if we need to move the data forward
|
||||
data = malloc(filesz + BLOCK_SIZE);
|
||||
data = calloc(filesz + BLOCK_SIZE, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
fprintf(stderr, "Error: Out of memory\n");
|
||||
return -1;
|
||||
@@ -111,7 +111,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
||||
uint32_t new_length = this_end - prev_seg->start;
|
||||
uint32_t this_offset = paddr - prev_seg->start;
|
||||
uint32_t hole = this_offset - prev_seg->length;
|
||||
uint8_t *new_data = malloc(new_length);
|
||||
uint8_t *new_data = calloc(new_length, sizeof(uint8_t));
|
||||
if (!new_data) {
|
||||
fprintf(stderr, "Error: Out of memory\n");
|
||||
free(data);
|
||||
@@ -223,7 +223,7 @@ int flash_load(flash_file_t *ctx, const char *name, int can_write_bl) {
|
||||
}
|
||||
num_phdrs = le16(ehdr.e_phnum);
|
||||
|
||||
phdrs = malloc(le16(ehdr.e_phnum) * sizeof(Elf32_Phdr));
|
||||
phdrs = calloc(le16(ehdr.e_phnum) * sizeof(Elf32_Phdr), sizeof(uint8_t));
|
||||
if (!phdrs) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto fail;
|
||||
|
||||
@@ -59,7 +59,7 @@ static void usage(void)
|
||||
|
||||
static voidpf fpga_deflate_malloc(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
return malloc(items*size);
|
||||
return calloc(items*size, sizeof(uint8_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
|
||||
z_stream compressed_fpga_stream;
|
||||
|
||||
if (hardnested_mode) {
|
||||
fpga_config = malloc(num_infiles * HARDNESTED_TABLE_SIZE);
|
||||
fpga_config = calloc(num_infiles * HARDNESTED_TABLE_SIZE, sizeof(uint8_t));
|
||||
} else {
|
||||
fpga_config = malloc(num_infiles * FPGA_CONFIG_SIZE);
|
||||
fpga_config = calloc(num_infiles * FPGA_CONFIG_SIZE, sizeof(uint8_t));
|
||||
}
|
||||
// read the input files. Interleave them into fpga_config[]
|
||||
i = 0;
|
||||
|
||||
@@ -40,7 +40,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
||||
flash_seg_t *seg;
|
||||
uint32_t last_end = 0;
|
||||
|
||||
ctx->segments = malloc(sizeof(flash_seg_t) * num_phdrs);
|
||||
ctx->segments = calloc(sizeof(flash_seg_t) * num_phdrs, sizeof(uint8_t));
|
||||
if (!ctx->segments) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
return -1;
|
||||
@@ -90,7 +90,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
||||
|
||||
uint8_t *data;
|
||||
// make extra space if we need to move the data forward
|
||||
data = malloc(filesz + BLOCK_SIZE);
|
||||
data = calloc(filesz + BLOCK_SIZE, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
return -1;
|
||||
@@ -226,7 +226,7 @@ int flash_load(flash_file_t *ctx, const char *name, int can_write_bl)
|
||||
}
|
||||
num_phdrs = le16(ehdr.e_phnum);
|
||||
|
||||
phdrs = malloc(le16(ehdr.e_phnum) * sizeof(Elf32_Phdr));
|
||||
phdrs = calloc(le16(ehdr.e_phnum) * sizeof(Elf32_Phdr), sizeof(uint8_t));
|
||||
if (!phdrs) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto fail;
|
||||
|
||||
@@ -224,7 +224,7 @@ void doMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4])
|
||||
{
|
||||
uint8_t cc_nr[13] = { 0 };
|
||||
uint8_t div_key[8];
|
||||
//cc_nr=(uint8_t*)malloc(length+1);
|
||||
//cc_nr=(uint8_t*) calloc(length+1, sizeof(uint8_t));
|
||||
|
||||
memcpy(cc_nr, cc_nr_p, 12);
|
||||
memcpy(div_key, div_key_p, 8);
|
||||
@@ -244,7 +244,7 @@ void doMAC_N(uint8_t *address_data_p, uint8_t address_data_size, uint8_t *div_ke
|
||||
{
|
||||
uint8_t *address_data;
|
||||
uint8_t div_key[8];
|
||||
address_data = (uint8_t*) malloc(address_data_size);
|
||||
address_data = (uint8_t*) calloc(address_data_size, sizeof(uint8_t));
|
||||
|
||||
memcpy(address_data, address_data_p, address_data_size);
|
||||
memcpy(div_key, div_key_p, 8);
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef struct {
|
||||
uint8_t * buffer;
|
||||
uint8_t numbits;
|
||||
uint8_t position;
|
||||
}BitstreamOut;
|
||||
} BitstreamOut;
|
||||
|
||||
bool headBit( BitstreamIn *stream);
|
||||
bool tailBit( BitstreamIn *stream);
|
||||
|
||||
@@ -493,7 +493,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
|
||||
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
dumpdata* attack = (dumpdata* ) malloc(itemsize);
|
||||
dumpdata* attack = (dumpdata* ) calloc(itemsize, sizeof(uint8_t));
|
||||
|
||||
for (i = 0 ; i * itemsize < dumpsize ; i++ ) {
|
||||
memcpy(attack, dump + i * itemsize, itemsize);
|
||||
|
||||
+16
-17
@@ -71,14 +71,14 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si
|
||||
/*Opening file for writing in binary mode*/
|
||||
FILE *f = fopen(fileName, "wb");
|
||||
if (!f) {
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '%s'", fileName);
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_(%s)"'", fileName);
|
||||
free(fileName);
|
||||
return 1;
|
||||
}
|
||||
fwrite(data, 1, datalen, f);
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
PrintAndLogDevice(SUCCESS, "saved %u bytes to binary file %s", datalen, fileName);
|
||||
PrintAndLogDevice(SUCCESS, "saved %u bytes to binary file " _YELLOW_(%s), datalen, fileName);
|
||||
free(fileName);
|
||||
return 0;
|
||||
}
|
||||
@@ -106,8 +106,8 @@ int saveFileEML(const char *preferredName, const char *suffix, uint8_t* data, si
|
||||
|
||||
/*Opening file for writing in text mode*/
|
||||
FILE *f = fopen(fileName, "w+");
|
||||
if (!f) {
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '%s'", fileName);
|
||||
if (!f) {
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_(%s)"'", fileName);
|
||||
retval = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ int saveFileEML(const char *preferredName, const char *suffix, uint8_t* data, si
|
||||
}
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
PrintAndLogDevice(SUCCESS, "saved %d blocks to text file %s", blocks, fileName);
|
||||
PrintAndLogDevice(SUCCESS, "saved %d blocks to text file " _YELLOW_(%s), blocks, fileName);
|
||||
|
||||
out:
|
||||
free(fileName);
|
||||
@@ -240,13 +240,12 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
||||
|
||||
int res = json_dump_file(root, fileName, JSON_INDENT(2));
|
||||
if (res) {
|
||||
PrintAndLogDevice(FAILED, "error: can't save the file: %s", fileName);
|
||||
PrintAndLogDevice(FAILED, "error: can't save the file: " _YELLOW_(%s), fileName);
|
||||
json_decref(root);
|
||||
retval = 200;
|
||||
goto out;
|
||||
}
|
||||
PrintAndLogDevice(SUCCESS, "File `%s` saved.", fileName);
|
||||
|
||||
PrintAndLogDevice(SUCCESS, "saved to json file " _YELLOW_(%s), fileName);
|
||||
json_decref(root);
|
||||
|
||||
out:
|
||||
@@ -266,7 +265,7 @@ int loadFile(const char *preferredName, const char *suffix, void* data, size_t*
|
||||
|
||||
FILE *f = fopen(fileName, "rb");
|
||||
if ( !f ) {
|
||||
PrintAndLogDevice(FAILED, "file: %s: not found or locked.", fileName);
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_(%s)"'", fileName);
|
||||
retval = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -305,7 +304,7 @@ int loadFile(const char *preferredName, const char *suffix, void* data, size_t*
|
||||
memcpy( (data), dump, bytes_read);
|
||||
free(dump);
|
||||
|
||||
PrintAndLogDevice(SUCCESS, "loaded %d bytes from binary file %s", bytes_read, fileName);
|
||||
PrintAndLogDevice(SUCCESS, "loaded %d bytes from binary file " _YELLOW_(%s), bytes_read, fileName);
|
||||
|
||||
*datalen = bytes_read;
|
||||
|
||||
@@ -328,7 +327,7 @@ int loadFileEML(const char *preferredName, const char *suffix, void* data, size_
|
||||
|
||||
FILE *f = fopen(fileName, "r");
|
||||
if ( !f ) {
|
||||
PrintAndLogDevice(FAILED, "file: %s: not found or locked.", fileName);
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_(%s)"'", fileName);
|
||||
retval = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -359,7 +358,7 @@ int loadFileEML(const char *preferredName, const char *suffix, void* data, size_
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
PrintAndLogDevice(SUCCESS, "loaded %d bytes from text file %s", counter, fileName);
|
||||
PrintAndLogDevice(SUCCESS, "loaded %d bytes from text file " _YELLOW_(%s), counter, fileName);
|
||||
*datalen = counter;
|
||||
|
||||
out:
|
||||
@@ -382,13 +381,13 @@ int loadFileJSON(const char *preferredName, const char *suffix, void* data, size
|
||||
|
||||
root = json_load_file(fileName, 0, &error);
|
||||
if (!root) {
|
||||
PrintAndLog("ERROR: json (%s) error on line %d: %s", fileName, error.line, error.text);
|
||||
PrintAndLog("ERROR: json " _YELLOW_(%s) " error on line %d: %s", fileName, error.line, error.text);
|
||||
retval = 2;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!json_is_object(root)) {
|
||||
PrintAndLog("ERROR: Invalid json (%s) format. root must be an object.", fileName);
|
||||
PrintAndLog("ERROR: Invalid json " _YELLOW_(%s) " format. root must be an object.", fileName);
|
||||
retval = 3;
|
||||
goto out;
|
||||
}
|
||||
@@ -446,7 +445,7 @@ int loadFileJSON(const char *preferredName, const char *suffix, void* data, size
|
||||
}
|
||||
|
||||
|
||||
PrintAndLog("Loaded JSON: (%s) OK.", fileName);
|
||||
PrintAndLog("loaded from JSON file " _YELLOW_(%s), fileName);
|
||||
out:
|
||||
json_decref(root);
|
||||
free(fileName);
|
||||
@@ -479,7 +478,7 @@ int loadFileDICTIONARY(const char *preferredName, const char *suffix, void* data
|
||||
|
||||
FILE *f = fopen(fileName, "r");
|
||||
if ( !f ) {
|
||||
PrintAndLogDevice(FAILED, "file: %s: not found or locked.", fileName);
|
||||
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_(%s)"'", fileName);
|
||||
retval = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -512,7 +511,7 @@ int loadFileDICTIONARY(const char *preferredName, const char *suffix, void* data
|
||||
counter += (keylen >> 1);
|
||||
}
|
||||
fclose(f);
|
||||
PrintAndLogDevice(SUCCESS, "loaded " _GREEN_(%2d) "keys from dictionary file %s", *keycnt, fileName);
|
||||
PrintAndLogDevice(SUCCESS, "loaded " _GREEN_(%2d) "keys from dictionary file " _YELLOW_(%s), *keycnt, fileName);
|
||||
*datalen = counter;
|
||||
out:
|
||||
free(fileName);
|
||||
|
||||
+113
-72
@@ -1,72 +1,115 @@
|
||||
local manufacturer = {}
|
||||
manufacturer[0x01]='Motorola [UK]'
|
||||
manufacturer[0x02]='STMicroelectronics SA [France]'
|
||||
manufacturer[0x03]='Hitachi, Ltd [Japan]'
|
||||
manufacturer[0x04]='NXP Semiconductors [Germany]'
|
||||
manufacturer[0x05]='Infineon Technologies AG [Germany]'
|
||||
manufacturer[0x06]='Cylink [USA]'
|
||||
manufacturer[0x07]='Texas Instrument [France]'
|
||||
manufacturer[0x08]='Fujitsu Limited [Japan]'
|
||||
manufacturer[0x09]='Matsushita Electronics Corporation, Semiconductor Company [Japan]'
|
||||
manufacturer[0x0A]='NEC [Japan]'
|
||||
manufacturer[0x0B]='Oki Electric Industry Co. Ltd [Japan]'
|
||||
manufacturer[0x0C]='Toshiba Corp. [Japan]'
|
||||
manufacturer[0x0D]='Mitsubishi Electric Corp. [Japan]'
|
||||
manufacturer[0x0E]='Samsung Electronics Co. Ltd [Korea]'
|
||||
manufacturer[0x0F]='Hynix [Korea]'
|
||||
manufacturer[0x10]='LG-Semiconductors Co. Ltd [Korea]'
|
||||
manufacturer[0x11]='Emosyn-EM Microelectronics [USA]'
|
||||
manufacturer[0x12]='INSIDE Technology [France]'
|
||||
manufacturer[0x13]='ORGA Kartensysteme GmbH [Germany]'
|
||||
manufacturer[0x14]='SHARP Corporation [Japan]'
|
||||
manufacturer[0x15]='ATMEL [France]'
|
||||
manufacturer[0x16]='EM Microelectronic-Marin SA [Switzerland]'
|
||||
manufacturer[0x17]='KSW Microtec GmbH [Germany]'
|
||||
manufacturer[0x18]='ZMD AG [Germany]'
|
||||
manufacturer[0x19]='XICOR, Inc. [USA]'
|
||||
manufacturer[0x1A]='Sony Corporation [Japan]'
|
||||
manufacturer[0x1B]='Malaysia Microelectronic Solutions Sdn. Bhd [Malaysia]'
|
||||
manufacturer[0x1C]='Emosyn [USA]'
|
||||
manufacturer[0x1D]='Shanghai Fudan Microelectronics Co. Ltd. P.R. [China]'
|
||||
manufacturer[0x1E]='Magellan Technology Pty Limited [Australia]'
|
||||
manufacturer[0x1F]='Melexis NV BO [Switzerland]'
|
||||
manufacturer[0x20]='Renesas Technology Corp. [Japan]'
|
||||
manufacturer[0x21]='TAGSYS [France]'
|
||||
manufacturer[0x22]='Transcore [USA]'
|
||||
manufacturer[0x23]='Shanghai belling corp., ltd. [China]'
|
||||
manufacturer[0x24]='Masktech Germany Gmbh [Germany]'
|
||||
manufacturer[0x25]='Innovision Research and Technology Plc [UK]'
|
||||
manufacturer[0x26]='Hitachi ULSI Systems Co., Ltd. [Japan]'
|
||||
manufacturer[0x27]='Cypak AB [Sweden]'
|
||||
manufacturer[0x28]='Ricoh [Japan]'
|
||||
manufacturer[0x29]='ASK [France]'
|
||||
manufacturer[0x2A]='Unicore Microsystems, LLC [RussianFederation]'
|
||||
manufacturer[0x2B]='Dallas Semiconductor/Maxim [USA]'
|
||||
manufacturer[0x2C]='Impinj, Inc. [USA]'
|
||||
manufacturer[0x2D]='RightPlug Alliance [USA]'
|
||||
manufacturer[0x2E]='Broadcom Corporation [USA]'
|
||||
manufacturer[0x2F]='MStar Semiconductor, Inc Taiwan, [ROC]'
|
||||
manufacturer[0x30]='BeeDar Technology Inc. [USA]'
|
||||
manufacturer[0x31]='RFIDsec [Denmark]'
|
||||
manufacturer[0x32]='Schweizer Electronic AG [Germany]'
|
||||
manufacturer[0x33]='AMIC Technology Corp [Taiwan]'
|
||||
manufacturer[0x34]='Mikron JSC [Russia]'
|
||||
manufacturer[0x35]='Fraunhofer Institute for Photonic Microsystems [Germany]'
|
||||
manufacturer[0x36]='IDS Microchip AG [Switzerland]'
|
||||
manufacturer[0x37]='Kovio [USA]'
|
||||
manufacturer[0x38]='HMT Microelectronic Ltd [Switzerland]'
|
||||
manufacturer[0x39]='Silicon Craft Technology [Thailand]'
|
||||
manufacturer[0x3A]='Advanced Film Device Inc. [Japan]'
|
||||
manufacturer[0x3B]='Nitecrest Ltd [UK]'
|
||||
manufacturer[0x3C]='Verayo Inc. [USA]'
|
||||
manufacturer[0x3D]='HID Global [USA]'
|
||||
manufacturer[0x3E]='Productivity Engineering Gmbh [Germany]'
|
||||
manufacturer[0x3F]='Austriamicrosystems AG (reserved) [Austria]'
|
||||
manufacturer[0x40]='Gemalto SA [France]'
|
||||
manufacturer[0x41]='Renesas Electronics Corporation [Japan]'
|
||||
manufacturer[0x42]='3Alogics Inc [Korea]'
|
||||
manufacturer[0x43]='Top TroniQ Asia Limited Hong [Kong]'
|
||||
manufacturer[0x44]='Gentag Inc (USA) [USA]'
|
||||
local m = {}
|
||||
m[0x01]='Motorola UK'
|
||||
m[0x02]='ST Microelectronics SA France'
|
||||
m[0x03]='Hitachi, Ltd Japan'
|
||||
m[0x04]='NXP Semiconductors Germany'
|
||||
m[0x05]='Infineon Technologies AG Germany'
|
||||
m[0x06]='Cylink USA'
|
||||
m[0x07]='Texas Instrument France'
|
||||
m[0x08]='Fujitsu Limited Japan'
|
||||
m[0x09]='Matsushita Electronics Corporation, Semiconductor Company Japan'
|
||||
m[0x0A]='NEC Japan'
|
||||
m[0x0B]='Oki Electric Industry Co. Ltd Japan'
|
||||
m[0x0C]='Toshiba Corp. Japan'
|
||||
m[0x0D]='Mitsubishi Electric Corp. Japan'
|
||||
m[0x0E]='Samsung Electronics Co. Ltd Korea'
|
||||
m[0x0F]='Hynix / Hyundai, Korea'
|
||||
m[0x10]='LG-Semiconductors Co. Ltd Korea'
|
||||
m[0x11]='Emosyn-EM Microelectronics USA'
|
||||
m[0x12]='INSIDE Technology France'
|
||||
m[0x13]='ORGA Kartensysteme GmbH Germany'
|
||||
m[0x14]='SHARP Corporation Japan'
|
||||
m[0x15]='ATMEL France'
|
||||
m[0x16]='EM Microelectronic-Marin SA Switzerland'
|
||||
m[0x17]='KSW Microtec GmbH Germany'
|
||||
m[0x18]='ZMD AG Germany'
|
||||
m[0x19]='XICOR, Inc. USA'
|
||||
m[0x1A]='Sony Corporation Japan'
|
||||
m[0x1B]='Malaysia Microelectronic Solutions Sdn. Bhd Malaysia'
|
||||
m[0x1C]='Emosyn USA'
|
||||
m[0x1D]='Shanghai Fudan Microelectronics Co. Ltd. P.R. China'
|
||||
m[0x1E]='Magellan Technology Pty Limited Australia'
|
||||
m[0x1F]='Melexis NV BO Switzerland'
|
||||
m[0x20]='Renesas Technology Corp. Japan'
|
||||
m[0x21]='TAGSYS France'
|
||||
m[0x22]='Transcore USA'
|
||||
m[0x23]='Shanghai belling corp., ltd. China'
|
||||
m[0x24]='Masktech Germany Gmbh Germany'
|
||||
m[0x25]='Innovision Research and Technology Plc UK'
|
||||
m[0x26]='Hitachi ULSI Systems Co., Ltd. Japan'
|
||||
m[0x27]='Cypak AB Sweden'
|
||||
m[0x28]='Ricoh Japan'
|
||||
m[0x29]='ASK France'
|
||||
m[0x2A]='Unicore Microsystems, LLC RussianFederation'
|
||||
m[0x2B]='Dallas Semiconductor/Maxim USA'
|
||||
m[0x2C]='Impinj, Inc. USA'
|
||||
m[0x2D]='RightPlug Alliance USA'
|
||||
m[0x2E]='Broadcom Corporation USA'
|
||||
m[0x2F]='MStar Semiconductor, Inc Taiwan, ROC'
|
||||
m[0x30]='BeeDar Technology Inc. USA'
|
||||
m[0x31]='RFIDsec Denmark'
|
||||
m[0x32]='Schweizer Electronic AG Germany'
|
||||
m[0x33]='AMIC Technology Corp Taiwan'
|
||||
m[0x34]='Mikron JSC Russia'
|
||||
m[0x35]='Fraunhofer Institute for Photonic Microsystems Germany'
|
||||
m[0x36]='IDS Microchip AG Switzerland'
|
||||
m[0x37]='Kovio USA'
|
||||
m[0x38]='HMT Microelectronic Ltd Switzerland'
|
||||
m[0x39]='Silicon Craft Technology Thailand'
|
||||
m[0x3A]='Advanced Film Device Inc. Japan'
|
||||
m[0x3B]='Nitecrest Ltd UK'
|
||||
m[0x3C]='Verayo Inc. USA'
|
||||
m[0x3D]='HID Global USA'
|
||||
m[0x3E]='Productivity Engineering Gmbh Germany'
|
||||
m[0x3F]='Austriamicrosystems AG (reserved) Austria'
|
||||
m[0x40]='Gemalto SA France'
|
||||
m[0x41]='Renesas Electronics Corporation Japan'
|
||||
m[0x42]='3Alogics Inc Korea'
|
||||
m[0x43]='Top TroniQ Asia Limited Hong Kong'
|
||||
m[0x44]='Gentag Inc USA'
|
||||
m[0x45]='Invengo Information Technology Co.Ltd China'
|
||||
m[0x46]='Guangzhou Sysur Microelectronics, Inc China'
|
||||
m[0x47]='CEITEC S.A. Brazil'
|
||||
m[0x48]='Shanghai Quanray Electronics Co. Ltd. China'
|
||||
m[0x49]='MediaTek Inc Taiwan'
|
||||
m[0x4A]='Angstrem PJSC Russia'
|
||||
m[0x4B]='Celisic Semiconductor (Hong Kong) Limited China'
|
||||
m[0x4C]='LEGIC Identsystems AG Switzerland'
|
||||
m[0x4D]='Balluff GmbH Germany'
|
||||
m[0x4E]='Oberthur Technologies France'
|
||||
m[0x4F]='Silterra Malaysia Sdn. Bhd. Malaysia'
|
||||
m[0x50]='DELTA Danish Electronics, Light & Acoustics Denmark'
|
||||
m[0x51]='Giesecke & Devrient GmbH Germany'
|
||||
m[0x52]='Shenzhen China Vision Microelectronics Co., Ltd. China'
|
||||
m[0x53]='Shanghai Feiju Microelectronics Co. Ltd. China'
|
||||
m[0x54]='Intel Corporation USA'
|
||||
m[0x55]='Microsensys GmbH Germany'
|
||||
m[0x56]='Sonix Technology Co., Ltd. Taiwan'
|
||||
m[0x57]='Qualcomm Technologies Inc USA'
|
||||
m[0x58]='Realtek Semiconductor Corp Taiwan'
|
||||
m[0x59]='Freevision Technologies Co. Ltd China'
|
||||
m[0x5A]='Giantec Semiconductor Inc. China'
|
||||
m[0x5B]='JSC Angstrem-T Russia'
|
||||
m[0x5C]='STARCHIP France'
|
||||
m[0x5D]='SPIRTECH France'
|
||||
m[0x5E]='GANTNER Electronic GmbH Austria'
|
||||
m[0x5F]='Nordic Semiconductor Norway'
|
||||
m[0x60]='Verisiti Inc USA'
|
||||
m[0x61]='Wearlinks Technology Inc. China'
|
||||
m[0x62]='Userstar Information Systems Co., Ltd Taiwan'
|
||||
m[0x63]='Pragmatic Printing Ltd. UK'
|
||||
m[0x64]='Associacao do Laboratorio de Sistemas Integraveis Tecnologico – LSI-TEC Brazil'
|
||||
m[0x65]='Tendyron Corporation China'
|
||||
m[0x66]='MUTO Smart Co., Ltd. Korea'
|
||||
m[0x67]='ON Semiconductor USA'
|
||||
m[0x68]='TUBITAK BILGEM Turkey'
|
||||
m[0x69]='Huada Semiconductor Co., Ltd China'
|
||||
m[0x6A]='SEVENEY France'
|
||||
m[0x6B]='ISSM France'
|
||||
m[0x6C]='Wisesec Ltd Israel'
|
||||
m[0x7C]='DB HiTek Co Ltd Korea'
|
||||
m[0x7D]='SATO Vicinity Australia'
|
||||
m[0x7E]='Holtek Taiwan'
|
||||
|
||||
return {
|
||||
lookupManufacturer = function (value)
|
||||
@@ -76,8 +119,6 @@ return {
|
||||
value = v
|
||||
end
|
||||
|
||||
return manufacturer[value] or "no tag-info available"
|
||||
return m[value] or "no tag-info available"
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
+11
-10
@@ -173,18 +173,19 @@ int mfCheckKeys_fast( uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
|
||||
|
||||
// success array. each byte is status of key
|
||||
uint8_t arr[80];
|
||||
uint64_t foo = bytes_to_num(resp.d.asBytes+480, 8);
|
||||
for (uint8_t i = 0; i < 64; ++i) {
|
||||
arr[i] = (foo >> i) & 0x1;
|
||||
}
|
||||
foo = bytes_to_num(resp.d.asBytes+488, 2);
|
||||
for (uint8_t i = 0; i < 16; ++i) {
|
||||
arr[i+64] = (foo >> i) & 0x1;
|
||||
}
|
||||
uint64_t foo = 0;
|
||||
uint16_t bar = 0;
|
||||
foo = bytes_to_num(resp.d.asBytes+480, 8);
|
||||
bar = (resp.d.asBytes[489] << 8 | resp.d.asBytes[488]);
|
||||
|
||||
for (uint8_t i = 0; i < 64; i++)
|
||||
arr[i] = (foo >> i) & 0x1;
|
||||
|
||||
for (uint8_t i = 0; i < 16; i++)
|
||||
arr[i+64] = (bar >> i) & 0x1;
|
||||
|
||||
// initialize storage for found keys
|
||||
icesector_t *tmp = NULL;
|
||||
tmp = calloc(sectorsCnt, sizeof(icesector_t));
|
||||
icesector_t *tmp = calloc(sectorsCnt, sizeof(icesector_t));
|
||||
if (tmp == NULL)
|
||||
return 1;
|
||||
memcpy(tmp, resp.d.asBytes, sectorsCnt * sizeof(icesector_t) );
|
||||
|
||||
+4
-4
@@ -215,11 +215,11 @@ const char *get_my_executable_directory(void) {
|
||||
static void set_my_executable_path(void) {
|
||||
int path_length = wai_getExecutablePath(NULL, 0, NULL);
|
||||
if (path_length != -1) {
|
||||
my_executable_path = (char*)malloc(path_length + 1);
|
||||
my_executable_path = (char*)calloc(path_length + 1, sizeof(uint8_t));
|
||||
int dirname_length = 0;
|
||||
if (wai_getExecutablePath(my_executable_path, path_length, &dirname_length) != -1) {
|
||||
my_executable_path[path_length] = '\0';
|
||||
my_executable_directory = (char *)malloc(dirname_length + 2);
|
||||
my_executable_directory = (char *)calloc(dirname_length + 2, sizeof(uint8_t));
|
||||
strncpy(my_executable_directory, my_executable_path, dirname_length+1);
|
||||
my_executable_directory[dirname_length+1] = '\0';
|
||||
}
|
||||
@@ -321,9 +321,9 @@ int main(int argc, char* argv[]) {
|
||||
} else {
|
||||
if (addLuaExec){
|
||||
// add "script run " to command
|
||||
char *ctmp = NULL;
|
||||
int len = strlen(script_cmd) + 11 + 1;
|
||||
if ((ctmp = (char*) malloc(len)) != NULL) {
|
||||
char *ctmp = (char*) calloc(len, sizeof(uint8_t));
|
||||
if (ctmp != NULL) {
|
||||
memset(ctmp, 0, len);
|
||||
strcpy(ctmp, "script run ");
|
||||
strcpy(&ctmp[11], script_cmd);
|
||||
|
||||
+3
-1
@@ -377,7 +377,9 @@ ipqx:
|
||||
|
||||
/* allocate argument array */
|
||||
args = argc - optind;
|
||||
if(!(apolys = malloc(args * sizeof(poly_t)))){
|
||||
|
||||
apolys = calloc(args * sizeof(poly_t), sizeof(char));
|
||||
if ( !apolys ){
|
||||
uerror("cannot allocate memory for argument list");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ char * mtostr(const model_t *model) {
|
||||
+ (checkstr && *checkstr ? strlen(checkstr) : 6)
|
||||
+ (magicstr && *magicstr ? strlen(magicstr) : 6)
|
||||
+ (model->name && *model->name ? 2 + strlen(model->name) : 6);
|
||||
if ((string = malloc(size))) {
|
||||
if ((string = calloc(size, sizeof(uint8_t)))) {
|
||||
sprintf(strbuf, "\"%s\"", model->name);
|
||||
sprintf(string,
|
||||
"width=%lu "
|
||||
|
||||
@@ -349,7 +349,7 @@ pxsubs(const poly_t poly, int flags, int bperhx, unsigned long start, unsigned l
|
||||
size *= cperhx;
|
||||
if(!size || ~flags & P_SPACE) ++size; /* for trailing null */
|
||||
|
||||
if(!(sptr = string = (char *) malloc(size)))
|
||||
if(!(sptr = string = (char *) calloc(size, sizeof(char))))
|
||||
uerror("cannot allocate memory for string");
|
||||
|
||||
size = end - start;
|
||||
|
||||
@@ -811,7 +811,9 @@ int mbynam(model_t *dest, const char *key) {
|
||||
|
||||
if (!aliases->name)
|
||||
return(-1);
|
||||
if (!(ukey = malloc((size_t) 1 + strlen(key) + 1))) {
|
||||
|
||||
ukey = calloc((size_t) 1 + strlen(key) + 1, sizeof(char));
|
||||
if (!ukey) {
|
||||
uerror("[!] cannot allocate memory for comparison string");
|
||||
return(0);
|
||||
}
|
||||
@@ -861,7 +863,9 @@ char * mnames(void) {
|
||||
++aptr;
|
||||
}
|
||||
if (!size) return(NULL);
|
||||
if ((string = malloc(size))) {
|
||||
|
||||
string = calloc(size, sizeof(char));
|
||||
if (string) {
|
||||
aptr = aliases;
|
||||
sptr = string;
|
||||
while (aptr->name) {
|
||||
|
||||
@@ -173,8 +173,9 @@ modpol(const poly_t init, int rflags, int args, const poly_t *argpolys) {
|
||||
unsigned long alen, blen;
|
||||
|
||||
if(args < 2) return(NULL);
|
||||
|
||||
if(!(result = malloc(((((args - 1) * args) >> 1) + 1) * sizeof(poly_t))))
|
||||
|
||||
result = calloc(((((args - 1) * args) >> 1) + 1) * sizeof(poly_t), sizeof(char));
|
||||
if(!result)
|
||||
uerror("cannot allocate memory for codeword table");
|
||||
|
||||
rptr = result;
|
||||
@@ -240,7 +241,8 @@ engini(int *resc, model_t **result, const poly_t divisor, int flags, int args, c
|
||||
dlen = plen(divisor);
|
||||
|
||||
/* Allocate the CRC matrix */
|
||||
if(!(mat = (poly_t *) malloc((dlen << 1) * sizeof(poly_t))))
|
||||
mat = (poly_t *) calloc((dlen << 1) * sizeof(poly_t), sizeof(char));
|
||||
if(!mat)
|
||||
uerror("cannot allocate memory for CRC matrix");
|
||||
|
||||
/* Find arguments of the two shortest lengths */
|
||||
|
||||
+2
-1
@@ -51,7 +51,8 @@ int scandir (const char *dir,
|
||||
nl = ntmp;
|
||||
}
|
||||
|
||||
if (!(etmp = (struct dirent *) malloc (sizeof *ent))) {
|
||||
etmp = (struct dirent *) calloc (sizeof *ent, sizeof(char));
|
||||
if (!etmp) {
|
||||
err_no = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
+9
-1
@@ -758,6 +758,15 @@ int set_pm3_libraries(lua_State *L) {
|
||||
//-- remove the global environment table from the stack
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
||||
//--add to the LUA_PATH (package.path in lua)
|
||||
// so we can load scripts from the ./scripts/ - directory
|
||||
char scripts_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, get_my_executable_directory());
|
||||
strcat(scripts_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(scripts_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, scripts_path);
|
||||
|
||||
//-- Last but not least, add to the LUA_PATH (package.path in lua)
|
||||
// so we can load libraries from the ./lualib/ - directory
|
||||
char libraries_path[strlen(get_my_executable_directory()) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
@@ -765,6 +774,5 @@ int set_pm3_libraries(lua_State *L) {
|
||||
strcat(libraries_path, LUA_LIBRARIES_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, libraries_path);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ local utils = require('utils')
|
||||
|
||||
copyright = 'Copyright (c) 2018 IceSQL AB. All rights reserved.'
|
||||
author = 'Christian Herrmann'
|
||||
version = 'v1.0.3'
|
||||
version = 'v1.0.4'
|
||||
desc = [[
|
||||
This script tries to set UID on a IS15693 SLIX magic card
|
||||
Remember the UID ->MUST<- start with 0xE0
|
||||
@@ -15,6 +15,8 @@ example = [[
|
||||
-- ISO15693 slix magic tag
|
||||
|
||||
script run iso15_magic -u E004013344556677
|
||||
|
||||
script run iso15_magic -u E004013344556677 -a
|
||||
]]
|
||||
usage = [[
|
||||
script run iso15_magic -h -u <uid>
|
||||
@@ -22,6 +24,7 @@ script run iso15_magic -h -u <uid>
|
||||
Arguments:
|
||||
-h : this help
|
||||
-u <UID> : UID (16 hexsymbols)
|
||||
-a : use offical pm3 repo ISO15 commands instead of iceman fork.
|
||||
]]
|
||||
|
||||
local DEBUG = true
|
||||
@@ -82,11 +85,13 @@ function main(args)
|
||||
print()
|
||||
|
||||
local uid = 'E004013344556677'
|
||||
local use_iceman = true
|
||||
|
||||
-- Read the parameters
|
||||
for o, a in getopt.getopt(args, 'hu:') do
|
||||
for o, a in getopt.getopt(args, 'hu:a') do
|
||||
if o == "h" then return help() end
|
||||
if o == "u" then uid = a end
|
||||
if o == "a" then use_iceman = false end
|
||||
end
|
||||
|
||||
-- uid string checks
|
||||
@@ -103,8 +108,11 @@ function main(args)
|
||||
|
||||
core.clearCommandBuffer()
|
||||
|
||||
magicUID_iceman(block0, block1)
|
||||
--magicUID_offical(block0, block1)
|
||||
if use_iceman then
|
||||
magicUID_iceman(block0, block1)
|
||||
else
|
||||
magicUID_offical(block0, block1)
|
||||
end
|
||||
end
|
||||
|
||||
main(args)
|
||||
+155
-140
@@ -513,8 +513,8 @@ function readFromPM3()
|
||||
return tag
|
||||
end
|
||||
|
||||
function padString(str)
|
||||
if (str:len() == 1) then
|
||||
local function padString(str)
|
||||
if (#str == 1) then
|
||||
return '0'..str
|
||||
end
|
||||
|
||||
@@ -524,73 +524,84 @@ end
|
||||
---
|
||||
-- write virtual Tag to real Tag
|
||||
function writeToTag(tag)
|
||||
local bytes
|
||||
local filename='MylegicClone.hex'
|
||||
local taglen=22
|
||||
local bytes
|
||||
local filename = 'MylegicClone.hex'
|
||||
local taglen = 22
|
||||
if(utils.confirm(acred.."\nplace the (empty) Tag onto the PM3\nand confirm writing to this Tag: "..acoff) == false) then
|
||||
return
|
||||
end
|
||||
-- get used bytes / tag-len
|
||||
if(istable(tag.SEG)) then
|
||||
if (istable(tag.Bck)) then
|
||||
for i=0, #tag.SEG do
|
||||
taglen=taglen+tag.SEG[i].len+5
|
||||
end
|
||||
end
|
||||
local uid_old=tag.MCD..tag.MSN0..tag.MSN1..tag.MSN2
|
||||
-- read new tag into memory so we can xor the new data with the new MCC
|
||||
outTAG=readFromPM3()
|
||||
outbytes=tagToBytes(outTAG)
|
||||
-- copy 'inputbuffer' to 'outputbuffer'
|
||||
tag.MCD = outbytes[1]
|
||||
tag.MSN0 = outbytes[2]
|
||||
tag.MSN1 = outbytes[3]
|
||||
tag.MSN2 = outbytes[4]
|
||||
tag.MCC = outbytes[5]
|
||||
-- recheck all segments-crc/kghcrc (only on a credential)
|
||||
if(istable(tag.Bck)) then
|
||||
checkAllSegCrc(tag)
|
||||
checkAllKghCrc(tag)
|
||||
local uid_new=tag.MCD..tag.MSN0..tag.MSN1..tag.MSN2
|
||||
for i=0, #tag.SEG do
|
||||
if (check43rdPartyCash1(uid_old, tag.SEG[i].data)) then
|
||||
io.write(accyan.."\nfixing known checksums"..acoff.." ... ")
|
||||
if (fix3rdPartyCash1(uid_new, tag.SEG[i].data)) then
|
||||
io.write(acgreen.." done\n"..acoff)
|
||||
else oops("\nsomething went wrong at the repair of the 3rd-party-cash-segment") end
|
||||
end
|
||||
end
|
||||
end
|
||||
bytes=tagToBytes(tag)
|
||||
-- master-token-crc
|
||||
if (tag.Type ~= "SAM") then bytes[22] = calcMtCrc(bytes) end
|
||||
if (bytes) then
|
||||
print("write temp-file '"..filename.."'")
|
||||
print(accyan)
|
||||
writeFile(bytes, filename..".bin")
|
||||
print(acoff)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- get used bytes / tag-len
|
||||
if (istable(tag.SEG)) then
|
||||
if (istable(tag.Bck)) then
|
||||
for i=0, #tag.SEG do
|
||||
taglen = taglen + tag.SEG[i] . len + 5
|
||||
end
|
||||
end
|
||||
local uid_old = tag.MCD..tag.MSN0..tag.MSN1..tag.MSN2
|
||||
|
||||
-- read new tag into memory so we can xor the new data with the new MCC
|
||||
outTAG = readFromPM3()
|
||||
outbytes = tagToBytes(outTAG)
|
||||
-- copy 'inputbuffer' to 'outputbuffer'
|
||||
tag.MCD = outbytes[1]
|
||||
tag.MSN0 = outbytes[2]
|
||||
tag.MSN1 = outbytes[3]
|
||||
tag.MSN2 = outbytes[4]
|
||||
tag.MCC = outbytes[5]
|
||||
-- recheck all segments-crc/kghcrc (only on a credential)
|
||||
if (istable(tag.Bck)) then
|
||||
checkAllSegCrc(tag)
|
||||
checkAllKghCrc(tag)
|
||||
local uid_new = tag.MCD..tag.MSN0..tag.MSN1..tag.MSN2
|
||||
for i=0, #tag.SEG do
|
||||
if (check43rdPartyCash1(uid_old, tag.SEG[i].data)) then
|
||||
io.write(accyan.."\nfixing known checksums"..acoff.." ... ")
|
||||
if (fix3rdPartyCash1(uid_new, tag.SEG[i].data)) then
|
||||
io.write(acgreen.." done\n"..acoff)
|
||||
else
|
||||
oops("\nsomething went wrong at the repair of the 3rd-party-cash-segment")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
bytes = tagToBytes(tag)
|
||||
-- master-token-crc
|
||||
if (tag.Type ~= "SAM") then
|
||||
bytes[22] = calcMtCrc(bytes)
|
||||
end
|
||||
if (bytes) then
|
||||
print("write temp-file '"..filename.."'")
|
||||
print(accyan)
|
||||
writeFile(bytes, filename..".bin")
|
||||
print(acoff)
|
||||
end
|
||||
end
|
||||
|
||||
-- write data to file
|
||||
-- write data to file
|
||||
if (taglen > 0) then
|
||||
WriteBytes = utils.input(acyellow.."enter number of bytes to write?"..acoff, taglen)
|
||||
-- load file into pm3-buffer
|
||||
if (type(filename) ~= "string") then filename=input(acyellow.."filename to load to pm3-buffer?"..acoff,"legic.temp") end
|
||||
if (type(filename) ~= "string") then
|
||||
filename = input(acyellow.."filename to load to pm3-buffer?"..acoff, "legic.temp")
|
||||
end
|
||||
|
||||
cmd = 'hf legic eload 2 '..filename
|
||||
core.console(cmd)
|
||||
-- write pm3-buffer to Tag
|
||||
for i=0, WriteBytes do
|
||||
if (i > 6) then
|
||||
cmd = 'hf legic write o '..string.format("%x", i)..' d '..padString(bytes[i])
|
||||
print(acgreen..cmd..acoff)
|
||||
cmd = ("hf legic write o %x d %s "):format(i, padString(bytes[i]))
|
||||
print(acgreen..cmd..acoff)
|
||||
core.console(cmd)
|
||||
core.clearCommandBuffer()
|
||||
elseif (i == 6) then
|
||||
-- write DCF in reverse order (requires 'mosci-patch')
|
||||
cmd = 'hf legic write o 05 d '..padString(bytes[i-1])..padString(bytes[i])
|
||||
print(acgreen..cmd..acoff)
|
||||
-- write DCF in reverse order (requires 'mosci-patch')
|
||||
cmd = ('hf legic write o 05 d %s%s'):format(padString(bytes[i-1]), padString(bytes[i]))
|
||||
print(acgreen..cmd..acoff)
|
||||
core.console(cmd)
|
||||
elseif (i == 5) then
|
||||
core.clearCommandBuffer()
|
||||
elseif (i == 5) then
|
||||
print(acgreen.."skip byte 0x05 - will be written next step"..acoff)
|
||||
else
|
||||
print(acgreen.."skip byte 0x00-0x04 - unwritable area"..acoff)
|
||||
@@ -603,26 +614,28 @@ end
|
||||
--- File I/O ---
|
||||
---
|
||||
-- read file into virtual-tag
|
||||
function readFile(filename)
|
||||
print(accyan)
|
||||
local bytes = {}
|
||||
local tag = {}
|
||||
if file_check(filename) == false then return oops("input file: "..filename.." not found") end
|
||||
local function readFile(filename)
|
||||
print(accyan)
|
||||
local bytes = {}
|
||||
local tag = {}
|
||||
if file_check(filename) == false then
|
||||
return oops("input file: "..filename.." not found")
|
||||
end
|
||||
|
||||
bytes = getInputBytes(filename)
|
||||
bytes = getInputBytes(filename)
|
||||
|
||||
if bytes == false then return oops('couldnt get input bytes') end
|
||||
if bytes == false then return oops('couldnt get input bytes') end
|
||||
|
||||
-- make plain bytes
|
||||
bytes = xorBytes(bytes,bytes[5])
|
||||
print("create virtual tag from ".. #bytes .. " bytes")
|
||||
-- create Tag for plain bytes
|
||||
tag=createTagTable()
|
||||
-- load plain bytes to tag-table
|
||||
print(acoff)
|
||||
tag=bytesToTag(bytes, tag)
|
||||
-- make plain bytes
|
||||
bytes = xorBytes(bytes,bytes[5])
|
||||
print("create virtual tag from ".. #bytes .. " bytes")
|
||||
-- create Tag for plain bytes
|
||||
tag = createTagTable()
|
||||
-- load plain bytes to tag-table
|
||||
print(acoff)
|
||||
tag = bytesToTag(bytes, tag)
|
||||
|
||||
return tag
|
||||
return tag
|
||||
end
|
||||
|
||||
---
|
||||
@@ -631,14 +644,16 @@ function writeFile(bytes, filename)
|
||||
if (filename ~= 'MylegicClone.hex') then
|
||||
if (file_check(filename)) then
|
||||
local answer = confirm("\nthe output-file "..filename.." already exists!\nthis will delete the previous content!\ncontinue?")
|
||||
if (answer==false) then return print("user abort") end
|
||||
if not answer then return print("user abort") end
|
||||
end
|
||||
end
|
||||
local line
|
||||
local bcnt=0
|
||||
local fho,err = io.open(filename, "w")
|
||||
if err then oops("OOps ... failed to open output-file ".. filename) end
|
||||
bytes=xorBytes(bytes, bytes[5])
|
||||
local bcnt = 0
|
||||
local fho, err = io.open(filename, "w")
|
||||
if err then
|
||||
return oops("OOps ... failed to open output-file ".. filename)
|
||||
end
|
||||
bytes = xorBytes(bytes, bytes[5])
|
||||
for i = 1, #bytes do
|
||||
if (bcnt == 0) then
|
||||
line = bytes[i]
|
||||
@@ -662,96 +677,96 @@ end
|
||||
--- Map related ---
|
||||
---
|
||||
-- make tagMap
|
||||
function makeTagMap()
|
||||
local tagMap={}
|
||||
if (#tagMap == 0) then
|
||||
tagMap['name'] = input(accyan.."enter Name for this Map: "..acoff , "newTagMap")
|
||||
tagMap['mappings']={}
|
||||
tagMap['crc8']={}
|
||||
-- insert fixed Tag-CRC
|
||||
table.insert(tagMap.crc8, {name='TAG-CRC', pos=5, seq={1, 4}})
|
||||
tagMap['crc16']={}
|
||||
end
|
||||
print(accyan.."new tagMap created"..acoff)
|
||||
return tagMap
|
||||
local function makeTagMap()
|
||||
local tagMap = {}
|
||||
if (#tagMap == 0) then
|
||||
tagMap['name'] = input(accyan.."enter Name for this Map: "..acoff , "newTagMap")
|
||||
tagMap['mappings'] = {}
|
||||
tagMap['crc8'] = {}
|
||||
-- insert fixed Tag-CRC
|
||||
table.insert(tagMap.crc8, {name = 'TAG-CRC', pos = 5, seq = {1, 4}})
|
||||
tagMap['crc16'] = {}
|
||||
end
|
||||
print(accyan.."new tagMap created"..acoff)
|
||||
return tagMap
|
||||
end
|
||||
|
||||
---
|
||||
-- save mapping to file
|
||||
function saveTagMap(map, filename)
|
||||
if (string.len(filename)>0) then
|
||||
if (file_check(filename)) then
|
||||
local answer = confirm("\nthe output-file "..filename.." alredy exists!\nthis will delete the previous content!\ncontinue?")
|
||||
if (answer==false) then return print("user abort") end
|
||||
end
|
||||
end
|
||||
local function saveTagMap(map, filename)
|
||||
if (string.len(filename)>0) then
|
||||
if (file_check(filename)) then
|
||||
local answer = confirm("\nthe output-file "..filename.." alredy exists!\nthis will delete the previous content!\ncontinue?")
|
||||
if not answer then return print("user abort") end
|
||||
end
|
||||
end
|
||||
|
||||
local line
|
||||
local line
|
||||
local fho,err = io.open(filename, "w")
|
||||
if err then oops("OOps ... faild to open output-file ".. filename) end
|
||||
|
||||
-- write line to new file
|
||||
for k, v in pairs(map) do
|
||||
if (istable(v)) then
|
||||
for k2, v2 in pairs(v) do
|
||||
if (k=='mappings') then
|
||||
fho:write(k..","..k2..","..v2['name']..","..v2['start']..","..v2['end']..","..((v2['highlight']) and "1" or "0").."\n")
|
||||
elseif (k=="crc8") then
|
||||
local tmp=""
|
||||
tmp=k..","..k2..","..v2['name']..","..v2['pos']..","
|
||||
tmp=tmp..tbl2seqstr(v2['seq'])
|
||||
fho:write(tmp.."\n")
|
||||
end
|
||||
end
|
||||
else
|
||||
fho:write(k..","..v.."\n")
|
||||
end
|
||||
end
|
||||
-- write line to new file
|
||||
for k, v in pairs(map) do
|
||||
if (istable(v)) then
|
||||
for k2, v2 in pairs(v) do
|
||||
if (k == 'mappings') then
|
||||
fho:write(k..","..k2..","..v2['name']..","..v2['start']..","..v2['end']..","..((v2['highlight']) and "1" or "0").."\n")
|
||||
elseif (k == "crc8") then
|
||||
local tmp = ""
|
||||
tmp = k..","..k2..","..v2['name']..","..v2['pos']..","
|
||||
tmp=tmp..tbl2seqstr(v2['seq'])
|
||||
fho:write(tmp.."\n")
|
||||
end
|
||||
end
|
||||
else
|
||||
fho:write(k..","..v.."\n")
|
||||
end
|
||||
end
|
||||
fho:close()
|
||||
return true
|
||||
end
|
||||
|
||||
---
|
||||
-- toggle higligh
|
||||
function toggleHighlight(tbl)
|
||||
local function toggleHighlight(tbl)
|
||||
if (tbl['highlight']) then
|
||||
tbl['highlight'] = false
|
||||
else
|
||||
tbl['highlight'] = true
|
||||
end
|
||||
return tbl
|
||||
return tbl
|
||||
end
|
||||
|
||||
---
|
||||
-- return table od seqence-string
|
||||
function seqstr2tbl(seqstr)
|
||||
local s=split(seqstr)
|
||||
local res={}
|
||||
if (#s>=1) then
|
||||
for sk, sv in pairs(s) do
|
||||
s2=split(sv, '-')
|
||||
if(#s2==2) then
|
||||
table.insert(res, s2[1])
|
||||
table.insert(res, s2[2])
|
||||
end
|
||||
end
|
||||
end
|
||||
return res
|
||||
local function seqstr2tbl(seqstr)
|
||||
local s = split(seqstr)
|
||||
local res = {}
|
||||
if (#s >= 1) then
|
||||
for sk, sv in pairs(s) do
|
||||
s2 = split(sv, '-')
|
||||
if(#s2 == 2) then
|
||||
table.insert(res, s2[1])
|
||||
table.insert(res, s2[2])
|
||||
end
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
---
|
||||
-- return sequence-string from table
|
||||
function tbl2seqstr(seqtbl)
|
||||
local res=""
|
||||
if (istable(seqtbl)) then
|
||||
for sk, sv in pairs(seqtbl) do
|
||||
res=res..sv..((sk%2==0) and "," or "-")
|
||||
end
|
||||
if (string.sub(res, string.len(res))==",") then
|
||||
res=string.sub(res, 1, string.len(res)-1)
|
||||
end
|
||||
end
|
||||
return res
|
||||
local function tbl2seqstr(seqtbl)
|
||||
local res = ""
|
||||
if (istable(seqtbl)) then
|
||||
for sk, sv in pairs(seqtbl) do
|
||||
res = res..sv..((sk%2==0) and "," or "-")
|
||||
end
|
||||
if (string.sub(res, string.len(res))== ",") then
|
||||
res = string.sub(res, 1, string.len(res)-1)
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
---
|
||||
|
||||
@@ -12,8 +12,10 @@ This is a script which automates cracking and dumping mifare classic cards. It s
|
||||
place by the device.
|
||||
|
||||
Arguments:
|
||||
-d debug logging on
|
||||
-h this help
|
||||
-h this help
|
||||
-d debug logging on
|
||||
-k known key for Sector 0 , keytype A
|
||||
|
||||
|
||||
Output files from this operation:
|
||||
<uid>.eml - emulator file
|
||||
@@ -73,12 +75,12 @@ local function nested(key,sak)
|
||||
if 0x18 == sak then --NXP MIFARE Classic 4k | Plus 4k | Ev1 4k
|
||||
typ = 4
|
||||
elseif 0x08 == sak then -- NXP MIFARE CLASSIC 1k | Plus 2k | Ev1 1K
|
||||
typ= 1
|
||||
typ = 1
|
||||
elseif 0x09 == sak then -- NXP MIFARE Mini 0.3k
|
||||
typ = 0
|
||||
elseif 0x10 == sak then-- "NXP MIFARE Plus 2k"
|
||||
elseif 0x10 == sak then-- "NXP MIFARE Plus 2k"
|
||||
typ = 2
|
||||
elseif 0x01 == sak then-- "NXP MIFARE TNP3xxx 1K"
|
||||
elseif 0x01 == sak then-- "NXP MIFARE TNP3xxx 1K"
|
||||
typ = 1
|
||||
else
|
||||
print("I don't know how many sectors there are on this type of card, defaulting to 16")
|
||||
@@ -87,22 +89,40 @@ local function nested(key,sak)
|
||||
core.console(cmd)
|
||||
end
|
||||
|
||||
local function dump(uid)
|
||||
local function dump(uid, numsectors)
|
||||
dbg('dumping tag memory')
|
||||
|
||||
local typ = 1
|
||||
if 0x18 == sak then --NXP MIFARE Classic 4k | Plus 4k | Ev1 4k
|
||||
typ = 4
|
||||
elseif 0x08 == sak then -- NXP MIFARE CLASSIC 1k | Plus 2k | Ev1 1K
|
||||
typ = 1
|
||||
elseif 0x09 == sak then -- NXP MIFARE Mini 0.3k
|
||||
typ = 0
|
||||
elseif 0x10 == sak then-- "NXP MIFARE Plus 2k"
|
||||
typ = 2
|
||||
elseif 0x01 == sak then-- "NXP MIFARE TNP3xxx 1K"
|
||||
typ = 1
|
||||
end
|
||||
|
||||
if utils.confirm('Do you wish to create a memory dump of tag?') then
|
||||
|
||||
core.console("hf mf dump")
|
||||
local dumpfile = 'hf-mf-'..uid..'-data.bin'
|
||||
|
||||
local dmp = ('hf mf dump %s f %s'):format(typ, dumpfile)
|
||||
core.console(dmp)
|
||||
|
||||
-- Save the global args, those are *our* arguments
|
||||
local myargs = args
|
||||
-- Set the arguments for htmldump script
|
||||
args =("-o %s.html"):format(uid)
|
||||
args =('-i %s -o %s.html'):format(dumpfile, uid)
|
||||
-- call it
|
||||
require('../scripts/htmldump')
|
||||
require('htmldump')
|
||||
|
||||
args =""
|
||||
-- dump to emulator
|
||||
require('../scripts/dumptoemul')
|
||||
args =('-i %s -o %s.eml'):format(dumpfile, uid)
|
||||
require('dumptoemul')
|
||||
|
||||
-- Set back args. Not that it's used, just for the karma...
|
||||
args = myargs
|
||||
end
|
||||
@@ -177,9 +197,9 @@ local function main(args)
|
||||
print("Found valid key: "..key);
|
||||
end
|
||||
-- Use nested attack
|
||||
nested(key,sak)
|
||||
nested(key, sak)
|
||||
-- Dump info
|
||||
dump(uid)
|
||||
dump(uid, sak)
|
||||
|
||||
if #key == 12 then exit = true end
|
||||
else
|
||||
|
||||
@@ -24,13 +24,13 @@ local example = "script run xxx"
|
||||
local author = "Martin Holst Swende & Asper"
|
||||
---
|
||||
-- PrintAndLog
|
||||
function prlog(...)
|
||||
local function prlog(...)
|
||||
-- TODO; replace this with a call to the proper PrintAndLog
|
||||
print(...)
|
||||
end
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
function oops(err)
|
||||
local function oops(err)
|
||||
prlog("ERROR: ",err)
|
||||
return nil,err
|
||||
end
|
||||
@@ -70,13 +70,13 @@ local utils = {
|
||||
|
||||
---
|
||||
-- Usage help
|
||||
function help()
|
||||
local function help()
|
||||
prlog(desc)
|
||||
prlog("Example usage")
|
||||
prlog(example)
|
||||
end
|
||||
|
||||
function debug(...)
|
||||
local function debug(...)
|
||||
if DEBUG then
|
||||
prlog("debug:", ...)
|
||||
end
|
||||
@@ -158,7 +158,7 @@ end
|
||||
|
||||
--- This function is a lua-implementation of
|
||||
-- cmdhf14a.c:waitCmd(uint8_t iSelect)
|
||||
function waitCmd(iSelect)
|
||||
local function waitCmd(iSelect)
|
||||
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,1000)
|
||||
if response then
|
||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',response)
|
||||
|
||||
@@ -21,6 +21,9 @@ Arguments:
|
||||
-o <offset> : memory offset, default is 0
|
||||
-l <length> : length in bytes, default is 256
|
||||
-k <keylen> : key length in bytes <4|6|8> , default is 4
|
||||
-m : print Mifare dictionary keys
|
||||
-t : print t55xx dictionary passwords
|
||||
-i : print iClass dictionary keys
|
||||
]]
|
||||
example =
|
||||
[[
|
||||
@@ -67,7 +70,7 @@ local function main(args)
|
||||
local keylength = 4
|
||||
local usedkey = false
|
||||
|
||||
for o, a in getopt.getopt(args, 'ho:l:k:') do
|
||||
for o, a in getopt.getopt(args, 'ho:l:k:mti') do
|
||||
|
||||
-- help
|
||||
if o == "h" then return help() end
|
||||
@@ -80,6 +83,10 @@ local function main(args)
|
||||
|
||||
-- keylength
|
||||
if o == "k" then keylength = tonumber(a); usedkey = true end
|
||||
|
||||
if o == "m" then keylength =6; usedkey = true; offset = 0x3F000-0x4000; end
|
||||
if o == "t" then keylength =4; usedkey = true; offset = 0x3F000-0x3000; end
|
||||
if o == "i" then keylength =8; usedkey = true; offset = 0x3F000-0x5000; end
|
||||
end
|
||||
|
||||
if length < 0 or length > 256 then
|
||||
|
||||
@@ -72,6 +72,7 @@ local function sendCmds( cmds )
|
||||
if cmds[i] then
|
||||
print ( cmds[i] )
|
||||
core.console( cmds[i] )
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,13 +37,12 @@ Arguments:
|
||||
0020 - Swapforce
|
||||
]]
|
||||
|
||||
|
||||
-- This is only meant to be used when errors occur
|
||||
function oops(err)
|
||||
local function oops(err)
|
||||
print("ERROR: ",err)
|
||||
end
|
||||
-- Usage help
|
||||
function help()
|
||||
local function help()
|
||||
print(desc)
|
||||
print("Example usage")
|
||||
print(example)
|
||||
@@ -64,7 +63,7 @@ local function waitCmd()
|
||||
end
|
||||
|
||||
local function readblock( blocknum, keyA )
|
||||
-- Read block 0
|
||||
-- Read block N
|
||||
cmd = Command:new{cmd = cmds.CMD_MIFARE_READBL, arg1 = blocknum, arg2 = 0, arg3 = 0, data = keyA}
|
||||
err = core.SendCommand(cmd:getBytes())
|
||||
if err then return nil, err end
|
||||
@@ -72,8 +71,9 @@ local function readblock( blocknum, keyA )
|
||||
if err then return nil, err end
|
||||
return block0
|
||||
end
|
||||
|
||||
local function readmagicblock( blocknum )
|
||||
-- Read block 0
|
||||
-- Read block N
|
||||
local CSETBLOCK_SINGLE_OPERATION = 0x1F
|
||||
cmd = Command:new{cmd = cmds.CMD_MIFARE_CGETBLOCK, arg1 = CSETBLOCK_SINGLE_OPERATION, arg2 = 0, arg3 = blocknum}
|
||||
err = core.SendCommand(cmd:getBytes())
|
||||
@@ -89,11 +89,13 @@ local function main(args)
|
||||
print( string.rep('--',20) )
|
||||
|
||||
local numBlocks = 64
|
||||
local cset = 'hf mf csetbl '
|
||||
local cset = 'hf mf csetbl '
|
||||
local csetuid = 'hf mf csetuid '
|
||||
local cget = 'hf mf cgetbl '
|
||||
local empty = '00000000000000000000000000000000'
|
||||
local AccAndKeyB = '7F078869000000000000'
|
||||
local AccAndKeyB = '7F0F0869000000000000'
|
||||
local atqa = '0F01'
|
||||
local sak = '81'
|
||||
-- Defaults to Gusto
|
||||
local toytype = 'C201'
|
||||
local subtype = '0030'
|
||||
@@ -107,42 +109,43 @@ local function main(args)
|
||||
if o == "l" then return toys.List() end
|
||||
end
|
||||
|
||||
if #toytype ~= 4 then return oops('Wrong size - toytype. (4hex symbols)') end
|
||||
if #subtype ~= 4 then return oops('Wrong size - subtype. (4hex symbols)') end
|
||||
if #toytype ~= 4 then return oops('[!] Wrong size - toytype. (4hex symbols)') end
|
||||
if #subtype ~= 4 then return oops('[!] Wrong size - subtype. (4hex symbols)') end
|
||||
|
||||
-- look up type, find & validate types
|
||||
local item = toys.Find( toytype, subtype)
|
||||
if item then
|
||||
print( (' Looking up input: Found %s - %s (%s)'):format(item[6],item[5], item[4]) )
|
||||
print( ('[+] Looking up input: Found %s - %s (%s)'):format(item[6],item[5], item[4]) )
|
||||
else
|
||||
print('Didn\'t find item type. If you are sure about it, report it in')
|
||||
print('[-] Didn\'t find item type. If you are sure about it, post on forum')
|
||||
end
|
||||
--15,16
|
||||
--13-14
|
||||
|
||||
--13-14
|
||||
|
||||
-- find tag
|
||||
result, err = lib14a.read(false, true)
|
||||
if not result then return oops(err) end
|
||||
if not result then return oops(err) end
|
||||
|
||||
-- load keys
|
||||
local akeys = pre.GetAll(result.uid)
|
||||
local keyA = akeys:sub(1, 12 )
|
||||
local keyA = akeys:sub(1, 12 )
|
||||
|
||||
local b0 = readblock(0,keyA)
|
||||
local b0 = readblock(0, keyA)
|
||||
if not b0 then
|
||||
print('failed reading block with factorydefault key. Trying chinese magic read.')
|
||||
print('[-] failed reading block with factorydefault key. Trying chinese magic read.')
|
||||
b0, err = readmagicblock(0)
|
||||
if not b0 then
|
||||
oops(err)
|
||||
return oops('failed reading block with chinese magic command. quitting...')
|
||||
oops('[!] '..err)
|
||||
return oops('[!] failed reading block with chinese magic command. Quitting...')
|
||||
end
|
||||
end
|
||||
|
||||
-- wipe card.
|
||||
local cmd = (csetuid..'%s 0004 08 w'):format(result.uid)
|
||||
core.console(cmd)
|
||||
core.clearCommandBuffer()
|
||||
|
||||
-- wipe card.
|
||||
local cmd = (csetuid..'%s %s %s w'):format(result.uid, atqa, sak)
|
||||
core.console(cmd)
|
||||
core.clearCommandBuffer()
|
||||
|
||||
local b1 = toytype..string.rep('00',10)..subtype
|
||||
|
||||
local calc = utils.Crc16(b0..b1)
|
||||
@@ -150,6 +153,7 @@ local function main(args)
|
||||
|
||||
local cmd = (cset..'1 %s%04x'):format( b1, calcEndian)
|
||||
core.console(cmd)
|
||||
core.clearCommandBuffer()
|
||||
|
||||
local pos, key
|
||||
for blockNo = 2, numBlocks-1, 1 do
|
||||
@@ -161,5 +165,10 @@ local function main(args)
|
||||
end
|
||||
end
|
||||
core.clearCommandBuffer()
|
||||
|
||||
-- Set sector trailer S0, since it has different access rights
|
||||
cmd = ('%s 3 %s0f0f0f69000000000000'):format(cset, keyA)
|
||||
core.console(cmd)
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
main(args)
|
||||
main(args)
|
||||
@@ -105,7 +105,7 @@ CborError _cbor_value_dup_string(const CborValue *value, void **buffer, size_t *
|
||||
return err;
|
||||
|
||||
++*buflen;
|
||||
*buffer = malloc(*buflen);
|
||||
*buffer = calloc(*buflen, sizeof(uint8_t));
|
||||
if (!*buffer) {
|
||||
/* out of memory */
|
||||
return CborErrorOutOfMemory;
|
||||
|
||||
@@ -178,7 +178,7 @@ static CborError dump_bytestring_base16(char **result, CborValue *it)
|
||||
return err;
|
||||
|
||||
/* a Base16 (hex) output is twice as big as our buffer */
|
||||
buffer = (uint8_t *)malloc(n * 2 + 1);
|
||||
buffer = (uint8_t *)calloc(n * 2 + 1, sizeof(uint8_t));
|
||||
*result = (char *)buffer;
|
||||
|
||||
/* let cbor_value_copy_byte_string know we have an extra byte for the terminating NUL */
|
||||
@@ -204,7 +204,7 @@ static CborError generic_dump_base64(char **result, CborValue *it, const char al
|
||||
|
||||
/* a Base64 output (untruncated) has 4 bytes for every 3 in the input */
|
||||
size_t len = (n + 5) / 3 * 4;
|
||||
out = buffer = (uint8_t *)malloc(len + 1);
|
||||
out = buffer = (uint8_t *)calloc(len + 1, sizeof(uint8_t));
|
||||
*result = (char *)buffer;
|
||||
|
||||
/* we read our byte string at the tail end of the buffer
|
||||
|
||||
@@ -90,7 +90,7 @@ static int close_buffer(void *cookie)
|
||||
|
||||
FILE *open_memstream(char **bufptr, size_t *lenptr)
|
||||
{
|
||||
struct Buffer *b = (struct Buffer *)malloc(sizeof(struct Buffer));
|
||||
struct Buffer *b = (struct Buffer *)calloc(sizeof(struct Buffer), sizeof(uint8_t));
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
b->alloc = 0;
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ void SetFlushAfterWrite(bool value) {
|
||||
|
||||
int i,j;
|
||||
|
||||
int * output = (int* ) malloc(sizeof(int) * len);
|
||||
int * output = (int* ) calloc(sizeof(int) * len, sizeof(uint8_t));
|
||||
if ( !output ) return;
|
||||
|
||||
// clear mem
|
||||
|
||||
+3
-3
@@ -280,7 +280,7 @@ void sprint_bin_break_ex(uint8_t *src, size_t srclen, char *dest , uint8_t break
|
||||
printf("(sprint_bin_break) rowlen %d\n", rowlen);
|
||||
|
||||
// 3072 + end of line characters if broken at 8 bits
|
||||
dest = (char *)malloc(MAX_BIN_BREAK_LENGTH);
|
||||
dest = (char *)calloc(MAX_BIN_BREAK_LENGTH, sizeof(uint8_t));
|
||||
if (dest == NULL) return;
|
||||
|
||||
//clear memory
|
||||
@@ -884,8 +884,8 @@ extern void strcreplace(char *buf, size_t len, char from, char to) {
|
||||
}
|
||||
|
||||
extern char *strmcopy(char *buf) {
|
||||
char* str = NULL;
|
||||
if ((str = (char*) malloc(strlen(buf) + 1)) != NULL) {
|
||||
char* str = (char*) calloc(strlen(buf) + 1, sizeof(uint8_t));
|
||||
if (str != NULL) {
|
||||
memset(str, 0, strlen(buf) + 1);
|
||||
strcpy(str, buf);
|
||||
}
|
||||
|
||||
@@ -178,6 +178,14 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DropFieldEx
|
||||
#define DropFieldEx(x) { \
|
||||
if ( (x) == ECC_CONTACTLESS) { \
|
||||
DropField(); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
extern uint8_t g_debugMode;
|
||||
|
||||
extern int ukbhit(void);
|
||||
|
||||
Reference in new issue
Block a user