diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-08-13 15:20:38 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-08-13 15:24:02 +0800 |
commit | fe1bcc3fb1ba672d4a0dc046b769c386a7eed550 (patch) | |
tree | 1f43252a850da676a8ba77368031beccfe70c5b5 /easytool | |
parent | b4915a6f814e1b410063c1da83057af232346af0 (diff) |
Unravel the mystery of Block 15 Sector 2: Total sum of purchases / day
This is how they implement the daily limit of the card
Diffstat (limited to 'easytool')
-rw-r--r-- | easytool/easytool.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/easytool/easytool.c b/easytool/easytool.c index 62c5a0f..d6b799e 100644 --- a/easytool/easytool.c +++ b/easytool/easytool.c @@ -61,6 +61,16 @@ struct easy_block2sec0 { 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; @@ -155,10 +165,12 @@ static void dump_easycard(mifare_tag *mft) { unsigned int sect; mifare_block_manufacturer *manuf = &mft->amb[0].mbm; - struct mfcl_value_block *val = + struct mfcl_value_block *val = (struct mfcl_value_block *) mft->amb[8].mbd.abtData; - struct easy_block2sec0 *b2s0 = - (struct easy_block2sec0 *) mft->amb[4].mbd.abtData; + struct easy_block2sec0 *b2s0 = + (struct easy_block2sec0 *) mft->amb[2*4+0].mbd.abtData; + struct easy_block15sec2 *b15s2 = + (struct easy_block15sec2 *) mft->amb[15*4+2].mbd.abtData; uint32_t uid = *((uint32_t *) manuf->abtUID); /* dump the header */ @@ -166,6 +178,8 @@ static void dump_easycard(mifare_tag *mft) printf("Date of manufacture: %s\n", easy_asc_timestamp(b2s0->timestamp)); printf("Current Balance: %5u NTD\n", val->value); + printf("Sum of all purchases on day %u (of month): %u NTD\n", + b15s2->day_of_month, b15s2->sum_of_day); printf("\nTransaction Log:\n"); /* dump the transaction log */ |