case CMD_EMV_DUMP_CARD:
EMVdumpcard();
break;
+/*
+ case CMD_EMV_READ_RECORD:
+ EMVReadRecord(c->arg[0], c->arg[1], NULL);
+ break;
+ case CMD_EMV_TRANSACTION:
+ EMVTransaction();
+ break;
+ case CMD_EMV_CLONE:
+ EMVClone(c->arg[0], c->arg[1]);
+ break;
+ case CMD_EMV_SIM:
+ EMVSim();
+ break;
+ case CMD_EMV_TEST:
+ EMVTest();
+ break;
+ case CMD_EMV_FUZZ_RATS:
+ EMVFuzz_RATS(c->arg[0],c->d.asBytes);
+ break;
+ */
#endif
#ifdef WITH_ICLASS
// Makes use of ISO14443a FPGA Firmware
// arg0 = startindex
// arg1 = length bytes to transfer
// arg2 = RFU
- //Dbprintf("transfer to client parameters: %llu | %llu | %llu", c->arg[0], c->arg[1], c->arg[2]);
+ //Dbprintf("transfer to client parameters: %" PRIu64 " | %" PRIu64 " | %" PRIu64, c->arg[0], c->arg[1], c->arg[2]);
for(size_t i = 0; i < c->arg[1]; i += USB_CMD_DATA_SIZE) {
len = MIN( (c->arg[1] - i), USB_CMD_DATA_SIZE);
void cmac_generate_subkeys (desfirekey_t key);
void cmac (const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t len, uint8_t *cmac);
-/// iso15693.h
+// iso15693.h
void RecordRawAdcSamplesIso15693(void);
void AcquireRawAdcSamplesIso15693(void);
void ReaderIso15693(uint32_t parameter); // Simulate an ISO15693 reader - greg
void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]); // send arbitrary commands from CLI - atrox
void SetDebugIso15693(uint32_t flag);
-/// iclass.h
+// iclass.h
void RAMFUNC SnoopIClass(void);
void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
void ReaderIClass(uint8_t arg0);
void EMVloadvalue(uint32_t tag, uint8_t* datain);
void EMVdumpcard(void);
+/*
+//void EMVSelect(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
+void EMVFuzz_RATS(uint8_t len, uint8_t* RATS);
+void EMVReadRecord(uint8_t arg0, uint8_t arg1,emvcard* inputcard);
+void EMVSelectPPSE();
+void EMVSelectAID(uint8_t *AID, uint8_t AIDlen, emvcard* inputcard);
+void EMVTransaction(); //perform an EMV transaction
+void EMVClone(uint8_t maxsfi, uint8_t maxrecord); //clone an EMV card.
+void EMVSim();
+void EMVTest(); //test function for emv stuff.
+*/
+
#ifdef __cplusplus
}
#endif
int wordCnt = 0;
while(1){
- while(isspace(str[beginIndex])){
+ while(isspace(str[beginIndex])) {
++beginIndex;
}
- if(str[beginIndex] == '\0')
+ if(str[beginIndex] == '\0') {
break;
+ }
endIndex = beginIndex;
- while (str[endIndex] && !isspace(str[endIndex])){
+ while (str[endIndex] && !isspace(str[endIndex])) {
++endIndex;
}
int len = endIndex - beginIndex;
* searched.
*/
/* scan against preset models */
- if(~uflags & C_FORCE) {
+ if (~uflags & C_FORCE) {
pass = 0;
Cnt = 0;
do {
mbynum(&pset, --psets);
/* skip if different width, or refin or refout don't match */
- if(plen(pset.spoly) != width[0] || (model.flags ^ pset.flags) & (P_REFIN | P_REFOUT))
+ if( plen(pset.spoly) != width[0] || (model.flags ^ pset.flags) & (P_REFIN | P_REFOUT))
continue;
/* skip if the preset doesn't match specified parameters */
- if(rflags & R_HAVEP && pcmp(&model.spoly, &pset.spoly))
+ if (rflags & R_HAVEP && pcmp(&model.spoly, &pset.spoly))
continue;
- if(rflags & R_HAVEI && psncmp(&model.init, &pset.init))
+ if (rflags & R_HAVEI && psncmp(&model.init, &pset.init))
continue;
- if(rflags & R_HAVEX && psncmp(&model.xorout, &pset.xorout))
+ if (rflags & R_HAVEX && psncmp(&model.xorout, &pset.xorout))
continue;
- //for additional args (not used yet, maybe future?)
+ //for additional args (not used yet, maybe future?)
apoly = pclone(pset.xorout);
- if(pset.flags & P_REFOUT)
+
+ if (pset.flags & P_REFOUT)
prev(&apoly);
-
- for(qptr = apolys; qptr < pptr; ++qptr) {
+
+
+ for (qptr = apolys; qptr < pptr; ++qptr) {
crc = pcrc(*qptr, pset.spoly, pset.init, apoly, 0);
- if(ptst(crc)) {
+ if (ptst(crc)) {
pfree(&crc);
break;
- } else
- pfree(&crc);
+ }
+ pfree(&crc);
}
pfree(&apoly);
- if(qptr == pptr) {
+
+ if (qptr == pptr) {
/* the selected model solved all arguments */
-
mcanon(&pset);
size_t size = (pset.name && *pset.name) ? strlen(pset.name) : 6;
PrintAndLog("out of memory?");
return 0;
}
- width[Cnt] = width[0];
+ width[Cnt] = width[0];
memcpy(tmp, pset.name, size);
Models[Cnt++] = tmp;
*count = Cnt;
mfree(&pset);
/* toggle refIn/refOut and reflect arguments */
- if(~rflags & R_HAVERI) {
+ if (~rflags & R_HAVERI) {
model.flags ^= P_REFIN | P_REFOUT;
- for(qptr = apolys; qptr < pptr; ++qptr)
+ for (qptr = apolys; qptr < pptr; ++qptr) {
prevch(qptr, ibperhx);
+ }
}
- } while(~rflags & R_HAVERI && ++pass < 2);
+ } while (~rflags & R_HAVERI && ++pass < 2);
}
//got everything now free the memory...
- if(uflags & C_RESULT) {
- for(qptr = apolys; qptr < pptr; ++qptr)
+ if (uflags & C_RESULT) {
+ for (qptr = apolys; qptr < pptr; ++qptr) {
pfree(qptr);
+ }
}
- if(!(model.flags & P_REFIN) != !(model.flags & P_REFOUT))
+ if (!(model.flags & P_REFIN) != !(model.flags & P_REFOUT))
return uerr("cannot search for crossed-endian models");
pass = 0;
do {
mptr = candmods = reveng(&model, qpoly, rflags, args, apolys);
- if(mptr && plen(mptr->spoly))
+ if (mptr && plen(mptr->spoly)) {
uflags |= C_RESULT;
- while(mptr && plen(mptr->spoly)) {
+ }
+ while (mptr && plen(mptr->spoly)) {
mfree(mptr++);
}
free(candmods);
- if(~rflags & R_HAVERI) {
+ if (~rflags & R_HAVERI) {
model.flags ^= P_REFIN | P_REFOUT;
- for(qptr = apolys; qptr < pptr; ++qptr)
+ for (qptr = apolys; qptr < pptr; ++qptr) {
prevch(qptr, ibperhx);
+ }
}
- } while(~rflags & R_HAVERI && ++pass < 2);
- for(qptr = apolys; qptr < pptr; ++qptr)
+ } while (~rflags & R_HAVERI && ++pass < 2);
+
+ for (qptr = apolys; qptr < pptr; ++qptr) {
pfree(qptr);
+ }
free(apolys);
- if(~uflags & C_RESULT)
+ if (~uflags & C_RESULT)
return uerr("no models found");
+
mfree(&model);
-
}
return 1;
}
SETBMP();
//set model
- if(!(c = mbynam(&model, inModel))) {
+ if (!(c = mbynam(&model, inModel))) {
PrintAndLog("error: preset model '%s' not found. Use reveng -D to list presets.", inModel);
return 0;
}
- if(c < 0)
+ if (c < 0)
return uerr("no preset models available");
rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX;
* Consequently Init is the mirror image of the
* one resulting from -V, and so we have:
*/
- if(~model.flags & P_REFOUT) {
+ if (~model.flags & P_REFOUT) {
prev(&model.init);
prev(&model.xorout);
}
/* in the Williams model, xorout is applied after the refout stage.
* as refout is part of ptostr(), we reverse xorout here.
*/
- if(model.flags & P_REFOUT)
+ if (model.flags & P_REFOUT)
prev(&model.xorout);
apoly = strtop(inHexStr, model.flags, ibperhx);
- if(reverse)
+ if (reverse)
prev(&apoly);
crc = pcrc(apoly, model.spoly, model.init, model.xorout, model.flags);
- if(reverse)
+ if (reverse)
prev(&crc);
string = ptostr(crc, model.flags, obperhx);
}
if (hi){
//output 88 bit em id
- PrintAndLog("\nEM TAG ID : %06X%016llX", hi, id);
+ PrintAndLog("\nEM TAG ID : %06X%016" PRIX64, hi, id);
} else{
//output 40 bit em id
- PrintAndLog("\nEM TAG ID : %010llX", id);
- PrintAndLog("Unique TAG ID : %010llX", id2lo);
+ PrintAndLog("\nEM TAG ID : %010" PRIX64, id);
+ PrintAndLog("Unique TAG ID : %010" PRIX64, id2lo);
PrintAndLog("\nPossible de-scramble patterns");
PrintAndLog("HoneyWell IdentKey {");
- PrintAndLog("DEZ 8 : %08lld",id & 0xFFFFFF);
- PrintAndLog("DEZ 10 : %010lld",id & 0xFFFFFFFF);
- PrintAndLog("DEZ 5.5 : %05lld.%05lld",(id>>16LL) & 0xFFFF,(id & 0xFFFF));
- PrintAndLog("DEZ 3.5A : %03lld.%05lld",(id>>32ll),(id & 0xFFFF));
- PrintAndLog("DEZ 3.5B : %03lld.%05lld",(id & 0xFF000000) >> 24,(id & 0xFFFF));
- PrintAndLog("DEZ 3.5C : %03lld.%05lld",(id & 0xFF0000) >> 16,(id & 0xFFFF));
- PrintAndLog("DEZ 14/IK2 : %014lld",id);
- PrintAndLog("DEZ 15/IK3 : %015lld",id2lo);
+ PrintAndLog("DEZ 8 : %08" PRIu64, id & 0xFFFFFF);
+ PrintAndLog("DEZ 10 : %010" PRIu64, id & 0xFFFFFFFF);
+ PrintAndLog("DEZ 5.5 : %05" PRIu64 ".%05" PRIu64, (id>>16LL) & 0xFFFF, (id & 0xFFFF));
+ PrintAndLog("DEZ 3.5A : %03" PRIu64 ".%05" PRIu64, (id>>32ll), (id & 0xFFFF));
+ PrintAndLog("DEZ 3.5B : %03" PRIu64 ".%05" PRIu64, (id & 0xFF000000) >> 24, (id & 0xFFFF));
+ PrintAndLog("DEZ 3.5C : %03" PRIu64 ".%05" PRIu64, (id & 0xFF0000) >> 16, (id & 0xFFFF));
+ PrintAndLog("DEZ 14/IK2 : %014" PRIu64, id);
+ PrintAndLog("DEZ 15/IK3 : %015" PRIu64, id2lo);
PrintAndLog("DEZ 20/ZK : %02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld",
(id2lo & 0xf000000000) >> 36,
(id2lo & 0x0f00000000) >> 32,
(id2lo & 0x000000000f)
);
uint64_t paxton = (((id>>32) << 24) | (id & 0xffffff)) + 0x143e00;
- PrintAndLog("}\nOther : %05lld_%03lld_%08lld",(id&0xFFFF),((id>>16LL) & 0xFF),(id & 0xFFFFFF));
- PrintAndLog("Pattern Paxton : %lld [0x%llX]", paxton, paxton);
+ PrintAndLog("}\nOther : %05" PRIu64 "_%03" PRIu64 "_%08" PRIu64, (id&0xFFFF), ((id>>16LL) & 0xFF), (id & 0xFFFFFF));
+ PrintAndLog("Pattern Paxton : %" PRIu64 " [0x%" PRIX64 "]", paxton, paxton);
uint32_t p1id = (id & 0xFFFFFF);
uint8_t arr[32] = {0x00};
if (g_debugMode) PrintAndLog("Raw ID Hex: %s", sprint_hex(raw,8));
uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
- PrintAndLog("Animal ID: %04u-%012llu", countryCode, NationalCode);
- PrintAndLog("National Code: %012llu", NationalCode);
+ PrintAndLog("Animal ID: %04u-%012" PRIu64, countryCode, NationalCode);
+ PrintAndLog("National Code: %012" PRIu64, NationalCode);
PrintAndLog("CountryCode: %04u", countryCode);
PrintAndLog("Reserved/RFU: %u", reservedCode);
if(errors) return usage_hf_emv_sim();
UsbCommand c = {CMD_SIMULATE_TAG_LEGIC_RF, {6,3,0}};
- sscanf(Cmd, " %"lli" %"lli" %"lli, &c.arg[0], &c.arg[1], &c.arg[2]);
+ sscanf(Cmd, " %" SCNi64 " %" SCNi64 " %" SCNi64 , &c.arg[0], &c.arg[1], &c.arg[2]);
clearCommandBuffer();
SendCommand(&c);
return 0;
m = m > 0 ? m : 1;
n = n > 0 ? n : 1;
- PrintAndLog("Collecting %u %"hhu"-byte nonces", n, m);
+ PrintAndLog("Collecting %u %u byte nonces", n, m);
PrintAndLog("Start: %u", time(NULL));
// repeat n times
for (unsigned int i = 0; i < n; i++) {
return 0;
}
-/*
-uint64_t xorcheck(uint64_t sdiv,uint64_t hdiv) {
- uint64_t new_div = 0x00;
- new_div ^= sdiv;
- new_div ^= hdiv;
- return new_div;
-}
-
-uint64_t hexarray_to_uint64(uint8_t *key) {
- char temp[17];
- uint64_t uint_key;
- for (int i = 0;i < 8;i++)
- sprintf(&temp[(i *2)],"%02X",key[i]);
- temp[16] = '\0';
- if (sscanf(temp,"%016"llX,&uint_key) < 1)
- return 0;
- return uint_key;
-}
-*/
void HFiClassCalcDivKey(uint8_t *CSN, uint8_t *KEY, uint8_t *div_key, bool elite){
uint8_t keytable[128] = {0};
uint8_t key_index[8] = {0};
// int phase, int frame, int reqresp
int CmdLegicRfSim(const char *Cmd) {
UsbCommand c = {CMD_SIMULATE_TAG_LEGIC_RF, {6,3,0}};
- sscanf(Cmd, " %"lli" %"lli" %"lli, &c.arg[0], &c.arg[1], &c.arg[2]);
+ sscanf(Cmd, " %" SCNi64 " %" SCNi64 " %" SCNi64 , &c.arg[0], &c.arg[1], &c.arg[2]);
clearCommandBuffer();
SendCommand(&c);
return 0;
c.arg[0] = false;\r
goto start;\r
} else {\r
- PrintAndLog("Found valid key: %012"llx" \n", r_key);\r
+ PrintAndLog("Found valid key: %012" PRIx64 " \n", r_key);\r
goto END;\r
}\r
}\r
uint64_t key64 = 0;\r
int res = mfCheckKeys(blockNo, keytype - 0x60 , false, 1, keyblock, &key64);\r
if ( res > 0 ) {\r
- PrintAndLog("Candidate Key found (%012"llx") - Test authentication failed. [%d] Restarting darkside attack", r_key, res); \r
+ PrintAndLog("Candidate Key found (%012" PRIx64 ") - Test authentication failed. [%d] Restarting darkside attack", r_key, res); \r
goto start;\r
}\r
- PrintAndLog("Found valid key: %012"llx" \n", r_key);\r
+ PrintAndLog("Found valid key: %012" PRIx64 " \n", r_key);\r
}\r
END:\r
t1 = clock() - t1;\r
uint8_t blockNo = 0;\r
uint8_t keyType = 0;\r
uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
- \r
- char cmdp = 0x00;\r
-\r
+ char cmdp = 0x00;\r
\r
if (strlen(Cmd)<3) {\r
PrintAndLog("Usage: hf mf rdbl <block number> <key A/B> <key (12 hex symbols)>");\r
}\r
memset(keyBlock + 6 * keycnt, 0, 6);\r
num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);\r
- PrintAndLog("check key[%2d] %012"llx, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));\r
+ PrintAndLog("check key[%2d] %012" PRIx64, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));\r
keycnt++;\r
memset(buf, 0, sizeof(buf));\r
}\r
uint8_t sector = data.sector;\r
uint8_t keytype = data.keytype;\r
\r
- PrintAndLog("Reader is trying authenticate with: Key %s, sector %02d: [%012"llx"]"\r
+ PrintAndLog("Reader is trying authenticate with: Key %s, sector %02d: [%012" PRIx64 "]"\r
, keytype ? "B" : "A"\r
, sector\r
, key\r
time(&start);\r
\r
if (mfKeyBrute( blockNo, keytype, key, &foundkey))\r
- PrintAndLog("Found valid key: %012"llx" \n", foundkey);\r
+ PrintAndLog("Found valid key: %012" PRIx64 " \n", foundkey);\r
else\r
PrintAndLog("Key not found");\r
\r
PrintAndLog("|sec|key A |res|key B |res|");\r
PrintAndLog("|---|----------------|---|----------------|---|");\r
for (uint8_t i = 0; i < sectorscnt; ++i) {\r
- PrintAndLog("|%03d| %012"llx" | %d | %012"llx" | %d |", i,\r
+ PrintAndLog("|%03d| %012" PRIx64 " | %d | %012" PRIx64 " | %d |", i,\r
e_sector[i].Key[0], e_sector[i].foundKey[0], \r
e_sector[i].Key[1], e_sector[i].foundKey[1]\r
);\r
{\r
uint8_t memBlock[16];\r
uint8_t blockNo = 0;\r
-\r
memset(memBlock, 0x00, sizeof(memBlock));\r
\r
if (strlen(Cmd) < 3 || param_getchar(Cmd, 0) == 'h') {\r
}\r
keyA = bytes_to_num(data, 6);\r
keyB = bytes_to_num(data + 10, 6);\r
- PrintAndLog("|%03d| %012"llx" | %012"llx" |", i, keyA, keyB);\r
+ PrintAndLog("|%03d| %012" PRIx64 " | %012" PRIx64 " |", i, keyA, keyB);\r
}\r
PrintAndLog("|---|----------------|----------------|");\r
\r
cuid = (rand() & 0xff) << 24 | (rand() & 0xff) << 16 | (rand() & 0xff) << 8 | (rand() & 0xff);
known_target_key = ((uint64_t)rand() & 0xfff) << 36 | ((uint64_t)rand() & 0xfff) << 24 | ((uint64_t)rand() & 0xfff) << 12 | ((uint64_t)rand() & 0xfff);
- printf("Simulating nonce acquisition for target key %012"llx", cuid %08x ...\n", known_target_key, cuid);
- fprintf(fstats, "%012"llx";%08x;", known_target_key, cuid);
+ printf("Simulating nonce acquisition for target key %012" PRIx64 ", cuid %08x ...\n", known_target_key, cuid);
+ fprintf(fstats, "%012" PRIx64 ";%08x;", known_target_key, cuid);
do {
uint32_t nt_enc = 0;
uint32_t state_odd = pcs->odd & 0x00ffffff;
uint32_t state_even = pcs->even & 0x00ffffff;
- //printf("Tests: searching for key %llx after first byte 0x%02x (state_odd = 0x%06x, state_even = 0x%06x) ...\n", key, best_first_bytes[0], state_odd, state_even);
+ //printf("Tests: searching for key %" PRIx64 " after first byte 0x%02x (state_odd = 0x%06x, state_even = 0x%06x) ...\n", key, best_first_bytes[0], state_odd, state_even);
printf("Validating key search space\n");
uint64_t count = 0;
for (statelist_t *p = candidates; p != NULL; p = p->next) {
count += (p_odd - p->states[ODD_STATE]) * (p_even - p->states[EVEN_STATE]);
if (found_odd && found_even) {
if (known_target_key != -1) {
- PrintAndLog("Key Found after testing %llu (2^%1.1f) out of %lld (2^%1.1f) keys.",
+ PrintAndLog("Key Found after testing %" PRIu64 " (2^%1.1f) out of %lld (2^%1.1f) keys.",
count,
log(count)/log(2),
maximum_states,
}
CmdLFRead("s");
- getSamples("8201",true); //capture enough to get 2 complete preambles (4096*2+9)
+ //getSamples("8201",true); //capture enough to get 2 complete preambles (4096*2+9)
+ getSamples("6144",true);
} while (!CmdEM410xRead(""));
return 0;
{
// loops if the captured ID was in XL-format.
CmdEM410xWatch(Cmd);
- PrintAndLog("# Replaying captured ID: %llu", g_em410xid);
+ PrintAndLog("# Replaying captured ID: %" PRIu64 , g_em410xid);
CmdLFaskSim("");
return 0;
}
}
#define EM_PREAMBLE_LEN 6
-// download samples from device
-// and copy them to Graphbuffer
+// download samples from device and copy to Graphbuffer
bool downloadSamplesEM(){
// 8 bit preamble + 32 bit word response (max clock (128) * 40bits = 5120 samples)
setGraphBuf(got, sizeof(got));
return TRUE;
}
-//search for given preamble in given BitStream and return success=1 or fail=0 and startIndex
+
+// em_demod
bool doPreambleSearch(size_t *startIdx){
// sanity check
if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 demodbuffer too small");
return FALSE;
}
-
- // skip first two 0 bits as they might have been missed in the demod
- uint8_t preamble[EM_PREAMBLE_LEN] = {0,0,1,0,1,0};
-
- // set size to 15 to only test first 4 positions for the preamble
- size_t size = (15 > DemodBufferLen) ? DemodBufferLen : 15;
+
+ // set size to 20 to only test first 14 positions for the preamble
+ size_t size = (20 > DemodBufferLen) ? DemodBufferLen : 20;
*startIdx = 0;
- uint8_t found = 0;
-
- // em only sends preamble once, so look for it once in the first x bits
- for (int idx = 0; idx < size - EM_PREAMBLE_LEN; idx++){
- if (memcmp(DemodBuffer+idx, preamble, EM_PREAMBLE_LEN) == 0){
- //first index found
- *startIdx = idx;
- found = 1;
- break;
- }
- }
+ // skip first two 0 bits as they might have been missed in the demod
+ uint8_t preamble[EM_PREAMBLE_LEN] = {0,0,1,0,1,0};
- if ( !found) {
+ if ( !preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, startIdx, TRUE)) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 preamble not found :: %d", *startIdx);
return FALSE;
}
return FALSE;
}
- size_t size = removeParity(DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 44);
- if (!size) {
- if (g_debugMode) PrintAndLog("DEBUG: Error - EM Parity not detected");
+ if (!removeParity(DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 44)) {
+ if (g_debugMode) PrintAndLog("DEBUG: Error - EM, failed removing parity");
return FALSE;
}
- // set & copy to output
setDemodBuf(DemodBuffer, 40, 0);
*word = bytebits_to_byteLSBF(DemodBuffer, 32);
return TRUE;
if (!downloadSamplesEM())
return -1;
- //todo: check response for 00001010 then write data for write confirmation!
-
+
//attempt demod:
//need 0 bits demoded (after preamble) to verify write cmd
uint32_t dummy = 0;
uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found: Raw : %s", sprint_hex(raw, 8));
- PrintAndLog("Animal ID %04u-%012llu", countryCode, NationalCode);
- PrintAndLog("National Code %012llu (0x%llX)", NationalCode, NationalCode);
+ PrintAndLog("Animal ID %04u-%012" PRIu64, countryCode, NationalCode);
+ PrintAndLog("National Code %012" PRIu64 " (0x%" PRIx64 ")", NationalCode, NationalCode);
PrintAndLog("Country Code %04u", countryCode);
PrintAndLog("Reserved/RFU %u (0x04%X)", reservedCode, reservedCode);
PrintAndLog("");
uint8_t shifts = 64-fmtlen[i];
wiegand >>= shifts;
- PrintAndLog(" %u | %03u | %03u | %llu | %llX | %llX",
+ PrintAndLog(" %u | %03u | %03u | %" PRIu64 " | %" PRIX64 " | %" PRIX64 ,
fmtlen[i],
oem,
fc,
{
int res = 0;
UsbCommand c = {CMD_WRITE_TI_TYPE};
- res = sscanf(Cmd, "%012"llx" %012"llx" %012"llx"", &c.arg[0], &c.arg[1], &c.arg[2]);
+ res = sscanf(Cmd, "%012" SCNx64 " %012" SCNx64 " %012" SCNx64, &c.arg[0], &c.arg[1], &c.arg[2]);
if (res == 2) c.arg[2]=0;
if (res < 2) {
// arg1 = length bytes to transfer
// arg2 = bigbuff tracelength (?)
memcpy( sample_buf + (UC->arg[0]), UC->d.asBytes, UC->arg[1]);
- //printf("DBG:: Download from device. chunk %llu | size %llu | tracelen:%llu \n", UC->arg[0], UC->arg[1], UC->arg[2]);
+ //printf("DBG:: Download from device. chunk %" PRIu64 " | size %" PRIu64 " | tracelen:%" PRIu64 " \n", UC->arg[0], UC->arg[1], UC->arg[2]);
break;
}
default: {
*state = resp.arg[0];
break;
default:
- fprintf(stderr, "Error: Couldn't get proxmark state, bad response type: 0x%04"llx"\n", resp.cmd);
+ fprintf(stderr, "Error: Couldn't get proxmark state, bad response type: 0x%04" PRIx64 "\n", resp.cmd);
return -1;
break;
}
{
ReceiveCommand(ack);
if (ack->cmd != CMD_ACK) {
- printf("Error: Unexpected reply 0x%04"llx" %s (expected ACK)\n", ack->cmd, (ack->cmd==CMD_NACK)?"NACK":"");
+ printf("Error: Unexpected reply 0x%04" PRIx64 " %s (expected ACK)\n", ack->cmd, (ack->cmd==CMD_NACK)?"NACK":"");
return -1;
}
return 0;
void cmd_debug(UsbCommand* UC) {
// Debug
printf("UsbCommand length[len=%zd]\n",sizeof(UsbCommand));
- printf(" cmd[len=%zd]: %016"llx"\n",sizeof(UC->cmd),UC->cmd);
- printf(" arg0[len=%zd]: %016"llx"\n",sizeof(UC->arg[0]),UC->arg[0]);
- printf(" arg1[len=%zd]: %016"llx"\n",sizeof(UC->arg[1]),UC->arg[1]);
- printf(" arg2[len=%zd]: %016"llx"\n",sizeof(UC->arg[2]),UC->arg[2]);
+ printf(" cmd[len=%zd]: %016" PRIx64"\n",sizeof(UC->cmd),UC->cmd);
+ printf(" arg0[len=%zd]: %016" PRIx64"\n",sizeof(UC->arg[0]),UC->arg[0]);
+ printf(" arg1[len=%zd]: %016" PRIx64"\n",sizeof(UC->arg[1]),UC->arg[1]);
+ printf(" arg2[len=%zd]: %016" PRIx64"\n",sizeof(UC->arg[2]),UC->arg[2]);
printf(" data[len=%zd]: ",sizeof(UC->d.asBytes));
for (size_t i=0; i<16; i++)
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
+#include <inttypes.h>
#include "zlib.h"
#define MAX(a,b) ((a)>(b)?(a):(b))
ret = deflate(&compressed_fpga_stream, Z_FINISH);
}
- fprintf(stderr, "compressed %u input bytes to %lu output bytes\n", i, compressed_fpga_stream.total_out);
+ fprintf(stderr, "compressed %u input bytes to %" PRIu32 " output bytes\n", i, compressed_fpga_stream.total_out);
if (ret != Z_STREAM_END) {
fprintf(stderr, "Error in deflate(): %d %s\n", ret, compressed_fpga_stream.msg);
free(statelists[1].head.slhead);\r
num_to_bytes(key64, 6, resultKey);\r
\r
- PrintAndLog("UID: %08x target block:%3u key type: %c -- Found key [%012"llx"]",\r
+ PrintAndLog("UID: %08x target block:%3u key type: %c -- Found key [%012" PRIx64 "]",\r
uid,\r
(uint16_t)resp.arg[2] & 0xff,\r
(resp.arg[2] >> 8) ? 'B' : 'A',\r
lfsr_rollback_word(revstate, nr_enc, 1);\r
lfsr_rollback_word(revstate, cuid ^ nt, 0);\r
crypto1_get_lfsr(revstate, &key);\r
- PrintAndLog("Found Key: [%012"llx"]", key);\r
+ PrintAndLog("Found Key: [%012" PRIx64 "]", key);\r
\r
//if ( tryMfk64(cuid, nt, nr_enc, ar_enc, at_enc, &key) )\r
AddLogUint64(logHexFileName, "Found Key: ", key); \r
#include "crypto1_bs.h"
#include <inttypes.h>
#define __STDC_FORMAT_MACROS
-#define llx PRIx64
-#define lli PRIi64
-#define lu PRIu32
// The following functions use this global or thread-local state
// It is sized to fit exactly KEYSTREAM_SIZE more states next to the initial state
state_t values[MAX_BITSLICES] = {{0x00}};
crypto1_bs_convert_states(bitsliced_states, values);
for(slice_idx = 0; slice_idx < MAX_BITSLICES; slice_idx++){
- printf("State %03zu: %012"llx"\n", slice_idx, values[slice_idx].value);
+ printf("State %03zu: %012" PRIx64 "\n", slice_idx, values[slice_idx].value);
}
}
// Reset the last three significant bits of the reader nonce
nr &= 0xffffff1f;
- PrintAndLog("uid(%08x) nt(%08x) par(%016"llx") ks(%016"llx") nr(%08x)", uid, nt, par_info, ks_info, nr);
+ PrintAndLog("uid(%08x) nt(%08x) par(%016" PRIx64") ks(%016" PRIx64") nr(%08x)", uid, nt, par_info, ks_info, nr);
for ( pos = 0; pos < 8; pos++ ) {
ks3x[7-pos] = (ks_info >> (pos*8)) & 0x0f;
free(last_keylist);
last_keylist = state_s;
PrintAndLog("parity is all zero, testing special attack. First call, this attack needs at least two calls. Hold on...");
- PrintAndLog("uid(%08x) nt(%08x) ks(%016"llx") nr(%08x)", uid, nt, ks_info, nr);
+ PrintAndLog("uid(%08x) nt(%08x) ks(%016" PRIx64") nr(%08x)", uid, nt, ks_info, nr);
return 1;
}
- PrintAndLog("uid(%08x) nt(%08x) ks(%016"llx") nr(%08x)", uid, nt, ks_info, nr);
+ PrintAndLog("uid(%08x) nt(%08x) ks(%016" PRIx64") nr(%08x)", uid, nt, ks_info, nr);
//Create the intersection:
int64_t *p1, *p2, *p3;
while ( *p1 != -1 && *p2 != -1 ) {
if (compar_intA(p1, p2) == 0) {
- PrintAndLog("p1:%"llx" p2:%"llx" p3:%"llx" key:%012"llx,(uint64_t)(p1-last_keylist),(uint64_t)(p2-state_s),(uint64_t)(p3-last_keylist),*p1);
+ PrintAndLog("p1:%" PRIx64" p2:%" PRIx64" p3:%" PRIx64" key:%012" PRIx64
+ , (uint64_t)(p1-last_keylist)
+ , (uint64_t)(p2-state_s)
+ , (uint64_t)(p3-last_keylist)
+ , *p1
+ );
*p3++ = *p1++;
p2++;
}
lfsr_rollback_word(revstate, uid ^ nt, 0);
crypto1_get_lfsr(revstate, &key);
- PrintAndLog("Found Key: [%012"llx"]", key);
+ PrintAndLog("Found Key: [%012" PRIx64 "]", key);
t1 = clock() - t1;
if ( t1 > 0 ) PrintAndLog("Time in mfkey64: %.0f ticks", (float)t1);
//-----------------------------------------------------------------------------
// Main binary
//-----------------------------------------------------------------------------
-
#ifndef PROXMARK3_H__
#define PROXMARK3_H__
#include <inttypes.h>
#include "usb_cmd.h"
+/*
#define lu PRIu32
#define lx PRIx32
-#define llx PRIx64
-#define lli PRIi64
-#define llu PRIu64
-#define hhu PRIu8
+*/
#define PROXPROMPT "pm3 --> "
void SendCommand(UsbCommand *c);
-
-#endif
+#endif
\ No newline at end of file
unsigned long fulllength = poly->length + ofs;
bmp_t accu;
- if(ofs)
+ if(ofs) {
/* removable optimisation */
if(poly->length < (unsigned long) BMP_BIT) {
*poly->bitmap = rev(*poly->bitmap >> ofs, (int) poly->length) << ofs;
return;
}
-
- /* claim remaining bits of last word (as we use public function pshift()) */
- poly->length = fulllength;
+ }
+ /* claim remaining bits of last word (as we use public function pshift()) */
+ poly->length = fulllength;
/* reverse and swap words in the array, leaving it right-justified */
while(leftidx < rightidx) {
uint8_t dest_key[8];
num_to_bytes(key,sizeof(dest_key),dest_key);
- //printf("Pushing to lua stack: %012"llx"\n",key);
+ //printf("Pushing to lua stack: %012" PRIx64 "\n",key);
lua_pushlstring(L,(const char *) dest_key,sizeof(dest_key));
return 2; //Two return values
uint8_t dest_key[6];
num_to_bytes(foundkey, sizeof(dest_key), dest_key);
- //printf("Pushing to lua stack: %012"llx"\n",key);
+ //printf("Pushing to lua stack: %012" PRIx64 "\n",key);
lua_pushlstring(L, (const char *) dest_key, sizeof(dest_key));
return 2; //Two return values
}
char buf[20] = {0};
memset(buf, 0x00, sizeof(buf));
//sprintf(buf, "%X%X", (unsigned int)((data & 0xFFFFFFFF00000000) >> 32), (unsigned int)(data & 0xFFFFFFFF));
- sprintf(buf, "%012"llx"", data);
+ sprintf(buf, "%012" PRIx64 "", data);
AddLogLine(fileName, extData, buf);
}
endif
-#
# uncomment these two; to enable EMV
-#
#APP_CFLAGS += -DWITH_EMV
#COMMON_FLAGS += -DWITH_EMV
-#
+
# uncomment these two; to fix 256 vs 512kb PM3 devices
# flashing bootrom -b is needed
-#
APP_CFLAGS += -DHAS_512_FLASH
COMMON_FLAGS += -DHAS_512_FLASH
#include <stdlib.h>
#include <time.h>
-#define llx PRIx64
-#define lli PRIi64
int main (int argc, char *argv[]) {
struct Crypto1State *s,*t;
uint64_t key; // recovered key
crypto1_word(t, uid ^ nt, 0);
crypto1_word(t, nr1_enc, 1);
if (ar1_enc == (crypto1_word(t, 0, 0) ^ p64)) {
- printf("\nFound Key: [%012"llx"]\n\n",key);
+ printf("\nFound Key: [%012" PRIx64 "]\n\n",key);
break;}
}
free(s);
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-
-#define llx PRIx64
-#define lli PRIi64
+
int main (int argc, char *argv[]) {
struct Crypto1State *s,*t;
uint64_t key; // recovered key
crypto1_word(t, uid ^ nt1, 0);
crypto1_word(t, nr1_enc, 1);
if (ar1_enc == (crypto1_word(t, 0, 0) ^ p64b)) {
- printf("\nFound Key: [%012"llx"]\n\n",key);
+ printf("\nFound Key: [%012" PRIx64 "]\n\n",key);
break;}
}
free(s);
#include <inttypes.h>
#include "crapto1.h"
-#define llx PRIx64
-#define lli PRIi64
-
int main (int argc, char *argv[]) {
struct Crypto1State *revstate;
uint64_t key; // recovered key
lfsr_rollback_word(revstate, nr_enc, 1);
lfsr_rollback_word(revstate, uid ^ nt, 0);
crypto1_get_lfsr(revstate, &key);
- printf("\nFound Key: [%012"llx"]\n\n", key);
+ printf("\nFound Key: [%012" PRIx64 "]\n\n", key);
crypto1_destroy(revstate);
t1 = clock() - t1;
#include "crapto1.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
-#define llx PRIx64
#include <stdio.h>
#include <time.h>
typedef unsigned char byte_t;
printf("\nsyntax: %s <uid> <nt> <par> <ks>\n\n",argv[0]);
return 1;
}
- sscanf(argv[1],"%08x",&uid);
- sscanf(argv[2],"%08x",&nt);
- sscanf(argv[3],"%016"llx,&par_info);
- sscanf(argv[4],"%016"llx,&ks_info);
+ sscanf(argv[1],"%08x", &uid);
+ sscanf(argv[2],"%08x", &nt);
+ sscanf(argv[3],"%016" SCNx64 ,&par_info);
+ sscanf(argv[4],"%016" SCNx64 ,&ks_info);
// Reset the last three significant bits of the reader nonce
nr &= 0xffffff1f;
- printf("\nuid(%08x) nt(%08x) par(%016"llx") ks(%016"llx")\n\n",uid,nt,par_info,ks_info);
+ printf("\nuid(%08x) nt(%08x) par(%016" PRIx64 ") ks(%016" PRIx64 ")\n\n", uid, nt, par_info, ks_info);
for ( pos = 0; pos < 8; pos++ ) {
ks3x[7-pos] = (ks_info >> (pos*8)) & 0x0f;
state = lfsr_common_prefix(nr,rr,ks3x,par);
lfsr_rollback_word(state,uid^nt,0);
crypto1_get_lfsr(state,&key_recovered);
- printf("\nkey recovered: %012"llx"\n\n",key_recovered);
+ printf("\nkey recovered: %012" PRIx64 "\n\n", key_recovered);
crypto1_destroy(state);
t1 = clock() - t1;
opt_lenb = (s->opt_len+3+7)>>3;
static_lenb = (s->static_len+3+7)>>3;
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
+ Tracev((stderr, "\nopt %" PRIu32 "(%" PRIu32 ") stat %" PRIu32 "(%" PRIu32 ") stored %" PRIu32 " lit %u ",
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
s->last_lit));