X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/8b576d2d3125081ab24a970f6430044a19a4231d..6982ac2612c12af9fa65437bf4279007d734cc59:/client/command.c diff --git a/client/command.c b/client/command.c index 9bfb18f2..0d954258 100644 --- a/client/command.c +++ b/client/command.c @@ -93,6 +93,12 @@ static void CmdTune(char *str) SendCommand(&c); } +static void CmdHiTune(char *str) +{ + UsbCommand c={CMD_MEASURE_ANTENNA_TUNING_HF}; + SendCommand(&c); +} + static void CmdHi15read(char *str) { UsbCommand c={CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693}; @@ -571,7 +577,6 @@ retest: static void CmdEM410xsim(char *str) { int i, n, j, h, binary[4], parity[4]; - char *s = "0"; /* clock is 64 in EM410x tags */ int clock = 64; @@ -622,12 +627,40 @@ static void CmdEM410xsim(char *str) } /* modulate that biatch */ - Cmdmanchestermod(s); + Cmdmanchestermod(""); /* booyah! */ RepaintGraphWindow(); + + CmdLosim(""); +} + +/* simulate an LF Manchester encoded tag with specified bitstream, clock rate and inter-id gap */ +static void CmdLosimManchester(char *str) +{ + static int clock, gap; + static char data[1024], gapstring[8]; + int i; + + /* get settings/bits */ + sscanf(str, "%i %s %i", &clock, &data[0], &gap); + + /* clear our graph */ + CmdClearGraph(0); + + /* fill it with our bitstream */ + for (i= 0; i < strlen(data) ; ++i) + CmdAppendGraph(0, clock, data[i]- '0'); + + /* modulate */ + Cmdmanchestermod(""); + + /* show what we've done */ + RepaintGraphWindow(); - CmdLosim(s); + /* simulate */ + sprintf(&gapstring[0], "%i", gap); + CmdLosim(gapstring); } static void ChkBitstream(char *str) @@ -648,10 +681,14 @@ static void ChkBitstream(char *str) static void CmdLosim(char *str) { int i; + static int gap; + + sscanf(str,"%i",&gap); /* convert to bitstream if necessary */ ChkBitstream(str); + PrintToScrollback("Sending data, please wait..."); for (i = 0; i < GraphTraceLen; i += 48) { UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}}; int j; @@ -659,9 +696,11 @@ static void CmdLosim(char *str) c.d.asBytes[j] = GraphBuffer[i+j]; } SendCommand(&c); + wait_for_response(CMD_ACK); } - UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, 0, 0}}; + PrintToScrollback("Starting simulator..."); + UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}}; SendCommand(&c); } @@ -847,7 +886,15 @@ static int CmdHisamplest(char *str, int nrlow) static void CmdHexsamples(char *str) { int i, j, n; - int requested = strtol(str, NULL, 0); + int requested = 0; + int offset = 0; + sscanf(str, "%i %i", &requested, &offset); + if (offset % 4!=0) { + PrintToScrollback("Offset must be a multiple of 4"); + return; + } + offset = offset/4; + int delivered = 0; if (requested == 0) { @@ -857,7 +904,7 @@ static void CmdHexsamples(char *str) n = requested/4; } - for(i = 0; i < n; i += 12) { + for(i = offset; i < n+offset; i += 12) { UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {i, 0, 0}}; SendCommand(&c); wait_for_response(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K); @@ -2825,6 +2872,7 @@ static struct { /* low-level hardware control */ {"fpgaoff", CmdFPGAOff, 0, "Set FPGA off"}, {"tune", CmdTune, 0, "Measure antenna tuning"}, + {"hitune", CmdHiTune, 0, "Continuously measure HF antenna tuning"}, {"readmem", CmdReadmem, 0, "[address] -- Read memory at decimal address from flash"}, {"reset", CmdReset, 0, "Reset the Proxmark3"}, {"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"}, @@ -2836,7 +2884,7 @@ static struct { /* data transfer functions */ {"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"}, - {"hexsamples", CmdHexsamples, 0, " -- Dump big buffer as hex bytes"}, + {"hexsamples", CmdHexsamples, 0, " [] -- Dump big buffer as hex bytes"}, {"higet", CmdHi14read_sim, 0, " -- Get samples HF, 'analog'"}, {"hisamples", CmdHisamples, 0, "Get raw samples for HF tag"}, {"hisampless", CmdHisampless, 0, " -- Get signed raw samples, HF tag"}, @@ -2866,7 +2914,8 @@ static struct { {"hi15sim", CmdHi15tag, 0, "Fake an ISO15693 tag"}, {"hidsimtag", CmdHIDsimTAG, 0, " -- HID tag simulator"}, {"hisimlisten", CmdHisimlisten, 0, "Get HF samples as fake tag"}, - {"losim", CmdLosim, 0, "Simulate LF tag"}, + {"losim", CmdLosim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"}, + {"losimman", CmdLosimManchester, 0, " [GAP] Simulate arbitrary Manchester LF tag"}, {"losimbidir", CmdLosimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"}, /* card reading functions */ @@ -2908,7 +2957,7 @@ static struct { void CommandReceived(char *cmd) { int i; - char line[256]; + char line[512]; PrintToScrollback("> %s", cmd); @@ -3017,14 +3066,19 @@ void UsbCommandReceived(UsbCommand *c) /* Maybe it's a response: */ switch(current_command) { case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: - if (c->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) goto unexpected_response; - int i; - for(i=0; i<48; i++) sample_buf[i] = c->d.asBytes[i]; - received_command = c->cmd; - return; - default: - unexpected_response: - PrintToScrollback("unrecognized command %08x\n", c->cmd); - break; + if (c->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) goto unexpected_response; + int i; + for(i=0; i<48; i++) sample_buf[i] = c->d.asBytes[i]; + received_command = c->cmd; + return; + case CMD_DOWNLOADED_SIM_SAMPLES_125K: + if (c->cmd != CMD_ACK) goto unexpected_response; + // got ACK + received_command = c->cmd; + return; + default: + unexpected_response: + PrintToScrollback("unrecognized command %08x\n", c->cmd); + break; } }