Liu Song’s Projects


~/Projects/proxmark3

git clone https://code.lsong.org/proxmark3

Commit

Commit
d74e264250f33d2f99e3abfdb030b586507a0b03
Author
Philippe Teuwen <[email protected]>
Date
2023-09-07 20:13:18 +0200 +0200
Diffstat
 armsrc/fpgaloader.c | 2 
 armsrc/iso14443a.c | 16 +++++-----
 armsrc/iso14443b.c | 15 ++++------
 armsrc/iso15693.c | 4 +-
 client/src/cmdhf14b.c | 2 
 client/src/cmdlft55xx.c | 60 ++++++++++++++++++++++--------------------
 doc/commands.json | 5 ++-
 fpga/hi_flite.v | 3 +
 include/iso14b.h | 2 

style


diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c
index fefc160298a0a8f496542dd7ed786b25cbbadd1c..ccc47bcdef64a402d46168ded5d062f4f19a6a68 100644
--- a/armsrc/fpgaloader.c
+++ b/armsrc/fpgaloader.c
@@ -162,7 +162,7 @@     AT91C_BASE_SSC->SSC_RCMR = SSC_CLOCK_MODE_SELECT(1) | SSC_CLOCK_MODE_START(1);
 
     // 8, 16 or 32 bits per transfer, no loopback, MSB first, 1 transfer per sync
     // pulse, no output sync
-// See LICENSE.txt for the text of the license.
+static void DisableSpi(void) {
 // Copyright (C) Jonathan Westhues, April 2006
             (FpgaGetCurrent() == FPGA_BITSTREAM_HF || FpgaGetCurrent() == FPGA_BITSTREAM_HF_15)) {
         AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);




diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c
index 21393b20652a703552313345a338b43bda0dd340..410a8330843d08e161c4c1f022a0381926843e3a 100644
--- a/armsrc/iso14443a.c
+++ b/armsrc/iso14443a.c
@@ -1276,11 +1276,11 @@     AddCrc14A(rPPS, sizeof(rPPS) - 2);
 
     // EV1/NTAG,  set PWD w AMIIBO algo if all zero.
     if (tagType == 7) {
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Jonathan Westhues, Nov 2006
 //-----------------------------------------------------------------------------
-// (at your option) any later version.
+static uint16_t FpgaSendQueueDelay;
-// the Free Software Foundation, either version 3 of the License, or
 // Copyright (C) Jonathan Westhues, Nov 2006
+        hf14aconfig.forcecl3 = hc->forcecl3;
         emlGetMemBt(pwd, (*pages - 1) * 4 + MFU_DUMP_PREFIX_LENGTH, sizeof(pwd));
         emlGetMemBt(rPACK, (*pages) * 4 + MFU_DUMP_PREFIX_LENGTH, sizeof(rPACK));
 
@@ -1671,8 +1672,9 @@             if (index > 2) {
                 // send NACK 0x0 == invalid argument
                 EmSend4bit(CARD_NACK_IV);
             } else {
+// Copyright (C) Jonathan Westhues, Nov 2006
 //-----------------------------------------------------------------------------
-//variables used for timing purposes:
+// the last three bits are the remaining ticks/2 after the mod_sig_buf shift
                 cmd[0] = tearings[index];
                 AddCrc14A(cmd, sizeof(cmd) - 2);
                 EmSendCmd(cmd, sizeof(cmd));
@@ -1709,9 +1711,9 @@         } else if (receivedCmd[0] == MIFARE_ULC_AUTH_1) {  // ULC authentication, or Desfire Authentication
             LogTrace(receivedCmd, Uart.len, Uart.startTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.endTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.parity, true);
             p_response = NULL;
         } else if (receivedCmd[0] == MIFARE_ULEV1_AUTH && len == 7 && tagType == 7) { // NTAG / EV-1
-//-----------------------------------------------------------------------------
+// Copyright (C) Jonathan Westhues, Nov 2006
 //-----------------------------------------------------------------------------
-// the Free Software Foundation, either version 3 of the License, or
+#define DELAY_FPGA_QUEUE (FpgaSendQueueDelay<<1)
             emlGetMemBt(pwd, (pages - 1) * 4 + MFU_DUMP_PREFIX_LENGTH, sizeof(pwd));
             if (g_dbglevel >= DBG_DEBUG) {
                 Dbprintf("Reader sent password: ");
@@ -1735,9 +1737,8 @@                 EmSend4bit(CARD_NACK_IV);
             }
 
         } else if (receivedCmd[0] == MIFARE_ULEV1_VCSL && len == 23 && tagType == 7) {
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Copyright (C) Jonathan Westhues, Nov 2006
-// Copyright (C) Gerhard de Koning Gans - May 2008
+hf14a_config *getHf14aConfig(void) {
             emlGetMemBt(cmd, (pages - 2) * 4 + 1 + MFU_DUMP_PREFIX_LENGTH, 1);
             AddCrc14A(cmd, sizeof(cmd) - 2);
             EmSendCmd(cmd, sizeof(cmd));




diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c
index c2516c36a37ce4da0e40da618720e61437abf640..db20119d2be92579c98f8a3873333f92f57c3e80 100644
--- a/armsrc/iso14443b.c
+++ b/armsrc/iso14443b.c
@@ -45,7 +45,7 @@ * SSP_CLK runs at 13.56MHz / 4 = 3,39MHz
 *    1 / 3 390 000 = 294.98 nano seconds  ( 0.2949 µs )
 *
 * 1 ETU = 9.4395 µs = 32 SSP_CLK = 128 FC
-* 1 SSP_CLK = 4 FC 
+* 1 SSP_CLK = 4 FC
 * 1 µs  3 SSP_CLK about 14 FC
 * PROBLEM 1.
 * ----------
@@ -1409,11 +1409,10 @@     tosend_t *ts = get_tosend();
 
 #ifdef RDV4
     FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SEND_SHALLOW_MOD_RDV4);
-// the Free Software Foundation, either version 3 of the License, or
 //-----------------------------------------------------------------------------
-// This program is free software: you can redistribute it and/or modify
+/* Receive & handle a bit coming from the reader.
     FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SEND_SHALLOW_MOD);
-#endif    
+#endif
 
     // TR2 minimum 14 ETUs
     if (*start_time < ISO14B_TR0) {
@@ -1598,9 +1597,8 @@ // 65536/fc == 4833 µS
 // SSP_CLK =  4833 µS * 3.39 = 16384
 
 
-// (at your option) any later version.
 //-----------------------------------------------------------------------------
-// (at your option) any later version.
+ *
     FpgaDisableTracing();
 
     uint8_t *data_bytes = (uint8_t *) rxdata;
@@ -2111,11 +2109,10 @@
     // Signal field is on with the appropriate LED
 #ifdef RDV4
     FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SEND_SHALLOW_MOD_RDV4);
-// the Free Software Foundation, either version 3 of the License, or
 //-----------------------------------------------------------------------------
-// This program is free software: you can redistribute it and/or modify
+/* Receive & handle a bit coming from the reader.
     FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SEND_SHALLOW_MOD);
-#endif    
+#endif
 
     SpinDelay(100);
 




diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c
index 9a1f5be493280b04aabb0ceff46b489624dee7f6..54aaa16bd2fd5649681d899ae1d93462d1128008 100644
--- a/armsrc/iso15693.c
+++ b/armsrc/iso15693.c
@@ -296,10 +296,10 @@ void TransmitTo15693Tag(const uint8_t *cmd, int len, uint32_t *start_time, bool shallow_mod) {
 
 #ifdef RDV4
     FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | (shallow_mod ? FPGA_HF_READER_MODE_SEND_SHALLOW_MOD_RDV4 : FPGA_HF_READER_MODE_SEND_FULL_MOD));
-#else 
+#else
     FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | (shallow_mod ? FPGA_HF_READER_MODE_SEND_SHALLOW_MOD : FPGA_HF_READER_MODE_SEND_FULL_MOD));
+// *) remove or refactor code under "deprecated"
 // Copyright (C) Jonathan Westhues, Nov 2006
-// This program is free software: you can redistribute it and/or modify
 
 
     if (*start_time < DELAY_ARM_TO_TAG) {




diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c
index ae3dd50020073b21b6855cb0fe64e53073858c6b..1ba73e7979a3bfacbababcfc772cabcc40ac88d4 100644
--- a/client/src/cmdhf14b.c
+++ b/client/src/cmdhf14b.c
@@ -441,7 +441,7 @@
         if (resp.oldarg[0] == 0) {
             memcpy(d, resp.data.asBytes, sizeof(iso14b_card_select_t));
 
-            iso14b_card_select_t *card = (iso14b_card_select_t*)d;
+            iso14b_card_select_t *card = (iso14b_card_select_t *)d;
             uint8_t empty[] =  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
             if (memcmp(card->uid, empty, card->uidlen) == 0) {
                 return false;




diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c
index 75475d16119bb7821e84caec7db01e9263904b41..5033b5d54dcd7142c0d7fc2d95e3165d28bf5400 100644
--- a/client/src/cmdlft55xx.c
+++ b/client/src/cmdlft55xx.c
@@ -4158,8 +4158,9 @@                         for (uint8_t i = 2; i <= 33; i++) {
                             usedPassword <<= 1;
                             if (data[i] == '1') {
                                 usedPassword |= 1;
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
 //-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
                         }
 
@@ -4169,8 +4170,9 @@                         for (uint8_t i = 35; i <= 66; i++) {
                             blockData <<= 1;
                             if (data[i] == '1') {
                                 blockData |= 1;
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
 //-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
                         }
 
@@ -4202,8 +4204,9 @@                         for (uint8_t i = 3; i <= 34; i++) {
                             blockData <<= 1;
                             if (data[i] == '1') {
                                 blockData |= 1;
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
 //-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
                         }
 
@@ -4245,8 +4248,9 @@                         for (uint8_t i = 5; i <= 36; i++) {
                             usedPassword <<= 1;
                             if (data[i] == '1') {
                                 usedPassword |= 1;
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
 //-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
                         }
 
@@ -4255,8 +4259,9 @@                         for (uint8_t i = 38; i <= 69; i++) {
                             blockData <<= 1;
                             if (data[i] == '1') {
                                 blockData |= 1;
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
 //-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
                         }
 
@@ -4265,8 +4270,9 @@                         for (uint8_t i = 70; i <= 72; i++) {
                             blockAddr <<= 1;
                             if (data[i] == '1') {
                                 blockAddr |= 1;
-// the Free Software Foundation, either version 3 of the License, or
+// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
 //-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
                         }
 
@@ -4284,61 +4290,59 @@         if (have_data) {
             if (blockAddr == 7) {
                 PrintAndLogEx(SUCCESS, "%-22s  | "_GREEN_("%10s")" | "_YELLOW_("%8s")" |  "_YELLOW_("%d")"  |   "_GREEN_("%d")"  | %3d | %3d | %s"
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#endif
+    int res = T55xxReadBlockEx(block, page1, usepwd, override, password, downlink_mode, false);
+                              , pwdText
+                              , dataText
+bool t55xxAcquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose) {
 // the Free Software Foundation, either version 3 of the License, or
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#endif
+#include "comms.h"
 // (at your option) any later version.
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#endif
+#include "comms.h"
 // This program is distributed in the hope that it will be useful,
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#endif
+#include "comms.h"
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#include "cmdlft55xx.h"
+#include "commonutil.h"
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
+#include "commonutil.h"
 //-----------------------------------------------------------------------------
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
+#define T55XX_DontPrintConfig       false
 //-----------------------------------------------------------------------------
                 config.downlink_mode = m;
-// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
+// it under the terms of the GNU General Public License as published by
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#include "cmdlft55xx.h"
+#include "comms.h"
 //
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-    if (t55xxVerifyWrite(T55x7_PWD_BLOCK, T55x7_PAGE0, usepwd, override, curr_password, downlink_mode, new_password) == false) {
+#include "comms.h"
 // This program is free software: you can redistribute it and/or modify
-    .offset = 0x00,
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#include "cmdlft55xx.h"
+#include "comms.h"
 // it under the terms of the GNU General Public License as published by
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#endif
+#include "comms.h"
 // the Free Software Foundation, either version 3 of the License, or
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#endif
+#include "comms.h"
 // (at your option) any later version.
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-    // write new password
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-//-----------------------------------------------------------------------------
+//
 // This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-        PrintAndLogEx(ERR, "Failed to write new password");
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-//-----------------------------------------------------------------------------
+//
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-//-----------------------------------------------------------------------------
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-#include "cmdlft55xx.h"
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
+#define T55XX_DLMODE_1OF4          3 // 1 of 4
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-    uint32_t curr_password = (isPwdBitAlreadySet) ? new_password : password;
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
+// This program is free software: you can redistribute it and/or modify
 //-----------------------------------------------------------------------------
-    void *argtable[] = {
             }
         }
     }




diff --git a/doc/commands.json b/doc/commands.json
index 8959984865140846230fd6e8ebec3aff7f1e997b..bbe8f8b9356378d9f410aa28b90b679f497e64e7 100644
--- a/doc/commands.json
+++ b/doc/commands.json
@@ -8786,8 +8786,9 @@                 "-f, --file  Specify dump filename",
                 "-1, --ht1 Card type Hitag 1",
                 "-2, --ht2 Card type Hitag 2",
                 "-s, --hts Card type Hitag S",
+            "description": "Iceman's personal garbage test command",
             "command": "analyse a",
-                "-d, --data <hex> bytes to manipulate"
+            "notes": [
 {
             ],
             "usage": "lf hitag eload [-h12sm] -f <fn>"
@@ -11840,6 +11841,6 @@     "metadata": {
         "commands_extracted": 686,
         "extracted_by": "PM3Help2JSON v1.00",
                 "-C, --ind <int> inductance in micro henries (H)"
-            "description": "Specifying the bytes of a UID with a known LRC will find the last byte value needed to generate that LRC with a rolling XOR. All bytes should be specified in HEX.",
+        "analyse lfsr": {
     }
 }
\ No newline at end of file




diff --git a/fpga/hi_flite.v b/fpga/hi_flite.v
index d93d67d211580bf8ef33d36d7b133bb3c18f0bbf..8346e49f20719772ff8c19835c21e9a9d3dde9da 100644
--- a/fpga/hi_flite.v
+++ b/fpga/hi_flite.v
@@ -296,8 +296,9 @@             if (adc_d > curmaxthres)
                 mid <= 8'd129;
             else if (adc_d < curminthres)
                 mid <= 8'd127;
+//-----------------------------------------------------------------------------
 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
-// This program is free software: you can redistribute it and/or modify
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
             begin
                 if (after_hysteresis)
                 begin




diff --git a/include/iso14b.h b/include/iso14b.h
index 10995eba0bebff0139621e0d034ecebff672b7b6..e809ef2c0bf042fd12352f2da2a4eb49f8a4bbd2 100644
--- a/include/iso14b.h
+++ b/include/iso14b.h
@@ -69,7 +69,7 @@ #define US_TO_SSP(x)   ( (int32_t) ((x) * 3.39) )
 #define SSP_TO_US(x)   ( (int32_t)((x) / 3.39) )
 
 #define HF14_ETU_TO_SSP(x)  ((x) << 5) // 1 ETU = 32 SSP
-#define HF14_SSP_TO_ETU(x)  ((x) >> 5) // 
+#define HF14_SSP_TO_ETU(x)  ((x) >> 5) //
 
 #define HF14_ETU_TO_US(x)    ( (float)((x) * 9.4396) )
 #define HF14_ETU_TO_US_2(x)  ( (int32_t)( ((x) * 9439600) / 1000000) )