Merge pull request #3361 from dangerous-tac0s/ultimatecard-pack-fix
PACK fix for the lua script hf_mf_ultimatecard
This commit is contained in:
2 files changed
+92
-26
No files matched your search
@@ -11,9 +11,11 @@ local _ntagpassword = nil
|
||||
local _key = '00000000' -- default UMC key
|
||||
local err_lock = 'use -k or change cfg0 block'
|
||||
local _print = 0
|
||||
local _ug4_version = ''
|
||||
local _packpage = 'E6'
|
||||
copyright = ''
|
||||
author = 'Nathan Glaser'
|
||||
version = 'v1.0.5'
|
||||
version = 'v1.0.6'
|
||||
date = 'Created - Jan 2022'
|
||||
desc = 'This script enables easy programming of an Ultimate Mifare Magic card'
|
||||
example = [[
|
||||
@@ -179,6 +181,30 @@ local function connect()
|
||||
end
|
||||
return true
|
||||
end
|
||||
---
|
||||
-- Probe UMC revision robustly. CF<key>CC occasionally returns a truncated
|
||||
-- frame (e.g. 3F/7F), so retry until we get a well-formed 5-byte version.
|
||||
-- New "UG4" replies 00 00 00 06 A0 -> PACK page 0x13; clean non-06A0 reads
|
||||
-- and an unprobeable card fall back to page 0xE6.
|
||||
local function detect_packpage()
|
||||
if _ug4_version ~= '' then return end -- already classified this run
|
||||
for i = 1, 5 do
|
||||
local v = (send("CF".._key.."CC") or ''):sub(1,10)
|
||||
if #v == 10 and v:find('^%x+$') then -- exactly 5 hex bytes
|
||||
_ug4_version = v:upper()
|
||||
break
|
||||
end
|
||||
end
|
||||
if _ug4_version == '00000006A0' then
|
||||
_packpage = '13'
|
||||
else
|
||||
_packpage = 'E6'
|
||||
if _ug4_version == '' then
|
||||
print('[!] Warning: could not confirm UMC revision (CC probe corrupted); using PACK page 0xE6')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---
|
||||
-- Read magic configuration
|
||||
local function read_config()
|
||||
@@ -195,6 +221,7 @@ local function read_config()
|
||||
atqaf = atqa1..' '..atqa2
|
||||
cardtype, cardprotocol, gtustr, atsstr = 'unknown', 'unknown', 'unknown', 'unknown'
|
||||
if magicconfig == nil then lib14a.disconnect(); return nil, "can't read configuration, "..err_lock end
|
||||
detect_packpage()
|
||||
if #magicconfig ~= 64 and #magicconfig ~= 68 then lib14a.disconnect(); return nil, "partial read of configuration, "..err_lock end
|
||||
if gtumode == '00' then gtustr = 'Pre-write/Shadow Mode'
|
||||
elseif gtumode == '01' or gtumode == '04' then gtustr = 'Restore Mode'
|
||||
@@ -204,7 +231,7 @@ local function read_config()
|
||||
if ats:sub(1,2) == '00' then atsstr = 'Disabled'
|
||||
else atsstr = (string.sub(ats, 3))
|
||||
end
|
||||
if ulprotocol == '00' then
|
||||
if ulprotocol == '00' then
|
||||
cardprotocol = 'MIFARE Classic Protocol'
|
||||
ultype = 'Disabled'
|
||||
if uidlength == '00' then
|
||||
@@ -263,7 +290,7 @@ local function read_config()
|
||||
if pwd == '04' then lib14a.disconnect(); return nil, "can't read configuration, "..err_lock end
|
||||
-- read PACK
|
||||
cpack = send("30F1"):sub(1,4)
|
||||
pack = send("30E6"):sub(1,4)
|
||||
pack = send("30".._packpage):sub(1,4) -- *should* be E6, testing shows 13 on version 006a.
|
||||
-- read SIGNATURE
|
||||
signature1 = send('30F2'):sub(1,32)
|
||||
signature2 = send('30F6'):sub(1,32)
|
||||
@@ -271,7 +298,7 @@ local function read_config()
|
||||
end
|
||||
if _print < 1 then
|
||||
print(string.rep('=', 88))
|
||||
print('\t\t\tUltimate Magic Card Configuration')
|
||||
print('\t\t\tUltimate Magic Card Configuration ('.._ug4_version..')')
|
||||
print(string.rep('=', 88))
|
||||
print(' - Raw Config ', string.sub(magicconfig, 1, -9))
|
||||
print(' - Card Protocol ', cardprotocol)
|
||||
@@ -293,7 +320,7 @@ local function read_config()
|
||||
print(string.rep('=', 88))
|
||||
print(' - ATS ', atsstr)
|
||||
print(' - Password ', '[0xE5] '..pwd, '[0xF0] '..cpwd)
|
||||
print(' - Pack ', '[0xE6] '..pack, '[0xF1] '..cpack)
|
||||
print(' - Pack ', '[0x'.._packpage..'] '..pack, '[0xF1] '..cpack)
|
||||
print(' - Version ', cversion)
|
||||
print(' - Signature ', signature1..signature2)
|
||||
end
|
||||
@@ -444,7 +471,7 @@ local function write_pack(userpack)
|
||||
local info = connect()
|
||||
if not info then return false, "Can't select card" end
|
||||
print('Writing new PACK', userpack)
|
||||
send('A2E6'..userpack..'0000')
|
||||
send('A2'.._packpage..userpack..'0000')
|
||||
send('A2F1'..userpack..'0000')
|
||||
lib14a.disconnect()
|
||||
return true, 'Ok'
|
||||
|
||||
+59
-20
@@ -1162,17 +1162,17 @@ No implemented commands today
|
||||
### Variations
|
||||
|
||||
^[Top](#top)
|
||||
| Factory configuration | Name |
|
||||
| --- | --- |
|
||||
| 850000000000000000005A5A00000008 | GDM |
|
||||
| 850000000000005A00FF005A00000008 | GDCUID |
|
||||
| 850000000000005A0000005A5A5A0008 | UCUID |
|
||||
| Factory configuration | Name |
|
||||
| -------------------------------- | ------------- |
|
||||
| 850000000000000000005A5A00000008 | GDM |
|
||||
| 850000000000005A00FF005A00000008 | GDCUID |
|
||||
| 850000000000005A0000005A5A5A0008 | UCUID |
|
||||
| 8500000000005A00005A005A005A0008 | "7 byte hard" |
|
||||
| 7AFF850102015A00005A005A005A0008 | M1-7B |
|
||||
| 7AFF85000000000000FF000000000008 | FUID |
|
||||
| 7AFF000000000000BAFA358500000008 | PFUID |
|
||||
| 7AFF000000000000BAFA000000000008 | UFUID |
|
||||
| 7AFF0000000000000000000000000008 | ZUID |
|
||||
| 7AFF850102015A00005A005A005A0008 | M1-7B |
|
||||
| 7AFF85000000000000FF000000000008 | FUID |
|
||||
| 7AFF000000000000BAFA358500000008 | PFUID |
|
||||
| 7AFF000000000000BAFA000000000008 | UFUID |
|
||||
| 7AFF0000000000000000000000000008 | ZUID |
|
||||
|
||||
*Not all tags are the same!* UFUID, ZUID and PFUID* are not full implementations of USCUID - they only acknowledge the first 8 (except wakeup command) and last config byte(s).
|
||||
|
||||
@@ -2245,11 +2245,11 @@ No implemented commands at time of writing
|
||||
|
||||
^[Top](#top)
|
||||
|
||||
| Factory configuration | Name |
|
||||
| --- | --- |
|
||||
| 850000A0 00000AC3 00040301 01000B03 | UL-11 |
|
||||
| 850000A0 00000A3C 00040301 01000E03 | UL-21 |
|
||||
| 850000A0 0A000A00 00000000 00000000 | UL-C |
|
||||
| Factory configuration | Name |
|
||||
| ----------------------------------- | ------- |
|
||||
| 850000A0 00000AC3 00040301 01000B03 | UL-11 |
|
||||
| 850000A0 00000A3C 00040301 01000E03 | UL-21 |
|
||||
| 850000A0 0A000A00 00000000 00000000 | UL-C |
|
||||
| 850085A0 00000AA5 00040402 01000F03 | NTAG213 |
|
||||
| 850000A0 00000A5A 00040402 01001103 | NTAG215 |
|
||||
| 850000A0 00000AAA 00040402 01001303 | NTAG216 |
|
||||
@@ -2693,6 +2693,7 @@ Can emulate MIFARE Classic, Ultralight/NTAG families, 14b UID & App Data
|
||||
* [Set 14443B UID and ATQB](#set-14443b-uid-and-atqb)
|
||||
* [(De)Activate Ultralight mode](#deactivate-ultralight-mode)
|
||||
* [Select Ultralight mode](#select-ultralight-mode)
|
||||
* [NTAG21X/I2C Notes](#ntag-notes)
|
||||
* [Set shadow mode (GTU)](#set-shadow-mode-gtu)
|
||||
* [Direct block read and write](#direct-block-read-and-write)
|
||||
* [(De)Activate direct write to block 0](#deactivate-direct-write-to-block-0)
|
||||
@@ -2830,6 +2831,12 @@ Default `<passwd>`: `00000000`
|
||||
* Shadow mode: GTU
|
||||
* Backdoor password mode
|
||||
|
||||
## UMC Version/Factory Test
|
||||
|
||||
The CF..CC command is commonly considered to be a way of determining UMC versions. The card in circulation in recent years (2024? to present) is 06A0. It has some quirks. The older (previous?) 03A0 is assumed to have a full working featureset. The arm source points to the command being a "factory test." It also lists other possible values:
|
||||
- 6666 "Card type generic"
|
||||
- 02AA "Card type limited functionality"
|
||||
|
||||
### Proxmark3 commands
|
||||
|
||||
^[Top](#top) ^^[Gen4](#g4top)
|
||||
@@ -2858,7 +2865,7 @@ hf 14a raw -s -c -t 1000 CF00000000CE02
|
||||
...
|
||||
```
|
||||
|
||||
👉 **TODO** In Mifare Ultralight / NTAG mode, the special writes (`hf mfu restore` option `-s`, `-e`, `-r`) do not apply. Use `script run hf_mf_ultimatecard` for UID and signature, and `hf mfu wrbl` for PWD and PACK.
|
||||
👉 **TODO** In Mifare Ultralight / NTAG mode, the special writes (`hf mfu restore` option `-s`, `-e`, `-r`) do not apply. Use `script run hf_mf_ultimatecard` for UID and signature, and `hf mfu wrbl` for [PWD](#set-ntag-pwd) and [PACK](#set-ntag-pack).
|
||||
|
||||
### Change ATQA / SAK
|
||||
|
||||
@@ -3072,6 +3079,37 @@ Example: set maximum 63 blocks read/write for Mifare Classic 1K
|
||||
hf 14a raw -s -c -t 1000 CF000000006B3F
|
||||
```
|
||||
|
||||
### NTAG Notes
|
||||
|
||||
^[Top](#top) ^^[Gen4](#g4top)
|
||||
|
||||
**For UMC 06A0**
|
||||
|
||||
Despite varying memory structures on their specs, the UMC derives things like the
|
||||
PWD and PACK from fixed pages. The PWD is stored at E5 which matches the NTAG216/I2C transponders while the PACK is stored at 13 like an NTAG210.
|
||||
|
||||
#### Set NTAG PWD
|
||||
|
||||
```
|
||||
hf mfu wrbl -b e5 -d <new 4-byte PWD>
|
||||
```
|
||||
or
|
||||
```
|
||||
hf 14a raw -s -c -t 1000 a2e5<new 4-byte PWD>
|
||||
```
|
||||
or
|
||||
```
|
||||
script run hf_mf_ultimatecard -p <new 4-byte PWD>
|
||||
```
|
||||
#### Set NTAG PACK
|
||||
```
|
||||
hf mfu wrbl -b 13 -d <2-byte PACK>00
|
||||
```
|
||||
or
|
||||
```
|
||||
hf 14a -s -c -t 1000 a213<2-byte PACK>0000
|
||||
```
|
||||
|
||||
### Set shadow mode (GTU)
|
||||
|
||||
^[Top](#top) ^^[Gen4](#g4top)
|
||||
@@ -3083,10 +3121,10 @@ This description of shadow modes wroted by seller at marketpalces:
|
||||
And these conclusions were made after a number of tests with UMC (new version, configured as MFC for example):
|
||||
|
||||
| Mode | Buffer | Standart command (rdbl, wrbl e.t.c) | Backdoor command (gsetblk, ggetblk, gload e.t.c.) |
|
||||
|------|--------|-----------------------------------------|---------------------------------------------------|
|
||||
| 2,3 | buf23 | read/write from/to buf23 | read/write from/to buf23 |
|
||||
| 0 | buf0 | read from buf0, write to buf0 and buf23 | read/write from/to buf23 |
|
||||
| 4 | - | read from buf0, write to buf23 | read/write from/to buf23 |
|
||||
| ---- | ------ | --------------------------------------- | ------------------------------------------------- |
|
||||
| 2,3 | buf23 | read/write from/to buf23 | read/write from/to buf23 |
|
||||
| 0 | buf0 | read from buf0, write to buf0 and buf23 | read/write from/to buf23 |
|
||||
| 4 | - | read from buf0, write to buf23 | read/write from/to buf23 |
|
||||
|
||||
Mode 1: For new card this mode looks like a bug. Reading/writing first two block use *buf23*. Reading other blocks use invalid region of memory and all returned data looks like pseudo-random. All acl looks like invalid. All data is readable by the keys and acl wich was written in *buf0*. Any writing operations in this mode use copy of *buf0* and only it. It`s not affected any other buffers. So if you change keys or/and acl you will must use new keys to read data.
|
||||
|
||||
@@ -3316,6 +3354,7 @@ hf 14a raw -s -c -t 1000 CF00000000F001010000000003000978009102DABC1910101112131
|
||||
hf 14a raw -s -c -t 1000 CF00000000F001010000000003000978009102DABC19101011121314151644000001FB
|
||||
```
|
||||
|
||||
|
||||
### Version and Signature
|
||||
|
||||
^[Top](#top) ^^[Gen4](#g4top)
|
||||
|
||||
Reference in new issue
Block a user