mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
style
This commit is contained in:
parent
7afe2dab8c
commit
2d9c1a941c
6 changed files with 264 additions and 296 deletions
|
@ -90,8 +90,7 @@ void RunMod(void) {
|
|||
while (1) {
|
||||
SpinDelay(200);
|
||||
LED_B_OFF();
|
||||
if (BUTTON_HELD(500) > 0)
|
||||
{
|
||||
if (BUTTON_HELD(500) > 0) {
|
||||
LEDsoff();
|
||||
Dbprintf("Quiting");
|
||||
return;
|
||||
|
@ -100,18 +99,15 @@ void RunMod(void) {
|
|||
res = SendDataTag(cmd, 4, true, true, recv, sizeof(recv), start_time, ISO15693_READER_TIMEOUT, &eof_time, &recvLen);
|
||||
if (res < 0)
|
||||
continue;
|
||||
if (recvLen<10) // error: recv too short
|
||||
{
|
||||
if (recvLen < 10) { // error: recv too short
|
||||
Dbprintf("recvLen<10");
|
||||
continue;
|
||||
}
|
||||
if (!CheckCrc15(recv,recvLen)) // error crc not valid
|
||||
{
|
||||
if (!CheckCrc15(recv, recvLen)) { // error crc not valid
|
||||
Dbprintf("crc failed");
|
||||
continue;
|
||||
}
|
||||
if (recv[0] & ISO15_RES_ERROR) // received error from tag
|
||||
{
|
||||
if (recv[0] & ISO15_RES_ERROR) { // received error from tag
|
||||
Dbprintf("error received");
|
||||
continue;
|
||||
}
|
||||
|
@ -126,13 +122,11 @@ void RunMod(void) {
|
|||
tag->dsfid = recv[i++];
|
||||
if (recv[1] & 0x02)
|
||||
tag->afi = recv[i++];
|
||||
if (recv[1] & 0x04)
|
||||
{
|
||||
if (recv[1] & 0x04) {
|
||||
tag->pagesCount = recv[i++] + 1;
|
||||
tag->bytesPerPage = recv[i++] + 1;
|
||||
}
|
||||
else
|
||||
{ // Set default tag values (if can't be readed in SYSINFO)
|
||||
} else {
|
||||
// Set default tag values (if can't be readed in SYSINFO)
|
||||
tag->bytesPerPage = 4;
|
||||
tag->pagesCount = 128;
|
||||
}
|
||||
|
@ -157,23 +151,19 @@ void RunMod(void) {
|
|||
start_time = eof_time;
|
||||
res = SendDataTag(cmd, 5, false, true, recv, sizeof(recv), start_time, ISO15693_READER_TIMEOUT, &eof_time, &recvLen);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
if (res < 0) {
|
||||
SpinDelay(100);
|
||||
continue;
|
||||
}
|
||||
if (recvLen < 4 + tag->bytesPerPage) // error: recv too short
|
||||
{
|
||||
if (recvLen < 4 + tag->bytesPerPage) { // error: recv too short
|
||||
Dbprintf("recvLen < 4 + tag->bytesPerPage");
|
||||
continue;
|
||||
}
|
||||
if (!CheckCrc15(recv,recvLen)) // error crc not valid
|
||||
{
|
||||
if (!CheckCrc15(recv, recvLen)) { // error crc not valid
|
||||
Dbprintf("crc failed");
|
||||
continue;
|
||||
}
|
||||
if (recv[0] & ISO15_RES_ERROR) // received error from tag
|
||||
{
|
||||
if (recv[0] & ISO15_RES_ERROR) { // received error from tag
|
||||
Dbprintf("error received");
|
||||
continue;
|
||||
}
|
||||
|
@ -185,8 +175,7 @@ void RunMod(void) {
|
|||
}
|
||||
|
||||
LEDsoff();
|
||||
if (retry >= 8)
|
||||
{
|
||||
if (retry >= 8) {
|
||||
Dbprintf("Max retry attemps exeeded");
|
||||
Dbprintf("-=[ exit ]=-");
|
||||
return;
|
||||
|
|
|
@ -1332,8 +1332,7 @@ static int RAMFUNC Handle15693SampleFromReader(bool bit, DecodeReader_t *reader)
|
|||
reader->posCount = -4;
|
||||
}
|
||||
|
||||
if (reader->bitCount == 8)
|
||||
{
|
||||
if (reader->bitCount == 8) {
|
||||
reader->output[reader->byteCount++] = reader->shiftReg;
|
||||
if (reader->byteCount > reader->byteCountMax) {
|
||||
// buffer overflow, give up
|
||||
|
@ -2133,16 +2132,15 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
BigBuf_free_keep_EM();
|
||||
|
||||
iso15_tag_t *tag = (iso15_tag_t *) BigBuf_get_EM_addr();
|
||||
if (tag == NULL)
|
||||
{
|
||||
if (tag == NULL) {
|
||||
Dbprintf("Can't allocate emulator memory");
|
||||
reply_ng(CMD_HF_ISO15693_SIMULATE, PM3_EFAILED, NULL, 0);
|
||||
return;
|
||||
}
|
||||
if (uid != NULL) { // new tag (need initialization)
|
||||
uint8_t nullUid[8] = { 0 };
|
||||
if (memcmp(uid, nullUid, 8) != 0)
|
||||
{ // simulate a new tag bazed on client parameters
|
||||
if (memcmp(uid, nullUid, 8) != 0) {
|
||||
// simulate a new tag bazed on client parameters
|
||||
memcpy(tag->uid, uid, 8);
|
||||
tag->dsfid = 0;
|
||||
tag->dsfidLock = false;
|
||||
|
@ -2243,14 +2241,11 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
if (((crc & 0xff) != cmd[cmd_len - 2]) || ((crc >> 8) != cmd[cmd_len - 1])) {
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("CrcFail!, expected CRC=%02X%02X", crc & 0xff, crc >> 8);
|
||||
continue;
|
||||
}
|
||||
else if (g_dbglevel >= DBG_DEBUG)
|
||||
} else if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("CrcOK");
|
||||
}
|
||||
else if (g_dbglevel >= DBG_DEBUG)
|
||||
} else if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("CrcOK");
|
||||
}
|
||||
else if (g_dbglevel >= DBG_DEBUG)
|
||||
} else if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("CrcOK");
|
||||
|
||||
cmd_len -= 2; // remove the CRC from the cmd
|
||||
|
@ -2323,8 +2318,7 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
recv[1] = tag->dsfid;
|
||||
memcpy(&recv[2], tag->uid, 8);
|
||||
recvLen = 10;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ((cmd[0] & ISO15_REQ_SELECT) == ISO15_REQ_SELECT) {
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Selected Request");
|
||||
if (tag->state != TAG_STATE_SELECTED)
|
||||
|
@ -2337,10 +2331,9 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Addressed Request");
|
||||
if (cmd_len < cmdCpt + 8)
|
||||
continue;
|
||||
if (memcmp(&cmd[cmdCpt], tag->uid, 8) != 0)
|
||||
{
|
||||
if (cmd_len < cmdCpt+9 || memcmp(&cmd[cmdCpt+1], tag->uid, 8) != 0)
|
||||
{ // check uid even if manifacturer byte is present
|
||||
if (memcmp(&cmd[cmdCpt], tag->uid, 8) != 0) {
|
||||
if (cmd_len < cmdCpt + 9 || memcmp(&cmd[cmdCpt + 1], tag->uid, 8) != 0) {
|
||||
// check uid even if manifacturer byte is present
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Address don't match tag uid");
|
||||
if (cmd[1] == ISO15693_SELECT)
|
||||
tag->state = TAG_STATE_READY; // we are not anymore the selected TAG
|
||||
|
@ -2350,9 +2343,7 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
}
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Address match tag uid");
|
||||
cmdCpt += 8;
|
||||
}
|
||||
else if (tag->state == TAG_STATE_SILENCED)
|
||||
{
|
||||
} else if (tag->state == TAG_STATE_SILENCED) {
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Unaddressed request in quiet state: drop");
|
||||
continue; // drop unadressed request in quiet state
|
||||
}
|
||||
|
@ -2520,11 +2511,9 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("SetPassword cmd");
|
||||
if (cmd_len > cmdCpt + 5)
|
||||
cmdCpt++; // skip manifacturer code
|
||||
if (cmd_len > cmdCpt+4)
|
||||
{
|
||||
if (cmd_len > cmdCpt + 4) {
|
||||
pwdId = cmd[cmdCpt++];
|
||||
if (pwdId == 4) // Privacy password
|
||||
{
|
||||
if (pwdId == 4) { // Privacy password
|
||||
tag->privacyPasswd[0] = cmd[cmdCpt] ^ tag->random[0];
|
||||
tag->privacyPasswd[1] = cmd[cmdCpt + 1] ^ tag->random[1];
|
||||
tag->privacyPasswd[2] = cmd[cmdCpt + 2] ^ tag->random[0];
|
||||
|
@ -2569,8 +2558,7 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
if (tag->expectFsk) { // Not suppoted yet
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("%ERROR: FSK answers are not supported yet");
|
||||
//TransmitTo15693ReaderFSK(ts->buf,ts->max, &response_time, 0, !tag->expectFast);
|
||||
}
|
||||
else
|
||||
} else
|
||||
TransmitTo15693Reader(ts->buf, ts->max, &response_time, 0, !tag->expectFast);
|
||||
|
||||
LogTrace_ISO15693(recv, recvLen, response_time * 32, (response_time * 32) + (ts->max * 32 * 64), NULL, false);
|
||||
|
|
|
@ -536,8 +536,7 @@ static uint16_t arg_get_raw_flag(uint8_t uidlen, bool unaddressed, bool scan, bo
|
|||
if (uidlen == 8 || scan || unaddressed) {
|
||||
flags = (ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY);
|
||||
}
|
||||
if ((!unaddressed) || scan)
|
||||
{
|
||||
if ((!unaddressed) || scan) {
|
||||
flags |= ISO15_REQ_ADDRESS;
|
||||
}
|
||||
if (add_option) {
|
||||
|
@ -1278,8 +1277,7 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize, boo
|
|||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
if (blocksize == 0 || bytes == 0)
|
||||
{
|
||||
if (blocksize == 0 || bytes == 0) {
|
||||
PrintAndLogEx(INFO, "Tag is empty!");
|
||||
return;
|
||||
}
|
||||
|
@ -1432,8 +1430,7 @@ static int CmdHF15Sim(const char *Cmd) {
|
|||
}
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (uidlen == 0) // get UID from emulator
|
||||
{
|
||||
if (uidlen == 0) { // get UID from emulator
|
||||
// reserve memory
|
||||
iso15_tag_t *tag = calloc(1, sizeof(iso15_tag_t));
|
||||
if (tag == NULL) {
|
||||
|
@ -1847,21 +1844,18 @@ static int CmdHF15Dump(const char *Cmd) {
|
|||
tag->dsfid = d[dCpt++];
|
||||
if (d[1] & 0x02)
|
||||
tag->afi = d[dCpt++];
|
||||
if (d[1] & 0x04)
|
||||
{
|
||||
if (d[1] & 0x04) {
|
||||
tag->pagesCount = d[dCpt++] + 1;
|
||||
tag->bytesPerPage = d[dCpt++] + 1;
|
||||
}
|
||||
else
|
||||
{ // Set tag memory layout values (if can't be readed in SYSINFO)
|
||||
} else {
|
||||
// Set tag memory layout values (if can't be readed in SYSINFO)
|
||||
tag->bytesPerPage = blocksize;
|
||||
tag->pagesCount = 128;
|
||||
}
|
||||
if (d[1] & 0x08)
|
||||
tag->ic = d[dCpt++];
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
if (verbose) {
|
||||
print_emltag_info_15693(tag);
|
||||
}
|
||||
|
||||
|
|
|
@ -1662,32 +1662,28 @@
|
|||
"command": "hf 15 esave",
|
||||
"description": "Save emulator memory into two files (bin/json)",
|
||||
"notes": [
|
||||
"hf 15 esave -f hf-15-01020304hf 15 esave -b 8 -c 42 -f hf-15-01020304"
|
||||
"hf 15 esave -f hf-15-01020304"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help This help",
|
||||
"-f, --file <fn> Specify a filename for dump file",
|
||||
"--bsize <dec> block size (def 4)",
|
||||
"-c, --count <dec> number of blocks to export (def all)"
|
||||
"-f, --file <fn> Specify a filename for dump file"
|
||||
],
|
||||
"usage": "hf 15 esave [-h] -f <fn> [--bsize <dec>] [-c <dec>]"
|
||||
"usage": "hf 15 esave [-h] -f <fn>"
|
||||
},
|
||||
"hf 15 eview": {
|
||||
"command": "hf 15 eview",
|
||||
"description": "It displays emulator memory",
|
||||
"notes": [
|
||||
"hf 15 eview",
|
||||
"hf 15 eview -b 8 -c 60"
|
||||
"hf 15 eview -z"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help This help",
|
||||
"-b, --blocksize <dec> block size (def 4)",
|
||||
"-c, --count <dec> number of blocks to display (def all)",
|
||||
"-z, --dense dense dump output style"
|
||||
],
|
||||
"usage": "hf 15 eview [-hz] [-b <dec>] [-c <dec>]"
|
||||
"usage": "hf 15 eview [-hz]"
|
||||
},
|
||||
"hf 15 findafi": {
|
||||
"command": "hf 15 findafi",
|
||||
|
@ -1886,6 +1882,7 @@
|
|||
"command": "hf 15 sim",
|
||||
"description": "Simulate a ISO-15693 tag",
|
||||
"notes": [
|
||||
"hf 15 sim",
|
||||
"hf 15 sim -u E011223344556677"
|
||||
],
|
||||
"offline": false,
|
||||
|
@ -1894,7 +1891,7 @@
|
|||
"-u, --uid <hex> UID, 8 hex bytes",
|
||||
"-b, --blocksize <dec> block size (def 4)"
|
||||
],
|
||||
"usage": "hf 15 sim [-h] -u <hex> [-b <dec>]"
|
||||
"usage": "hf 15 sim [-h] [-u <hex>] [-b <dec>]"
|
||||
},
|
||||
"hf 15 slixeasdisable": {
|
||||
"command": "hf 15 slixeasdisable",
|
||||
|
@ -12341,6 +12338,6 @@
|
|||
"metadata": {
|
||||
"commands_extracted": 711,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2024-01-23T14:27:27"
|
||||
"extracted_on": "2024-01-24T17:12:09"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue