X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/b69adb794594cc7ea43d3aa70aab091265195abf..966c111e8c8e45e624465502d0ee405ebda9a39c:/client/cmdhftopaz.c diff --git a/client/cmdhftopaz.c b/client/cmdhftopaz.c index 4e9d5380..2f9bc3dc 100644 --- a/client/cmdhftopaz.c +++ b/client/cmdhftopaz.c @@ -21,6 +21,7 @@ #include "proxmark3.h" #include "iso14443crc.h" #include "protocols.h" +#include "cmdhf.h" #define TOPAZ_MAX_MEMORY 2048 @@ -33,7 +34,6 @@ static struct { uint8_t *dynamic_reserved_areas; } topaz_tag; - static void topaz_switch_on_field(void) { UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE, 0, 0}}; @@ -188,7 +188,7 @@ static bool topaz_print_lock_control_TLVs(uint8_t *memory) if (tag == 0x01) { // the Lock Control TLV uint8_t pages_addr = value[0] >> 4; uint8_t byte_offset = value[0] & 0x0f; - uint8_t size_in_bits = value[1] ? value[1] : 256; + uint8_t size_in_bits = value[1] ? value[1] : 255; uint8_t bytes_per_page = 1 << (value[2] & 0x0f); uint8_t bytes_locked_per_bit = 1 << (value[2] >> 4); PrintAndLog("Lock Area of %d bits at byte offset 0x%02x. Each Lock Bit locks %d bytes.", @@ -222,7 +222,7 @@ static int topaz_print_reserved_memory_control_TLVs(uint8_t *memory) if (tag == 0x02) { // the Reserved Memory Control TLV uint8_t pages_addr = value[0] >> 4; uint8_t byte_offset = value[0] & 0x0f; - uint8_t size_in_bytes = value[1] ? value[1] : 256; + uint8_t size_in_bytes = value[1] ? value[1] : 255; uint8_t bytes_per_page = 1 << (value[2] & 0x0f); PrintAndLog("Reserved Memory of %d bytes at byte offset 0x%02x.", size_in_bytes, @@ -252,18 +252,21 @@ static void topaz_print_NDEF(uint8_t *data) } -int CmdHFTopazReader(const char *Cmd) -{ +int CmdHFTopazReader(const char *Cmd) { int status; uint8_t atqa[2]; uint8_t rid_response[8]; uint8_t *uid_echo = &rid_response[2]; - uint8_t rall_response[124]; + uint8_t rall_response[130]; + bool verbose = TRUE; + + char ctmp = param_getchar(Cmd, 0); + if ( ctmp == 'S' || ctmp == 's') verbose = FALSE; status = topaz_select(atqa, rid_response); - + if (status == -1) { - PrintAndLog("Error: couldn't receive ATQA"); + if (verbose) PrintAndLog("Error: couldn't receive ATQA"); return -1; } @@ -287,7 +290,7 @@ int CmdHFTopazReader(const char *Cmd) PrintAndLog("HR0 : %02x (%sa Topaz tag (%scapable of carrying a NDEF message), %s memory map)", rid_response[0], (rid_response[0] & 0xF0) == 0x10 ? "" : "not ", (rid_response[0] & 0xF0) == 0x10 ? "" : "not ", - (rid_response[0] & 0x0F) == 0x10 ? "static" : "dynamic"); + (rid_response[0] & 0x0F) == 0x01 ? "static" : "dynamic"); PrintAndLog("HR1 : %02x", rid_response[1]); status = topaz_rall(uid_echo, rall_response); @@ -307,6 +310,7 @@ int CmdHFTopazReader(const char *Cmd) topaz_tag.uid[2], topaz_tag.uid[1], topaz_tag.uid[0]); + PrintAndLog(" UID[6] (Manufacturer Byte) = %02x, Manufacturer: %s", topaz_tag.uid[6], getTagInfo(topaz_tag.uid[6])); @@ -367,24 +371,23 @@ int CmdHFTopazReader(const char *Cmd) return 0; } - -int CmdHFTopazSim(const char *Cmd) -{ +int CmdHFTopazSim(const char *Cmd) { PrintAndLog("not yet implemented"); return 0; } - -int CmdHFTopazCmdRaw(const char *Cmd) -{ +int CmdHFTopazCmdRaw(const char *Cmd) { PrintAndLog("not yet implemented"); return 0; } +int CmdHFTopazList(const char *Cmd) { + CmdHFList("topaz"); + return 0; +} static int CmdHelp(const char *Cmd); - static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"}, @@ -392,14 +395,15 @@ static command_t CommandTable[] = {"sim", CmdHFTopazSim, 0, " -- Simulate Topaz tag"}, {"sniff", CmdHF14ASniff, 0, "Sniff Topaz reader-tag communication"}, {"raw", CmdHFTopazCmdRaw, 0, "Send raw hex data to tag"}, + {"list", CmdHFTopazList, 0, "[Deprecated] List Topaz history"}, {NULL, NULL, 0, NULL} }; - int CmdHFTopaz(const char *Cmd) { // flush - WaitForResponseTimeout(CMD_ACK,NULL,100); - + //WaitForResponseTimeout(CMD_ACK,NULL,100); + clearCommandBuffer(); + // parse CmdsParse(CommandTable, Cmd); return 0;