]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
add 'losimman' command - simulate arbitrary Manchester encoded LF tags
authoradam@algroup.co.uk <adam@algroup.co.uk@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 28 Jan 2010 11:49:05 +0000 (11:49 +0000)
committeradam@algroup.co.uk <adam@algroup.co.uk@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 28 Jan 2010 11:49:05 +0000 (11:49 +0000)
armsrc/appmain.c
armsrc/apps.h
armsrc/lfops.c
client/command.c

index a14d8fb8415dea094da0f3a9e2ab57fa237f3cc8..674c891741e62e5abdaf17fa61eaf20f663b33bc 100644 (file)
@@ -26,7 +26,7 @@ int kvsprintf(char const *fmt, void *arg, int radix, va_list ap);
 // is the order in which they go out on the wire.\r
 //=============================================================================\r
 \r
-BYTE ToSend[256];\r
+BYTE ToSend[512];\r
 int ToSendMax;\r
 static int ToSendBit;\r
 struct common_area common_area __attribute__((section(".commonarea")));\r
@@ -34,7 +34,7 @@ struct common_area common_area __attribute__((section(".commonarea")));
 void BufferClear(void)\r
 {\r
        memset(BigBuf,0,sizeof(BigBuf));\r
-       DbpString("Buffer cleared");\r
+       Dbprintf("Buffer cleared (%i bytes)",sizeof(BigBuf));\r
 }\r
 \r
 void ToSendReset(void)\r
@@ -718,13 +718,14 @@ void UsbPacketReceived(BYTE *packet, int len)
                case CMD_DOWNLOADED_SIM_SAMPLES_125K: {\r
                        BYTE *b = (BYTE *)BigBuf;\r
                        memcpy(b+c->arg[0], c->d.asBytes, 48);\r
+                       //Dbprintf("copied 48 bytes to %i",b+c->arg[0]);\r
                        break;\r
                }\r
 \r
 #ifdef WITH_LF\r
                case CMD_SIMULATE_TAG_125K:\r
                        LED_A_ON();\r
-                       SimulateTagLowFrequency(c->arg[0], 1);\r
+                       SimulateTagLowFrequency(c->arg[0], c->arg[1], 1);\r
                        LED_A_OFF();\r
                        break;\r
 #endif\r
@@ -794,7 +795,7 @@ void UsbPacketReceived(BYTE *packet, int len)
                }\r
                        break;\r
                default:\r
-                       DbpString("unknown command");\r
+                       Dbprintf("%s: 0x%04x","unknown command:",c->cmd);\r
                        break;\r
        }\r
 }\r
index 1c17882a5f797cfae443711bd582df7c2cdd6122..71c25d1a5d8af2839155649e5ecae19e5d99c036 100644 (file)
@@ -78,7 +78,7 @@ void ReadTItag(void);
 void WriteTItag(DWORD idhi, DWORD idlo, WORD crc);\r
 void AcquireTiType(void);\r
 void AcquireRawBitsTI(void);\r
-void SimulateTagLowFrequency(int period, int ledcontrol);\r
+void SimulateTagLowFrequency(int period, int gap, int ledcontrol);\r
 void CmdHIDsimTAG(int hi, int lo, int ledcontrol);\r
 void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol);\r
 void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);\r
index 27088b7ee4309a87f3da1c3b591761bdc46ba8b2..a6216eecbb7f28ed467bf6a9c49d2a9edf00b8f5 100644 (file)
@@ -423,7 +423,7 @@ void WriteTItag(DWORD idhi, DWORD idlo, WORD crc)
        DbpString("Now use tiread to check");\r
 }\r
 \r
-void SimulateTagLowFrequency(int period, int ledcontrol)\r
+void SimulateTagLowFrequency(int period, int gap, int ledcontrol)\r
 {\r
        int i;\r
        BYTE *tab = (BYTE *)BigBuf;\r
@@ -468,7 +468,13 @@ void SimulateTagLowFrequency(int period, int ledcontrol)
                }\r
 \r
                i++;\r
