]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
fix 'hf iclass sim':
authorpwpiwi <pwpiwi@users.noreply.github.com>
Wed, 25 Sep 2019 12:24:36 +0000 (14:24 +0200)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Wed, 25 Sep 2019 12:24:36 +0000 (14:24 +0200)
* ignore standard iso15693 INVENTORY commands silently
* make iso15693 command decoder more strict (prevent decoding rubbish)
* re-enable sim 3

armsrc/iclass.c
armsrc/iso15693.c
client/cmdhficlass.c

index 23701540f1c50f0f29a1b16a010640ab96203524..2e3a4db896a3e296fc5cf5295071746672a7f8ed 100644 (file)
@@ -1128,6 +1128,9 @@ int doIClassSimulation(int simulationMode, uint8_t *reader_mac_buf) {
                                // Otherwise, we should answer 8bytes (block) + 2bytes CRC
                        }
 
+               } else if (receivedCmd[0] == 0x26 && len == 5) {
+                       // standard ISO15693 INVENTORY command. Ignore.
+
                } else {
                        // don't know how to handle this command
                        char debug_message[250]; // should be enough
index f33e0156cda0614154f45bc56694b1828dc39c86..dbc1ca4c4a48101331282c9f504e91e6a4dc1a4a 100644 (file)
@@ -827,6 +827,7 @@ static int inline __attribute__((always_inline)) Handle15693SampleFromReader(uin
                        break;
 
                case STATE_READER_RECEIVE_DATA_1_OUT_OF_4:
+                       bit = !!bit;
                        DecodeReader->posCount++;
                        if (DecodeReader->posCount == 1) {
                                DecodeReader->sum1 = bit;
@@ -839,17 +840,14 @@ static int inline __attribute__((always_inline)) Handle15693SampleFromReader(uin
                        }
                        if (DecodeReader->posCount == 8) {
                                DecodeReader->posCount = 0;
-                               int corr10 = DecodeReader->sum1 - DecodeReader->sum2;
-                               int corr01 = DecodeReader->sum2 - DecodeReader->sum1;
-                               int corr11 = (DecodeReader->sum1 + DecodeReader->sum2) / 2;
-                               if (corr01 > corr11 && corr01 > corr10) { // EOF
+                               if (DecodeReader->sum1 <= 1 && DecodeReader->sum2 >= 3) { // EOF
                                        LED_B_OFF(); // Finished receiving
                                        DecodeReaderReset(DecodeReader);
                                        if (DecodeReader->byteCount != 0) {
                                                return true;
                                        }
                                }
-                               if (corr10 > corr11) { // detected a 2bit position
+                               if (DecodeReader->sum1 >= 3 && DecodeReader->sum2 <= 1) { // detected a 2bit position
                                        DecodeReader->shiftReg >>= 2;
                                        DecodeReader->shiftReg |= (DecodeReader->bitCount << 6);
                                }
@@ -869,6 +867,7 @@ static int inline __attribute__((always_inline)) Handle15693SampleFromReader(uin
                        break;
 
                case STATE_READER_RECEIVE_DATA_1_OUT_OF_256:
+                       bit = !!bit;
                        DecodeReader->posCount++;
                        if (DecodeReader->posCount == 1) {
                                DecodeReader->sum1 = bit;
@@ -881,17 +880,14 @@ static int inline __attribute__((always_inline)) Handle15693SampleFromReader(uin
                        }
                        if (DecodeReader->posCount == 8) {
                                DecodeReader->posCount = 0;
-                               int corr10 = DecodeReader->sum1 - DecodeReader->sum2;
-                               int corr01 = DecodeReader->sum2 - DecodeReader->sum1;
-                               int corr11 = (DecodeReader->sum1 + DecodeReader->sum2) / 2;
-                               if (corr01 > corr11 && corr01 > corr10) { // EOF
+                               if (DecodeReader->sum1 <= 1 && DecodeReader->sum2 >= 3) { // EOF
                                        LED_B_OFF(); // Finished receiving
                                        DecodeReaderReset(DecodeReader);
                                        if (DecodeReader->byteCount != 0) {
                                                return true;
                                        }
                                }
-                               if (corr10 > corr11) { // detected the bit position
+                               if (DecodeReader->sum1 >= 3 && DecodeReader->sum2 <= 1) { // detected the bit position
                                        DecodeReader->shiftReg = DecodeReader->bitCount;
                                }
                                if (DecodeReader->bitCount == 255) { // we have a full byte
index 48b62b176b94e07002d221d89f12f9217b4ff7cb..6f7cc4a49ffddf869f7f260d87e2fce737d1e51b 100644 (file)
@@ -144,7 +144,7 @@ int CmdHFiClassSim(const char *Cmd) {
        uint8_t simType = 0;
        uint8_t CSN[8] = {0, 0, 0, 0, 0, 0, 0, 0};
 
-       if (strlen(Cmd)<1) {
+       if (strlen(Cmd) < 1) {
                return usage_hf_iclass_sim();
        }
        simType = param_get8ex(Cmd, 0, 0, 10);
@@ -157,7 +157,6 @@ int CmdHFiClassSim(const char *Cmd) {
                PrintAndLog("--simtype:%02x csn:%s", simType, sprint_hex(CSN, 8));
        }
 
-       uint8_t numberOfCSNs = 0;
        if (simType == ICLASS_SIM_MODE_READER_ATTACK) {
                UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}};
                UsbCommand resp = {0};
@@ -196,8 +195,8 @@ int CmdHFiClassSim(const char *Cmd) {
                saveFile("iclass_mac_attack", "bin", dump,datalen);
                free(dump);
 
-       } else if (simType == ICLASS_SIM_MODE_CSN || simType == ICLASS_SIM_MODE_CSN_DEFAULT) {
-               UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, numberOfCSNs}};
+       } else if (simType == ICLASS_SIM_MODE_CSN || simType == ICLASS_SIM_MODE_CSN_DEFAULT || simType == ICLASS_SIM_MODE_FULL) {
+               UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, 0}};
                memcpy(c.d.asBytes, CSN, 8);
                SendCommand(&c);
 
Impressum, Datenschutz