mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-09 01:36:52 +08:00
chg: 'lf hitag writer' - refactored with timeouts etc.
chg: 'lf hitag' test without toggle mode enabled
This commit is contained in:
parent
0790c8b328
commit
b35ea2e352
3 changed files with 33 additions and 23 deletions
|
@ -705,7 +705,8 @@ void SniffHitag(uint32_t type) {
|
||||||
|
|
||||||
// Set up eavesdropping mode, frequency divisor which will drive the FPGA
|
// Set up eavesdropping mode, frequency divisor which will drive the FPGA
|
||||||
// and analog mux selection.
|
// and analog mux selection.
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_TOGGLE_MODE);
|
//FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_TOGGLE_MODE);
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT);
|
||||||
|
|
||||||
//125Khz
|
//125Khz
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95);
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <amiibo.h>
|
#include <amiibo.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../loclass/fileutil.h"
|
#include "../loclass/fileutils.h"
|
||||||
|
|
||||||
#define NTAG215_SIZE 540
|
#define NTAG215_SIZE 540
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ size_t nbytes(size_t nbits) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int usage_hitag_reader(void) {
|
int usage_hitag_reader(void) {
|
||||||
|
PrintAndLogEx(NORMAL, "Hitag reader functions");
|
||||||
PrintAndLogEx(NORMAL, "Usage: lf hitag reader [h] <reader function #>");
|
PrintAndLogEx(NORMAL, "Usage: lf hitag reader [h] <reader function #>");
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
PrintAndLogEx(NORMAL, "Options:");
|
||||||
PrintAndLogEx(NORMAL, " h This help");
|
PrintAndLogEx(NORMAL, " h This help");
|
||||||
|
@ -45,6 +46,19 @@ int usage_hitag_reader(void) {
|
||||||
PrintAndLogEx(NORMAL, " 26 Just read UID");
|
PrintAndLogEx(NORMAL, " 26 Just read UID");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int usage_hitag_writer(void) {
|
||||||
|
PrintAndLogEx(NORMAL, "Hitag writer functions");
|
||||||
|
PrintAndLogEx(NORMAL, "Usage: lf hitag write [h] <reader function #>");
|
||||||
|
PrintAndLogEx(NORMAL, "Options:");
|
||||||
|
PrintAndLogEx(NORMAL, " h This help");
|
||||||
|
PrintAndLogEx(NORMAL, " HitagS (0*)");
|
||||||
|
PrintAndLogEx(NORMAL, " 03 <nr,ar> (Challenge) <page> <byte0...byte3> write page on a Hitag S tag");
|
||||||
|
PrintAndLogEx(NORMAL, " 04 <key> (set to 0 if no authentication is needed) <page> <byte0...byte3> write page on a Hitag S tag");
|
||||||
|
PrintAndLogEx(NORMAL, " Hitag1 (1*)");
|
||||||
|
PrintAndLogEx(NORMAL, " Hitag2 (2*)");
|
||||||
|
PrintAndLogEx(NORMAL, " 24 <key> (set to 0 if no authentication is needed) <page> <byte0...byte3> write page on a Hitag2 tag");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int CmdLFHitagList(const char *Cmd) {
|
int CmdLFHitagList(const char *Cmd) {
|
||||||
uint8_t *got = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *got = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
|
@ -256,7 +270,6 @@ int CmdLFHitagReader(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
PrintAndLogEx(NORMAL, "\nError: unkown reader function %d", htf);
|
|
||||||
return usage_hitag_reader();
|
return usage_hitag_reader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,44 +381,40 @@ int CmdLFHitagWP(const char *Cmd) {
|
||||||
UsbCommand c = { CMD_WR_HITAG_S };
|
UsbCommand c = { CMD_WR_HITAG_S };
|
||||||
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
||||||
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
||||||
|
|
||||||
switch (htf) {
|
switch (htf) {
|
||||||
case 03: { //WHTSF_CHALLENGE
|
case WHTSF_CHALLENGE: {
|
||||||
num_to_bytes(param_get64ex(Cmd, 1, 0, 16), 8, htd->auth.NrAr);
|
num_to_bytes(param_get64ex(Cmd, 1, 0, 16), 8, htd->auth.NrAr);
|
||||||
c.arg[2] = param_get32ex(Cmd, 2, 0, 10);
|
c.arg[2] = param_get32ex(Cmd, 2, 0, 10);
|
||||||
num_to_bytes(param_get32ex(Cmd, 3, 0, 16), 4, htd->auth.data);
|
num_to_bytes(param_get32ex(Cmd, 3, 0, 16), 4, htd->auth.data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case WHTSF_KEY:
|
||||||
case 04:
|
case WHT2F_CRYPTO: {
|
||||||
case 24: {
|
|
||||||
//WHTSF_KEY
|
|
||||||
num_to_bytes(param_get64ex(Cmd, 1, 0, 16), 6, htd->crypto.key);
|
num_to_bytes(param_get64ex(Cmd, 1, 0, 16), 6, htd->crypto.key);
|
||||||
c.arg[2] = param_get32ex(Cmd, 2, 0, 10);
|
c.arg[2] = param_get32ex(Cmd, 2, 0, 10);
|
||||||
num_to_bytes(param_get32ex(Cmd, 3, 0, 16), 4, htd->crypto.data);
|
num_to_bytes(param_get32ex(Cmd, 3, 0, 16), 4, htd->crypto.data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default: {
|
default: {
|
||||||
PrintAndLogEx(WARNING, "Error: unkown writer function %d", htf);
|
return usage_hitag_writer();
|
||||||
PrintAndLogEx(NORMAL, "Hitag writer functions");
|
|
||||||
PrintAndLogEx(NORMAL, " HitagS (0*)");
|
|
||||||
PrintAndLogEx(NORMAL, " 03 <nr,ar> (Challenge) <page> <byte0...byte3> write page on a Hitag S tag");
|
|
||||||
PrintAndLogEx(NORMAL, " 04 <key> (set to 0 if no authentication is needed) <page> <byte0...byte3> write page on a Hitag S tag");
|
|
||||||
PrintAndLogEx(NORMAL, " Hitag1 (1*)");
|
|
||||||
PrintAndLogEx(NORMAL, " Hitag2 (2*)");
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
// Copy the hitag function into the first argument
|
|
||||||
c.arg[0] = htf;
|
c.arg[0] = htf;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
WaitForResponse(CMD_ACK, &resp);
|
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
|
||||||
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Check the return status, stored in the first argument
|
if (resp.arg[0] == false) {
|
||||||
if (resp.arg[0] == false) return 1;
|
PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue