Merge branch 'RfidResearchGroup:master' into fix-flash-suggest
This commit is contained in:
24 files changed
+313
-949
No files matched your search
@@ -1247,6 +1247,14 @@
|
||||
"Description": "PIV End Point Applet. Last 2 bytes designate version",
|
||||
"Type": ""
|
||||
},
|
||||
{
|
||||
"AID": "A000000308000010000100",
|
||||
"Vendor": "National Institute of Standards and Technology",
|
||||
"Country": "United States",
|
||||
"Name": "Personal Identity Verification (PIV) / ID-ONE PIV BIO",
|
||||
"Description": "PIV End Point Applet. Last 2 bytes designate version",
|
||||
"Type": ""
|
||||
},
|
||||
{
|
||||
"AID": "A00000031510100528",
|
||||
"Vendor": "Currence Holding/PIN BV",
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for iCLASS / PicoPass tag...");
|
||||
if (IfPm3Iclass()) {
|
||||
if (read_iclass_csn(false, false) == PM3_SUCCESS) {
|
||||
if (read_iclass_csn(false, false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("iCLASS tag / PicoPass tag") " found\n");
|
||||
res = PM3_SUCCESS;
|
||||
}
|
||||
|
||||
+17
-8
@@ -67,7 +67,7 @@ typedef struct {
|
||||
// structure and database for uid -> tagtype lookups
|
||||
typedef struct {
|
||||
uint64_t uid;
|
||||
int mask; // how many MSB bits used
|
||||
uint64_t mask; // how many MSB bits used, or mask itself if larger than 64
|
||||
const char *desc;
|
||||
} productName_t;
|
||||
|
||||
@@ -90,17 +90,22 @@ static const productName_t uidmapping[] = {
|
||||
// E0 04 xx
|
||||
// 04 = Manufacturer code (Philips/NXP)
|
||||
// XX = IC id (Chip ID Family)
|
||||
//I-Code SLI SL2 ICS20 [IC id = 01]
|
||||
//I-Code SLI-S [IC id = 02]
|
||||
//I-Code SLI-L [IC id = 03]
|
||||
//I-Code SLIX [IC id = 01 + bit36 set to 1 (starting from bit0 - different from normal SLI)]
|
||||
//I-Code SLI SL2 ICS20 [IC id = 01 + bit35 set to 0 + bit36 set to 0]
|
||||
//I-Code SLIX [IC id = 01 + bit35 set to 0 + bit36 set to 1]
|
||||
//I-Code SLIX2 [IC id = 01 + bit35 set to 1 + bit36 set to 0]
|
||||
//I-Code SLI-S [IC id = 02 + bit36 set to 0]
|
||||
//I-Code SLIX-S [IC id = 02 + bit36 set to 1]
|
||||
//I-Code SLI-L [IC id = 03 + bit36 set to 0]
|
||||
//I-Code SLIX-L [IC id = 03 + bit36 set to 1]
|
||||
{ 0xE004000000000000LL, 16, "NXP Semiconductors Germany (Philips)" },
|
||||
{ 0xE004010000000000LL, 24, "NXP(Philips); IC SL2 ICS20/ICS21(SLI) ICS2002/ICS2102(SLIX) ICS2602(SLIX2)" },
|
||||
{ 0xE004020000000000LL, 24, "NXP(Philips); IC SL2 ICS53/ICS54(SLI-S) ICS5302/ICS5402(SLIX-S)" },
|
||||
{ 0xE004030000000000LL, 24, "NXP(Philips); IC SL2 ICS50/ICS51(SLI-L) ICS5002/ICS5102(SLIX-L)" },
|
||||
{ 0xE004010000000000LL, 0xFFFFFF1800000000LL, "NXP(Philips); IC SL2 ICS20/ICS21(SLI)" },
|
||||
{ 0xE004011000000000LL, 0xFFFFFF1800000000LL, "NXP(Philips); IC SL2 ICS2002/ICS2102(SLIX)" },
|
||||
{ 0xE004010800000000LL, 0xFFFFFF1800000000LL, "NXP(Philips); IC SL2 ICS2602(SLIX2)" },
|
||||
{ 0xE004020000000000LL, 0xFFFFFF1000000000LL, "NXP(Philips); IC SL2 ICS53/ICS54(SLI-S)" },
|
||||
{ 0xE004021000000000LL, 0xFFFFFF1000000000LL, "NXP(Philips); ICS5302/ICS5402(SLIX-S)" },
|
||||
{ 0xE004030000000000LL, 0xFFFFFF1000000000LL, "NXP(Philips); IC SL2 ICS50/ICS51(SLI-L)" },
|
||||
{ 0xE004031000000000LL, 0xFFFFFF1000000000LL, "NXP(Philips); ICS5002/ICS5102(SLIX-L)" },
|
||||
|
||||
// E0 05 XX .. .. ..
|
||||
// 05 = Manufacturer code (Infineon)
|
||||
@@ -364,7 +369,11 @@ static const char *getTagInfo_15(uint8_t *uid) {
|
||||
int i = 0, best = -1;
|
||||
memcpy(&myuid, uid, sizeof(uint64_t));
|
||||
while (uidmapping[i].mask > 0) {
|
||||
mask = (~0ULL) << (64 - uidmapping[i].mask);
|
||||
if (uidmapping[i].mask > 64) {
|
||||
mask = uidmapping[i].mask;
|
||||
} else {
|
||||
mask = (~0ULL) << (64 - uidmapping[i].mask);
|
||||
}
|
||||
if ((myuid & mask) == uidmapping[i].uid) {
|
||||
if (best == -1) {
|
||||
best = i;
|
||||
|
||||
+53
-13
@@ -285,7 +285,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
|
||||
|
||||
// get header from card
|
||||
PrintAndLogEx(INFO, "trying to read a card..");
|
||||
int res = read_iclass_csn(false, false);
|
||||
int res = read_iclass_csn(false, false, false);
|
||||
if (res == PM3_SUCCESS) {
|
||||
cc = &iclass_last_known_card;
|
||||
// calc diversified key for selected card
|
||||
@@ -905,19 +905,25 @@ static int CmdHFiClassInfo(const char *Cmd) {
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool shallow_mod = arg_get_lit(ctx, 1);
|
||||
CLIParserFree(ctx);
|
||||
return info_iclass();
|
||||
return info_iclass(shallow_mod);
|
||||
}
|
||||
|
||||
int read_iclass_csn(bool loop, bool verbose) {
|
||||
int read_iclass_csn(bool loop, bool verbose, bool shallow_mod) {
|
||||
|
||||
iclass_card_select_t payload = {
|
||||
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
|
||||
};
|
||||
|
||||
if (shallow_mod) {
|
||||
payload.flags |= FLAG_ICLASS_READER_SHALLOW_MOD;
|
||||
}
|
||||
|
||||
int res = PM3_SUCCESS;
|
||||
|
||||
do {
|
||||
@@ -973,17 +979,19 @@ static int CmdHFiClassReader(const char *Cmd) {
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("@", NULL, "optional - continuous reader mode"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool cm = arg_get_lit(ctx, 1);
|
||||
bool shallow_mod = arg_get_lit(ctx, 2);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (cm) {
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
||||
}
|
||||
|
||||
return read_iclass_csn(cm, true);
|
||||
return read_iclass_csn(cm, true, shallow_mod);
|
||||
}
|
||||
|
||||
static int CmdHFiClassELoad(const char *Cmd) {
|
||||
@@ -1547,12 +1555,16 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool verbose) {
|
||||
static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool verbose, bool shallow_mod) {
|
||||
|
||||
iclass_card_select_t payload = {
|
||||
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
|
||||
};
|
||||
|
||||
if (shallow_mod) {
|
||||
payload.flags |= FLAG_ICLASS_READER_SHALLOW_MOD;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
|
||||
@@ -1608,6 +1620,7 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
arg_lit0(NULL, "nr", "replay of NR/MAC"),
|
||||
arg_lit0("z", "dense", "dense dump output style"),
|
||||
arg_lit0(NULL, "force", "force unsecure card read"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
@@ -1693,6 +1706,7 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
bool use_replay = arg_get_lit(ctx, 8);
|
||||
bool dense_output = g_session.dense_output || arg_get_lit(ctx, 9);
|
||||
bool force = arg_get_lit(ctx, 10);
|
||||
bool shallow_mod = arg_get_lit(ctx, 11);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -1711,6 +1725,11 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
iclass_card_select_t payload_rdr = {
|
||||
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
|
||||
};
|
||||
|
||||
if (shallow_mod) {
|
||||
payload_rdr.flags |= FLAG_ICLASS_READER_SHALLOW_MOD;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload_rdr, sizeof(iclass_card_select_t));
|
||||
@@ -1790,6 +1809,7 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
.req.use_replay = use_replay,
|
||||
.req.send_reply = true,
|
||||
.req.do_auth = auth,
|
||||
.req.shallow_mod = shallow_mod,
|
||||
.end_block = app_limit1,
|
||||
};
|
||||
memcpy(payload.req.key, key, 8);
|
||||
@@ -1950,7 +1970,7 @@ write_dump:
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int iclass_write_block(uint8_t blockno, uint8_t *bldata, uint8_t *macdata, uint8_t *KEY, bool use_credit_key, bool elite, bool rawkey, bool replay, bool verbose, bool use_secure_pagemode) {
|
||||
static int iclass_write_block(uint8_t blockno, uint8_t *bldata, uint8_t *macdata, uint8_t *KEY, bool use_credit_key, bool elite, bool rawkey, bool replay, bool verbose, bool use_secure_pagemode, bool shallow_mod) {
|
||||
|
||||
iclass_writeblock_req_t payload = {
|
||||
.req.use_raw = rawkey,
|
||||
@@ -1960,6 +1980,7 @@ static int iclass_write_block(uint8_t blockno, uint8_t *bldata, uint8_t *macdata
|
||||
.req.blockno = blockno,
|
||||
.req.send_reply = true,
|
||||
.req.do_auth = use_secure_pagemode,
|
||||
.req.shallow_mod = shallow_mod,
|
||||
};
|
||||
memcpy(payload.req.key, KEY, 8);
|
||||
memcpy(payload.data, bldata, sizeof(payload.data));
|
||||
@@ -2004,6 +2025,7 @@ static int CmdHFiClass_WriteBlock(const char *Cmd) {
|
||||
arg_lit0(NULL, "raw", "no computations applied to key"),
|
||||
arg_lit0(NULL, "nr", "replay of NR/MAC"),
|
||||
arg_lit0("v", "verbose", "verbose output"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -2072,6 +2094,7 @@ static int CmdHFiClass_WriteBlock(const char *Cmd) {
|
||||
bool rawkey = arg_get_lit(ctx, 8);
|
||||
bool use_replay = arg_get_lit(ctx, 9);
|
||||
bool verbose = arg_get_lit(ctx, 10);
|
||||
bool shallow_mod = arg_get_lit(ctx, 11);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -2080,7 +2103,7 @@ static int CmdHFiClass_WriteBlock(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
int isok = iclass_write_block(blockno, data, mac, key, use_credit_key, elite, rawkey, use_replay, verbose, auth);
|
||||
int isok = iclass_write_block(blockno, data, mac, key, use_credit_key, elite, rawkey, use_replay, verbose, auth, shallow_mod);
|
||||
switch (isok) {
|
||||
case PM3_SUCCESS:
|
||||
PrintAndLogEx(SUCCESS, "Wrote block %3d/0x%02X successful", blockno, blockno);
|
||||
@@ -2116,6 +2139,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||
arg_lit0(NULL, "elite", "elite computations applied to key"),
|
||||
arg_lit0(NULL, "raw", "no computations applied to key"),
|
||||
arg_lit0("v", "verbose", "verbose output"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -2165,6 +2189,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||
bool elite = arg_get_lit(ctx, 7);
|
||||
bool rawkey = arg_get_lit(ctx, 8);
|
||||
bool verbose = arg_get_lit(ctx, 9);
|
||||
bool shallow_mod = arg_get_lit(ctx, 10);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -2215,6 +2240,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||
payload->req.blockno = startblock;
|
||||
payload->req.send_reply = true;
|
||||
payload->req.do_auth = true;
|
||||
payload->req.shallow_mod = shallow_mod;
|
||||
memcpy(payload->req.key, key, 8);
|
||||
|
||||
payload->item_cnt = (endblock - startblock + 1);
|
||||
@@ -2268,7 +2294,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||
return resp.status;
|
||||
}
|
||||
|
||||
static int iclass_read_block(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool replay, bool verbose, bool auth, uint8_t *out) {
|
||||
static int iclass_read_block(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool replay, bool verbose, bool auth, bool shallow_mod, uint8_t *out) {
|
||||
|
||||
iclass_auth_req_t payload = {
|
||||
.use_raw = rawkey,
|
||||
@@ -2278,6 +2304,7 @@ static int iclass_read_block(uint8_t *KEY, uint8_t blockno, uint8_t keyType, boo
|
||||
.blockno = blockno,
|
||||
.send_reply = true,
|
||||
.do_auth = auth,
|
||||
.shallow_mod = shallow_mod,
|
||||
};
|
||||
memcpy(payload.key, KEY, 8);
|
||||
|
||||
@@ -2331,6 +2358,7 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
arg_lit0(NULL, "raw", "no computations applied to key"),
|
||||
arg_lit0(NULL, "nr", "replay of NR/MAC"),
|
||||
arg_lit0("v", "verbose", "verbose output"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -2381,6 +2409,7 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
bool rawkey = arg_get_lit(ctx, 6);
|
||||
bool use_replay = arg_get_lit(ctx, 7);
|
||||
bool verbose = arg_get_lit(ctx, 8);
|
||||
bool shallow_mod = arg_get_lit(ctx, 9);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -2400,7 +2429,7 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint8_t data[8] = {0};
|
||||
int res = iclass_read_block(key, blockno, keyType, elite, rawkey, use_replay, verbose, auth, data);
|
||||
int res = iclass_read_block(key, blockno, keyType, elite, rawkey, use_replay, verbose, auth, shallow_mod, data);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
|
||||
@@ -2975,7 +3004,7 @@ static int CmdHFiClassCalcNewKey(const char *Cmd) {
|
||||
|
||||
if (givenCSN == false) {
|
||||
uint8_t CCNR[12] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
if (select_only(csn, CCNR, true) == false) {
|
||||
if (select_only(csn, CCNR, true, false) == false) {
|
||||
DropField();
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
@@ -3173,6 +3202,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
arg_lit0(NULL, "credit", "key is assumed to be the credit key"),
|
||||
arg_lit0(NULL, "elite", "elite computations applied to key"),
|
||||
arg_lit0(NULL, "raw", "no computations applied to key (raw)"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -3184,6 +3214,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
bool use_credit_key = arg_get_lit(ctx, 2);
|
||||
bool use_elite = arg_get_lit(ctx, 3);
|
||||
bool use_raw = arg_get_lit(ctx, 4);
|
||||
bool shallow_mod = arg_get_lit(ctx, 5);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -3213,7 +3244,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
|
||||
bool got_csn = false;
|
||||
for (uint8_t i = 0; i < ICLASS_AUTH_RETRY; i++) {
|
||||
got_csn = select_only(CSN, CCNR, false);
|
||||
got_csn = select_only(CSN, CCNR, false, shallow_mod);
|
||||
if (got_csn == false)
|
||||
PrintAndLogEx(WARNING, "one more try");
|
||||
else
|
||||
@@ -3295,6 +3326,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
}
|
||||
packet->use_credit_key = use_credit_key;
|
||||
packet->count = curr_chunk_cnt;
|
||||
packet->shallow_mod = shallow_mod;
|
||||
// copy chunk of pre calculated macs to packet
|
||||
memcpy(packet->items, (pre + chunk_offset), (4 * curr_chunk_cnt));
|
||||
|
||||
@@ -3799,6 +3831,7 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
||||
arg_u64_0(NULL, "fc", "<dec>", "facility code"),
|
||||
arg_u64_0(NULL, "cn", "<dec>", "card number"),
|
||||
arg_str0("w", "wiegand", "<format>", "see " _YELLOW_("`wiegand list`") " for available formats"),
|
||||
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -3843,6 +3876,8 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
||||
int format_len = 0;
|
||||
CLIParamStrToBuf(arg_get_str(ctx, 9), (uint8_t *)format, sizeof(format), &format_len);
|
||||
|
||||
bool shallow_mod = arg_get_lit(ctx, 10);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ((rawkey + elite) > 1) {
|
||||
@@ -3964,7 +3999,7 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
||||
int isok = PM3_SUCCESS;
|
||||
// write
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
isok = iclass_write_block(6 + i, credential + (i * 8), NULL, key, use_credit_key, elite, rawkey, false, false, auth);
|
||||
isok = iclass_write_block(6 + i, credential + (i * 8), NULL, key, use_credit_key, elite, rawkey, false, false, auth, shallow_mod);
|
||||
switch (isok) {
|
||||
case PM3_SUCCESS:
|
||||
PrintAndLogEx(SUCCESS, "Write block %d/0x0%x ( " _GREEN_("ok") " ) --> " _YELLOW_("%s"), 6 + i, 6 + i, sprint_hex_inrow(credential + (i * 8), 8));
|
||||
@@ -4135,11 +4170,16 @@ int CmdHFiClass(const char *Cmd) {
|
||||
// DESFIRE| | |
|
||||
//}
|
||||
|
||||
int info_iclass(void) {
|
||||
int info_iclass(bool shallow_mod) {
|
||||
|
||||
iclass_card_select_t payload = {
|
||||
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
|
||||
};
|
||||
|
||||
if (shallow_mod) {
|
||||
payload.flags |= FLAG_ICLASS_READER_SHALLOW_MOD;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
int CmdHFiClass(const char *Cmd);
|
||||
|
||||
int info_iclass(void);
|
||||
int read_iclass_csn(bool loop, bool verbose);
|
||||
int info_iclass(bool shallow_mod);
|
||||
int read_iclass_csn(bool loop, bool verbose, bool shallow_mod);
|
||||
void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize, bool dense_output);
|
||||
void HFiClassCalcDivKey(uint8_t *CSN, uint8_t *KEY, uint8_t *div_key, bool elite);
|
||||
|
||||
|
||||
+35
-28
@@ -41,6 +41,7 @@
|
||||
#include "generator.h"
|
||||
#include "cliparser.h"
|
||||
#include "cmdhw.h"
|
||||
#include "util.h"
|
||||
|
||||
//////////////// 4205 / 4305 commands
|
||||
|
||||
@@ -1996,8 +1997,7 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||
const char *cmdText;
|
||||
char dataText[100];
|
||||
char blkAddr[4];
|
||||
char bits[80];
|
||||
int i, bitidx;
|
||||
int i;
|
||||
int ZeroWidth; // 32-42 "1" is 32
|
||||
int CycleWidth;
|
||||
size_t pulseSamples;
|
||||
@@ -2018,6 +2018,10 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||
PrintAndLogEx(SUCCESS, "offset | Command | Data | blk | raw");
|
||||
PrintAndLogEx(SUCCESS, "-------+-------------+----------+-----+------------------------------------------------------------");
|
||||
|
||||
smartbuf bits = { 0 };
|
||||
bits.ptr = malloc(EM4X05_BITS_BUFSIZE);
|
||||
bits.size = EM4X05_BITS_BUFSIZE;
|
||||
bits.idx = 0;
|
||||
size_t idx = 0;
|
||||
// loop though sample buffer
|
||||
while (idx < g_GraphTraceLen) {
|
||||
@@ -2037,8 +2041,8 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||
|
||||
if (ZeroWidth <= 50) {
|
||||
pktOffset -= ZeroWidth;
|
||||
memset(bits, 0x00, sizeof(bits));
|
||||
bitidx = 0;
|
||||
memset(bits.ptr, 0, bits.size);
|
||||
bits.idx = 0;
|
||||
|
||||
while ((idx < g_GraphTraceLen) && !eop) {
|
||||
CycleWidth = idx;
|
||||
@@ -2047,7 +2051,7 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||
CycleWidth = idx - CycleWidth;
|
||||
if ((CycleWidth > 300) || (CycleWidth < (ZeroWidth - 5))) { // to long or too short
|
||||
eop = true;
|
||||
bits[bitidx++] = '0'; // Append last zero from the last bit find
|
||||
sb_append_char(&bits, '0'); // Append last zero from the last bit find
|
||||
cmdText = "";
|
||||
|
||||
// EM4305 command lengths
|
||||
@@ -2059,76 +2063,77 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||
// -> disable 1010 11111111 0 11111111 0 11111111 0 11111111 0 00000000 0
|
||||
|
||||
// Check to see if we got the leading 0
|
||||
if (((strncmp(bits, "00011", 5) == 0) && (bitidx == 50)) ||
|
||||
((strncmp(bits, "00101", 5) == 0) && (bitidx == 57)) ||
|
||||
((strncmp(bits, "01001", 5) == 0) && (bitidx == 12)) ||
|
||||
((strncmp(bits, "01100", 5) == 0) && (bitidx == 50)) ||
|
||||
((strncmp(bits, "01010", 5) == 0) && (bitidx == 50))) {
|
||||
memmove(bits, &bits[1], bitidx - 1);
|
||||
bitidx--;
|
||||
if (((strncmp(bits.ptr, "00011", 5) == 0) && (bits.idx == 50)) ||
|
||||
((strncmp(bits.ptr, "00101", 5) == 0) && (bits.idx == 57)) ||
|
||||
((strncmp(bits.ptr, "01001", 5) == 0) && (bits.idx == 12)) ||
|
||||
((strncmp(bits.ptr, "01100", 5) == 0) && (bits.idx == 50)) ||
|
||||
((strncmp(bits.ptr, "01010", 5) == 0) && (bits.idx == 50))) {
|
||||
memmove(bits.ptr, &bits.ptr[1], bits.idx - 1);
|
||||
bits.idx--;
|
||||
PrintAndLogEx(INFO, "Trim leading 0");
|
||||
}
|
||||
bits[bitidx] = 0;
|
||||
sb_append_char(&bits, 0);
|
||||
bits.idx--;
|
||||
|
||||
// logon
|
||||
if ((strncmp(bits, "0011", 4) == 0) && (bitidx == 49)) {
|
||||
if ((strncmp(bits.ptr, "0011", 4) == 0) && (bits.idx == 49)) {
|
||||
haveData = true;
|
||||
pwd = true;
|
||||
cmdText = "Logon";
|
||||
strncpy(blkAddr, " ", sizeof(blkAddr));
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits[4], fwd);
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits.ptr[4], fwd);
|
||||
snprintf(dataText, sizeof(dataText), "%08X", tmpValue);
|
||||
}
|
||||
|
||||
// write
|
||||
if ((strncmp(bits, "0101", 4) == 0) && (bitidx == 56)) {
|
||||
if ((strncmp(bits.ptr, "0101", 4) == 0) && (bits.idx == 56)) {
|
||||
haveData = true;
|
||||
cmdText = "Write";
|
||||
tmpValue = (bits[4] - '0') + ((bits[5] - '0') << 1) + ((bits[6] - '0') << 2) + ((bits[7] - '0') << 3);
|
||||
tmpValue = (bits.ptr[4] - '0') + ((bits.ptr[5] - '0') << 1) + ((bits.ptr[6] - '0') << 2) + ((bits.ptr[7] - '0') << 3);
|
||||
snprintf(blkAddr, sizeof(blkAddr), "%u", tmpValue);
|
||||
if (tmpValue == 2) {
|
||||
pwd = true;
|
||||
}
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits[11], fwd);
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits.ptr[11], fwd);
|
||||
snprintf(dataText, sizeof(dataText), "%08X", tmpValue);
|
||||
}
|
||||
|
||||
// read
|
||||
if ((strncmp(bits, "1001", 4) == 0) && (bitidx == 11)) {
|
||||
if ((strncmp(bits.ptr, "1001", 4) == 0) && (bits.idx == 11)) {
|
||||
haveData = true;
|
||||
pwd = false;
|
||||
cmdText = "Read";
|
||||
tmpValue = (bits[4] - '0') + ((bits[5] - '0') << 1) + ((bits[6] - '0') << 2) + ((bits[7] - '0') << 3);
|
||||
tmpValue = (bits.ptr[4] - '0') + ((bits.ptr[5] - '0') << 1) + ((bits.ptr[6] - '0') << 2) + ((bits.ptr[7] - '0') << 3);
|
||||
snprintf(blkAddr, sizeof(blkAddr), "%u", tmpValue);
|
||||
strncpy(dataText, " ", sizeof(dataText));
|
||||
}
|
||||
|
||||
// protect
|
||||
if ((strncmp(bits, "1100", 4) == 0) && (bitidx == 49)) {
|
||||
if ((strncmp(bits.ptr, "1100", 4) == 0) && (bits.idx == 49)) {
|
||||
haveData = true;
|
||||
pwd = false;
|
||||
cmdText = "Protect";
|
||||
strncpy(blkAddr, " ", sizeof(blkAddr));
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits[11], fwd);
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits.ptr[11], fwd);
|
||||
snprintf(dataText, sizeof(dataText), "%08X", tmpValue);
|
||||
}
|
||||
|
||||
// disable
|
||||
if ((strncmp(bits, "1010", 4) == 0) && (bitidx == 49)) {
|
||||
if ((strncmp(bits.ptr, "1010", 4) == 0) && (bits.idx == 49)) {
|
||||
haveData = true;
|
||||
pwd = false;
|
||||
cmdText = "Disable";
|
||||
strncpy(blkAddr, " ", sizeof(blkAddr));
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits[11], fwd);
|
||||
tmpValue = em4x05_Sniff_GetBlock(&bits.ptr[11], fwd);
|
||||
snprintf(dataText, sizeof(dataText), "%08X", tmpValue);
|
||||
}
|
||||
|
||||
// bits[bitidx] = 0;
|
||||
} else {
|
||||
i = (CycleWidth - ZeroWidth) / 28;
|
||||
bits[bitidx++] = '0';
|
||||
sb_append_char(&bits, '0');
|
||||
for (int ii = 0; ii < i; ii++) {
|
||||
bits[bitidx++] = '1';
|
||||
sb_append_char(&bits, '1');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2139,11 +2144,13 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||
// Print results
|
||||
if (haveData) { //&& (minWidth > 1) && (maxWidth > minWidth)){
|
||||
if (pwd)
|
||||
PrintAndLogEx(SUCCESS, "%6zu | %-10s | " _YELLOW_("%8s")" | " _YELLOW_("%3s")" | %s", pktOffset, cmdText, dataText, blkAddr, bits);
|
||||
PrintAndLogEx(SUCCESS, "%6zu | %-10s | " _YELLOW_("%8s")" | " _YELLOW_("%3s")" | %s", pktOffset, cmdText, dataText, blkAddr, bits.ptr);
|
||||
else
|
||||
PrintAndLogEx(SUCCESS, "%6zu | %-10s | " _GREEN_("%8s")" | " _GREEN_("%3s")" | %s", pktOffset, cmdText, dataText, blkAddr, bits);
|
||||
PrintAndLogEx(SUCCESS, "%6zu | %-10s | " _GREEN_("%8s")" | " _GREEN_("%3s")" | %s", pktOffset, cmdText, dataText, blkAddr, bits.ptr);
|
||||
}
|
||||
}
|
||||
free(bits.ptr);
|
||||
bits.ptr = NULL;
|
||||
|
||||
// footer
|
||||
PrintAndLogEx(SUCCESS, "---------------------------------------------------------------------------------------------------");
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#define EM4305_PROT2_BLOCK 15
|
||||
#define EM4469_PROT_BLOCK 3
|
||||
|
||||
#define EM4X05_BITS_BUFSIZE 128
|
||||
|
||||
// config blocks
|
||||
#define EM4305_DEFAULT_CONFIG_BLOCK (EM4x05_SET_BITRATE(32) | EM4x05_MODULATION_MANCHESTER | EM4x05_SET_NUM_BLOCKS(4) ) // ASK/MAN , data rate 32, 4 data blocks
|
||||
//#define EM4305_DEFAULT_CONFIG_BLOCK (EM4x05_SET_BITRATE(32) | EM4x05_MODULATION_BIPHASE | EM4x05_SET_NUM_BLOCKS(4) ) // ASK/BIPHASE , data rate 32, 4 data blocks
|
||||
|
||||
@@ -573,7 +573,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
//2 Not crc-command
|
||||
|
||||
//--- Draw the data column
|
||||
char line[18][140] = {{0}};
|
||||
char line[18][160] = {{0}};
|
||||
|
||||
if (data_len == 0) {
|
||||
if (protocol == ICLASS && duration == 2048) {
|
||||
@@ -633,8 +633,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint8_t crc_format_string_offset = 0;
|
||||
if (markCRCBytes) {
|
||||
if (markCRCBytes && data_len > 2) {
|
||||
//CRC-command
|
||||
if (((protocol == PROTO_HITAG1) || (protocol == PROTO_HITAGS)) && (data_len > 1)) {
|
||||
// Note that UID REQUEST response has no CRC, but we don't know
|
||||
@@ -647,6 +648,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
} else {
|
||||
|
||||
if (crcStatus == 0 || crcStatus == 1) {
|
||||
|
||||
char *pos1 = line[(data_len - 2) / 18];
|
||||
pos1 += (((data_len - 2) % 18) * 4) - 1;
|
||||
|
||||
|
||||
+85
-28
@@ -214,18 +214,23 @@ bool create_path(const char *dirname) {
|
||||
}
|
||||
*/
|
||||
|
||||
bool setDefaultPath(savePaths_t pathIndex, const char *Path) {
|
||||
bool setDefaultPath(savePaths_t pathIndex, const char *path) {
|
||||
|
||||
if (pathIndex < spItemCount) {
|
||||
if ((Path == NULL) && (g_session.defaultPaths[pathIndex] != NULL)) {
|
||||
|
||||
if ((path == NULL) && (g_session.defaultPaths[pathIndex] != NULL)) {
|
||||
free(g_session.defaultPaths[pathIndex]);
|
||||
g_session.defaultPaths[pathIndex] = NULL;
|
||||
}
|
||||
|
||||
if (Path != NULL) {
|
||||
g_session.defaultPaths[pathIndex] = (char *)realloc(g_session.defaultPaths[pathIndex], strlen(Path) + 1);
|
||||
strcpy(g_session.defaultPaths[pathIndex], Path);
|
||||
if (path == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = strlen(path);
|
||||
|
||||
g_session.defaultPaths[pathIndex] = (char *)realloc(g_session.defaultPaths[pathIndex], len + 1);
|
||||
strcpy(g_session.defaultPaths[pathIndex], path);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -234,47 +239,70 @@ bool setDefaultPath(savePaths_t pathIndex, const char *Path) {
|
||||
static char *filenamemcopy(const char *preferredName, const char *suffix) {
|
||||
if (preferredName == NULL) return NULL;
|
||||
if (suffix == NULL) return NULL;
|
||||
|
||||
char *fileName = (char *) calloc(strlen(preferredName) + strlen(suffix) + 1, sizeof(uint8_t));
|
||||
if (fileName == NULL)
|
||||
if (fileName == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(fileName, preferredName);
|
||||
if (str_endswith(fileName, suffix))
|
||||
if (str_endswith(fileName, suffix)) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
strcat(fileName, suffix);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
static size_t path_size(savePaths_t a) {
|
||||
if (a == spItemCount) {
|
||||
return 0;
|
||||
}
|
||||
return strlen( g_session.defaultPaths[a] );
|
||||
}
|
||||
|
||||
char *newfilenamemcopy(const char *preferredName, const char *suffix) {
|
||||
if (preferredName == NULL) return NULL;
|
||||
if (suffix == NULL) return NULL;
|
||||
if (preferredName == NULL || suffix == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t p_namelen = strlen(preferredName);
|
||||
if (str_endswith(preferredName, suffix))
|
||||
p_namelen -= strlen(suffix);
|
||||
|
||||
const size_t fileNameLen = p_namelen + strlen(suffix) + 1 + 10;
|
||||
const size_t fileNameSize = fileNameLen * sizeof(uint8_t);
|
||||
// 10: room for filenum to ensure new filename
|
||||
const size_t len = p_namelen + strlen(suffix) + 1 + 10;
|
||||
|
||||
char *fileName = (char *) calloc(fileNameLen, sizeof(uint8_t)); // 10: room for filenum to ensure new filename
|
||||
int foobar = path_size(spDefault);
|
||||
(void) foobar;
|
||||
|
||||
char *fileName = (char *) calloc(len, sizeof(uint8_t));
|
||||
if (fileName == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int num = 1;
|
||||
snprintf(fileName, fileNameSize, "%.*s%s", p_namelen, preferredName, suffix);
|
||||
|
||||
snprintf(fileName, len, "%.*s%s", p_namelen, preferredName, suffix);
|
||||
while (fileExists(fileName)) {
|
||||
snprintf(fileName, fileNameSize, "%.*s-%d%s", p_namelen, preferredName, num, suffix);
|
||||
snprintf(fileName, len, "%.*s-%d%s", p_namelen, preferredName, num, suffix);
|
||||
num++;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "FILE PATH: %s", fileName);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
int saveFile(const char *preferredName, const char *suffix, const void *data, size_t datalen) {
|
||||
|
||||
if (data == NULL) return PM3_EINVARG;
|
||||
if (data == NULL || datalen == 0) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
char *fileName = newfilenamemcopy(preferredName, suffix);
|
||||
if (fileName == NULL) return PM3_EMALLOC;
|
||||
if (fileName == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
/* We should have a valid filename now, e.g. dumpdata-3.bin */
|
||||
|
||||
@@ -295,9 +323,14 @@ int saveFile(const char *preferredName, const char *suffix, const void *data, si
|
||||
|
||||
int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t blocksize) {
|
||||
|
||||
if (data == NULL) return PM3_EINVARG;
|
||||
if (data == NULL || datalen == 0) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
char *fileName = newfilenamemcopy(preferredName, ".eml");
|
||||
if (fileName == NULL) return PM3_EMALLOC;
|
||||
if (fileName == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
int retval = PM3_SUCCESS;
|
||||
int blocks = datalen / blocksize;
|
||||
@@ -343,10 +376,14 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
|
||||
}
|
||||
int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data, size_t datalen, bool verbose, void (*callback)(json_t *)) {
|
||||
|
||||
if (data == NULL) return PM3_EINVARG;
|
||||
if (data == NULL || datalen == 0) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
char *fileName = newfilenamemcopy(preferredName, ".json");
|
||||
if (fileName == NULL) return PM3_EMALLOC;
|
||||
if (fileName == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
int retval = PM3_SUCCESS;
|
||||
|
||||
@@ -704,9 +741,15 @@ int saveFileJSONrootEx(const char *preferredName, void *root, size_t flags, bool
|
||||
|
||||
int saveFileWAVE(const char *preferredName, const int *data, size_t datalen) {
|
||||
|
||||
if (data == NULL) return PM3_EINVARG;
|
||||
if (data == NULL || datalen == 0) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
char *fileName = newfilenamemcopy(preferredName, ".wav");
|
||||
if (fileName == NULL) return PM3_EMALLOC;
|
||||
if (fileName == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
int retval = PM3_SUCCESS;
|
||||
|
||||
struct wave_info_t wave_info = {
|
||||
@@ -731,11 +774,14 @@ int saveFileWAVE(const char *preferredName, const int *data, size_t datalen) {
|
||||
retval = PM3_EFILE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
fwrite(&wave_info, sizeof(wave_info), 1, wave_file);
|
||||
|
||||
for (int i = 0; i < datalen; i++) {
|
||||
uint8_t sample = data[i] + 128;
|
||||
fwrite(&sample, 1, 1, wave_file);
|
||||
}
|
||||
|
||||
fclose(wave_file);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "saved " _YELLOW_("%zu") " bytes to wave file " _YELLOW_("'%s'"), 2 * datalen, fileName);
|
||||
@@ -747,9 +793,14 @@ out:
|
||||
|
||||
int saveFilePM3(const char *preferredName, int *data, size_t datalen) {
|
||||
|
||||
if (data == NULL) return PM3_EINVARG;
|
||||
if (data == NULL || datalen == 0) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
char *fileName = newfilenamemcopy(preferredName, ".pm3");
|
||||
if (fileName == NULL) return PM3_EMALLOC;
|
||||
if (fileName == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
int retval = PM3_SUCCESS;
|
||||
|
||||
@@ -760,8 +811,9 @@ int saveFilePM3(const char *preferredName, int *data, size_t datalen) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < datalen; i++)
|
||||
for (uint32_t i = 0; i < datalen; i++) {
|
||||
fprintf(f, "%d\n", data[i]);
|
||||
}
|
||||
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
@@ -1862,14 +1914,18 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
||||
(strcmp(PYTHON_SCRIPTS_SUBDIR, pm3dir) == 0) ||
|
||||
(strcmp(RESOURCES_SUBDIR, pm3dir) == 0))) {
|
||||
char *path = calloc(strlen(exec_path) + strlen(pm3dir) + strlen(filename) + 1, sizeof(char));
|
||||
if (path == NULL)
|
||||
if (path == NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
strcpy(path, exec_path);
|
||||
strcat(path, pm3dir);
|
||||
strcat(path, filename);
|
||||
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Searching %s", path);
|
||||
}
|
||||
|
||||
if (fileExists(path)) {
|
||||
free(filename);
|
||||
*foundpath = path;
|
||||
@@ -2007,7 +2063,8 @@ int pm3_load_dump(const char *fn, void **pdump, size_t *dumplen, size_t maxdumpl
|
||||
}
|
||||
|
||||
int pm3_save_dump(const char *fn, uint8_t *d, size_t n, JSONFileType jsft, size_t blocksize) {
|
||||
if (n == 0) {
|
||||
|
||||
if (d == NULL || n == 0) {
|
||||
PrintAndLogEx(INFO, "No data to save. Skipping...");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,9 @@ typedef enum {
|
||||
|
||||
int fileExists(const char *filename);
|
||||
//bool create_path(const char *dirname);
|
||||
bool setDefaultPath(savePaths_t pathIndex, const char *Path); // set a path in the path list g_session.defaultPaths
|
||||
|
||||
// set a path in the path list g_session.defaultPaths
|
||||
bool setDefaultPath(savePaths_t pathIndex, const char *path);
|
||||
|
||||
char *newfilenamemcopy(const char *preferredName, const char *suffix);
|
||||
|
||||
|
||||
+3
-1
@@ -35,7 +35,9 @@ typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLA
|
||||
typedef enum emojiMode {EMO_ALIAS, EMO_EMOJI, EMO_ALTTEXT, EMO_NONE} emojiMode_t;
|
||||
typedef enum clientdebugLevel {cdbOFF, cdbSIMPLE, cdbFULL} clientdebugLevel_t;
|
||||
// typedef enum devicedebugLevel {ddbOFF, ddbERROR, ddbINFO, ddbDEBUG, ddbEXTENDED} devicedebugLevel_t;
|
||||
typedef enum savePaths {spDefault, spDump, spTrace, spItemCount} savePaths_t; // last item spItemCount used to auto map to number of files
|
||||
|
||||
// last item spItemCount used to auto map to number of files
|
||||
typedef enum savePaths {spDefault, spDump, spTrace, spItemCount} savePaths_t;
|
||||
typedef struct {int x; int y; int h; int w;} qtWindow_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
+11
-1
@@ -303,7 +303,8 @@ void print_hex_noascii_break(const uint8_t *data, const size_t len, uint8_t brea
|
||||
|
||||
static void print_buffer_ex(const uint8_t *data, const size_t len, int level, uint8_t breaks) {
|
||||
|
||||
if (len < 1)
|
||||
// sanity checks
|
||||
if ((data == NULL) || (len < 1))
|
||||
return;
|
||||
|
||||
char buf[UTIL_BUFFER_SIZE_SPRINT + 3];
|
||||
@@ -1260,3 +1261,12 @@ int byte_strstr(uint8_t *src, size_t srclen, uint8_t *pattern, size_t plen) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void sb_append_char(smartbuf *sb, unsigned char c) {
|
||||
if (sb->idx >= sb->size) {
|
||||
sb->size *= 2;
|
||||
sb->ptr = realloc(sb->ptr, sb->size);
|
||||
}
|
||||
sb->ptr[sb->idx] = c;
|
||||
sb->idx++;
|
||||
}
|
||||
@@ -146,4 +146,11 @@ uint32_t leadingzeros32(uint32_t a);
|
||||
uint64_t leadingzeros64(uint64_t a);
|
||||
|
||||
int byte_strstr(uint8_t *src, size_t srclen, uint8_t *pattern, size_t plen);
|
||||
|
||||
struct smartbuf {
|
||||
char *ptr;
|
||||
size_t size;
|
||||
size_t idx;
|
||||
} typedef smartbuf;
|
||||
void sb_append_char(smartbuf *sb, unsigned char c);
|
||||
#endif
|
||||
Reference in new issue
Block a user