style
This commit is contained in:
@@ -27,28 +27,28 @@ static int usage_thinfilm_info(void) {
|
||||
// https://github.com/nfc-tools/libnfc/blob/master/utils/nfc-barcode.c
|
||||
static int print_barcode(uint8_t *barcode, const size_t barcode_len) {
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0] );
|
||||
PrintAndLogEx(SUCCESS, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0]);
|
||||
PrintAndLogEx(SUCCESS, " Data format : "_YELLOW_("%02X"), barcode[1]);
|
||||
|
||||
uint8_t b1, b2;
|
||||
compute_crc(CRC_14443_A, barcode, barcode_len - 2, &b1, &b2);
|
||||
bool isok = (barcode[barcode_len - 1] == b1 && barcode[barcode_len - 2] == b2);
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, " checksum : "_YELLOW_("%02X %02X")"- %s", b2, b1, (isok) ? _GREEN_("OK") : _RED_("fail"));
|
||||
PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"),
|
||||
sprint_hex(barcode, barcode_len)
|
||||
);
|
||||
sprint_hex(barcode, barcode_len)
|
||||
);
|
||||
|
||||
|
||||
char s[45];
|
||||
memset(s, 0x00, sizeof(s));
|
||||
|
||||
|
||||
switch (barcode[1]) {
|
||||
case 0:
|
||||
printf("Data Format Field: Reserved for allocation by tag manufacturer\n");
|
||||
return PM3_SUCCESS;
|
||||
case 1:
|
||||
snprintf(s, sizeof(s), "http://www." );
|
||||
snprintf(s, sizeof(s), "http://www.");
|
||||
break;
|
||||
case 2:
|
||||
snprintf(s, sizeof(s), "https://www.");
|
||||
@@ -60,15 +60,15 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len) {
|
||||
snprintf(s, sizeof(s), "https://");
|
||||
break;
|
||||
case 5:
|
||||
PrintAndLogEx(SUCCESS, "EPC: %s", sprint_hex(barcode + 2, 12) );
|
||||
PrintAndLogEx(SUCCESS, "EPC: %s", sprint_hex(barcode + 2, 12));
|
||||
return PM3_SUCCESS;
|
||||
default:
|
||||
PrintAndLogEx(SUCCESS, "Data Format Field: unknown (%02X)", barcode[1]);
|
||||
PrintAndLogEx(SUCCESS, "Data:" _YELLOW_("%s"), sprint_hex(barcode + 2, barcode_len - 2) );
|
||||
PrintAndLogEx(SUCCESS, "Data:" _YELLOW_("%s"), sprint_hex(barcode + 2, barcode_len - 2));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
snprintf(s + strlen(s), barcode_len - 3, (const char*)&barcode[2] , barcode_len - 4);
|
||||
|
||||
snprintf(s + strlen(s), barcode_len - 3, (const char *)&barcode[2], barcode_len - 4);
|
||||
|
||||
for (uint8_t i = 0; i < strlen(s); i++) {
|
||||
|
||||
@@ -108,8 +108,8 @@ static int CmdHfThinFilmInfo(const char *Cmd) {
|
||||
}
|
||||
|
||||
int infoThinFilm(void) {
|
||||
|
||||
clearCommandBuffer();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_THINFILM_READ, NULL, 0);
|
||||
|
||||
PacketResponseNG resp;
|
||||
@@ -117,9 +117,9 @@ int infoThinFilm(void) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if ( resp.status == PM3_SUCCESS ) {
|
||||
print_barcode( resp.data.asBytes, resp.length );
|
||||
|
||||
if (resp.status == PM3_SUCCESS) {
|
||||
print_barcode(resp.data.asBytes, resp.length);
|
||||
}
|
||||
|
||||
return resp.status;
|
||||
|
||||
@@ -43,7 +43,7 @@ static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response, uint
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0, cmd, len);
|
||||
|
||||
PacketResponseNG resp;
|
||||
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
@@ -98,10 +98,10 @@ static int topaz_select(uint8_t *atqa, uint8_t *rid_response) {
|
||||
|
||||
// read all of the static memory of a selected Topaz tag.
|
||||
static int topaz_rall(uint8_t *uid, uint8_t *response) {
|
||||
uint16_t resp_len = 0;
|
||||
uint16_t resp_len = 0;
|
||||
uint8_t rall_cmd[] = {TOPAZ_RALL, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
memcpy(&rall_cmd[3], uid, 4);
|
||||
|
||||
|
||||
if (topaz_send_cmd(rall_cmd, sizeof(rall_cmd), response, &resp_len) == PM3_ETIMEOUT) {
|
||||
topaz_switch_off_field();
|
||||
return PM3_ESOFT; // RALL failed
|
||||
@@ -119,7 +119,7 @@ static int topaz_read_block(uint8_t *uid, uint8_t blockno, uint8_t *block_data)
|
||||
|
||||
read8_cmd[1] = blockno;
|
||||
memcpy(&read8_cmd[10], uid, 4);
|
||||
|
||||
|
||||
if (topaz_send_cmd(read8_cmd, sizeof(read8_cmd), read8_response, &resp_len) == PM3_ETIMEOUT) {
|
||||
topaz_switch_off_field();
|
||||
return PM3_ESOFT; // READ8 failed
|
||||
@@ -136,7 +136,7 @@ static int topaz_read_segment(uint8_t *uid, uint8_t segno, uint8_t *segment_data
|
||||
|
||||
rseg_cmd[1] = segno << 4;
|
||||
memcpy(&rseg_cmd[10], uid, 4);
|
||||
|
||||
|
||||
if (topaz_send_cmd(rseg_cmd, sizeof(rseg_cmd), rseg_response, &resp_len) == PM3_ETIMEOUT) {
|
||||
topaz_switch_off_field();
|
||||
return PM3_ESOFT; // RSEG failed
|
||||
@@ -420,7 +420,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
||||
(rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
|
||||
(rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
|
||||
(rid_response[0] & 0x0F) == 0x01 ? "static" : "dynamic");
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "HR1 : %02x", rid_response[1]);
|
||||
|
||||
status = topaz_rall(uid_echo, rall_response);
|
||||
@@ -475,7 +475,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
||||
sprintf(&line[3 * j], "%02x ", topaz_tag.data_blocks[0x0e][j]);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "-------+--------+-------------------------+------------");
|
||||
PrintAndLogEx(NORMAL, " 0x%02x | 0x%02x | %s| %-3s", 0x0e, 0x0e * 8, line, "n/a");
|
||||
PrintAndLogEx(NORMAL, " 0x%02x | 0x%02x | %s| %-3s", 0x0e, 0x0e * 8, line, "n/a");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
status = topaz_print_CC(&topaz_tag.data_blocks[1][0]);
|
||||
|
||||
Reference in New Issue
Block a user