text and style

This commit is contained in:
iceman1001 2025-03-21 08:30:13 +01:00
commit a5dcb4a812
6 changed files with 114 additions and 90 deletions

View file

@ -2566,6 +2566,75 @@ static int CmdFSKToNRZ(const char *Cmd) {
return ans;
}
/*
// If reactivated, beware it doesn't compile on Android (DXL)
void iceIIR_Butterworth(int *data, const size_t len) {
int *output = (int *) calloc(sizeof(int) * len, sizeof(uint8_t));
if (!output) return;
// clear mem
memset(output, 0x00, len);
size_t adjustedLen = len;
float fc = 0.1125f; // center frequency
// create very simple low-pass filter to remove images (2nd-order Butterworth)
float complex iir_buf[3] = {0, 0, 0};
float b[3] = {0.003621681514929, 0.007243363029857, 0.003621681514929};
float a[3] = {1.000000000000000, -1.822694925196308, 0.837181651256023};
for (size_t i = 0; i < adjustedLen; ++i) {
float sample = data[i]; // input sample read from array
float complex x_prime = 1.0f; // save sample for estimating frequency
float complex x;
// remove DC offset and mix to complex baseband
x = (sample - 127.5f) * cexpf(_Complex_I * 2 * M_PI * fc * i);
// apply low-pass filter, removing spectral image (IIR using direct-form II)
iir_buf[2] = iir_buf[1];
iir_buf[1] = iir_buf[0];
iir_buf[0] = x - a[1] * iir_buf[1] - a[2] * iir_buf[2];
x = b[0] * iir_buf[0] +
b[1] * iir_buf[1] +
b[2] * iir_buf[2];
// compute instantaneous frequency by looking at phase difference
// between adjacent samples
float freq = cargf(x * conjf(x_prime));
x_prime = x; // retain this sample for next iteration
output[i] = (freq > 0) ? 127 : -127;
}
// show data
//memcpy(data, output, adjustedLen);
for (size_t j = 0; j < adjustedLen; ++j)
data[j] = output[j];
free(output);
}
*/
static void iceSimple_Filter(int *data, const size_t len, uint8_t k) {
// ref: http://www.edn.com/design/systems-design/4320010/A-simple-software-lowpass-filter-suits-embedded-system-applications
// parameter K
#define FILTER_SHIFT 4
int32_t filter_reg = 0;
int8_t shift = (k <= 8) ? k : FILTER_SHIFT;
for (size_t i = 0; i < len; ++i) {
// Update filter with current sample
filter_reg = filter_reg - (filter_reg >> shift) + data[i];
// Scale output for unity gain
data[i] = filter_reg >> shift;
}
}
static int CmdDataIIR(const char *Cmd) {
CLIParserContext *ctx;

View file

@ -2191,11 +2191,12 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
PrintAndLogEx(SUCCESS, "MANUFACTURER: " _YELLOW_("%s"), getTagInfo(card.uid[0]));
switch (card.uid[0]) {
case 0x02: // ST
case 0x02: { // ST
isST = true;
isMifareClassic = false;
break;
case 0x04: // NXP
}
case 0x04: { // NXP
nxptype = detect_nxp_card_print(card.sak, ((card.atqa[1] << 8) + card.atqa[0]), select_status);
isMifareMini = ((nxptype & MTMINI) == MTMINI);
@ -2205,17 +2206,21 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
isNTAG424 = ((nxptype & MT424) == MT424);
if ((nxptype & MTOTHER) == MTOTHER)
if ((nxptype & MTOTHER) == MTOTHER) {
isMifareClassic = true;
}
if ((nxptype & MTFUDAN) == MTFUDAN)
if ((nxptype & MTFUDAN) == MTFUDAN) {
isFUDAN = true;
}
if ((nxptype & MTEMV) == MTEMV)
if ((nxptype & MTEMV) == MTEMV) {
isEMV = true;
}
break;
case 0x05: // Infineon
}
case 0x05: { // Infineon
if ((card.uid[1] & 0xF0) == 0x10) {
printTag("my-d(tm) command set SLE 66R04/16/32P, SLE 66R04/16/32S");
} else if ((card.uid[1] & 0xF0) == 0x20) {
@ -2235,19 +2240,22 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
}
getTagLabel(card.uid[0], card.uid[1]);
break;
case 0x46:
}
case 0x46: {
if (memcmp(card.uid, "FSTN10m", 7) == 0) {
isMifareClassic = false;
printTag("Waveshare NFC-Powered e-Paper 1.54\" (please disregard MANUFACTURER mapping above)");
}
break;
case 0x57:
}
case 0x57: {
if (memcmp(card.uid, "WSDZ10m", 7) == 0) {
isMifareClassic = false;
printTag("Waveshare NFC-Powered e-Paper (please disregard MANUFACTURER mapping above)");
}
break;
default:
}
default: {
getTagLabel(card.uid[0], card.uid[1]);
switch (card.sak) {
case 0x00: {
@ -2322,6 +2330,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
break;
}
}
}
// try to request ATS even if tag claims not to support it
if (select_status == 2) {
@ -2356,6 +2365,12 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
bad_ats = true;
}
if (card.ats_len == 7 && memcmp(card.ats, "\x05\x78\x77\x80\x02\x9C\x3A", 7) == 0) {
isSEOS = true;
isNTAG424 = false;
isMifareDESFire = false;
}
PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02X %02X ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 2], card.ats[card.ats_len - 1]);
PrintAndLogEx(INFO, " " _YELLOW_("%02X") "............... TL length is " _GREEN_("%d") " bytes", card.ats[0], card.ats[0]);

View file

@ -1640,7 +1640,8 @@ static int CmdHfSeosList(const char *Cmd) {
static int CmdHfSeosSAM(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf seos sam",
"Extract PACS via a HID SAM\n",
"Extract PACS information via a HID SAM\n"
"Make sure you got a SAM inserted in your sim module",
"hf seos sam\n"
"hf seos sam -d a005a103800104 -> get PACS data\n"
);
@ -1662,8 +1663,13 @@ static int CmdHfSeosSAM(const char *Cmd) {
bool decodeTLV = arg_get_lit(ctx, 4);
uint8_t flags = 0;
if (disconnectAfter) flags |= BITMASK(0);
if (skipDetect) flags |= BITMASK(1);
if (disconnectAfter) {
flags |= BITMASK(0);
}
if (skipDetect) {
flags |= BITMASK(1);
}
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
data[0] = flags;
@ -1680,24 +1686,29 @@ static int CmdHfSeosSAM(const char *Cmd) {
return PM3_ESOFT;
}
// iceman: this command should use a struct for its data being transfered.
clearCommandBuffer();
SendCommandNG(CMD_HF_SAM_SEOS, data, cmdlen + 1);
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_HF_SAM_SEOS, &resp, 4000) == false) {
PrintAndLogEx(WARNING, "SAM timeout");
PrintAndLogEx(WARNING, "timeout while waiting for reply");
return PM3_ETIMEOUT;
}
switch (resp.status) {
case PM3_SUCCESS:
case PM3_SUCCESS: {
break;
case PM3_ENOPACS:
}
case PM3_ENOPACS: {
PrintAndLogEx(SUCCESS, "No PACS data found. Card empty?");
return resp.status;
default:
}
default: {
PrintAndLogEx(WARNING, "SAM select failed");
return resp.status;
}
}
uint8_t *d = resp.data.asBytes;
// check for standard SamCommandGetContentElement response
@ -1705,7 +1716,7 @@ static int CmdHfSeosSAM(const char *Cmd) {
// 8a 07
// 03 05 <- tag + length
// 06 85 80 6d c0 <- decoded PACS data
if (d[0] == 0xbd && d[2] == 0x8a && d[4] == 0x03) {
if (d[0] == 0xBD && d[2] == 0x8A && d[4] == 0x03) {
uint8_t pacs_length = d[5];
uint8_t *pacs_data = d + 6;
int res = HIDDumpPACSBits(pacs_data, pacs_length, verbose);

View file

@ -666,75 +666,6 @@ void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode
}
}
/*
// If reactivated, beware it doesn't compile on Android (DXL)
void iceIIR_Butterworth(int *data, const size_t len) {
int *output = (int *) calloc(sizeof(int) * len, sizeof(uint8_t));
if (!output) return;
// clear mem
memset(output, 0x00, len);
size_t adjustedLen = len;
float fc = 0.1125f; // center frequency
// create very simple low-pass filter to remove images (2nd-order Butterworth)
float complex iir_buf[3] = {0, 0, 0};
float b[3] = {0.003621681514929, 0.007243363029857, 0.003621681514929};
float a[3] = {1.000000000000000, -1.822694925196308, 0.837181651256023};
for (size_t i = 0; i < adjustedLen; ++i) {
float sample = data[i]; // input sample read from array
float complex x_prime = 1.0f; // save sample for estimating frequency
float complex x;
// remove DC offset and mix to complex baseband
x = (sample - 127.5f) * cexpf(_Complex_I * 2 * M_PI * fc * i);
// apply low-pass filter, removing spectral image (IIR using direct-form II)
iir_buf[2] = iir_buf[1];
iir_buf[1] = iir_buf[0];
iir_buf[0] = x - a[1] * iir_buf[1] - a[2] * iir_buf[2];
x = b[0] * iir_buf[0] +
b[1] * iir_buf[1] +
b[2] * iir_buf[2];
// compute instantaneous frequency by looking at phase difference
// between adjacent samples
float freq = cargf(x * conjf(x_prime));
x_prime = x; // retain this sample for next iteration
output[i] = (freq > 0) ? 127 : -127;
}
// show data
//memcpy(data, output, adjustedLen);
for (size_t j = 0; j < adjustedLen; ++j)
data[j] = output[j];
free(output);
}
*/
void iceSimple_Filter(int *data, const size_t len, uint8_t k) {
// ref: http://www.edn.com/design/systems-design/4320010/A-simple-software-lowpass-filter-suits-embedded-system-applications
// parameter K
#define FILTER_SHIFT 4
int32_t filter_reg = 0;
int8_t shift = (k <= 8) ? k : FILTER_SHIFT;
for (size_t i = 0; i < len; ++i) {
// Update filter with current sample
filter_reg = filter_reg - (filter_reg >> shift) + data[i];
// Scale output for unity gain
data[i] = filter_reg >> shift;
}
}
void print_progress(uint64_t count, uint64_t max, barMode_t style) {
int cols = 100 + 35;
max = (count > max) ? count : max;

View file

@ -88,8 +88,6 @@ extern pthread_mutex_t g_print_lock;
void print_progress(uint64_t count, uint64_t max, barMode_t style);
void iceIIR_Butterworth(int *data, const size_t len);
void iceSimple_Filter(int *data, const size_t len, uint8_t k);
#ifdef __cplusplus
}
#endif

View file

@ -7734,7 +7734,7 @@
},
"hf seos sam": {
"command": "hf seos sam",
"description": "Extract PACS via a HID SAM",
"description": "Extract PACS information via a HID SAM Make sure you got a SAM inserted in your sim module",
"notes": [
"hf seos sam",
"hf seos sam -d a005a103800104 -> get PACS data"
@ -13356,6 +13356,6 @@
"metadata": {
"commands_extracted": 767,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2025-03-20T21:56:35"
"extracted_on": "2025-03-21T07:07:05"
}
}