]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge branch 'master' of https://github.com/Proxmark/proxmark3
authoriceman1001 <iceman@iuse.se>
Thu, 12 Feb 2015 08:54:21 +0000 (09:54 +0100)
committericeman1001 <iceman@iuse.se>
Thu, 12 Feb 2015 08:54:21 +0000 (09:54 +0100)
Conflicts:
armsrc/epa.c

armsrc/epa.c
armsrc/iso14443a.c
armsrc/iso14443a.h
client/Makefile
client/cmdhf14a.c
client/cmdlf.c
client/cmdlft55xx.c
fpga/fpga_hf.bit
fpga/hi_iso14443a.v

index 7bff9f1987082b511524a36cea10634ae5e98629..86f7c864d904d4dde9fe0d39e4a43ff449cce782 100644 (file)
@@ -259,10 +259,6 @@ void EPA_PACE_Collect_Nonce(UsbCommand *c)
                return;
        }
 
-       // increase the timeout (at least some cards really do need this!)
-       iso14a_set_timeout(0x0002FFFF);
-       Dbprintf("epa: Epic!");
-       
        // read the CardAccess file
        // this array will hold the CardAccess file
        uint8_t card_access[256] = {0};
@@ -436,8 +432,6 @@ int EPA_Setup()
        
        iso14a_set_timeout(10500);
        
-       iso14a_set_timeout(10500);
-       
        // select the card
        return_code = iso14443a_select_card(uid, &card_select_info, NULL);
        if (return_code != 1) {
index a7102168e09d75522e1e35ac02526136a464a57d..f2fa1ff29e3e766ad1581dfaca5304cecb088689 100644 (file)
@@ -141,16 +141,40 @@ const uint8_t OddByteParity[256] = {
   1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
 };
 
+
 void iso14a_set_trigger(bool enable) {
        trigger = enable;
 }
 
 
-
 void iso14a_set_timeout(uint32_t timeout) {
        iso14a_timeout = timeout;
+       if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", iso14a_timeout, iso14a_timeout / 106);
 }
 
+
+void iso14a_set_ATS_timeout(uint8_t *ats) {
+
+       uint8_t tb1;
+       uint8_t fwi; 
+       uint32_t fwt;
+       
+       if (ats[0] > 1) {                                                       // there is a format byte T0
+               if ((ats[1] & 0x20) == 0x20) {                  // there is an interface byte TB(1)
+                       if ((ats[1] & 0x10) == 0x10) {          // there is an interface byte TA(1) preceding TB(1)
+                               tb1 = ats[3];
+                       } else {
+                               tb1 = ats[2];
+                       }
+                       fwi = (tb1 & 0xf0) >> 4;                        // frame waiting indicator (FWI)
+                       fwt = 256 * 16 * (1 << fwi);            // frame waiting time (FWT) in 1/fc
+                       
+                       iso14a_set_timeout(fwt/(8*16));
+               }
+       }
+}
+
+
 //-----------------------------------------------------------------------------
 // Generate the parity value for a byte sequence
 //
@@ -1600,7 +1624,7 @@ static int GetIso14443aAnswerFromTag(uint8_t *receivedResponse, uint8_t *receive
                        if(ManchesterDecoding(b, offset, 0)) {
                                NextTransferTime = MAX(NextTransferTime, Demod.endTime - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/16 + FRAME_DELAY_TIME_PICC_TO_PCD);
                                return TRUE;
-                       } else if (c++ > iso14a_timeout) {
+                       } else if (c++ > iso14a_timeout && Demod.state == DEMOD_UNSYNCD) {
                                return FALSE; 
                        }
                }
@@ -1798,6 +1822,10 @@ int iso14443a_select_card(byte_t *uid_ptr, iso14a_card_select_t *p_hi14a_card, u
 
        // reset the PCB block number
        iso14_pcb_blocknum = 0;
+
+       // set default timeout based on ATS
+       iso14a_set_ATS_timeout(resp);
+
        return 1;       
 }
 
index 7fcad0e06379e7e6232acd08ed7011d6310e2af8..be8775cef7d0f66e83f4514e830a3de1a60a1983 100644 (file)
@@ -86,6 +86,5 @@ extern void iso14443a_setup(uint8_t fpga_minor_mode);
 extern int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data);
 extern int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *resp_data, uint32_t *cuid_ptr);
 extern void iso14a_set_trigger(bool enable);
-extern void iso14a_set_timeout(uint32_t timeout);
 
 #endif /* __ISO14443A_H */
index fcbd4d7ca1e3c27398fd442c56df74aa7b5ec4c7..48a18c94b39f8ee7d70691065e812b0693695fc8 100644 (file)
@@ -12,9 +12,9 @@ CXX=g++
 VPATH = ../common
 OBJDIR = obj
 
-LDLIBS = -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lreadline -lpthread -lm
+LDLIBS =  -L/mingw/lib -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lm -lreadline -lpthread -lgdi32
 LDFLAGS = $(COMMON_FLAGS)
-CFLAGS = -std=c99 -I. -I../include -I../common -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4
+CFLAGS = -std=c99 -I. -I../include -I../common -I/mingw/include -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4
 LUAPLATFORM = generic
 ifneq (,$(findstring MINGW,$(platform)))
 CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
@@ -146,6 +146,17 @@ clean:
 tarbin: $(BINS)
        $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%)
 
+# must be run as root
+install_kext: Info.plist
+       mkdir -p /System/Library/Extensions/Proxmark3.kext/Contents
+       cp Info.plist /System/Library/Extensions/Proxmark3.kext/Contents
+       chown -R root:wheel /System/Library/Extensions/Proxmark3.kext
+       chmod 755 /System/Library/Extensions/Proxmark3.kext /System/Library/Extensions/Proxmark3.kext/Contents
+       chmod 644 /System/Library/Extensions/Proxmark3.kext/Contents/Info.plist
+       rm -rf /System/Library/Caches/com.apple.kext.caches
+       touch /System/Library/Extensions
+       @echo "*** You may need to reboot for the kext to take effect."
+
 lua_build:
        @echo Compiling liblua, using platform $(LUAPLATFORM)
        cd ../liblua && make $(LUAPLATFORM)
index 147e790ec0f15c1213289fe5f39b72d82a6e0b16..744b38758588d27342b229d33b3b5223accc4753 100644 (file)
@@ -129,11 +129,6 @@ int CmdHF14AList(const char *Cmd)
        return 0;
 }
 
-void iso14a_set_timeout(uint32_t timeout) {
-       UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_SET_TIMEOUT, 0, timeout}};
-       SendCommand(&c);
-}
-
 int CmdHF14AReader(const char *Cmd)
 {
        UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}};
@@ -346,7 +341,7 @@ int CmdHF14AReader(const char *Cmd)
        SendCommand(&c);
        WaitForResponse(CMD_ACK,&resp);
        uint8_t isOK  = resp.arg[0] & 0xff;
-       PrintAndLog(" Answers to chinese magic backdoor commands: %s", (isOK ? "YES" : "NO") );
+       PrintAndLog("Answers to chinese magic backdoor commands: %s", (isOK ? "YES" : "NO") );
        
        // disconnect
        c.cmd = CMD_READER_ISO_14443a;
