mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-20 13:23:25 -07:00
Merge pull request #219 from marshmellow42/master
em cleanup and fix bug in lf config [threshold] option making it not work...
This commit is contained in:
commit
38231ce012
5 changed files with 71 additions and 73 deletions
|
@ -176,8 +176,8 @@ void printEM410x(uint32_t hi, uint64_t id)
|
|||
} else{
|
||||
//output 40 bit em id
|
||||
PrintAndLog("\nEM TAG ID : %010" PRIX64, id);
|
||||
PrintAndLog("Unique TAG ID : %010" PRIX64, id2lo);
|
||||
PrintAndLog("\nPossible de-scramble patterns");
|
||||
PrintAndLog("Unique TAG ID : %010" PRIX64, id2lo);
|
||||
PrintAndLog("HoneyWell IdentKey {");
|
||||
PrintAndLog("DEZ 8 : %08" PRIu64,id & 0xFFFFFF);
|
||||
PrintAndLog("DEZ 10 : %010" PRIu64,id & 0xFFFFFFFF);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "cmdlfviking.h" // for viking menu
|
||||
#include "cmdlfcotag.h" // for COTAG menu
|
||||
|
||||
|
||||
bool g_lf_threshold_set = false;
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
||||
|
@ -510,7 +510,10 @@ int CmdLFSetConfig(const char *Cmd)
|
|||
case 't':
|
||||
errors |= param_getdec(Cmd,cmdp+1,&unsigned_trigg);
|
||||
cmdp+=2;
|
||||
if(!errors) trigger_threshold = unsigned_trigg;
|
||||
if(!errors) {
|
||||
trigger_threshold = unsigned_trigg;
|
||||
if (trigger_threshold > 0) g_lf_threshold_set = true;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
errors |= param_getdec(Cmd,cmdp+1,&bps);
|
||||
|
@ -557,7 +560,7 @@ int CmdLFSetConfig(const char *Cmd)
|
|||
|
||||
int CmdLFRead(const char *Cmd)
|
||||
{
|
||||
|
||||
if (offline) return 0;
|
||||
uint8_t cmdp = 0;
|
||||
bool arg1 = false;
|
||||
if (param_getchar(Cmd, cmdp) == 'h')
|
||||
|
@ -569,12 +572,14 @@ int CmdLFRead(const char *Cmd)
|
|||
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {arg1,0,0}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
//WaitForResponse(CMD_ACK,NULL);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
|
||||
PrintAndLog("command execution time out");
|
||||
return 1;
|
||||
if (g_lf_threshold_set) {
|
||||
WaitForResponse(CMD_ACK,NULL);
|
||||
} else {
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
|
||||
PrintAndLog("command execution time out");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,20 @@ int CmdEM410xRead(const char *Cmd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int usage_lf_em410x_sim(void) {
|
||||
PrintAndLog("Simulating EM410x tag");
|
||||
PrintAndLog("");
|
||||
PrintAndLog("Usage: lf em 410xsim [h] <uid> <clock>");
|
||||
PrintAndLog("Options:");
|
||||
PrintAndLog(" h - this help");
|
||||
PrintAndLog(" uid - uid (10 HEX symbols)");
|
||||
PrintAndLog(" clock - clock (32|64) (optional)");
|
||||
PrintAndLog("samples:");
|
||||
PrintAndLog(" lf em 410xsim 0F0368568B");
|
||||
PrintAndLog(" lf em 410xsim 0F0368568B 32");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// emulate an EM410X tag
|
||||
int CmdEM410xSim(const char *Cmd)
|
||||
{
|
||||
|
@ -71,12 +85,7 @@ int CmdEM410xSim(const char *Cmd)
|
|||
char cmdp = param_getchar(Cmd, 0);
|
||||
uint8_t uid[5] = {0x00};
|
||||
|
||||
if (cmdp == 'h' || cmdp == 'H') {
|
||||
PrintAndLog("Usage: lf em 410xsim <UID> <clock>");
|
||||
PrintAndLog("");
|
||||
PrintAndLog(" sample: lf em 410xsim 0F0368568B");
|
||||
return 0;
|
||||
}
|
||||
if (cmdp == 'h' || cmdp == 'H') return usage_lf_em410x_sim();
|
||||
/* clock is 64 in EM410x tags */
|
||||
uint8_t clock = 64;
|
||||
|
||||
|
@ -174,7 +183,7 @@ int CmdEM410xWrite(const char *Cmd)
|
|||
int card = 0xFF; // invalid card value
|
||||
unsigned int clock = 0; // invalid clock value
|
||||
|
||||
sscanf(Cmd, "%" PRIx64 " %d %d", &id, &card, &clock);
|
||||
sscanf(Cmd, "%" SCNx64 " %d %d", &id, &card, &clock);
|
||||
|
||||
// Check ID
|
||||
if (id == 0xFFFFFFFFFFFFFFFF) {
|
||||
|
@ -540,7 +549,7 @@ bool EM4x05testDemodReadData(uint32_t *word, bool readCmd) {
|
|||
// sanity check
|
||||
size = (size > DemodBufferLen) ? DemodBufferLen : size;
|
||||
// test preamble
|
||||
if ( !onePreambleSearch(DemodBuffer, preamble, sizeof(preamble), size, &startIdx) ) {
|
||||
if ( !preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &size, &startIdx, true) ) {
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 preamble not found :: %d", startIdx);
|
||||
return false;
|
||||
}
|
||||
|
@ -550,13 +559,13 @@ bool EM4x05testDemodReadData(uint32_t *word, bool readCmd) {
|
|||
if (g_debugMode) PrintAndLog("DEBUG: Error - End Parity check failed");
|
||||
return false;
|
||||
}
|
||||
// test for even parity bits.
|
||||
if ( removeParity(DemodBuffer, startIdx + sizeof(preamble),9,0,44) == 0 ) {
|
||||
// test for even parity bits and remove them. (leave out the end row of parities so 36 bits)
|
||||
if ( removeParity(DemodBuffer, startIdx + sizeof(preamble),9,0,36) == 0 ) {
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - Parity not detected");
|
||||
return false;
|
||||
}
|
||||
|
||||
setDemodBuf(DemodBuffer, 40, 0);
|
||||
setDemodBuf(DemodBuffer, 32, 0);
|
||||
*word = bytebits_to_byteLSBF(DemodBuffer, 32);
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue