From aacd31e32689c4dc1bf7b4cdc5e98d074c47619c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 14 Aug 2010 16:22:56 +0800 Subject: add functions to alter easycard log records and mifare value blocks --- easytool/easytool.c | 56 ----------------------------------------------------- 1 file changed, 56 deletions(-) (limited to 'easytool/easytool.c') diff --git a/easytool/easytool.c b/easytool/easytool.c index 65de185..fa15c6b 100644 --- a/easytool/easytool.c +++ b/easytool/easytool.c @@ -54,62 +54,6 @@ struct { mifare_tag *mft; } global; -/* Sector 0 of Block 2 seems to contain manufacturing timestamp */ -struct easy_block2sec0 { - uint8_t unknown[6]; - uint8_t timestamp[3]; - uint8_t unknown2[7]; -} __attribute__ ((packed)); - -/* Sector 2 of Block 15 */ -struct easy_block15sec2 { - uint8_t unknown[11]; - uint8_t day_of_month; - uint8_t unknown2; /* always 0x3d? */ - uint16_t sum_of_day; /* sum of all shop purchases on a day */ - uint8_t unknown3; -} __attribute__ ((packed)); - - -/* storage of a transaction log record on the transponder itself */ -struct easy_log_rec { - uint8_t trans_id; - uint8_t unknown; - uint8_t timestamp[3]; /* seconds since January 1st 1970 / 256 */ - uint8_t trans_type; - uint16_t amount; /* transaction amount / value */ - uint16_t remaining; /* remaining value on card _after_ trans */ - uint8_t unknown2; - uint8_t station_code; /* MRT station code */ - uint16_t reader_code; /* unique code of RFID reader */ - uint8_t unknown3[2]; -} __attribute__ ((packed)); - -/* Mifare classic VALUE BLOCK */ -struct mfcl_value_block { - uint32_t value; /* value in NTD */ - uint32_t value_inv; /* bit-inverted copy of value in NTD */ - uint32_t value_backup; /* backup copy of value in NTD */ - uint8_t addr[4]; -} __attribute__ ((packed)); - -static time_t easy_timestamp2time(const uint8_t *easy_ts) -{ - return (easy_ts[2] << 16 | easy_ts[1] << 8 | easy_ts[0]) << 8; -} - -static char tsbuf[64]; -char *easy_asc_timestamp(const uint8_t *timestamp) -{ - time_t t_time = easy_timestamp2time(timestamp); - struct tm *t_tm = gmtime(&t_time); - memset(tsbuf, 0, sizeof(tsbuf)); - snprintf(tsbuf, sizeof(tsbuf), "%4u-%02u-%02u %02u:%02u", - t_tm->tm_year+1900, t_tm->tm_mon+1, t_tm->tm_mday, - t_tm->tm_hour, t_tm->tm_min); - return tsbuf; -} - static void dump_easy_log(const struct easy_log_rec *elr) { printf("%s | %02x | %10s | Paid %4u NTD | %4u NTD remaining\n", -- cgit v1.2.3