@@ -510,12 +505,13 @@ int CmdHF14ACmdRaw(const char *cmd) {
     uint8_t active=0;
     uint8_t active_select=0;
     uint16_t numbits=0;
-       uint16_t timeout=0;
+       uint32_t timeout=0;
        uint8_t bTimeout=0;
     char buf[5]="";
     int i=0;
     uint8_t data[USB_CMD_DATA_SIZE];
-    unsigned int datalen=0, temp;
+       uint16_t datalen=0;
+       uint32_t temp;
 
     if (strlen(cmd)<2) {
         PrintAndLog("Usage: hf 14a raw [-r] [-c] [-p] [-f] [-b] [-t] <number of bits> <0A 0B 0C ... hex>");
@@ -525,7 +521,7 @@ int CmdHF14ACmdRaw(const char *cmd) {
         PrintAndLog("       -a    active signal field ON without select");
         PrintAndLog("       -s    active signal field ON with select");
         PrintAndLog("       -b    number of bits to send. Useful for send partial byte");
-               PrintAndLog("       -t    timeout");
+               PrintAndLog("       -t    timeout in ms");
         return 0;
     }
 
@@ -561,7 +557,7 @@ int CmdHF14ACmdRaw(const char *cmd) {
                                case 't':
                                        bTimeout=1;
                                        sscanf(cmd+i+2,"%d",&temp);
-                                       timeout = temp & 0xFFFF;
+                                       timeout = temp;
                                        i+=3;
                                        while(cmd[i]!=' ' && cmd[i]!='\0') { i++; }
                                        i+=2;
@@ -610,13 +606,13 @@ int CmdHF14ACmdRaw(const char *cmd) {
             c.arg[0] |= ISO14A_NO_SELECT;
     }
        if(bTimeout){
-           #define MAX_TIMEOUT 624*105 // max timeout is 624 ms
+           #define MAX_TIMEOUT 40542464        // (2^32-1) * (8*16) / 13560000Hz * 1000ms/s = 
         c.arg[0] |= ISO14A_SET_TIMEOUT;
-        c.arg[2] = timeout * 105; // each bit is about 9.4 us
-        if(c.arg[2]>MAX_TIMEOUT) {
-            c.arg[2] = MAX_TIMEOUT;
-            PrintAndLog("Set timeout to 624 ms. The max we can wait for response");
+        if(timeout > MAX_TIMEOUT) {
+            timeout = MAX_TIMEOUT;
+            PrintAndLog("Set timeout to 40542 seconds (11.26 hours). The max we can wait for response");
         }
+        c.arg[2] = 13560000 / 1000 / (8*16) * timeout; // timeout in ETUs (time to transfer 1 bit, approx. 9.4 us)
        }
     if(power)
         c.arg[0] |= ISO14A_NO_DISCONNECT;
index b7c1b13f75e8a61ee7766b75d8265bbb0cbbd7ee..136b05334a5e0446a6be3e7cf15decea79d15ecb 100644 (file)
@@ -756,12 +756,18 @@ int CmdLFfind(const char *Cmd)
 static command_t CommandTable[] = 
 {
   {"help",        CmdHelp,            1, "This help"},
-  {"cmdread",     CmdLFCommandRead,   0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},
   {"em4x",        CmdLFEM4X,          1, "{ EM4X RFIDs... }"},
+  {"hid",         CmdLFHID,           1, "{ HID RFIDs... }"},
+  {"hitag",       CmdLFHitag,         1, "{ HITAG RFIDs... }"},
+  {"io",                 CmdLFIO,                1, "{ IOPROX RFIDs... }"},
+  {"pcf7931",     CmdLFPCF7931,       1, "{ PCF7931 RFIDs... }"},
+  {"ti",          CmdLFTI,            1, "{ TI RFIDs... }"},
+  {"t55xx",       CmdLFT55XX,         1, "{ T55X7 RFIDs... }"},
+
   {"config",      CmdLFSetConfig,     0, "Set config for LF sampling, bit/sample, decimation, frequency"},
+  {"cmdread",     CmdLFCommandRead,   0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},
   {"flexdemod",   CmdFlexdemod,       1, "Demodulate samples for FlexPass"},
-  {"hid",         CmdLFHID,           1, "{ HID RFIDs... }"},
-  {"io",                 CmdLFIO,                1, "{ ioProx tags... }"},
   {"indalademod", CmdIndalaDemod,     1, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
   {"indalaclone", CmdIndalaClone,     0, "<UID> ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"},
   {"read",        CmdLFRead,          0, "Read 125/134 kHz LF ID-only tag. Do 'lf read h' for help"},
@@ -770,11 +776,7 @@ static command_t CommandTable[] =
   {"simbidir",    CmdLFSimBidir,      0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
   {"simman",      CmdLFSimManchester, 0, "<Clock> <Bitstream> [GAP] Simulate arbitrary Manchester LF tag"},
   {"snoop",       CmdLFSnoop,         0, "['l'|'h'|<divisor>] [trigger threshold]-- Snoop LF (l:125khz, h:134khz)"},
-  {"ti",          CmdLFTI,            1, "{ TI RFIDs... }"},
-  {"hitag",       CmdLFHitag,         1, "{ Hitag tags and transponders... }"},
   {"vchdemod",    CmdVchDemod,        1, "['clone'] -- Demodulate samples for VeriChip"},
-  {"t55xx",       CmdLFT55XX,         1, "{ T55xx RFIDs... }"},
-  {"pcf7931",     CmdLFPCF7931,       1, "{PCF7931 RFIDs...}"},
   {NULL, NULL, 0, NULL}
 };
 
index 4ac466d199cae0fb85b5925d610476f79862fb85..b060bdee83b94aaa829b06b43a31ccff51b1d3e1 100644 (file)
@@ -76,6 +76,19 @@ int usage_t55xx_dump(){
 \r
 static int CmdHelp(const char *Cmd);\r
 \r
+/*\r
+FSK1 / FSK1a\r
+size = fskdemod(dest, size, 32, 0, 8, 10);  // fsk1 RF/32 \r
+size = fskdemod(dest, size, 32, 1, 8, 10);  // fsk1a RF/32 \r
+\r
+FSK2 / FSK2a\r
+size = fskdemod(dest, size, 32, 0, 10, 8);  // fsk2 RF/32 \r
+size = fskdemod(dest, size, 32, 1, 10, 8);  // fsk2a RF/32 \r
+size = fskdemod(dest, size, 50, 1, 10, 8);  // fsk2a RF/50 \r
+size = fskdemod(dest, size, 64, 1, 10, 8);  // FSK2a RF/64 \r
+\r
+*/\r
+\r
 int CmdReadBlk(const char *Cmd)\r
 {\r
        int invert = 0;\r
index 8b0c7a3788ef438c94eaed81346a08f24927f954..4910e6ac50d6e3cb405bacee3eef47de443b0147 100644 (file)
Binary files a/fpga/fpga_hf.bit and b/fpga/fpga_hf.bit differ
index 3f614fdd82175805a0c6495a1b1dab32ba759f4b..46adda12c47c8d5ef5f0860754cfd8d996d468e5 100644 (file)
@@ -570,7 +570,7 @@ assign pwr_oe3 = 1'b0;
 // TAGSIM_MOD: short circuit antenna with different resistances (modulated by sub_carrier modulated by mod_sig_coil)
 // for pwr_oe4 = 1 (tristate): antenna load = 10k || 33                        = 32,9 Ohms
 // for pwr_oe4 = 0 (active):   antenna load = 10k || 33 || 33          = 16,5 Ohms
-assign pwr_oe4 = ~(mod_sig_coil & sub_carrier & (mod_type == `TAGSIM_MOD));
+assign pwr_oe4 = mod_sig_coil & sub_carrier & (mod_type == `TAGSIM_MOD);
 
 // This is all LF, so doesn't matter.
 assign pwr_oe2 = 1'b0;
Impressum, Datenschutz