|
@@ -67,17 +67,20 @@ void rw_tag(int coins, char *buy_date, char *expire_date) {
|
|
|
|
|
|
printf("=> Trying to authenticate with SecretKey "ANSI_COLOR_YELLOW"%.2x %.2x %.2x %.2x %.2x %.2x"ANSI_COLOR_RESET" ...\n", SecretKey[0][0], SecretKey[0][1], SecretKey[0][2], SecretKey[0][3], SecretKey[0][4], SecretKey[0][5]);
|
|
|
|
|
|
+ //Check for a good tag type
|
|
|
if(mifare_classic_connect(tags[i]) == OPERATION_OK) {
|
|
|
printf(ANSI_COLOR_GREEN"=> Mifare tag connected !\n"ANSI_COLOR_RESET);
|
|
|
}
|
|
|
else printf(ANSI_COLOR_RED"Non ca chie dans la colle mais grave, ton tag est moisi\n"ANSI_COLOR_RESET);
|
|
|
|
|
|
+ //Authenticating the tag
|
|
|
if(mifare_classic_authenticate(tags[i], 5, SecretKey[0], MFC_KEY_A) == OPERATION_OK) {
|
|
|
printf(ANSI_COLOR_GREEN"=> Tag authenticated !\n"ANSI_COLOR_RESET);
|
|
|
}
|
|
|
else printf(ANSI_COLOR_RED"Non ca chie dans la colle mais grave, check ta clé\n"ANSI_COLOR_RESET);
|
|
|
|
|
|
- if(coins != 0 && buy_date != NULL && expire_date != NULL) {
|
|
|
+ //Check of arguements in rw_tag() for read only or write/read
|
|
|
+ if((coins != 0 || coins == 0) && buy_date != NULL && expire_date != NULL) {
|
|
|
|
|
|
char *token;
|
|
|
token = strtok (buy_date,"/");
|
|
@@ -109,7 +112,6 @@ void rw_tag(int coins, char *buy_date, char *expire_date) {
|
|
|
printf("Reading a second time to check...\n");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if( (mifare_classic_read(tags[i], 5, &data_read5) == OPERATION_OK)
|
|
|
&&
|
|
|
(mifare_classic_read(tags[i], 4, &data_read4) == OPERATION_OK) )
|
|
@@ -119,6 +121,15 @@ void rw_tag(int coins, char *buy_date, char *expire_date) {
|
|
|
printf(" => Credits :\t\t"ANSI_COLOR_YELLOW"%.2d\n"ANSI_COLOR_RESET, data_read5[7]);
|
|
|
printf(" => Buy date :\t\t"ANSI_COLOR_YELLOW"%.2d/%.2d/%.2d\n"ANSI_COLOR_RESET, data_read5[0], data_read5[1], data_read5[2]);
|
|
|
printf(" => Expiration date :\t"ANSI_COLOR_YELLOW"%.2d/%.2d/%.2d\n"ANSI_COLOR_RESET, data_read5[3], data_read5[4], data_read5[5]);
|
|
|
+ if (data_read5[7] == 0) {
|
|
|
+ printf(" => Type : "ANSI_COLOR_YELLOW"\t\tFull access tag (Probably)\n"ANSI_COLOR_RESET);
|
|
|
+ printf(" => Last validation :\t"ANSI_COLOR_YELLOW"%.2d/%.2d/%.2d at %.2d:%.2d\n"ANSI_COLOR_RESET,
|
|
|
+ data_read5[8], data_read5[9], data_read5[10], data_read5[11], data_read5[12]);
|
|
|
+ }
|
|
|
+
|
|
|
+ else
|
|
|
+ printf(" => Type : "ANSI_COLOR_YELLOW"\t\tCredited card\n"ANSI_COLOR_RESET);
|
|
|
+
|
|
|
//printf(" => Card keeped :\t");
|
|
|
}
|
|
|
|