X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/7381e8f2f285aad4ce3919fa1964638cc08c3899..e3dfa4277219c1cb72b906860faf537336bf866c:/winsrc/command.cpp diff --git a/winsrc/command.cpp b/winsrc/command.cpp index 08feb3dd..0214a0ab 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -107,6 +107,20 @@ static void CmdSri512read(char *str) c.ext1 = atoi(str); SendCommand(&c, FALSE); } + +/* New command to read the contents of a SRIX4K tag + * SRIX4K tags are ISO14443-B modulated memory tags, + * this command just dumps the contents of the memory/ + */ +static void CmdSrix4kread(char *str) +{ + UsbCommand c; + c.cmd = CMD_READ_SRIX4K_TAG; + c.ext1 = atoi(str); + SendCommand(&c, FALSE); +} + + // ## New command static void CmdHi14areader(char *str) @@ -207,6 +221,20 @@ static void CmdHi14asnoop(char *str) SendCommand(&c, FALSE); } +static void CmdLegicRfSim(char *str) +{ + UsbCommand c; + c.cmd = CMD_SIMULATE_TAG_LEGIC_RF; + SendCommand(&c, FALSE); +} + +static void CmdLegicRfRead(char *str) +{ + UsbCommand c; + c.cmd = CMD_READER_LEGIC_RF; + SendCommand(&c, FALSE); +} + static void CmdFPGAOff(char *str) // ## FPGA Control { UsbCommand c; @@ -663,6 +691,15 @@ static void CmdLosim(char *str) SendCommand(&c, FALSE); } +static void CmdLosimBidir(char *str) +{ + UsbCommand c; + c.cmd = CMD_LF_SIMULATE_BIDIR; + c.ext1 = 47; /* Set ADC to twice the carrier for a slight supersampling */ + c.ext2 = 384; + SendCommand(&c, FALSE); +} + static void CmdLoread(char *str) { UsbCommand c; @@ -872,9 +909,12 @@ static void CmdHexsamples(char *str) { int i; int n; + int requested = atoi(str); + int delivered = 0; if(atoi(str) == 0) { n = 12; + requested = 12; } else { n = atoi(str)/4; } @@ -902,7 +942,12 @@ static void CmdHexsamples(char *str) c.d.asBytes[j+7], c.d.asBytes[j+8] ); + delivered += 8; + if(delivered >= requested) + break; } + if(delivered >= requested) + break; } } @@ -1799,6 +1844,40 @@ static void CmdNorm(char *str) RepaintGraphWindow(); } +static void CmdAmp(char *str) +{ + int i, rising, falling; + int max = INT_MIN, min = INT_MAX; + for(i = 10; i < GraphTraceLen; i++) { + if(GraphBuffer[i] > max) { + max = GraphBuffer[i]; + } + if(GraphBuffer[i] < min) { + min = GraphBuffer[i]; + } + } + if(max != min) { + rising= falling= 0; + for(i = 0; i < GraphTraceLen; i++) { + if(GraphBuffer[i+1] < GraphBuffer[i]) { + if(rising) { + GraphBuffer[i]= max; + rising= 0; + } + falling= 1; + } + if(GraphBuffer[i+1] > GraphBuffer[i]) { + if(falling) { + GraphBuffer[i]= min; + falling= 0; + } + rising= 1; + } + } + } + RepaintGraphWindow(); +} + static void CmdDec(char *str) { int i; @@ -2229,9 +2308,11 @@ static void Cmdaskdemod(char *str) { int c, high = 0, low = 0; // TODO: complain if we do not give 2 arguments here ! + // (AL - this doesn't make sense! we're only using one argument!!!) sscanf(str, "%i", &c); /* Detect high and lows and clock */ + // (AL - clock???) for (i = 0; i < GraphTraceLen; i++) { if (GraphBuffer[i] > high) @@ -2239,6 +2320,10 @@ static void Cmdaskdemod(char *str) { else if (GraphBuffer[i] < low) low = GraphBuffer[i]; } + if(c != 0 && c != 1) { + PrintToScrollback("Invalid argument: %s",str); + return; + } if (GraphBuffer[0] > 0) { GraphBuffer[0] = 1-c; @@ -2483,7 +2568,12 @@ static void Cmdmanchesterdemod(char *str) { /* Detect first transition */ /* Lo-Hi (arbitrary) */ - for (i = 0; i < GraphTraceLen; i++) + /* skip to the first high */ + for (i= 0; i < GraphTraceLen; i++) + if(GraphBuffer[i] == high) + break; + /* now look for the first low */ + for (; i < GraphTraceLen; i++) { if (GraphBuffer[i] == low) { @@ -2732,6 +2822,13 @@ static void CmdReadmem(char *str) SendCommand(&c, FALSE); } +static void CmdVersion(char *str) +{ + UsbCommand c; + c.cmd = CMD_VERSION; + SendCommand(&c, FALSE); +} + static void CmdLcdReset(char *str) { UsbCommand c; @@ -2769,6 +2866,22 @@ static void CmdSetDivisor(char *str) } } +static void CmdSetMux(char *str) +{ + UsbCommand c; + c.cmd = CMD_SET_ADC_MUX; + if(strcmp(str, "lopkd") == 0) { + c.ext1 = 0; + } else if(strcmp(str, "loraw") == 0) { + c.ext1 = 1; + } else if(strcmp(str, "hipkd") == 0) { + c.ext1 = 2; + } else if(strcmp(str, "hiraw") == 0) { + c.ext1 = 3; + } + SendCommand(&c, FALSE); +} + typedef void HandlerFunction(char *cmdline); /* in alphabetic order */ @@ -2778,7 +2891,8 @@ static struct { int offline; // 1 if the command can be used when in offline mode char *docString; } CommandTable[] = { - {"askdemod", Cmdaskdemod, 1, " <0|1> -- Attempt to demodulate simple ASK tags"}, + {"amp", CmdAmp, 1, "Amplify peaks"}, + {"askdemod", Cmdaskdemod, 1, "<0|1> -- Attempt to demodulate simple ASK tags"}, {"autocorr", CmdAutoCorr, 1, " -- Autocorrelation over window"}, {"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"}, {"bitstream", Cmdbitstream, 1, "[clock rate] -- Convert waveform into a bitstream"}, @@ -2822,11 +2936,14 @@ static struct { {"indalademod", CmdIndalademod, 0, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"}, {"lcd", CmdLcd, 0, " -- Send command/data to LCD"}, {"lcdreset", CmdLcdReset, 0, "Hardware reset LCD"}, + {"legicrfsim", CmdLegicRfSim, 0, "Start the LEGIC RF tag simulator"}, + {"legicrfread", CmdLegicRfRead, 0, "Start the LEGIC RF reader"}, {"load", CmdLoad, 1, " -- Load trace (to graph window"}, {"locomread", CmdLoCommandRead, 0, " <'0' period> <'1' period> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"}, {"loread", CmdLoread, 0, "['h'] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134)"}, {"losamples", CmdLosamples, 0, "[128 - 16000] -- Get raw samples for LF tag"}, {"losim", CmdLosim, 0, "Simulate LF tag"}, + {"losimbidir", CmdLosimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"}, {"ltrim", CmdLtrim, 1, " -- Trim samples from left of trace"}, {"mandemod", Cmdmanchesterdemod, 1, "[i] [clock rate] -- Manchester demodulate binary stream (option 'i' to invert output)"}, {"manmod", Cmdmanchestermod, 1, "[clock rate] -- Manchester modulate a binary stream"}, @@ -2838,13 +2955,16 @@ static struct { {"save", CmdSave, 1, " -- Save trace (from graph window)"}, {"scale", CmdScale, 1, " -- Set cursor display scale"}, {"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"}, + {"setmux", CmdSetMux, 0, " -- Set the ADC mux to a specific value"}, {"sri512read", CmdSri512read, 0, " -- Read contents of a SRI512 tag"}, + {"srix4kread", CmdSrix4kread, 0, " -- Read contents of a SRIX4K tag"}, {"tidemod", CmdTIDemod, 1, "Demodulate raw bits for TI-type LF tag"}, {"tiread", CmdTIRead, 0, "Read and decode a TI 134 kHz tag"}, {"tiwrite", CmdTIWrite, 0, "Write new data to a r/w TI 134 kHz tag"}, {"threshold", CmdThreshold, 1, "Maximize/minimize every value in the graph window depending on threshold"}, {"tune", CmdTune, 0, "Measure antenna tuning"}, {"vchdemod", CmdVchdemod, 0, "['clone'] -- Demodulate samples for VeriChip"}, + {"version", CmdVersion, 0, "Show version inforation about the connected Proxmark"}, {"zerocrossings", CmdZerocrossings, 1, "Count time between zero-crossings"}, };