Skip to content

Commit

Permalink
allow setting of UID for special 'chinese' ultralight cards
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamLaurie committed Aug 31, 2013
1 parent f6fff26 commit 07c54cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions utils/nfc-mfultralight.1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Be cautious that some parts of a Ultralight memory can be written only once
and some parts are used as lock bits, so please read the tag documentation
before experimenting too much!

To set the UID of a special writeable UID card, edit the first 7 bytes of a dump file and
then write it back, answering 'Y' to the question 'Write UID bytes?'.

.SH OPTIONS
.BR r " | " w
Perform read from (
Expand Down
19 changes: 14 additions & 5 deletions utils/nfc-mfultralight.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2013 Adam Laurie
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -112,11 +113,12 @@ write_card(void)
uint32_t uiBlock = 0;
bool bFailure = false;
uint32_t uiWritenPages = 0;
uint32_t uiSkippedPages;
uint32_t uiSkippedPages = 0;

char buffer[BUFSIZ];
bool write_otp;
bool write_lock;
bool write_uid;

printf("Write OTP bytes ? [yN] ");
if (!fgets(buffer, BUFSIZ, stdin)) {
Expand All @@ -128,13 +130,20 @@ write_card(void)
ERR("Unable to read standard input.");
}
write_lock = ((buffer[0] == 'y') || (buffer[0] == 'Y'));
printf("Write UID bytes (only for special writeable UID cards) ? [yN] ");
if (!fgets(buffer, BUFSIZ, stdin)) {
ERR("Unable to read standard input.");
}
write_uid = ((buffer[0] == 'y') || (buffer[0] == 'Y'));

printf("Writing %d pages |", uiBlocks + 1);
/* We need to skip 2 first pages. */
printf("ss");
uiSkippedPages = 2;
/* We may need to skip 2 first pages. */
if(!write_uid) {
printf("ss");
uiSkippedPages = 2;
}

for (int page = 0x2; page <= 0xF; page++) {
for (int page = uiSkippedPages; page <= 0xF; page++) {
if ((page == 0x2) && (!write_lock)) {
printf("s");
uiSkippedPages++;
Expand Down

0 comments on commit 07c54cd

Please sign in to comment.