-               if(i == period) i = 0;\r
+               if(i == period) {\r
+                       i = 0;\r
+                       if (gap) { \r
+                               SHORT_COIL();\r
+                               SpinDelayUs(gap);\r
+                       }\r
+               }\r
        }\r
 }\r
 \r
@@ -762,7 +768,7 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol)
 \r
        if (ledcontrol)\r
                LED_A_ON();\r
-       SimulateTagLowFrequency(n, ledcontrol);\r
+       SimulateTagLowFrequency(n, 0, ledcontrol);\r
 \r
        if (ledcontrol)\r
                LED_A_OFF();\r
index a2c567e6dc1587bdfa9579b277606a355b8236fb..8ecbc6847d0119fd9aa5f09ee579c02796f29c03 100644 (file)
@@ -577,7 +577,6 @@ retest:
 static void CmdEM410xsim(char *str)\r
 {\r
        int i, n, j, h, binary[4], parity[4];\r
-       char *s = "0";\r
 \r
        /* clock is 64 in EM410x tags */\r
        int clock = 64;\r
@@ -628,12 +627,40 @@ static void CmdEM410xsim(char *str)
        }\r
 \r
        /* modulate that biatch */\r
-       Cmdmanchestermod(s);\r
+       Cmdmanchestermod("");\r
 \r
        /* booyah! */\r
        RepaintGraphWindow();\r
+       \r
+       CmdLosim("");\r
+}\r
+\r
+/* simulate an LF Manchester encoded tag with specified bitstream, clock rate and inter-id gap */\r
+static void CmdLosimManchester(char *str)\r
+{\r
+       static int clock, gap;\r
+       static char data[1024], gapstring[8];\r
+       int i;\r
 \r
-       CmdLosim(s);\r
+       /* get settings/bits */\r
+       sscanf(str, "%i %s %i", &clock, &data[0], &gap);\r
+\r
+       /* clear our graph */\r
+       CmdClearGraph(0);\r
+\r
+       /* fill it with our bitstream */\r
+       for (i= 0; i < strlen(data) ; ++i)\r
+               CmdAppendGraph(0, clock, data[i]- '0');\r
+\r
+       /* modulate */\r
+       Cmdmanchestermod("");\r
+\r
+       /* show what we've done */\r
+       RepaintGraphWindow();\r
+\r
+       /* simulate */\r
+       sprintf(&gapstring[0], "%i", gap);\r
+       CmdLosim(gapstring);\r
 }\r
 \r
 static void ChkBitstream(char *str)\r
@@ -654,6 +681,9 @@ static void ChkBitstream(char *str)
 static void CmdLosim(char *str)\r
 {\r
        int i;\r
+       static int gap;\r
+\r
+       sscanf(str,"%i",&gap);\r
 \r
        /* convert to bitstream if necessary */\r
        ChkBitstream(str);\r
@@ -667,7 +697,7 @@ static void CmdLosim(char *str)
                SendCommand(&c);\r
        }\r
 \r
-       UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, 0, 0}};\r
+       UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}};\r
        SendCommand(&c);\r
 }\r
 \r
@@ -2881,7 +2911,8 @@ static struct {
        {"hi15sim",                     CmdHi15tag,                     0, "Fake an ISO15693 tag"},\r
        {"hidsimtag",           CmdHIDsimTAG,           0, "<ID> -- HID tag simulator"},\r
        {"hisimlisten",         CmdHisimlisten,         0, "Get HF samples as fake tag"},\r
-       {"losim",                       CmdLosim,                       0, "Simulate LF tag"},\r
+       {"losim",                       CmdLosim,                       0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},\r
+       {"losimman",                    CmdLosimManchester,                     0, "<Clock> <Bitstream> [GAP] Simulate arbitrary Manchester LF tag"},\r
        {"losimbidir",          CmdLosimBidir,          0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},\r
 \r
 /* card reading functions */\r
@@ -2923,7 +2954,7 @@ static struct {
 void CommandReceived(char *cmd)\r
 {\r
        int i;\r
-       char line[256];\r
+       char line[512];\r
 \r
        PrintToScrollback("> %s", cmd);\r
 \r
Impressum, Datenschutz