X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/9ab7a6c75566a2d06e56a8a97173c6382a3c5b3d..23487cd23c564c2fdc020746e757a8e1fa48aaf0:/armsrc/appmain.c diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 62f13fd4..e9e412d5 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1,8 +1,13 @@ //----------------------------------------------------------------------------- -// The main application code. This is the first thing called after start.c -// executes. // Jonathan Westhues, Mar 2006 // Edits by Gerhard de Koning Gans, Sep 2007 (##) +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// The main application code. This is the first thing called after start.c +// executes. //----------------------------------------------------------------------------- #include "proxmark3.h" @@ -119,6 +124,29 @@ void Dbprintf(const char *fmt, ...) { DbpString(output_string); } +// prints HEX & ASCII +void Dbhexdump(int len, uint8_t *d) { + int l=0,i; + char ascii[9]; + + while (len>0) { + if (len>8) l=8; + else l=len; + + memcpy(ascii,d,l); + ascii[l]=0; + + // filter safe ascii + for (i=0;i126) ascii[i]='.'; + + Dbprintf("%-8s %*D",ascii,l,d," "); + + len-=8; + d+=8; + } +} + //----------------------------------------------------------------------------- // Read an ADC channel and block till it completes, then return the result // in ADC units (0 to 1023). Also a routine to average 32 samples and @@ -143,7 +171,7 @@ static int ReadAdc(int ch) return d; } -static int AvgAdc(int ch) +int AvgAdc(int ch) // was static - merlok { int i; int a = 0; @@ -593,6 +621,24 @@ void UsbPacketReceived(uint8_t *packet, int len) break; #endif +#ifdef WITH_ISO15693 + case CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693: + RecordRawAdcSamplesIso15693(); + break; + + case CMD_ISO_15693_COMMAND: + DirectTag15693Command(c->arg[0],c->arg[1],c->arg[2],c->d.asBytes); + break; + + case CMD_ISO_15693_FIND_AFI: + BruteforceIso15693Afi(c->arg[0]); + break; + + case CMD_ISO_15693_DEBUG: + SetDebugIso15693(c->arg[0]); + break; + +#endif case CMD_BUFF_CLEAR: BufferClear(); break; @@ -603,6 +649,14 @@ void UsbPacketReceived(uint8_t *packet, int len) break; #endif + case CMD_SIMULATE_TAG_LEGIC_RF: + LegicRfSimulate(c->arg[0], c->arg[1], c->arg[2]); + break; + + case CMD_WRITER_LEGIC_RF: + LegicRfWriter(c->arg[1], c->arg[0]); + break; + case CMD_READER_LEGIC_RF: LegicRfReader(c->arg[0], c->arg[1]); break; @@ -630,7 +684,7 @@ void UsbPacketReceived(uint8_t *packet, int len) #ifdef WITH_ISO14443a case CMD_READER_ISO_14443a: - ReaderIso14443a(c->arg[0]); + ReaderIso14443a(c, &ack); break; #endif @@ -640,6 +694,45 @@ void UsbPacketReceived(uint8_t *packet, int len) break; #endif +#ifdef WITH_ISO14443a + case CMD_MIFARE_READBL: + MifareReadBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_READSC: + MifareReadSector(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_WRITEBL: + MifareWriteBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_NESTED: + MifareNested(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_CHKKEYS: + MifareChkKeys(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_SIMULATE_MIFARE_CARD: + Mifare1ksim(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + + // emulator + case CMD_MIFARE_SET_DBGMODE: + MifareSetDbgLvl(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_EML_MEMCLR: + MifareEMemClr(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_EML_MEMSET: + MifareEMemSet(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_EML_MEMGET: + MifareEMemGet(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + case CMD_MIFARE_EML_CARDLOAD: + MifareECardLoad(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); + break; + +#endif + #ifdef WITH_ISO14443b case CMD_SNOOP_ISO_14443: SnoopIso14443(); @@ -652,6 +745,13 @@ void UsbPacketReceived(uint8_t *packet, int len) break; #endif +#ifdef WITH_ISO14443a + // Makes use of ISO14443a FPGA Firmware + case CMD_SNOOP_ICLASS: + SnoopIClass(); + break; +#endif + case CMD_SIMULATE_TAG_HF_LISTEN: SimulateTagHfListen(); break; @@ -692,6 +792,12 @@ void UsbPacketReceived(uint8_t *packet, int len) break; #endif +#ifdef WITH_LF + case CMD_HID_CLONE_TAG: + CopyHIDtoT5567(c->arg[0], c->arg[1]); // Clone HID tag by ID to T55x7 + break; +#endif + case CMD_FPGA_MAJOR_MODE_OFF: // ## FPGA Control FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); SpinDelay(200); @@ -719,7 +825,9 @@ void UsbPacketReceived(uint8_t *packet, int len) } n.arg[0] = c->arg[0]; memcpy(n.d.asDwords, BigBuf+c->arg[0], 12*sizeof(uint32_t)); + LED_B_ON(); UsbSendPacket((uint8_t *)&n, sizeof(n)); + LED_B_OFF(); break; } @@ -845,6 +953,8 @@ void __attribute__((noreturn)) AppMain(void) // Load the FPGA image, which we have stored in our flash. FpgaDownloadAndGo(); + StartTickCount(); + #ifdef WITH_LCD LCDInit();