summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-08-13 15:20:38 +0800
committerHarald Welte <laforge@gnumonks.org>2010-08-13 15:24:02 +0800
commitfe1bcc3fb1ba672d4a0dc046b769c386a7eed550 (patch)
tree1f43252a850da676a8ba77368031beccfe70c5b5
parentb4915a6f814e1b410063c1da83057af232346af0 (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
-rw-r--r--easycard.2/notes.txt12
-rw-r--r--easytool/easytool.c20
2 files changed, 25 insertions, 7 deletions
diff --git a/easycard.2/notes.txt b/easycard.2/notes.txt
index c2e15c1..fefc5f1 100644
--- a/easycard.2/notes.txt
+++ b/easycard.2/notes.txt
@@ -52,16 +52,20 @@ Address 0x3e0
DATA BLOCK somehow related to shop purchasing
00003e0 0000 0000 0000 0000 0000 0b00 233d 0000
first purchase with easycard.1 (7eleven)
- 0x23 == 35 -> amount of purchase
+ 0x0b == day of month of purchase (11th)
+ 0x0023 == 35 -> amount of purchase
00003e0 0000 0000 0000 0000 0000 0c00 4b3d 0000
second purchase with easycard.1 (7eleven)
- 0x4b == 75 -> amount of purchase
+ 0x0c == day of month of purchase (12th)
+ 0x004b == 75 -> amount of purchase
00003e0 0000 0000 0000 0000 0000 0c00 5f3d 0000
first purchase with easycard.2 (starbucks)
- 0x5f == 95 -> amount of purchase
+ 0x0c == day of month of purchase (12th)
+ 0x005f == 95 -> amount of purchase
00003e0 0000 0000 0000 0000 0000 0c00 233d 0001
second purchase with easycard.2 (cosmed)
- 0x23 == 35 -> NOT amount of purchase (0xc4)
+ 0x0c == day of month of purchase (12th)
+ 0x0123 == 291 -> total of all purchases today
== timestamp ==
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 */
personal git repositories of Harald Welte. Your mileage may vary