mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-24 23:25:40 -07:00
prepping for fudan pm3 commands
This commit is contained in:
parent
712e46ab5a
commit
8f8f9f97ad
1 changed files with 121 additions and 31 deletions
|
@ -66,7 +66,7 @@ static void fudan_print_blocks(uint16_t n, uint8_t *d) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* GenerateFilename(iso14a_card_select_t *card, const char *prefix, const char *suffix) {
|
static char *GenerateFilename(iso14a_card_select_t *card, const char *prefix, const char *suffix) {
|
||||||
if (card == NULL) {
|
if (card == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ static int CmdHFFudanReader(const char *Cmd) {
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_lit0("v", "verbose", "Verbose scan and output"),
|
arg_lit0("v", "verbose", "verbose output"),
|
||||||
arg_lit0("@", NULL, "optional - continuous reader mode"),
|
arg_lit0("@", NULL, "optional - continuous reader mode"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
|
@ -224,9 +224,10 @@ static int CmdHFFudanReader(const char *Cmd) {
|
||||||
|
|
||||||
if (cm) {
|
if (cm) {
|
||||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
||||||
return read_fudan_uid(cm, verbose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_fudan_uid(cm, verbose);
|
||||||
|
|
||||||
DropField();
|
DropField();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +238,7 @@ static int CmdHFFudanDump(const char *Cmd) {
|
||||||
"Dump FUDAN tag to binary file\n"
|
"Dump FUDAN tag to binary file\n"
|
||||||
"If no <name> given, UID will be used as filename",
|
"If no <name> given, UID will be used as filename",
|
||||||
"hf fudan dump -f mydump --> dump using filename\n"
|
"hf fudan dump -f mydump --> dump using filename\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
|
@ -272,7 +273,7 @@ static int CmdHFFudanDump(const char *Cmd) {
|
||||||
// detect card size
|
// detect card size
|
||||||
// 512b, 8kbits
|
// 512b, 8kbits
|
||||||
uint8_t num_blocks = MAX_FUDAN_05_BLOCKS;
|
uint8_t num_blocks = MAX_FUDAN_05_BLOCKS;
|
||||||
switch(t) {
|
switch (t) {
|
||||||
case FM11RF008M:
|
case FM11RF008M:
|
||||||
num_blocks = MAX_FUDAN_08_BLOCKS;
|
num_blocks = MAX_FUDAN_08_BLOCKS;
|
||||||
break;
|
break;
|
||||||
|
@ -286,18 +287,6 @@ static int CmdHFFudanDump(const char *Cmd) {
|
||||||
|
|
||||||
uint8_t carddata[num_blocks * MAX_FUDAN_BLOCK_SIZE];
|
uint8_t carddata[num_blocks * MAX_FUDAN_BLOCK_SIZE];
|
||||||
|
|
||||||
/*
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -a -b 7 -k 26");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3000");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3001");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3002");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3003");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3004");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3005");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -k -c 3006");
|
|
||||||
PrintAndLogEx(HINT, " hf 14a raw -c 3007");
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
//
|
||||||
uint16_t flags = (ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS | ISO14A_RAW);
|
uint16_t flags = (ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS | ISO14A_RAW);
|
||||||
uint32_t argtimeout = 0;
|
uint32_t argtimeout = 0;
|
||||||
|
@ -361,6 +350,107 @@ static int CmdHFFudanDump(const char *Cmd) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int CmdHFFudanWrBl(const char *Cmd) {
|
||||||
|
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "hf fudan wrbl",
|
||||||
|
"Write fudan block with 4 hex bytes of data\n",
|
||||||
|
"hf mf wrbl --blk 1 -k FFFFFFFFFFFF -d 01020304"
|
||||||
|
);
|
||||||
|
void *argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_int1(NULL, "blk", "<dec>", "block number"),
|
||||||
|
arg_str0("k", "key", "<hex>", "key, 6 hex bytes"),
|
||||||
|
arg_str0("d", "data", "<hex>", "bytes to write, 4 hex bytes"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
|
int b = arg_get_int_def(ctx, 1, 1);
|
||||||
|
|
||||||
|
int keylen = 0;
|
||||||
|
uint8_t key[6] = {0};
|
||||||
|
CLIGetHexWithReturn(ctx, 2, key, &keylen);
|
||||||
|
|
||||||
|
uint8_t block[MAX_FUDAN_BLOCK_SIZE] = {0x00};
|
||||||
|
int blen = 0;
|
||||||
|
CLIGetHexWithReturn(ctx, 3, block, &blen);
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
if (blen != MAX_FUDAN_BLOCK_SIZE) {
|
||||||
|
PrintAndLogEx(WARNING, "block data must include 4 HEX bytes. Got %i", blen);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b > 255) {
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "Not implemented yet. Feel free to contribute!");
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
uint8_t blockno = (uint8_t)b;
|
||||||
|
|
||||||
|
PrintAndLogEx(INFO, "Writing block no %d, key %s", blockno, sprint_hex_inrow(key, sizeof(key)));
|
||||||
|
PrintAndLogEx(INFO, "data: %s", sprint_hex(block, sizeof(block)));
|
||||||
|
|
||||||
|
uint8_t data[26];
|
||||||
|
memcpy(data, key, sizeof(key));
|
||||||
|
memcpy(data + 10, block, sizeof(block));
|
||||||
|
clearCommandBuffer();
|
||||||
|
SendCommandMIX(CMD_HF_MIFARE_WRITEBL, blockno, 0, 0, data, sizeof(data));
|
||||||
|
|
||||||
|
PacketResponseNG resp;
|
||||||
|
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
|
||||||
|
PrintAndLogEx(FAILED, "Command execute timeout");
|
||||||
|
return PM3_ETIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t isok = resp.oldarg[0] & 0xff;
|
||||||
|
if (isok) {
|
||||||
|
PrintAndLogEx(SUCCESS, "Write ( " _GREEN_("ok") " )");
|
||||||
|
PrintAndLogEx(HINT, "try `" _YELLOW_("hf fudan rdbl") "` to verify");
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(FAILED, "Write ( " _RED_("fail") " )");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int CmdHFFudanRdBl(const char *Cmd) {
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "hf fudan rdbl",
|
||||||
|
"Read fudan block",
|
||||||
|
"hf fudan rdbl --blk 0 -k FFFFFFFFFFFF\n"
|
||||||
|
"hf fudan rdbl --blk 3 -v\n"
|
||||||
|
);
|
||||||
|
void *argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_int1(NULL, "blk", "<dec>", "block number"),
|
||||||
|
arg_str0("k", "key", "<hex>", "key, 6 hex bytes"),
|
||||||
|
arg_lit0("v", "verbose", "verbose output"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
int b = arg_get_int_def(ctx, 1, 0);
|
||||||
|
|
||||||
|
int keylen = 0;
|
||||||
|
uint8_t key[6] = {0};
|
||||||
|
CLIGetHexWithReturn(ctx, 2, key, &keylen);
|
||||||
|
// bool verbose = arg_get_lit(ctx, 3);
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
if (b > 255) {
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "Not implemented yet. Feel free to contribute!");
|
||||||
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int CmdHFFudanView(const char *Cmd) {
|
static int CmdHFFudanView(const char *Cmd) {
|
||||||
|
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
|
@ -402,9 +492,9 @@ static command_t CommandTable[] = {
|
||||||
{"reader", CmdHFFudanReader, IfPm3Iso14443a, "Act like a fudan reader"},
|
{"reader", CmdHFFudanReader, IfPm3Iso14443a, "Act like a fudan reader"},
|
||||||
{"dump", CmdHFFudanDump, IfPm3Iso14443a, "Dump FUDAN tag to binary file"},
|
{"dump", CmdHFFudanDump, IfPm3Iso14443a, "Dump FUDAN tag to binary file"},
|
||||||
//{"sim", CmdHFFudanSim, IfPm3Iso14443a, "Simulate a fudan tag"},
|
//{"sim", CmdHFFudanSim, IfPm3Iso14443a, "Simulate a fudan tag"},
|
||||||
//{"rdbl", CmdHFFudanRead, IfPm3Iso14443a, "Read a fudan tag"},
|
{"rdbl", CmdHFFudanRdBl, IfPm3Iso14443a, "Read a fudan tag"},
|
||||||
{"view", CmdHFFudanView, AlwaysAvailable, "Display content from tag dump file"},
|
{"view", CmdHFFudanView, AlwaysAvailable, "Display content from tag dump file"},
|
||||||
//{"wrbl", CmdHFFudanWrite, IfPm3Iso14443a, "Write a fudan tag"},
|
{"wrbl", CmdHFFudanWrBl, IfPm3Iso14443a, "Write a fudan tag"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue