REM: 'hf 15 debug' removed command, unified with mf_debuglevel instead. The idea is to have ONE debug flag on deviceside.

This commit is contained in:
iceman1001 2018-01-29 15:58:00 +01:00
commit b39332e938
8 changed files with 32 additions and 65 deletions

View file

@ -725,9 +725,6 @@ void UsbPacketReceived(uint8_t *packet, int len) {
case CMD_ISO_15693_FIND_AFI:
BruteforceIso15693Afi(c->arg[0]);
break;
case CMD_ISO_15693_DEBUG:
SetDebugIso15693(c->arg[0]);
break;
case CMD_READER_ISO_15693:
ReaderIso15693(c->arg[0]);
break;
@ -862,7 +859,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
// emulator
case CMD_MIFARE_SET_DBGMODE:
MifareSetDbgLvl(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
MifareSetDbgLvl(c->arg[0]);
break;
case CMD_MIFARE_EML_MEMCLR:
MifareEMemClr(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);

View file

@ -147,7 +147,7 @@ void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *
void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
void Mifare1ksim(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
void MifareSetDbgLvl(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
void MifareSetDbgLvl(uint16_t arg0);
void MifareEMemClr(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
@ -198,7 +198,6 @@ void ReaderIso15693(uint32_t parameter); // Simulate an ISO15693 reader - greg
void SimTagIso15693(uint32_t parameter, uint8_t *uid); // simulate an ISO15693 tag - greg
void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t *data); // send arbitrary commands from CLI - atrox
void SetDebugIso15693(uint32_t flag);
void Iso15693InitReader(void);
// iclass.h

View file

@ -71,22 +71,20 @@
///////////////////////////////////////////////////////////////////////
// 32 + 2 crc + 1
#define ISO15_MAX_FRAME 35
#define CMD_ID_RESP 5
#define CMD_READ_RESP 13
#define CMD_INV_RESP 12
#define ISO15_MAX_FRAME 35
#define CMD_ID_RESP 5
#define CMD_READ_RESP 13
#define CMD_INV_RESP 12
#define FrameSOF Iso15693FrameSOF
#define Logic0 Iso15693Logic0
#define Logic1 Iso15693Logic1
#define FrameEOF Iso15693FrameEOF
#define Crc(data,datalen) Iso15693Crc(data, datalen)
#define AddCrc(data,datalen) Iso15693AddCrc(data, datalen)
#define CheckCrc(data,datalen) Iso15693CheckCrc(data,datalen)
#define sprintUID(target,uid) Iso15693sprintUID(target, uid)
int DEBUG = 0;
#define Crc(data,datalen) Iso15693Crc((data), (datalen))
#define AddCrc(data,datalen) Iso15693AddCrc((data), (datalen))
#define CheckCrc(data,datalen) Iso15693CheckCrc((data), (datalen))
#define sprintUID(target,uid) Iso15693sprintUID((target), (uid))
static void BuildIdentifyRequest(uint8_t *cmdout);
//static void BuildReadBlockRequest(uint8_t *cmdout, uint8_t *uid, uint8_t blockNumber );
@ -345,7 +343,7 @@ static int DemodAnswer(uint8_t *received, uint8_t *dest, uint16_t samplecount) {
// Even things out by the length of the target waveform.
corr0 *= 4;
corr1 *= 4;
// if (DEBUG)
// if (MF_DBGLEVEL >= MF_DBG_EXTENDED)
// Dbprintf("Corr1 %d, Corr0 %d, CorrEOF %d", corr1, corr0, corrEOF);
if (corrEOF > corr1 && corrEOF > corr0)
@ -366,17 +364,17 @@ static int DemodAnswer(uint8_t *received, uint8_t *dest, uint16_t samplecount) {
}
if ( ( i + (int)ARRAYLEN(FrameEOF)) >= samplecount-1) {
//Dbprintf("ran off end! %d | %d",( i + (int)ARRAYLEN(FrameEOF)), samplecount-1);
//Dbprintf("[!] ran off end! %d | %d",( i + (int)ARRAYLEN(FrameEOF)), samplecount-1);
break;
}
}
if (DEBUG) Dbprintf("ice: demod bytes %u", k);
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("ice: demod bytes %u", k);
if (mask != 0x01) { // this happens, when we miss the EOF
// TODO: for some reason this happens quite often
if (DEBUG) Dbprintf("error, uneven octet! (extra bits!) mask %02x", mask);
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("[!] error, uneven octet! (extra bits!) mask %02x", mask);
//if (mask < 0x08) k--; // discard the last uneven octet;
// 0x08 is an assumption - but works quite often
}
@ -671,7 +669,7 @@ void Iso15693InitReader(void) {
// Start the timer
StartCountSspClk();
if (DEBUG) DbpString("Iso15693InitReader Exit");
if (MF_DBGLEVEL >= MF_DBG_EXTENDED ) DbpString("[+] Iso15693InitReader Exit");
LED_A_ON();
}
@ -846,7 +844,7 @@ void DbdecodeIso15693Answer(int len, uint8_t *d) {
else
strncat(status, "[!] crc fail", DBD15STATLEN);
if ( DEBUG ) Dbprintf("%s", status);
if ( MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("%s", status);
}
}
@ -854,12 +852,6 @@ void DbdecodeIso15693Answer(int len, uint8_t *d) {
// Functions called via USB/Client
///////////////////////////////////////////////////////////////////////
void SetDebugIso15693(uint32_t debug) {
DEBUG = debug;
Dbprintf("[!] Iso15693 debug is %s", DEBUG ? "on" : "off");
return;
}
//-----------------------------------------------------------------------------
// Act as ISO15693 reader, perform anti-collision and then attempt to read a sector
// all demodulation performed in arm rather than host. - greg
@ -908,8 +900,8 @@ void ReaderIso15693(uint32_t parameter) {
uid[6] = answer1[3];
uid[7] = answer1[2];
if ( DEBUG ) {
Dbprintf("UID = %02X%02X%02X%02X%02X%02X%02X%02X",
if ( MF_DBGLEVEL >= MF_DBG_EXTENDED) {
Dbprintf("[+] UID = %02X%02X%02X%02X%02X%02X%02X%02X",
uid[0], uid[1], uid[2], uid[3],
uid[4], uid[5], uid[5], uid[6]
);
@ -922,15 +914,15 @@ void ReaderIso15693(uint32_t parameter) {
cmd_send(CMD_ACK, 1, sizeof(uid), 0, uid, sizeof(uid));
}
if ( DEBUG ) {
Dbprintf("%d octets read from IDENTIFY request:", answerLen1);
if ( MF_DBGLEVEL >= MF_DBG_EXTENDED) {
Dbprintf("[+] %d octets read from IDENTIFY request:", answerLen1);
DbdecodeIso15693Answer(answerLen1, answer1);
Dbhexdump(answerLen1, answer1, true);
}
// DEBUG read all pages
/*
if (answerLen1 >= 12 && DEBUG) {
if (answerLen1 >= 12 && MF_DBGLEVEL >= MF_DBG_EXTENDED) {
i = 0;
while ( i < 32 ) { // sanity check, assume max 32 pages
@ -995,8 +987,8 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid) {
TransmitTo15693Reader(ToSend, ToSendMax, &tsamples, &wait);
LogTrace(cmd, CMD_INV_RESP, time_start << 4, (GetCountSspClk() - time_start) << 4, NULL, true);
if (DEBUG) {
Dbprintf("%d octets read from reader command: %x %x %x %x %x %x %x %x", ans,
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
Dbprintf("[+] %d octets read from reader command: %x %x %x %x %x %x %x %x", ans,
buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5], buf[6], buf[7]
);
@ -1067,8 +1059,8 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
uint8_t buf[ISO15_MAX_FRAME];
memset(buf, 0x00, sizeof(buf));
if (DEBUG) {
DbpString("SEND");
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
DbpString("[+] SEND");
Dbhexdump(datalen, data, true);
}
@ -1081,8 +1073,8 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
cmd_send(CMD_ACK, buflen, 0, 0, buf, buflen);
LED_B_OFF();
if (DEBUG) {
DbpString("RECV");
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
DbpString("[+] RECV");
DbdecodeIso15693Answer(buflen, buf);
Dbhexdump(buflen, buf, true);
}

View file

@ -1502,7 +1502,7 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
// MIFARE commands set debug level
//
//-----------------------------------------------------------------------------
void MifareSetDbgLvl(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
void MifareSetDbgLvl(uint16_t arg0){
MF_DBGLEVEL = arg0;
Dbprintf("Debug level: %d", MF_DBGLEVEL);
}

View file

@ -355,8 +355,7 @@ int CmdAnalyseCRC(const char *Cmd) {
uint16_t crcCC = b1 << 8 | b2;
printf("ICLASS crc | %04x == %04x \n", crcCC, iclass_new);
free(data);
return 0;
}
@ -468,6 +467,9 @@ int CmdAnalyseTEASelfTest(const char *Cmd){
int CmdAnalyseA(const char *Cmd){
PrintAndLog("ISO 15693 - x25 - Residue %04x ( %0xF0B8 expected) ", ISO15_CRC_CHECK);
uint8_t b1, b2;
// 14 a

View file

@ -333,12 +333,6 @@ int usage_15_restore(void){
PrintAndLog("'hf 15 restore' - to be implemented...");
return 0;
}
int usage_15_debug(void){
PrintAndLog("Usage: hf 15 debug <0|1>");
PrintAndLog(" 0 no debugging");
PrintAndLog(" 1 turn debugging on");
return 0;
}
int usage_15_raw(void){
PrintAndLog("Usage: hf 15 raw [-r] [-2] [-c] <0A 0B 0C ... hex>");
PrintAndLog(" -r do not read response");
@ -778,19 +772,6 @@ int CmdHF15List(const char *Cmd) {
return 0;
}
// Turns debugging on(1)/off(0)
int CmdHF15Debug( const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (strlen(Cmd)<1 || cmdp == 'h' || cmdp == 'H') return usage_15_debug();
int debug = atoi(Cmd);
UsbCommand c = {CMD_ISO_15693_DEBUG, {debug, 0, 0}};
clearCommandBuffer();
SendCommand(&c);
return 0;
}
int CmdHF15Raw(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
@ -1231,7 +1212,6 @@ int CmdHF15Select(const char *Cmd) {
static command_t CommandTable15[] = {
{"help", CmdHF15Help, 1, "This help"},
{"debug", CmdHF15Debug, 0, "Turn debugging on/off"},
{"demod", CmdHF15Demod, 1, "Demodulate ISO15693 from tag"},
{"dump", CmdHF15Dump, 0, "Read all memory pages of an ISO15693 tag, save to file"},
{"findafi", CmdHF15Afi, 0, "Brute force AFI of an ISO15693 tag"},

View file

@ -39,7 +39,6 @@ extern int CmdHF15Reader(const char *Cmd);
extern int CmdHF15Sim(const char *Cmd);
extern int CmdHF15Afi(const char *Cmd);
extern int CmdHF15Dump(const char*Cmd);
extern int CmdHF15Debug( const char *Cmd);
extern int CmdHF15Raw(const char *cmd);
extern int CmdHF15Readmulti(const char *Cmd);
extern int CmdHF15Read(const char *Cmd);
@ -57,7 +56,6 @@ extern int usage_15_sim(void);
extern int usage_15_findafi(void);
extern int usage_15_dump(void);
extern int usage_15_restore(void);
extern int usage_15_debug(void);
extern int usage_15_raw(void);
extern int usage_15_read(void);

View file

@ -110,7 +110,6 @@ typedef struct {
#define CMD_ISO_15693_COMMAND 0x0313
#define CMD_ISO_15693_COMMAND_DONE 0x0314
#define CMD_ISO_15693_FIND_AFI 0x0315
#define CMD_ISO_15693_DEBUG 0x0316
#define CMD_LF_SNOOP_RAW_ADC_SAMPLES 0x0317
// For Hitag2 transponders