From: edouard@lafargue.name Date: Mon, 27 Apr 2009 19:56:43 +0000 (+0000) Subject: - Restored the 'reset' command X-Git-Tag: v1.0.0~605 X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/d722c4ce7801988cec69aad84a3fe1386d80cd97 - Restored the 'reset' command - Linux client: detects offline mode and blocks commands which need a connected Proxmark3 (still do to on Windows) --- diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 3cbe5c4f..18b8d64a 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -704,6 +704,7 @@ void UsbPacketReceived(BYTE *packet, int len) #endif case CMD_SETUP_WRITE: case CMD_FINISH_WRITE: + case CMD_HARDWARE_RESET: USB_D_PLUS_PULLUP_OFF(); SpinDelay(1000); SpinDelay(1000); @@ -713,6 +714,7 @@ void UsbPacketReceived(BYTE *packet, int len) } break; + default: DbpString("unknown command"); break; diff --git a/linux/gui.c b/linux/gui.c index 6d442f0e..2179a5ec 100644 --- a/linux/gui.c +++ b/linux/gui.c @@ -10,6 +10,7 @@ int GraphBuffer[MAX_GRAPH_TRACE_LEN]; int GraphTraceLen; double CursorScaleFactor; int CommandFinished; +int offline; static char *logfilename = "proxmark3.log"; diff --git a/linux/proxgui.h b/linux/proxgui.h index c1e9198f..786d9361 100644 --- a/linux/proxgui.h +++ b/linux/proxgui.h @@ -14,6 +14,7 @@ extern int GraphBuffer[MAX_GRAPH_TRACE_LEN]; extern int GraphTraceLen; extern double CursorScaleFactor; extern int CommandFinished; +extern int offline; #ifdef __cplusplus } diff --git a/linux/proxmark3.c b/linux/proxmark3.c index b3621af0..2839db93 100644 --- a/linux/proxmark3.c +++ b/linux/proxmark3.c @@ -86,8 +86,10 @@ int main(int argc, char **argv) if (!(devh = OpenProxmark(1))) { fprintf(stderr,"PROXMARK3: NOT FOUND!\n"); marg.usb_present = 0; + offline = 1; } else { marg.usb_present = 1; + offline = 0; } pthread_create(&main_loop_t, NULL, &main_loop, &marg); diff --git a/winsrc/command.cpp b/winsrc/command.cpp index 9599645d..4b18d0a7 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -42,6 +42,14 @@ static void GetFromBigBuf(BYTE *dest, int bytes) } } +static void CmdReset(char *str) +{ + UsbCommand c; + c.cmd = CMD_HARDWARE_RESET; + SendCommand(&c, FALSE); +} + + static void CmdQuit(char *str) { exit(0); @@ -1829,6 +1837,8 @@ static void CmdLcd(char *str) } } + + static void CmdTest(char *str) { } @@ -1866,59 +1876,60 @@ static struct { int offline; // 1 if the command can be used when in offline mode char *docString; } CommandTable[] = { - "tune", CmdTune,0, "measure antenna tuning", - "tiread", CmdTiread,0, "read a TI-type 134 kHz tag", - "tibits", CmdTibits,0, "get raw bits for TI-type LF tag", - "tidemod", CmdTidemod,0, "demod raw bits for TI-type LF tag", - "vchdemod", CmdVchdemod,0, "demod samples for VeriChip", - "plot", CmdPlot,1, "show graph window", - "hide", CmdHide,1, "hide graph window", - "losim", CmdLosim,0, "simulate LF tag", - "loread", CmdLoread,0, "read (125/134 kHz) LF ID-only tag", + "tune", CmdTune,0, "measure antenna tuning", + "tiread", CmdTiread,0, "read a TI-type 134 kHz tag", + "tibits", CmdTibits,0, "get raw bits for TI-type LF tag", + "tidemod", CmdTidemod,0, "demod raw bits for TI-type LF tag", + "vchdemod", CmdVchdemod,0, "demod samples for VeriChip", + "plot", CmdPlot,1, "show graph window", + "hide", CmdHide,1, "hide graph window", + "losim", CmdLosim,0, "simulate LF tag", + "loread", CmdLoread,0, "read (125/134 kHz) LF ID-only tag", "losamples", CmdLosamples,0, "get raw samples for LF tag", "hisamples", CmdHisamples,0, "get raw samples for HF tag", "hisampless", CmdHisampless,0, "get signed raw samples, HF tag", "hisamplest", CmdHi14readt,0, "get samples HF, for testing", - "higet", CmdHi14read_sim,0, "get samples HF, 'analog'", + "higet", CmdHi14read_sim,0, "get samples HF, 'analog'", "bitsamples", CmdBitsamples,0, "get raw samples as bitstring", "hexsamples", CmdHexsamples,0, "dump big buffer as hex bytes", - "hi15read", CmdHi15read,0, "read HF tag (ISO 15693)", + "hi15read", CmdHi15read,0, "read HF tag (ISO 15693)", "hi15reader", CmdHi15reader,0, "act like an ISO15693 reader", // new command greg - "hi15sim", CmdHi15tag,0, "fake an ISO15693 tag", // new command greg - "hi14read", CmdHi14read,0, "read HF tag (ISO 14443)", + "hi15sim", CmdHi15tag,0, "fake an ISO15693 tag", // new command greg + "hi14read", CmdHi14read,0, "read HF tag (ISO 14443)", "sri512read", CmdSri512read,0, "Read contents of a SRI512 tag", "hi14areader", CmdHi14areader,0, "act like an ISO14443 Type A reader", // ## New reader command "hi15demod", CmdHi15demod,1, "demod ISO15693 from tag", "hi14bdemod", CmdHi14bdemod,1, "demod ISO14443 Type B from tag", - "autocorr", CmdAutoCorr,1, "autocorrelation over window", - "norm", CmdNorm,1, "normalize max/min to +/-500", - "dec", CmdDec,1, "decimate", - "hpf", CmdHpf,1, "remove DC offset from trace", + "autocorr", CmdAutoCorr,1, "autocorrelation over window", + "norm", CmdNorm,1, "normalize max/min to +/-500", + "dec", CmdDec,1, "decimate", + "hpf", CmdHpf,1, "remove DC offset from trace", "zerocrossings", CmdZerocrossings,1, "count time between zero-crossings", - "ltrim", CmdLtrim,1, "trim from left of trace", - "scale", CmdScale,1, "set cursor display scale", + "ltrim", CmdLtrim,1, "trim from left of trace", + "scale", CmdScale,1, "set cursor display scale", "flexdemod", CmdFlexdemod,1, "demod samples for FlexPass", - "save", CmdSave,1, "save trace (from graph window)", - "load", CmdLoad,1, "load trace (to graph window", + "save", CmdSave,1, "save trace (from graph window)", + "load", CmdLoad,1, "load trace (to graph window", "hisimlisten", CmdHisimlisten,0, "get HF samples as fake tag", - "hi14sim", CmdHi14sim,0, "fake ISO 14443 tag", - "hi14asim", CmdHi14asim,0, "fake ISO 14443a tag", // ## Simulate 14443a tag + "hi14sim", CmdHi14sim,0, "fake ISO 14443 tag", + "hi14asim", CmdHi14asim,0, "fake ISO 14443a tag", // ## Simulate 14443a tag "hi14snoop", CmdHi14snoop,0, "eavesdrop ISO 14443", "hi14asnoop", CmdHi14asnoop,0, "eavesdrop ISO 14443 Type A", // ## New snoop command - "hi14list", CmdHi14list,0, "list ISO 14443 history", + "hi14list", CmdHi14list,0, "list ISO 14443 history", "hi14alist", CmdHi14alist,0, "list ISO 14443a history", // ## New list command - "hiddemod", CmdHiddemod,1, "HID Prox Card II (not optimal)", + "hiddemod", CmdHiddemod,1, "HID Prox Card II (not optimal)", "hidfskdemod", CmdHIDdemodFSK,0, "HID FSK demodulator", - "indalademod", CmdIndalademod,0, "demod samples for Indala", - "askdemod", Cmdaskdemod,1, "Attempt to demodulate simple ASK tags", + "indalademod", CmdIndalademod,0, "demod samples for Indala", + "askdemod", Cmdaskdemod,1, "Attempt to demodulate simple ASK tags", "hidsimtag", CmdHIDsimTAG,0, "HID tag simulator", - "mandemod", Cmdmanchesterdemod,1, "Try a Manchester demodulation on a binary stream", - "fpgaoff", CmdFPGAOff,0, "set FPGA off", // ## FPGA Control - "lcdreset", CmdLcdReset,0, "Hardware reset LCD", - "lcd", CmdLcd,0, "Send command/data to LCD", + "mandemod", Cmdmanchesterdemod,1, "Try a Manchester demodulation on a binary stream", + "fpgaoff", CmdFPGAOff,0, "set FPGA off", // ## FPGA Control + "lcdreset", CmdLcdReset,0, "Hardware reset LCD", + "lcd", CmdLcd,0, "Send command/data to LCD", "setlfdivisor", CmdSetDivisor,0, "Drive LF antenna at 12Mhz/(divisor+1)", - "sweeplf", CmdSweepLF,0, "Sweep through LF freq range and store results in buffer", - "quit", CmdQuit,0, "quit program" + "sweeplf", CmdSweepLF,0, "Sweep through LF freq range and store results in buffer", + "reset", CmdReset,0, "Reset the Proxmark3", + "quit", CmdQuit,1, "quit program" }; @@ -1933,8 +1944,10 @@ void CommandReceived(char *cmd) PrintToScrollback("> %s", cmd); if(strcmp(cmd, "help")==0) { + if (offline) PrintToScrollback("Operating in OFFLINE mode (no device connected)"); PrintToScrollback("\r\nAvailable commands:"); for(i = 0; i < sizeof(CommandTable) / sizeof(CommandTable[0]); i++) { + if (offline && (CommandTable[i].offline==0)) continue; char line[256]; memset(line, ' ', sizeof(line)); strcpy(line+2, CommandTable[i].name); @@ -1956,6 +1969,10 @@ void CommandReceived(char *cmd) while(*cmd == ' ') { cmd++; } + if (offline && (CommandTable[i].offline==0)) { + PrintToScrollback("Offline mode, cannot use this command."); + return; + } (CommandTable[i].handler)(cmd); return; } diff --git a/winsrc/gui.cpp b/winsrc/gui.cpp index 05f05e1a..cc8e17f9 100644 --- a/winsrc/gui.cpp +++ b/winsrc/gui.cpp @@ -33,6 +33,7 @@ void dbp(char *str, ...) int GraphBuffer[MAX_GRAPH_TRACE_LEN]; int GraphTraceLen; +int offline; // Whether the GUI operates in Offline mode. HPEN GreyPen, GreenPen, WhitePen, YellowPen; HBRUSH GreenBrush, YellowBrush; diff --git a/winsrc/prox.h b/winsrc/prox.h index f3be604c..7c0219e0 100644 --- a/winsrc/prox.h +++ b/winsrc/prox.h @@ -19,6 +19,8 @@ extern int GraphBuffer[MAX_GRAPH_TRACE_LEN]; extern int GraphTraceLen; extern double CursorScaleFactor; extern int CommandFinished; +extern int offline; // Set to 1 if the proxmark is offline + // command.cpp void CommandReceived(char *cmd);