49 | 49 |
{ "write unlocked", com_write_tag_unlocked, 0, 1, "On pirate cards, write 1k tag with block 0" },
|
50 | 50 |
|
51 | 51 |
{ "print", com_print, 0, 1, "1k|4k : Print tag data" },
|
|
52 |
{ "print head", com_print_head, 0, 1, "Print first sector" },
|
52 | 53 |
{ "print keys", com_print_keys, 0, 1, "1k|4k : Print tag's keys" },
|
53 | 54 |
{ "print ac", com_print_ac, 0, 1, "Print access conditions" },
|
54 | 55 |
|
55 | 56 |
{ "set", com_set, 0, 1, "#block #offset = xx xx xx : Set tag data" },
|
|
57 |
{ "setuid", com_setuid, 0, 1, "xx xx xx xx: Set tag UID" },
|
56 | 58 |
|
57 | 59 |
{ "keys load", com_keys_load, 1, 1, "Load keys from a file" },
|
58 | 60 |
{ "keys save", com_keys_save, 1, 1, "Save keys to a file" },
|
|
278 | 280 |
return 0;
|
279 | 281 |
}
|
280 | 282 |
|
|
283 |
int com_print_head(char* arg) {
|
|
284 |
print_tag_head();
|
|
285 |
return 0;
|
|
286 |
}
|
|
287 |
|
281 | 288 |
int com_set(char* arg) {
|
282 | 289 |
char* block_str = strtok(arg, " ");
|
283 | 290 |
char* offset_str = strtok(NULL, " ");
|
|
329 | 336 |
current_tag.amb[block].mbd.abtData[offset++] = (uint8_t)byte;
|
330 | 337 |
|
331 | 338 |
} while((byte_str = strtok(NULL, " ")) != (char*)NULL);
|
|
339 |
|
|
340 |
return 0;
|
|
341 |
}
|
|
342 |
|
|
343 |
int com_setuid(char* arg) {
|
|
344 |
char* byte_str = strtok(arg, " ");
|
|
345 |
int block = 0;
|
|
346 |
|
|
347 |
/// TODO : Check arg size (display warning if < 4)
|
|
348 |
if (!byte_str) {
|
|
349 |
printf("Too few arguments: xx xx xx xx\n");
|
|
350 |
return -1;
|
|
351 |
}
|
|
352 |
|
|
353 |
// Consume the byte tokens
|
|
354 |
do {
|
|
355 |
long int byte = strtol(byte_str, &byte_str, 16);
|
|
356 |
|
|
357 |
if (byte < 0 || byte > 0xff) {
|
|
358 |
printf("Invalid byte value [0,ff]: %lx\n", byte);
|
|
359 |
return -1;
|
|
360 |
}
|
|
361 |
|
|
362 |
// Write the data
|
|
363 |
current_tag.amb[0].mbd.abtData[block++] = (uint8_t)byte;
|
|
364 |
|
|
365 |
} while(((byte_str = strtok(NULL, " ")) != (char*)NULL) && (block < 4));
|
|
366 |
// Compute and write BCC
|
|
367 |
current_tag.amb[0].mbd.abtData[4] = (uint8_t)current_tag.amb[0].mbd.abtData[0] ^
|
|
368 |
(uint8_t)current_tag.amb[0].mbd.abtData[1] ^
|
|
369 |
(uint8_t)current_tag.amb[0].mbd.abtData[2] ^
|
|
370 |
(uint8_t)current_tag.amb[0].mbd.abtData[3];
|
332 | 371 |
|
333 | 372 |
return 0;
|
334 | 373 |
}
|