mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
make style
This commit is contained in:
parent
5eeb356418
commit
a55e597e36
37 changed files with 193 additions and 193 deletions
|
@ -776,8 +776,8 @@ readysim:
|
|||
LED_C_ON();
|
||||
|
||||
uint16_t flags;
|
||||
switch (p_card.uidlen){
|
||||
case 10:
|
||||
switch (p_card.uidlen) {
|
||||
case 10:
|
||||
flags = FLAG_10B_UID_IN_DATA;
|
||||
break;
|
||||
case 7:
|
||||
|
|
|
@ -388,8 +388,8 @@ void RunMod() {
|
|||
LED_B_ON(); // green
|
||||
// assuming arg0==0, use hardcoded uid 0xdeadbeaf
|
||||
uint16_t flags;
|
||||
switch (p_card.uidlen){
|
||||
case 10:
|
||||
switch (p_card.uidlen) {
|
||||
case 10:
|
||||
flags = FLAG_10B_UID_IN_DATA;
|
||||
break;
|
||||
case 7:
|
||||
|
|
|
@ -677,40 +677,40 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
|||
break;
|
||||
}
|
||||
uint8_t uid1 = (uid[0] << 7)
|
||||
| (uid[1] << 6)
|
||||
| (uid[2] << 5)
|
||||
| (uid[3] << 4)
|
||||
| (uid[4] << 3)
|
||||
| (uid[5] << 2)
|
||||
| (uid[6] << 1)
|
||||
| uid[7];
|
||||
| (uid[1] << 6)
|
||||
| (uid[2] << 5)
|
||||
| (uid[3] << 4)
|
||||
| (uid[4] << 3)
|
||||
| (uid[5] << 2)
|
||||
| (uid[6] << 1)
|
||||
| uid[7];
|
||||
|
||||
uint8_t uid2 = (uid[8] << 7)
|
||||
| (uid[9] << 6)
|
||||
| (uid[10] << 5)
|
||||
| (uid[11] << 4)
|
||||
| (uid[12] << 3)
|
||||
| (uid[13] << 2)
|
||||
| (uid[14] << 1)
|
||||
| uid[15];
|
||||
| (uid[9] << 6)
|
||||
| (uid[10] << 5)
|
||||
| (uid[11] << 4)
|
||||
| (uid[12] << 3)
|
||||
| (uid[13] << 2)
|
||||
| (uid[14] << 1)
|
||||
| uid[15];
|
||||
|
||||
uint8_t uid3 = (uid[16] << 7)
|
||||
| (uid[17] << 6)
|
||||
| (uid[18] << 5)
|
||||
| (uid[19] << 4)
|
||||
| (uid[20] << 3)
|
||||
| (uid[21] << 2)
|
||||
| (uid[22] << 1)
|
||||
| uid[23];
|
||||
| (uid[17] << 6)
|
||||
| (uid[18] << 5)
|
||||
| (uid[19] << 4)
|
||||
| (uid[20] << 3)
|
||||
| (uid[21] << 2)
|
||||
| (uid[22] << 1)
|
||||
| uid[23];
|
||||
|
||||
uint8_t uid4 = (uid[24] << 7)
|
||||
| (uid[25] << 6)
|
||||
| (uid[26] << 5)
|
||||
| (uid[27] << 4)
|
||||
| (uid[28] << 3)
|
||||
| (uid[29] << 2)
|
||||
| (uid[30] << 1)
|
||||
| uid[31];
|
||||
| (uid[25] << 6)
|
||||
| (uid[26] << 5)
|
||||
| (uid[27] << 4)
|
||||
| (uid[28] << 3)
|
||||
| (uid[29] << 2)
|
||||
| (uid[30] << 1)
|
||||
| uid[31];
|
||||
|
||||
if (DEBUG)
|
||||
Dbprintf("UID: %02X %02X %02X %02X", uid1, uid2, uid3, uid4);
|
||||
|
|
|
@ -761,8 +761,8 @@ static bool GetIso14443aCommandFromReader(uint8_t *received, uint8_t *par, int *
|
|||
uint16_t check = 0;
|
||||
|
||||
for (;;) {
|
||||
if ( check == 1000 ) {
|
||||
if ( BUTTON_PRESS() || data_available() )
|
||||
if (check == 1000) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
return false;
|
||||
check = 0;
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
|||
int order = ORDER_NONE;
|
||||
|
||||
int retval = PM3_SUCCESS;
|
||||
|
||||
|
||||
// Just to allow some checks
|
||||
int happened = 0;
|
||||
int happened2 = 0;
|
||||
|
@ -1191,7 +1191,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
|||
ar_nr_nonces[index].state = SECOND;
|
||||
|
||||
// send to client (one struct nonces_t)
|
||||
reply_ng(CMD_SIMULATE_MIFARE_CARD, PM3_SUCCESS, (uint8_t*)&ar_nr_nonces[index], sizeof(nonces_t) );
|
||||
reply_ng(CMD_SIMULATE_MIFARE_CARD, PM3_SUCCESS, (uint8_t *)&ar_nr_nonces[index], sizeof(nonces_t));
|
||||
|
||||
ar_nr_nonces[index].state = EMPTY;
|
||||
ar_nr_nonces[index].sector = 0;
|
||||
|
@ -1515,7 +1515,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
|||
Dbprintf("-[ Num of received cmd [%d]", cmdsRecvd);
|
||||
Dbprintf("-[ Num of moebius tries [%d]", moebius_count);
|
||||
}
|
||||
|
||||
|
||||
reply_ng(CMD_SIMULATE_MIFARE_CARD, retval, NULL, 0);
|
||||
}
|
||||
|
||||
|
@ -1716,10 +1716,10 @@ int EmGetCmd(uint8_t *received, uint16_t *len, uint8_t *par) {
|
|||
for (;;) {
|
||||
WDT_HIT();
|
||||
|
||||
if ( check == 1000 ) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
return 1;
|
||||
check = 0;
|
||||
if (check == 1000) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
return 1;
|
||||
check = 0;
|
||||
}
|
||||
++check;
|
||||
|
||||
|
|
|
@ -606,7 +606,7 @@ void SimulateTagLowFrequencyEx(int period, int gap, bool ledcontrol, int numcycl
|
|||
// used as a simple detection of a reader field?
|
||||
while (!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) {
|
||||
WDT_HIT();
|
||||
if ( check == 1000) {
|
||||
if (check == 1000) {
|
||||
if (data_available() || BUTTON_PRESS())
|
||||
goto OUT;
|
||||
check = 0;
|
||||
|
|
|
@ -47,7 +47,7 @@ void MifareReadBlock(uint8_t blockNo, uint8_t keyType, uint8_t *datain) {
|
|||
uint8_t dataoutbuf[16] = {0x00};
|
||||
uint8_t uid[10] = {0x00};
|
||||
uint32_t cuid = 0, status = PM3_EOPABORTED;
|
||||
|
||||
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
pcs = &mpcs;
|
||||
|
@ -1616,7 +1616,7 @@ void MifareChkKeys(uint8_t *datain) {
|
|||
|
||||
void MifareEMemClr(void) {
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
emlClearMem();
|
||||
emlClearMem();
|
||||
}
|
||||
|
||||
void MifareEMemSet(uint8_t blockno, uint8_t blockcnt, uint8_t blockwidth, uint8_t *datain) {
|
||||
|
@ -1624,22 +1624,22 @@ void MifareEMemSet(uint8_t blockno, uint8_t blockcnt, uint8_t blockwidth, uint8_
|
|||
|
||||
if (blockwidth == 0)
|
||||
blockwidth = 16; // backwards compat... default bytewidth
|
||||
|
||||
|
||||
emlSetMem_xt(datain, blockno, blockcnt, blockwidth); // data, block num, blocks count, block byte width
|
||||
}
|
||||
|
||||
void MifareEMemGet(uint8_t blockno, uint8_t blockcnt) {
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
size_t size = blockcnt * 16;
|
||||
if ( size > PM3_CMD_DATA_SIZE) {
|
||||
if (size > PM3_CMD_DATA_SIZE) {
|
||||
reply_ng(CMD_MIFARE_EML_MEMGET, PM3_EMALLOC, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint8_t *buf = BigBuf_malloc(size);
|
||||
|
||||
|
||||
emlGetMem(buf, blockno, blockcnt); // data, block num, blocks count (max 4)
|
||||
|
||||
LED_B_ON();
|
||||
|
@ -1985,7 +1985,7 @@ TEST2:
|
|||
};
|
||||
|
||||
OUT:
|
||||
|
||||
|
||||
data[0] = isGen;
|
||||
reply_ng(CMD_MIFARE_CIDENT, PM3_SUCCESS, data, sizeof(data));
|
||||
// turns off
|
||||
|
|
|
@ -989,7 +989,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
|
|||
ar_nr_resp[i + mM].nonce2 = nonce;
|
||||
ar_nr_resp[i + mM].nr2 = nr;
|
||||
ar_nr_resp[i + mM].ar2 = ar;
|
||||
|
||||
|
||||
if (!gettingMoebius) {
|
||||
nonce2_count++;
|
||||
// check if this was the last second nonce we need for std attack
|
||||
|
@ -1006,7 +1006,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
|
|||
} else {
|
||||
moebius_n_count++;
|
||||
// if we've collected all the nonces we need - finish.
|
||||
if (nonce1_count == moebius_n_count)
|
||||
if (nonce1_count == moebius_n_count)
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,8 +345,8 @@ void BootROM(void) {
|
|||
common_area.flags.bootrom_present = 1;
|
||||
|
||||
if ((common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) ||
|
||||
(!common_area.flags.button_pressed && BUTTON_PRESS()) ||
|
||||
(_osimage_entry == 0xffffffffU)) {
|
||||
(!common_area.flags.button_pressed && BUTTON_PRESS()) ||
|
||||
(_osimage_entry == 0xffffffffU)) {
|
||||
flash_mode();
|
||||
} else {
|
||||
// clear button status, even if button still pressed
|
||||
|
|
|
@ -448,7 +448,7 @@ int CmdGetBitStream(const char *Cmd) {
|
|||
}
|
||||
int CmdConvertBitStream(const char *Cmd) {
|
||||
|
||||
if ( isGraphBitstream() ) {
|
||||
if (isGraphBitstream()) {
|
||||
convertGraphFromBitstream();
|
||||
} else {
|
||||
// get high, low
|
||||
|
@ -716,7 +716,7 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose) {
|
|||
setDemodBuff(BitStream, size, 0);
|
||||
setClockGrid(clk, startIdx + clk * offset / 2);
|
||||
if (g_debugMode || verbose) {
|
||||
PrintAndLogEx(NORMAL, "Biphase Decoded using offset %d | clock %d | #errors %d | start index %d\ndata\n", offset, clk, errCnt, (startIdx + clk * offset / 2) );
|
||||
PrintAndLogEx(NORMAL, "Biphase Decoded using offset %d | clock %d | #errors %d | start index %d\ndata\n", offset, clk, errCnt, (startIdx + clk * offset / 2));
|
||||
printDemodBuff();
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -490,10 +490,10 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
//
|
||||
|
||||
// public key Exponent E
|
||||
#define RSA_E "010001"
|
||||
#define RSA_E "010001"
|
||||
|
||||
// public key modulus N
|
||||
#define RSA_N "E28D809BF323171D11D1ACA4C32A5B7E0A8974FD171E75AD120D60E9B76968FF4B0A6364AE50583F9555B8EE1A725F279E949246DF0EFCE4C02B9F3ACDCC623F9337F21C0C066FFB703D8BFCB5067F309E056772096642C2B1A8F50305D5EC33DB7FB5A3C8AC42EB635AE3C148C910750ABAA280CE82DC2F180F49F30A1393B5"
|
||||
#define RSA_N "E28D809BF323171D11D1ACA4C32A5B7E0A8974FD171E75AD120D60E9B76968FF4B0A6364AE50583F9555B8EE1A725F279E949246DF0EFCE4C02B9F3ACDCC623F9337F21C0C066FFB703D8BFCB5067F309E056772096642C2B1A8F50305D5EC33DB7FB5A3C8AC42EB635AE3C148C910750ABAA280CE82DC2F180F49F30A1393B5"
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Example RSA-1024 keypair, for test purposes (from common/polarssl/rsa.c)
|
||||
|
|
|
@ -474,15 +474,15 @@ int CmdHF14ASim(const char *Cmd) {
|
|||
flags |= FLAG_UID_IN_EMUL;
|
||||
|
||||
struct {
|
||||
uint8_t tagtype;
|
||||
uint8_t flags;
|
||||
uint8_t uid[10];
|
||||
uint8_t tagtype;
|
||||
uint8_t flags;
|
||||
uint8_t uid[10];
|
||||
} PACKED payload;
|
||||
|
||||
|
||||
payload.tagtype = tagtype;
|
||||
payload.flags = flags;
|
||||
memcpy(payload.uid, uid, uidlen);
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SIMULATE_TAG_ISO_14443a, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
|
@ -492,13 +492,13 @@ int CmdHF14ASim(const char *Cmd) {
|
|||
while (!ukbhit()) {
|
||||
if (WaitForResponseTimeout(CMD_SIMULATE_MIFARE_CARD, &resp, 1500) == 0) continue;
|
||||
if (resp.status != PM3_SUCCESS) break;
|
||||
|
||||
|
||||
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) break;
|
||||
|
||||
nonces_t *data = (nonces_t*)resp.data.asBytes;
|
||||
|
||||
nonces_t *data = (nonces_t *)resp.data.asBytes;
|
||||
readerAttack(data[0], setEmulatorMem, verbose);
|
||||
}
|
||||
if (resp.status == PM3_EOPABORTED && ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) )
|
||||
if (resp.status == PM3_EOPABORTED && ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK))
|
||||
showSectorTable();
|
||||
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
|
|
|
@ -557,9 +557,9 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
|
|||
payload.blockno = blockNo;
|
||||
payload.keytype = keyType;
|
||||
memcpy(payload.key, key, sizeof(payload.key));
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t));
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) {
|
||||
|
@ -789,15 +789,15 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
mf_readblock_t payload;
|
||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) {
|
||||
printf(".");
|
||||
printf(".");
|
||||
fflush(NULL);
|
||||
|
||||
|
||||
payload.blockno = FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1;
|
||||
payload.keytype = 0;
|
||||
memcpy(payload.key, keyA[sectorNo], sizeof(payload.key));
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t));
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
|
||||
if (WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) {
|
||||
|
||||
|
@ -830,13 +830,13 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
|
||||
for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) {
|
||||
if (blockNo == NumBlocksPerSector(sectorNo) - 1) { // sector trailer. At least the Access Conditions can always be read with key A.
|
||||
|
||||
|
||||
payload.blockno = FirstBlockOfSector(sectorNo) + blockNo;
|
||||
payload.keytype = 0;
|
||||
memcpy(payload.key, keyA[sectorNo], sizeof(payload.key));
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t));
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500);
|
||||
} else { // data block. Check if it can be read with key A or key B
|
||||
uint8_t data_area = (sectorNo < 32) ? blockNo : blockNo / 5;
|
||||
|
@ -845,9 +845,9 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
payload.blockno = FirstBlockOfSector(sectorNo) + blockNo;
|
||||
payload.keytype = 1;
|
||||
memcpy(payload.key, keyB[sectorNo], sizeof(payload.key));
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t));
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500);
|
||||
} else if (rights[sectorNo][data_area] == 0x07) { // no key would work
|
||||
PrintAndLogEx(WARNING, "access rights do not allow reading of sector %2d block %3d", sectorNo, blockNo);
|
||||
|
@ -858,9 +858,9 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
payload.blockno = FirstBlockOfSector(sectorNo) + blockNo;
|
||||
payload.keytype = 0;
|
||||
memcpy(payload.key, keyA[sectorNo], sizeof(payload.key));
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t));
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500);
|
||||
}
|
||||
}
|
||||
|
@ -901,9 +901,9 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "time: %" PRIu64 " seconds\n", (msclock() - t1) / 1000);
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "\nSucceded in dumping all blocks");
|
||||
|
||||
if (strlen(dataFilename) < 1) {
|
||||
|
@ -1248,9 +1248,9 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
payload.keytype = 0;
|
||||
|
||||
num_to_bytes(e_sector[i].Key[0], 6, payload.key); // KEY A
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t) );
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) continue;
|
||||
|
@ -1277,13 +1277,13 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
conn.block_after_ACK = true;
|
||||
for (int i = 0; i < SectorsCnt; i++) {
|
||||
mfEmlGetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
|
||||
|
||||
if (e_sector[i].foundKey[0])
|
||||
num_to_bytes(e_sector[i].Key[0], 6, keyBlock);
|
||||
|
||||
|
||||
if (e_sector[i].foundKey[1])
|
||||
num_to_bytes(e_sector[i].Key[1], 6, &keyBlock[10]);
|
||||
|
||||
|
||||
if (i == SectorsCnt - 1) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
|
@ -2012,9 +2012,9 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
|||
payload.keytype = 0;
|
||||
|
||||
num_to_bytes(e_sector[i].Key[0], 6, payload.key); // KEY A
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t) );
|
||||
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) continue;
|
||||
|
@ -2265,15 +2265,15 @@ static int CmdHF14AMfSim(const char *Cmd) {
|
|||
, flags);
|
||||
|
||||
struct {
|
||||
uint16_t flags;
|
||||
uint8_t exitAfter;
|
||||
uint8_t uid[10];
|
||||
uint16_t flags;
|
||||
uint8_t exitAfter;
|
||||
uint8_t uid[10];
|
||||
} PACKED payload;
|
||||
|
||||
|
||||
payload.flags = flags;
|
||||
payload.exitAfter = exitAfterNReads;
|
||||
memcpy(payload.uid, uid, uidlen);
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SIMULATE_MIFARE_CARD, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
|
@ -2540,7 +2540,7 @@ static int CmdHF14AMfESet(const char *Cmd) {
|
|||
char c = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 3 || c == 'h')
|
||||
return usage_hf14_eset();
|
||||
|
||||
|
||||
uint8_t memBlock[16];
|
||||
memset(memBlock, 0x00, sizeof(memBlock));
|
||||
|
||||
|
@ -2914,7 +2914,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
size_t datalen = 0;
|
||||
int res = 0;
|
||||
if (fillFromBin) {
|
||||
|
@ -3186,7 +3186,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
param_gethex_ex(Cmd, 3, data, &len);
|
||||
len >>= 1;
|
||||
tryDecryptWord(nt, ar_enc, at_enc, data, len);
|
||||
|
@ -3215,15 +3215,15 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
|
|||
|
||||
uint8_t data[7];
|
||||
data[0] = mod;
|
||||
memcpy(data+1, key, 6);
|
||||
memcpy(data + 1, key, 6);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_SETMOD, data, sizeof(data));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_MIFARE_SETMOD, &resp, 1500)) {
|
||||
|
||||
if (resp.status == PM3_SUCCESS)
|
||||
|
||||
if (resp.status == PM3_SUCCESS)
|
||||
PrintAndLogEx(SUCCESS, "Success");
|
||||
else
|
||||
PrintAndLogEx(FAILED, "Failed");
|
||||
|
|
|
@ -417,7 +417,7 @@ static int CmdLCD(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdLCDReset(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LCD_RESET, NULL, 0);
|
||||
return PM3_SUCCESS;
|
||||
|
@ -532,7 +532,7 @@ static int CmdConnect(const char *Cmd) {
|
|||
uint32_t baudrate = USART_BAUD_RATE;
|
||||
uint8_t cmdp = 0;
|
||||
char port[FILE_PATH_SIZE] = {0};
|
||||
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
|
@ -553,7 +553,7 @@ static int CmdConnect(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// default back to previous used serial port
|
||||
if (strlen(port) == 0) {
|
||||
if (strlen((char *)conn.serial_port_name) == 0) {
|
||||
|
|
|
@ -201,18 +201,18 @@ int CmdLFCommandRead(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Sending");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, (uint8_t*)&payload, 8 + datalen );
|
||||
SendCommandNG(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, (uint8_t *)&payload, 8 + datalen);
|
||||
|
||||
printf("\n");
|
||||
uint8_t i = 10;
|
||||
while ( !WaitForResponseTimeout(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, NULL, 2000 ) && i != 0) {
|
||||
while (!WaitForResponseTimeout(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, NULL, 2000) && i != 0) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
i--;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if ( i ) {
|
||||
if (i) {
|
||||
PrintAndLogEx(SUCCESS, "Downloading response signal data");
|
||||
getSamples(0, true);
|
||||
return PM3_SUCCESS;
|
||||
|
@ -391,7 +391,7 @@ int lf_read(bool silent, uint32_t samples) {
|
|||
}
|
||||
|
||||
// resp.oldarg[0] is bits read not bytes read.
|
||||
uint32_t bits = (resp.data.asDwords[0] / 8 );
|
||||
uint32_t bits = (resp.data.asDwords[0] / 8);
|
||||
getSamples(bits, silent);
|
||||
|
||||
return PM3_SUCCESS;
|
||||
|
@ -449,7 +449,7 @@ static void ChkBitstream() {
|
|||
for (int i = 0; i < (int)(GraphTraceLen / 2); i++) {
|
||||
if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
|
||||
CmdGetBitStream("");
|
||||
PrintAndLogEx(INFO, "Converted to bitstream");
|
||||
PrintAndLogEx(INFO, "Converted to bitstream");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ int CmdLFSim(const char *Cmd) {
|
|||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
// sanity check
|
||||
if ( GraphTraceLen < 20 ) {
|
||||
if (GraphTraceLen < 20) {
|
||||
PrintAndLogEx(ERR, "No data in Graphbuffer");
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
|
@ -482,8 +482,8 @@ int CmdLFSim(const char *Cmd) {
|
|||
uint8_t data[PM3_CMD_DATA_SIZE - 3];
|
||||
} PACKED payload_up;
|
||||
|
||||
// flag =
|
||||
// b0 0
|
||||
// flag =
|
||||
// b0 0
|
||||
// 1 clear bigbuff
|
||||
payload_up.flag = 0x1;
|
||||
|
||||
|
@ -497,10 +497,10 @@ int CmdLFSim(const char *Cmd) {
|
|||
clearCommandBuffer();
|
||||
payload_up.offset = i;
|
||||
|
||||
for(uint16_t j = 0; j < len; j++)
|
||||
payload_up.data[j] = GraphBuffer[i+j];
|
||||
for (uint16_t j = 0; j < len; j++)
|
||||
payload_up.data[j] = GraphBuffer[i + j];
|
||||
|
||||
|
||||
|
||||
SendCommandNG(CMD_UPLOAD_SIM_SAMPLES_125K, (uint8_t *)&payload_up, sizeof(struct pupload));
|
||||
WaitForResponse(CMD_UPLOAD_SIM_SAMPLES_125K, NULL);
|
||||
printf(".");
|
||||
|
@ -519,7 +519,7 @@ int CmdLFSim(const char *Cmd) {
|
|||
uint16_t gap;
|
||||
} PACKED payload;
|
||||
payload.len = GraphTraceLen;
|
||||
payload.gap = gap;
|
||||
payload.gap = gap;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SIMULATE_TAG_125K, (uint8_t *)&payload, sizeof(payload));
|
||||
|
|
|
@ -332,7 +332,7 @@ static int CmdAWIDSim(const char *Cmd) {
|
|||
|
||||
verify_values(&fmtlen, &fc, &cn);
|
||||
|
||||
if ( getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS ) {
|
||||
if (getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ static int CmdAWIDClone(const char *Cmd) {
|
|||
|
||||
verify_values(&fmtlen, &fc, &cn);
|
||||
|
||||
if ( getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS ) {
|
||||
if (getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -512,12 +512,12 @@ static int CmdAWIDBrute(const char *Cmd) {
|
|||
|
||||
// Do one up
|
||||
if (up < 0xFFFF)
|
||||
if ( sendTry(fmtlen, fc, up++, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT;
|
||||
if (sendTry(fmtlen, fc, up++, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT;
|
||||
|
||||
// Do one down (if cardnumber is given)
|
||||
if (cn > 1)
|
||||
if (down > 1)
|
||||
if ( sendTry(fmtlen, fc, --down, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT;
|
||||
if (sendTry(fmtlen, fc, --down, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ int getAWIDBits(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint8_t *bits) {
|
|||
// add AWID 4bit parity
|
||||
size_t bitLen = addParity(pre, bits + 8, 66, 4, 1);
|
||||
|
||||
if (bitLen != 88)
|
||||
if (bitLen != 88)
|
||||
return PM3_ESOFT;
|
||||
|
||||
PrintAndLogEx(SUCCESS, "awid raw bits:\n %s \n", sprint_bin(bits, bitLen));
|
||||
|
|
|
@ -36,7 +36,7 @@ static int CmdCOTAGDemod(const char *Cmd) {
|
|||
|
||||
uint8_t alignPos = 0;
|
||||
uint16_t err = manrawdecode(bits, &bitlen, 1, &alignPos);
|
||||
if (err > 50 ) {
|
||||
if (err > 50) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - COTAG too many errors: %d", err);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ static void ConstructEM410xEmulGraph(const char *uid, const uint8_t clock) {
|
|||
/* clear our graph */
|
||||
ClearGraph(true);
|
||||
|
||||
/* write 16 zero bit sledge */
|
||||
/* write 16 zero bit sledge */
|
||||
for (i = 0; i < 20; i++)
|
||||
AppendGraph(false, clock, 0);
|
||||
|
||||
|
@ -387,12 +387,12 @@ int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
|
|||
bool st = true;
|
||||
|
||||
// em410x simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again
|
||||
if ( isGraphBitstream() ) {
|
||||
if (isGraphBitstream()) {
|
||||
convertGraphFromBitstream();
|
||||
}
|
||||
|
||||
if (ASKDemod_ext(Cmd, false, false, 1, &st) != PM3_SUCCESS)
|
||||
return PM3_ESOFT;
|
||||
if (ASKDemod_ext(Cmd, false, false, 1, &st) != PM3_SUCCESS)
|
||||
return PM3_ESOFT;
|
||||
return AskEm410xDecode(verbose, hi, lo);
|
||||
}
|
||||
/*
|
||||
|
@ -416,8 +416,8 @@ static int CmdEM410xDemod(const char *Cmd) {
|
|||
uint32_t hi = 0;
|
||||
uint64_t lo = 0;
|
||||
|
||||
if (AskEm410xDemod(Cmd, &hi, &lo, true) != PM3_SUCCESS)
|
||||
return PM3_ESOFT;
|
||||
if (AskEm410xDemod(Cmd, &hi, &lo, true) != PM3_SUCCESS)
|
||||
return PM3_ESOFT;
|
||||
|
||||
g_em410xid = lo;
|
||||
return PM3_SUCCESS;
|
||||
|
@ -1097,7 +1097,7 @@ static int setDemodBufferEM(uint32_t *word, size_t idx) {
|
|||
uint8_t parity[45] = {0};
|
||||
memcpy(parity, DemodBuffer, 45);
|
||||
if (!EM_EndParityTest(DemodBuffer + idx + EM_PREAMBLE_LEN, 45, 5, 9, 0)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - End Parity check failed");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - End Parity check failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -1140,16 +1140,16 @@ static int demodEM4x05resp(uint32_t *word) {
|
|||
//////////////// 4205 / 4305 commands
|
||||
static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
|
||||
|
||||
struct {
|
||||
struct {
|
||||
uint32_t password;
|
||||
uint8_t address;
|
||||
uint8_t usepwd;
|
||||
} PACKED payload;
|
||||
|
||||
|
||||
payload.password = pwd;
|
||||
payload.address = addr;
|
||||
payload.usepwd = usePwd;
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_EM4X_READ_WORD, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
|
@ -1250,20 +1250,20 @@ static int CmdEM4x05Write(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "Writing address %d data %08X using password %08X", addr, data, pwd);
|
||||
}
|
||||
|
||||
struct {
|
||||
struct {
|
||||
uint32_t password;
|
||||
uint32_t data;
|
||||
uint8_t address;
|
||||
uint8_t usepwd;
|
||||
} PACKED payload;
|
||||
|
||||
|
||||
payload.password = pwd;
|
||||
payload.data = data;
|
||||
payload.address = addr;
|
||||
payload.usepwd = usePwd;
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_EM4X_WRITE_WORD, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_EM4X_WRITE_WORD, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_EM4X_WRITE_WORD, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
|
@ -1493,7 +1493,7 @@ static int CmdEM4x05Info(const char *Cmd) {
|
|||
}
|
||||
|
||||
//something went wrong
|
||||
if (!(word & 0x8000))
|
||||
if (!(word & 0x8000))
|
||||
return PM3_ESOFT;
|
||||
|
||||
printEM4x05ProtectionBits(word);
|
||||
|
|
|
@ -336,7 +336,7 @@ static int CmdFdxSim(const char *Cmd) {
|
|||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_ASK_SIM_TAG, (uint8_t *)payload, sizeof(lf_asksim_t) + sizeof(bs));
|
||||
free(payload);
|
||||
|
||||
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ASK_SIM_TAG, &resp);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ static int CmdHIDDemod(const char *Cmd) {
|
|||
(void)Cmd; // Cmd is not used so far
|
||||
|
||||
// HID simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again
|
||||
if ( isGraphBitstream() ) {
|
||||
if (isGraphBitstream()) {
|
||||
convertGraphFromBitstream();
|
||||
}
|
||||
|
||||
|
@ -593,7 +593,7 @@ static int CmdHIDBrute(const char *Cmd) {
|
|||
|
||||
// Do one up
|
||||
if (up < 0xFFFF)
|
||||
if ( sendTry(fmtlen, fc, up++, delay, bits, verbose) != PM3_SUCCESS) return PM3_ESOFT;
|
||||
if (sendTry(fmtlen, fc, up++, delay, bits, verbose) != PM3_SUCCESS) return PM3_ESOFT;
|
||||
|
||||
// Do one down (if cardnumber is given)
|
||||
if (cn > 1)
|
||||
|
|
|
@ -175,7 +175,7 @@ static int CmdKeriClone(const char *Cmd) {
|
|||
static int CmdKeriSim(const char *Cmd) {
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h')
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h')
|
||||
return usage_lf_keri_sim();
|
||||
|
||||
uint64_t internalid = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
|
|
@ -151,7 +151,7 @@ static int CmdPrescoSim(const char *Cmd) {
|
|||
uint32_t sitecode = 0, usercode = 0, fullcode = 0;
|
||||
bool Q5 = false;
|
||||
// get wiegand from printed number.
|
||||
if (getWiegandFromPresco(Cmd, &sitecode, &usercode, &fullcode, &Q5) == PM3_EINVARG)
|
||||
if (getWiegandFromPresco(Cmd, &sitecode, &usercode, &fullcode, &Q5) == PM3_EINVARG)
|
||||
return usage_lf_presco_sim();
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Presco - SiteCode: %u, UserCode: %u, FullCode: %08X", sitecode, usercode, fullcode);
|
||||
|
|
|
@ -265,7 +265,7 @@ static int CmdPyramidSim(const char *Cmd) {
|
|||
|
||||
uint8_t bs[128];
|
||||
memset(bs, 0x00, sizeof(bs));
|
||||
|
||||
|
||||
if (sscanf(Cmd, "%u %u", &fc, &cn) != 2) return usage_lf_pyramid_sim();
|
||||
|
||||
facilitycode = (fc & 0x000000FF);
|
||||
|
@ -331,7 +331,8 @@ int getPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
|
|||
// Get 26 wiegand from FacilityCode, CardNumber
|
||||
uint8_t wiegand[24];
|
||||
memset(wiegand, 0x00, sizeof(wiegand));
|
||||
num_to_bytebits(fc, 8, wiegand); num_to_bytebits(cn, 16, wiegand + 8);
|
||||
num_to_bytebits(fc, 8, wiegand);
|
||||
num_to_bytebits(cn, 16, wiegand + 8);
|
||||
|
||||
// add wiegand parity bits (dest, source, len)
|
||||
wiegand_add_parity(pre + 80, wiegand, 24);
|
||||
|
|
|
@ -21,7 +21,7 @@ static int CmdSecurakeyDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ASK/Manchester Demod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (st)
|
||||
if (st)
|
||||
return PM3_ESOFT;
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
|
|
|
@ -564,7 +564,7 @@ bool tryDetectModulation(void) {
|
|||
ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, &firstClockEdge);
|
||||
|
||||
if (ans && ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5))) {
|
||||
if ( (FSKrawDemod("0 0", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ((FSKrawDemod("0 0", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_FSK;
|
||||
if (fc1 == 8 && fc2 == 5)
|
||||
tests[hits].modulation = DEMOD_FSK1a;
|
||||
|
@ -576,7 +576,7 @@ bool tryDetectModulation(void) {
|
|||
tests[hits].ST = false;
|
||||
++hits;
|
||||
}
|
||||
if ( (FSKrawDemod("0 1", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ((FSKrawDemod("0 1", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_FSK;
|
||||
if (fc1 == 8 && fc2 == 5)
|
||||
tests[hits].modulation = DEMOD_FSK1;
|
||||
|
@ -661,7 +661,7 @@ bool tryDetectModulation(void) {
|
|||
save_restoreGB(GRAPH_SAVE);
|
||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
CmdLtrim("160");
|
||||
if ( (PSKDemod("0 0 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ((PSKDemod("0 0 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK1;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
|
@ -1538,7 +1538,7 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
|
|||
payload.pwdmode = pwdmode;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_T55XX_READ_BLOCK, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_T55XX_READ_BLOCK, (uint8_t *)&payload, sizeof(payload));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_READ_BLOCK, NULL, 2500)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
return false;
|
||||
|
|
|
@ -312,7 +312,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, _RED_("WARNING: process only if strictly needed!"));
|
||||
PrintAndLogEx(WARNING, "This requires BT turned ON and NOT connected!");
|
||||
PrintAndLogEx(WARNING, "Is the add-on blue light blinking? (Say 'n' if you want to abort) [y/n]");
|
||||
while(!ukbhit()) {
|
||||
while (!ukbhit()) {
|
||||
msleep(200);
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
|
||||
if ((baudrate != USART_BAUD_RATE) || (parity != USART_PARITY)) {
|
||||
PrintAndLogEx(WARNING, "Add-on uart settings changed, please turn BT add-on OFF and ON again, then press any key.");
|
||||
while(!ukbhit()) {
|
||||
while (!ukbhit()) {
|
||||
msleep(200);
|
||||
}
|
||||
int gc = getchar();
|
||||
|
|
|
@ -603,7 +603,7 @@ int TestProxmark(void) {
|
|||
bool error = false;
|
||||
if (len)
|
||||
error = memcmp(data, resp.data.asBytes, len) != 0;
|
||||
|
||||
|
||||
if (error)
|
||||
return PM3_EIO;
|
||||
|
||||
|
@ -611,7 +611,7 @@ int TestProxmark(void) {
|
|||
if (WaitForResponseTimeoutW(CMD_CAPABILITIES, &resp, 1000, false) == 0) {
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
if ((resp.length != sizeof(pm3_capabilities)) || (resp.data.asBytes[0] != CAPABILITIES_VERSION)) {
|
||||
PrintAndLogEx(ERR, _RED_("Capabilities structure version sent by Proxmark3 is not the same as the one used by the client!"));
|
||||
PrintAndLogEx(ERR, _RED_("Please flash the Proxmark with the same version as the client."));
|
||||
|
@ -621,9 +621,9 @@ int TestProxmark(void) {
|
|||
memcpy(&pm3_capabilities, resp.data.asBytes, MIN(sizeof(capabilities_t), resp.length));
|
||||
conn.send_via_fpc_usart = pm3_capabilities.via_fpc;
|
||||
conn.uart_speed = pm3_capabilities.baudrate;
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "Communicating with PM3 over %s", conn.send_via_fpc_usart ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"));
|
||||
|
||||
|
||||
if (conn.send_via_fpc_usart) {
|
||||
PrintAndLogEx(INFO, "PM3 UART serial baudrate: " _YELLOW_("%u") "\n", conn.uart_speed);
|
||||
} else {
|
||||
|
|
|
@ -105,13 +105,13 @@ bool isGraphBitstream(void) {
|
|||
return true;
|
||||
}
|
||||
void convertGraphFromBitstream() {
|
||||
convertGraphFromBitstreamEx(1, 0);
|
||||
convertGraphFromBitstreamEx(1, 0);
|
||||
}
|
||||
void convertGraphFromBitstreamEx(int hi, int low) {
|
||||
for (int i = 0; i < GraphTraceLen; i++) {
|
||||
if (GraphBuffer[i] == hi)
|
||||
GraphBuffer[i] = 127;
|
||||
else if ( GraphBuffer[i] == low )
|
||||
else if (GraphBuffer[i] == low)
|
||||
GraphBuffer[i] = -127;
|
||||
else
|
||||
GraphBuffer[i] = 0;
|
||||
|
|
|
@ -173,7 +173,7 @@ function Command:sendNG( ignore_response, timeout )
|
|||
|
||||
data = nil
|
||||
cmd = nil
|
||||
local count, length, magic, status, crc, arg0, arg1, arg2
|
||||
local count, length, magic, status, crc, arg0, arg1, arg2
|
||||
|
||||
count, cmd, length, magic, status, crc, arg0, arg1, arg2 = bin.unpack('SSIsSLLL', response)
|
||||
count, data, ng = bin.unpack('H'..length..'C', response, count)
|
||||
|
|
|
@ -455,13 +455,13 @@ int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount) {
|
|||
uint8_t blockno;
|
||||
uint8_t blockcnt;
|
||||
} PACKED payload;
|
||||
|
||||
|
||||
payload.blockno = blockNum;
|
||||
payload.blockcnt = blocksCount;
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_EML_MEMGET, (uint8_t*)&payload, sizeof(payload));
|
||||
|
||||
SendCommandNG(CMD_MIFARE_EML_MEMGET, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_MIFARE_EML_MEMGET, &resp, 1500) == 0) {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
|
@ -479,14 +479,14 @@ int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
|
|||
}
|
||||
|
||||
int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {
|
||||
|
||||
|
||||
struct p {
|
||||
uint8_t blockno;
|
||||
uint8_t blockcnt;
|
||||
uint8_t blockwidth;
|
||||
uint8_t data[];
|
||||
} PACKED;
|
||||
|
||||
|
||||
size_t size = blocksCount * blockBtWidth;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(struct p))) {
|
||||
return PM3_ESOFT;
|
||||
|
@ -497,9 +497,9 @@ int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidt
|
|||
payload->blockcnt = blocksCount;
|
||||
payload->blockwidth = blockBtWidth;
|
||||
memcpy(payload->data, data, size);
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_EML_MEMSET, (uint8_t*)payload, sizeof(payload) + size );
|
||||
SendCommandNG(CMD_MIFARE_EML_MEMSET, (uint8_t *)payload, sizeof(payload) + size);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -963,7 +963,7 @@ int detect_classic_nackbug(bool verbose) {
|
|||
|
||||
if (WaitForResponseTimeout(CMD_MIFARE_NACK_DETECT, &resp, 500)) {
|
||||
|
||||
if ( resp.status == PM3_EOPABORTED ) {
|
||||
if (resp.status == PM3_EOPABORTED) {
|
||||
PrintAndLogEx(WARNING, "button pressed. Aborted.");
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ void detect_classic_magic(void) {
|
|||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MIFARE_CIDENT, NULL, 0);
|
||||
if (WaitForResponseTimeout(CMD_MIFARE_CIDENT, &resp, 1500)) {
|
||||
if ( resp.status == PM3_SUCCESS )
|
||||
if (resp.status == PM3_SUCCESS)
|
||||
isGeneration = resp.data.asBytes[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -160,12 +160,11 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
|||
} else {
|
||||
rl_event_hook = check_comm;
|
||||
if (session.pm3_present) {
|
||||
if ( conn.send_via_fpc_usart == false )
|
||||
if (conn.send_via_fpc_usart == false)
|
||||
cmd = readline(PROXPROMPT_USB);
|
||||
else
|
||||
else
|
||||
cmd = readline(PROXPROMPT_FPC);
|
||||
}
|
||||
else
|
||||
} else
|
||||
cmd = readline(PROXPROMPT_OFFLINE);
|
||||
|
||||
fflush(NULL);
|
||||
|
|
|
@ -254,7 +254,7 @@ local function test(modulation)
|
|||
local p_config_cmd = process_block0_cmds[_]
|
||||
local errors = 0
|
||||
core.clearCommandBuffer()
|
||||
|
||||
|
||||
-- Write Config block
|
||||
dbg(('lf t55xx write b 0 d %s'):format(p_config_cmd))
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ bool preambleSearchEx(uint8_t *bits, uint8_t *preamble, size_t pLen, size_t *siz
|
|||
if (foundCnt == 1) {
|
||||
prnt("DEBUG: (preambleSearchEx) preamble found at %i", idx);
|
||||
*startIdx = idx;
|
||||
if (findone)
|
||||
if (findone)
|
||||
return true;
|
||||
}
|
||||
if (foundCnt == 2) {
|
||||
|
@ -1467,7 +1467,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
|
|||
} else if (bits[i] <= low && !waveHigh) {
|
||||
smplCnt++;
|
||||
} else {
|
||||
//transition
|
||||
//transition
|
||||
if ((bits[i] >= high && !waveHigh) || (bits[i] <= low && waveHigh)) {
|
||||
|
||||
// 8 :: 8-2-1 = 5 8+2+1 = 11
|
||||
|
@ -1476,7 +1476,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
|
|||
// 64 :: 64-16-1 = 47 64+16+1 = 81
|
||||
if (smplCnt > clk - cl_4 - 1) { //full clock
|
||||
|
||||
if (smplCnt > clk + cl_4 + 1) {
|
||||
if (smplCnt > clk + cl_4 + 1) {
|
||||
//too many samples
|
||||
errCnt++;
|
||||
if (g_debugMode == 2) prnt("DEBUG ASK: cleanAskRawDemod ASK Modulation Error FULL at: %u [%u > %u]", i, smplCnt, clk + cl_4 + 1);
|
||||
|
@ -1490,7 +1490,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
|
|||
}
|
||||
if (*startIdx == 0) {
|
||||
*startIdx = i - clk;
|
||||
prnt("DEBUG ASK: cleanAskRawDemod minus clock [%d]", *startIdx);
|
||||
prnt("DEBUG ASK: cleanAskRawDemod minus clock [%d]", *startIdx);
|
||||
}
|
||||
waveHigh = !waveHigh;
|
||||
smplCnt = 0;
|
||||
|
@ -1511,7 +1511,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
|
|||
}
|
||||
if (*startIdx == 0) {
|
||||
*startIdx = i - cl_2;
|
||||
prnt("DEBUG ASK: cleanAskRawDemod minus half clock [%d]", *startIdx);
|
||||
prnt("DEBUG ASK: cleanAskRawDemod minus half clock [%d]", *startIdx);
|
||||
}
|
||||
waveHigh = !waveHigh;
|
||||
smplCnt = 0;
|
||||
|
@ -1527,10 +1527,10 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
|
|||
|
||||
*size = bitCnt;
|
||||
|
||||
/*
|
||||
if (*startIdx < 0)
|
||||
*startIdx = 0;
|
||||
*/
|
||||
/*
|
||||
if (*startIdx < 0)
|
||||
*startIdx = 0;
|
||||
*/
|
||||
|
||||
if (g_debugMode == 2) prnt("DEBUG ASK: cleanAskRawDemod Startidx %d", *startIdx);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ void usart_init(uint32_t baudrate, uint8_t parity) {
|
|||
AT91C_US_NBSTOP_1_BIT | // 1 stop bit
|
||||
AT91C_US_CHMODE_NORMAL; // channel mode: normal
|
||||
|
||||
switch(usart_parity) {
|
||||
switch (usart_parity) {
|
||||
case 'N':
|
||||
mode |= AT91C_US_PAR_NONE; // parity: none
|
||||
break;
|
||||
|
@ -228,12 +228,12 @@ void usart_init(uint32_t baudrate, uint8_t parity) {
|
|||
// baudrate == selected clock/16/CD
|
||||
// OVER = 1, -yes we are oversampling
|
||||
// baudrate == selected clock/8/CD --> this is ours
|
||||
//
|
||||
//
|
||||
uint32_t brgr = 48000000 / (usart_baudrate << 3);
|
||||
// doing fp = round((mck / (usart_baudrate << 3) - brgr) * 8) with integers:
|
||||
uint32_t fp = ((16 * 48000000 / (usart_baudrate << 3) - 16 * brgr)+1)/2;
|
||||
uint32_t fp = ((16 * 48000000 / (usart_baudrate << 3) - 16 * brgr) + 1) / 2;
|
||||
|
||||
pUS1->US_BRGR = (fp << 16) | brgr;
|
||||
pUS1->US_BRGR = (fp << 16) | brgr;
|
||||
|
||||
// Write the Timeguard Register
|
||||
pUS1->US_TTGR = 0;
|
||||
|
|
|
@ -57,7 +57,7 @@ extern uint32_t FLASHMEM_SPIBAUDRATE;
|
|||
// 0x3D000 - 1 4kb sector = default T55XX keys dictionary
|
||||
// 0x3B000 - 1 4kb sector = default ICLASS keys dictionary
|
||||
// 0x39000 - 2 4kb sectors = default MFC keys dictionary
|
||||
//
|
||||
//
|
||||
#ifndef FLASH_MEM_BLOCK_SIZE
|
||||
# define FLASH_MEM_BLOCK_SIZE 256
|
||||
#endif
|
||||
|
|
|
@ -204,9 +204,9 @@ typedef struct {
|
|||
} PACKED lf_psksim_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t blockno;
|
||||
uint8_t keytype;
|
||||
uint8_t key[6];
|
||||
uint8_t blockno;
|
||||
uint8_t keytype;
|
||||
uint8_t key[6];
|
||||
} PACKED mf_readblock_t;
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
|||
|
||||
struct addrinfo info;
|
||||
|
||||
memset (&info, 0, sizeof(info));
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
info.ai_socktype = SOCK_STREAM;
|
||||
|
||||
|
@ -249,7 +249,7 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
|
|||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
if ( newtimeout_pending ) {
|
||||
if (newtimeout_pending) {
|
||||
timeout.tv_usec = newtimeout_value * 1000;
|
||||
newtimeout_pending = false;
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ int uart_send(const serial_port sp, const uint8_t *pbtTx, const uint32_t len) {
|
|||
uint32_t pos = 0;
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
|
||||
while (pos < len) {
|
||||
// Reset file descriptor
|
||||
FD_ZERO(&rfds);
|
||||
|
|
|
@ -58,7 +58,7 @@ int uart_reconfigure_timeouts(uint32_t value) {
|
|||
}
|
||||
|
||||
static int uart_reconfigure_timeouts_polling(serial_port sp) {
|
||||
if ( newtimeout_pending == false )
|
||||
if (newtimeout_pending == false)
|
||||
return PM3_SUCCESS;
|
||||
newtimeout_pending = false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue