mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
- timeout corrections
- global parameter for password catch (used in standalone mode)
This commit is contained in:
parent
ed642855d8
commit
c5ac3c16f5
1 changed files with 23 additions and 18 deletions
|
@ -61,6 +61,7 @@
|
||||||
// div
|
// div
|
||||||
#define EM4X50_TAG_WORD 45
|
#define EM4X50_TAG_WORD 45
|
||||||
#define EM4X50_TAG_MAX_NO_BYTES 136
|
#define EM4X50_TAG_MAX_NO_BYTES 136
|
||||||
|
#define EM4X50_TIMEOUT_PULSE_EVAL 2500
|
||||||
|
|
||||||
int gHigh = 190;
|
int gHigh = 190;
|
||||||
int gLow = 60;
|
int gLow = 60;
|
||||||
|
@ -72,6 +73,8 @@ bool gLogin = false;
|
||||||
// compared to operations like read, write, login, so it is necessary to
|
// compared to operations like read, write, login, so it is necessary to
|
||||||
// to be able to identfiy it
|
// to be able to identfiy it
|
||||||
bool gWritePasswordProcess = false;
|
bool gWritePasswordProcess = false;
|
||||||
|
// if reader sends a different password than "expected" -> save it
|
||||||
|
uint32_t gPassword = 0;
|
||||||
|
|
||||||
// extract and check parities
|
// extract and check parities
|
||||||
// return result of parity check and extracted plain data
|
// return result of parity check and extracted plain data
|
||||||
|
@ -251,7 +254,8 @@ static bool invalid_bit(void) {
|
||||||
|
|
||||||
static uint32_t get_pulse_length(void) {
|
static uint32_t get_pulse_length(void) {
|
||||||
|
|
||||||
int32_t timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD), tval = 0;
|
//int32_t timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD), tval = 0;
|
||||||
|
int32_t timeout = EM4X50_TIMEOUT_PULSE_EVAL, tval = 0;
|
||||||
|
|
||||||
// iterates pulse length (low -> high -> low)
|
// iterates pulse length (low -> high -> low)
|
||||||
|
|
||||||
|
@ -260,23 +264,25 @@ static uint32_t get_pulse_length(void) {
|
||||||
while (sample > gLow && (timeout--))
|
while (sample > gLow && (timeout--))
|
||||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
|
||||||
if (timeout == 0)
|
if (timeout <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tval = GetTicks();
|
tval = GetTicks();
|
||||||
timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
//timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
||||||
|
timeout = EM4X50_TIMEOUT_PULSE_EVAL;
|
||||||
|
|
||||||
while (sample < gHigh && (timeout--))
|
while (sample < gHigh && (timeout--))
|
||||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
|
||||||
if (timeout == 0)
|
if (timeout <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
//timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
||||||
|
timeout = EM4X50_TIMEOUT_PULSE_EVAL;
|
||||||
while (sample > gLow && (timeout--))
|
while (sample > gLow && (timeout--))
|
||||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
|
||||||
if (timeout == 0)
|
if (timeout <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GetTicks() - tval;
|
return GetTicks() - tval;
|
||||||
|
@ -857,16 +863,16 @@ void em4x50_read(em4x50_data_t *etd) {
|
||||||
LED_C_ON();
|
LED_C_ON();
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
if (get_signalproperties() && find_em4x50_tag()) {
|
||||||
|
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
|
|
||||||
// try to login with given password
|
// try to login with given password
|
||||||
if (etd->pwd_given)
|
if (etd->pwd_given)
|
||||||
blogin = (login(etd->password1) == PM3_SUCCESS);
|
blogin = (login(etd->password1) == PM3_SUCCESS);
|
||||||
|
|
||||||
// only one word has to be read -> first word read = last word read
|
// only one word has to be read -> first word read = last word read
|
||||||
if (blogin)
|
if (blogin)
|
||||||
status = selective_read(etd->addresses, words);
|
status = selective_read(etd->addresses, words);
|
||||||
}
|
}
|
||||||
|
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
|
@ -1417,8 +1423,6 @@ static void em4x50_sim_send_nak(void) {
|
||||||
// standard read mode process (simulation mode)
|
// standard read mode process (simulation mode)
|
||||||
static int em4x50_sim_handle_standard_read_command(uint32_t *tag) {
|
static int em4x50_sim_handle_standard_read_command(uint32_t *tag) {
|
||||||
|
|
||||||
int command = 0;
|
|
||||||
|
|
||||||
// extract control data
|
// extract control data
|
||||||
int fwr = reflect32(tag[EM4X50_CONTROL]) & 0xFF; // first word read
|
int fwr = reflect32(tag[EM4X50_CONTROL]) & 0xFF; // first word read
|
||||||
int lwr = (reflect32(tag[EM4X50_CONTROL]) >> 8) & 0xFF; // last word read
|
int lwr = (reflect32(tag[EM4X50_CONTROL]) >> 8) & 0xFF; // last word read
|
||||||
|
@ -1458,8 +1462,6 @@ static int em4x50_sim_handle_standard_read_command(uint32_t *tag) {
|
||||||
// selective read mode process (simulation mode)
|
// selective read mode process (simulation mode)
|
||||||
static int em4x50_sim_handle_selective_read_command(uint32_t *tag) {
|
static int em4x50_sim_handle_selective_read_command(uint32_t *tag) {
|
||||||
|
|
||||||
int command = 0;
|
|
||||||
|
|
||||||
// read password
|
// read password
|
||||||
uint32_t address = 0;
|
uint32_t address = 0;
|
||||||
bool addr = em4x50_sim_read_word(&address);
|
bool addr = em4x50_sim_read_word(&address);
|
||||||
|
@ -1530,6 +1532,9 @@ static int em4x50_sim_handle_login_command(uint32_t *tag) {
|
||||||
em4x50_sim_send_nak();
|
em4x50_sim_send_nak();
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
|
|
||||||
|
// save transmitted password for future use (e.g. standalone mode)
|
||||||
|
gPassword = password;
|
||||||
}
|
}
|
||||||
// continue with standard read mode
|
// continue with standard read mode
|
||||||
return EM4X50_COMMAND_STANDARD_READ;
|
return EM4X50_COMMAND_STANDARD_READ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue