mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Refactor sniffing command.
This commit is contained in:
parent
eba19c0bd6
commit
76215fffc6
1 changed files with 66 additions and 34 deletions
|
@ -47,15 +47,18 @@ static int usage_hf_felica_sim(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int usage_hf_felica_sniff(void) {
|
static int usage_hf_felica_sniff(void) {
|
||||||
PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer.");
|
PrintAndLogEx(NORMAL, "\nInfo: It get data from the field and saves it into command buffer. ");
|
||||||
PrintAndLogEx(NORMAL, "Buffer accessible from command 'hf list felica'");
|
PrintAndLogEx(NORMAL, " Buffer accessible from command 'hf list felica'");
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf felica sniff <s> <t>");
|
PrintAndLogEx(NORMAL, "\nUsage: hf felica sniff [-h] [-s] [-t]");
|
||||||
PrintAndLogEx(NORMAL, " s samples to skip (decimal)");
|
PrintAndLogEx(NORMAL, " -h this help");
|
||||||
PrintAndLogEx(NORMAL, " t triggers to skip (decimal)");
|
PrintAndLogEx(NORMAL, " -s samples to skip (decimal) max 9999");
|
||||||
|
PrintAndLogEx(NORMAL, " -t triggers to skip (decimal) max 9999");
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
PrintAndLogEx(NORMAL, " hf felica sniff s 1000");
|
PrintAndLogEx(NORMAL, " hf felica sniff 10 10");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usage_hf_felica_simlite(void) {
|
static int usage_hf_felica_simlite(void) {
|
||||||
PrintAndLogEx(NORMAL, "\n Emulating ISO/18092 FeliCa Lite tag \n");
|
PrintAndLogEx(NORMAL, "\n Emulating ISO/18092 FeliCa Lite tag \n");
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf felica litesim [h] u <uid>");
|
PrintAndLogEx(NORMAL, "Usage: hf felica litesim [h] u <uid>");
|
||||||
|
@ -66,6 +69,7 @@ static int usage_hf_felica_simlite(void) {
|
||||||
PrintAndLogEx(NORMAL, " hf felica litesim 11223344556677");
|
PrintAndLogEx(NORMAL, " hf felica litesim 11223344556677");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usage_hf_felica_dumplite(void) {
|
static int usage_hf_felica_dumplite(void) {
|
||||||
PrintAndLogEx(NORMAL, "\n Dump ISO/18092 FeliCa Lite tag \n");
|
PrintAndLogEx(NORMAL, "\n Dump ISO/18092 FeliCa Lite tag \n");
|
||||||
PrintAndLogEx(NORMAL, "press button to abort run, otherwise it will loop for 200sec.");
|
PrintAndLogEx(NORMAL, "press button to abort run, otherwise it will loop for 200sec.");
|
||||||
|
@ -76,6 +80,7 @@ static int usage_hf_felica_dumplite(void) {
|
||||||
PrintAndLogEx(NORMAL, " hf felica litedump");
|
PrintAndLogEx(NORMAL, " hf felica litedump");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usage_hf_felica_raw(void) {
|
static int usage_hf_felica_raw(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf felica raw [-h] [-r] [-c] [-p] [-a] <0A 0B 0C ... hex>");
|
PrintAndLogEx(NORMAL, "Usage: hf felica raw [-h] [-r] [-c] [-p] [-a] <0A 0B 0C ... hex>");
|
||||||
PrintAndLogEx(NORMAL, " -h this help");
|
PrintAndLogEx(NORMAL, " -h this help");
|
||||||
|
@ -221,8 +226,8 @@ static int usage_hf_felica_write_without_encryption() {
|
||||||
PrintAndLogEx(NORMAL, "\nUsage: hf felica wrunencrypted [-h] <01 Number of Service hex> <0A0B Service Code List (Little Endian) hex> <01 Number of Block hex> <0A0B Block List Element hex> <0A0B0C0D0E0F... Data hex (16-Byte)>");
|
PrintAndLogEx(NORMAL, "\nUsage: hf felica wrunencrypted [-h] <01 Number of Service hex> <0A0B Service Code List (Little Endian) hex> <01 Number of Block hex> <0A0B Block List Element hex> <0A0B0C0D0E0F... Data hex (16-Byte)>");
|
||||||
PrintAndLogEx(NORMAL, " -h this help");
|
PrintAndLogEx(NORMAL, " -h this help");
|
||||||
PrintAndLogEx(NORMAL, " -i <0A0B0C ... hex> set custom IDm to use\n");
|
PrintAndLogEx(NORMAL, " -i <0A0B0C ... hex> set custom IDm to use\n");
|
||||||
PrintAndLogEx(NORMAL, " hf felica wrunencrypted 01 CB10 01 8001 0102030405060708090A0B0C0D0E0F10\n\n");
|
PrintAndLogEx(NORMAL, " hf felica wrunencrypted 01 CB10 01 8001 0102030405060708090A0B0C0D0E0F10");
|
||||||
|
PrintAndLogEx(NORMAL, " hf felica wrunencrypted -i 11100910C11BC407 01 CB10 01 8001 0102030405060708090A0B0C0D0E0F10\n\n");
|
||||||
PrintAndLogEx(NORMAL, "\nExamples: ");
|
PrintAndLogEx(NORMAL, "\nExamples: ");
|
||||||
PrintAndLogEx(NORMAL, " hf felica wrunencrypted ");
|
PrintAndLogEx(NORMAL, " hf felica wrunencrypted ");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -466,7 +471,7 @@ static int CmdHFFelicaWriteWithoutEncryption(const char *Cmd) {
|
||||||
switch (Cmd[i + 1]) {
|
switch (Cmd[i + 1]) {
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'h':
|
case 'h':
|
||||||
return usage_hf_felica_request_response();
|
return usage_hf_felica_write_without_encryption();
|
||||||
case 'i':
|
case 'i':
|
||||||
paramCount++;
|
paramCount++;
|
||||||
custom_IDm = true;
|
custom_IDm = true;
|
||||||
|
@ -476,6 +481,8 @@ static int CmdHFFelicaWriteWithoutEncryption(const char *Cmd) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
i += 16;
|
i += 16;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return usage_hf_felica_write_without_encryption();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -535,7 +542,7 @@ static int CmdHFFelicaReadWithoutEncryption(const char *Cmd) {
|
||||||
switch (Cmd[i + 1]) {
|
switch (Cmd[i + 1]) {
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'h':
|
case 'h':
|
||||||
return usage_hf_felica_request_response();
|
return usage_hf_felica_read_without_encryption();
|
||||||
case 'i':
|
case 'i':
|
||||||
paramCount++;
|
paramCount++;
|
||||||
custom_IDm = true;
|
custom_IDm = true;
|
||||||
|
@ -553,6 +560,8 @@ static int CmdHFFelicaReadWithoutEncryption(const char *Cmd) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
long_block_numbers = true;
|
long_block_numbers = true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return usage_hf_felica_read_without_encryption();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -641,6 +650,8 @@ static int CmdHFFelicaRequestResponse(const char *Cmd) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
i += 16;
|
i += 16;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return usage_hf_felica_request_response();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -834,35 +845,56 @@ static int CmdHFFelicaSim(const char *Cmd) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int CmdHFFelicaSniff(const char *Cmd) {
|
static int CmdHFFelicaSniff(const char *Cmd) {
|
||||||
uint8_t cmdp = 0;
|
if (strlen(Cmd) < 2) return usage_hf_felica_sniff();
|
||||||
|
uint8_t paramCount = 0;
|
||||||
uint64_t samples2skip = 0;
|
uint64_t samples2skip = 0;
|
||||||
uint64_t triggers2skip = 0;
|
uint64_t triggers2skip = 0;
|
||||||
bool errors = false;
|
strip_cmds(Cmd);
|
||||||
|
int i = 0;
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (Cmd[i] != '\0') {
|
||||||
switch (param_getchar(Cmd, cmdp)) {
|
if (Cmd[i] == '-') {
|
||||||
case 'h':
|
switch (Cmd[i + 1]) {
|
||||||
case 'H':
|
case 'h':
|
||||||
return usage_hf_felica_sniff();
|
case 'H':
|
||||||
case 's':
|
return usage_hf_felica_sniff();
|
||||||
case 'S':
|
case 's':
|
||||||
samples2skip = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
case 'S':
|
||||||
cmdp += 2;
|
paramCount++;
|
||||||
break;
|
if (param_getlength(Cmd, paramCount) < 5) {
|
||||||
case 't':
|
samples2skip = param_get32ex(Cmd, paramCount++, 0, 10);
|
||||||
case 'T':
|
}else{
|
||||||
triggers2skip = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
PrintAndLogEx(ERR, "Invalid samples number!");
|
||||||
cmdp += 2;
|
return PM3_EINVARG;
|
||||||
break;
|
}
|
||||||
default:
|
break;
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
case 't':
|
||||||
errors = true;
|
case 'T':
|
||||||
break;
|
paramCount++;
|
||||||
|
if (param_getlength(Cmd, paramCount) < 5) {
|
||||||
|
triggers2skip = param_get32ex(Cmd, paramCount++, 0, 10);
|
||||||
|
}else{
|
||||||
|
PrintAndLogEx(ERR, "Invalid triggers number!");
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, paramCount));
|
||||||
|
return usage_hf_felica_sniff();
|
||||||
|
}
|
||||||
|
i += 2;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if(samples2skip == 0){
|
||||||
|
samples2skip = 10;
|
||||||
|
PrintAndLogEx(INFO, "Set default samples2skip: %i", samples2skip);
|
||||||
|
}
|
||||||
|
if(triggers2skip == 0){
|
||||||
|
triggers2skip = 10;
|
||||||
|
PrintAndLogEx(INFO, "Set default triggers2skip: %i", triggers2skip);
|
||||||
}
|
}
|
||||||
//Validations
|
|
||||||
if (errors || cmdp == 0) return usage_hf_felica_sniff();
|
|
||||||
|
|
||||||
|
PrintAndLogEx(INFO, "Start Sniffing now. You can stop sniffing with clicking the PM3 Button");
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_FELICA_SNIFF, samples2skip, triggers2skip, 0, NULL, 0);
|
SendCommandMIX(CMD_HF_FELICA_SNIFF, samples2skip, triggers2skip, 0, NULL, 0);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue