Merge branch 'RfidResearchGroup:master' into master
This commit is contained in:
31 files changed
+2096
-748
No files matched your search
@@ -3,6 +3,26 @@ All notable changes to this project will be documented in this file.
|
|||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- Fixed `hf mf hardnested` - the device declared `num_nonces * 4` bytes but packs 9 bytes per nonce pair. Thanks @TheArchitect0880 (@iceman1001)
|
||||||
|
- Changed `hf mfdes detect` - with no `-n` it now sweeps every key number the application declares instead of only key 0 (@iceman1001)
|
||||||
|
- Fixed `hf mfdes detect` - the card error counter was shared by every key type, so a bad run during the DES pass could abort the AES pass (@iceman1001)
|
||||||
|
- Fixed `hf mfdes detect` - with no `-f` it drew candidates from the MIFARE Plus 16 byte key list, it now defaults to the bundled `mfdes_default_keys` dictionary (@iceman1001)
|
||||||
|
- Fixed `hf mfdes detect` - LRP was only found when the key settings happened to be unreadable (@iceman1001)
|
||||||
|
- Added `hf mfdes chk --schann` - now detect the secure channel EV/EV2/LRP mode; detected per application and can be overridden (@iceman1001)
|
||||||
|
- Fixed `hf mfdes chk` - found keys were tracked per key number instead of per application, so a key number recovered on one AID was skipped later (@iceman1001)
|
||||||
|
- Fixed `data modulation` - the 160 sample antenna settle trim was never undone, so the graph buffer stayed short for everything after it (@mfcarroll)
|
||||||
|
- Changed `tests/lf_t55xx_writetest.lua` - reads each block three times and names how a bad read differs (`rol1`, `ror5`, `inverted`, `shr1`) instead of only pass/fail (@mfcarroll)
|
||||||
|
- Fixed `lf t55xx detect` - PSK1 now detects at every bit rate and subcarrier. (@iceman1001)
|
||||||
|
- Fixed `lf t55xx detect` - FSK was skipped entirely when the field-clock pair measured as neither legal pair, losing FSK1 at RF/32 and RF/40 and every variant at RF/16 (@iceman1001)
|
||||||
|
- Fixed `lf t55xx detect` - the block 0 rotation was picked by scan order; the measured broadcast period now settles it (@mfcarroll)
|
||||||
|
- Fixed `lf t55xx detect` - the psk antenna-settle trim left the graph 160 samples short, so the graph-sample anchor was discarded on most block reads (@mfcarroll)
|
||||||
|
- Fixed `lf psk demod` - lead-in samples were accepted as a phase shift, complementing the rest of the word (@mfcarroll)
|
||||||
|
- Fixed `lf fsk demod` - a leading run too short to be a bit was forced to one, fabricating a bit and shifting the word (@mfcarroll)
|
||||||
|
- Fixed `lf nrz demod` - the samples before the first level change were counted as bits, rotating the word whenever that edge moved (@mfcarroll)
|
||||||
|
- Fixed `lf t55xx dump/read` - blocks were extracted at a bit offset cached from the last `detect` The offset is now anchored in graph samples (@iceman1001)
|
||||||
|
- Fixed `lf t55xx write --verify` - a successful write could be reported as a validation failure, both from the rotated read above and from the pre-write config decoding the post-write signal into garbage (@iceman1001)
|
||||||
|
- Fixed `lf t55xx detect` - the automatic detect after a block 0 write reported a password that was never supplied (@iceman1001)
|
||||||
|
- Fixed `hf emrtd info` - now correctly pretty print algos (@iceman1001)
|
||||||
- Fixed `trace list -t topaz` - now parses topaz reader frames up to 16 bytes (@iceman1001)
|
- Fixed `trace list -t topaz` - now parses topaz reader frames up to 16 bytes (@iceman1001)
|
||||||
- Fixed `hw bwm` - doc and comment references still named the flat `hw bwmsetcap`/`bwmcharge`/`bwmautooff` commands from before the subgroup move (@xilni)
|
- Fixed `hw bwm` - doc and comment references still named the flat `hw bwmsetcap`/`bwmcharge`/`bwmautooff` commands from before the subgroup move (@xilni)
|
||||||
- Added TA1=96 support via pwm to sim module `sim024.bin` - v4.66 (@antiklesys)
|
- Added TA1=96 support via pwm to sim module `sim024.bin` - v4.66 (@antiklesys)
|
||||||
|
|||||||
+29
-18
@@ -991,9 +991,14 @@ void MifareAcquireNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
uint8_t uid[10] = {0x00};
|
uint8_t uid[10] = {0x00};
|
||||||
uint8_t answer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
uint8_t answer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||||
uint8_t par[1] = {0x00};
|
uint8_t par[1] = {0x00};
|
||||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
|
||||||
|
// collect straight into the reply buffer, no second copy on the stack
|
||||||
|
uint8_t respbuf[sizeof(mf_nonces_resp_t) + (MFC_MAX_NONCES * 4)] = {0x00};
|
||||||
|
mf_nonces_resp_t *response = (mf_nonces_resp_t *)respbuf;
|
||||||
|
uint8_t *buf = response->nonces;
|
||||||
|
|
||||||
uint32_t cuid = 0;
|
uint32_t cuid = 0;
|
||||||
int16_t isOK = 0;
|
int16_t isOK = PM3_SUCCESS;
|
||||||
uint16_t num_nonces = 0;
|
uint16_t num_nonces = 0;
|
||||||
uint8_t cascade_levels = 0;
|
uint8_t cascade_levels = 0;
|
||||||
uint8_t blockNo = payload->blockno;
|
uint8_t blockNo = payload->blockno;
|
||||||
@@ -1019,7 +1024,7 @@ void MifareAcquireNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
|
|
||||||
// Test if the action was cancelled
|
// Test if the action was cancelled
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
isOK = 2;
|
isOK = PM3_EOPABORTED;
|
||||||
field_off = true;
|
field_off = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1072,12 +1077,12 @@ void MifareAcquireNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
|
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
uint8_t respbuf[PM3_CMD_DATA_SIZE] = {0x00};
|
|
||||||
mf_nonces_resp_t *response = (mf_nonces_resp_t *)respbuf;
|
// one bare 4 byte nonce per entry here, unlike the paired layout used by
|
||||||
|
// MifareAcquireEncryptedNonces. The loop above already caps num_nonces
|
||||||
|
uint16_t noncelen = num_nonces * 4;
|
||||||
response->cuid = cuid;
|
response->cuid = cuid;
|
||||||
response->num_nonces = num_nonces;
|
response->num_nonces = num_nonces;
|
||||||
uint16_t noncelen = MIN((uint16_t)(num_nonces * 4), (uint16_t)(MFC_MAX_NONCES * 4));
|
|
||||||
memcpy(response->nonces, buf, noncelen);
|
|
||||||
reply_ng(CMD_HF_MIFARE_ACQ_NONCES, isOK, respbuf, sizeof(mf_nonces_resp_t) + noncelen);
|
reply_ng(CMD_HF_MIFARE_ACQ_NONCES, isOK, respbuf, sizeof(mf_nonces_resp_t) + noncelen);
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
||||||
@@ -1106,12 +1111,17 @@ void MifareAcquireEncryptedNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
uint8_t uid[10] = {0x00};
|
uint8_t uid[10] = {0x00};
|
||||||
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||||
uint8_t par_enc[1] = {0x00};
|
uint8_t par_enc[1] = {0x00};
|
||||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
|
||||||
|
// collect straight into the reply buffer, no second copy on the stack
|
||||||
|
uint8_t respbuf[sizeof(mf_nonces_resp_t) + (MFC_MAX_NONCE_PAIRS * MFC_NONCE_PAIR_SIZE)] = {0x00};
|
||||||
|
mf_nonces_resp_t *response = (mf_nonces_resp_t *)respbuf;
|
||||||
|
uint8_t *buf = response->nonces;
|
||||||
|
|
||||||
uint64_t ui64Key = bytes_to_num(payload->key, 6);
|
uint64_t ui64Key = bytes_to_num(payload->key, 6);
|
||||||
uint32_t cuid = 0;
|
uint32_t cuid = 0;
|
||||||
int16_t isOK = PM3_SUCCESS;
|
int16_t isOK = PM3_SUCCESS;
|
||||||
uint16_t num_nonces = 0;
|
uint16_t num_nonces = 0;
|
||||||
|
uint16_t num_pairs = 0;
|
||||||
uint8_t nt_par_enc = 0;
|
uint8_t nt_par_enc = 0;
|
||||||
uint8_t cascade_levels = 0;
|
uint8_t cascade_levels = 0;
|
||||||
uint8_t blockNo = payload->blockno;
|
uint8_t blockNo = payload->blockno;
|
||||||
@@ -1139,7 +1149,7 @@ void MifareAcquireEncryptedNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
uint8_t prev_enc_nt[] = {0, 0, 0, 0};
|
uint8_t prev_enc_nt[] = {0, 0, 0, 0};
|
||||||
uint8_t prev_counter = 0;
|
uint8_t prev_counter = 0;
|
||||||
|
|
||||||
for (uint16_t i = 0; i <= (MFC_MAX_NONCES * 4) - 9;) {
|
while (num_pairs < MFC_MAX_NONCE_PAIRS) {
|
||||||
|
|
||||||
// Test if the action was cancelled
|
// Test if the action was cancelled
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
@@ -1196,14 +1206,15 @@ void MifareAcquireEncryptedNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_nonces++;
|
num_nonces++;
|
||||||
|
uint16_t ofs = num_pairs * MFC_NONCE_PAIR_SIZE;
|
||||||
if (num_nonces % 2) {
|
if (num_nonces % 2) {
|
||||||
memcpy(buf + i, receivedAnswer, 4);
|
memcpy(buf + ofs, receivedAnswer, 4);
|
||||||
nt_par_enc = par_enc[0] & 0xf0;
|
nt_par_enc = par_enc[0] & 0xf0;
|
||||||
} else {
|
} else {
|
||||||
nt_par_enc |= par_enc[0] >> 4;
|
nt_par_enc |= par_enc[0] >> 4;
|
||||||
memcpy(buf + i + 4, receivedAnswer, 4);
|
memcpy(buf + ofs + 4, receivedAnswer, 4);
|
||||||
memcpy(buf + i + 8, &nt_par_enc, 1);
|
buf[ofs + 8] = nt_par_enc;
|
||||||
i += 9;
|
num_pairs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1231,12 +1242,12 @@ void MifareAcquireEncryptedNonces(const mf_acquire_nonces_t *payload) {
|
|||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
crypto1_deinit(pcs);
|
crypto1_deinit(pcs);
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
uint8_t respbuf[PM3_CMD_DATA_SIZE] = {0x00};
|
|
||||||
mf_nonces_resp_t *response = (mf_nonces_resp_t *)respbuf;
|
// only whole pairs are transferred. An abort or a static nonce bailout can
|
||||||
|
// leave a dangling first nonce, it has no parity nibble yet so it is dropped
|
||||||
|
uint16_t noncelen = num_pairs * MFC_NONCE_PAIR_SIZE;
|
||||||
response->cuid = cuid;
|
response->cuid = cuid;
|
||||||
response->num_nonces = num_nonces;
|
response->num_nonces = num_pairs * 2;
|
||||||
uint16_t noncelen = MIN((uint16_t)(num_nonces * 4), (uint16_t)(MFC_MAX_NONCES * 4));
|
|
||||||
memcpy(response->nonces, buf, noncelen);
|
|
||||||
reply_ng(CMD_HF_MIFARE_ACQ_ENCRYPTED_NONCES, isOK, respbuf, sizeof(mf_nonces_resp_t) + noncelen);
|
reply_ng(CMD_HF_MIFARE_ACQ_ENCRYPTED_NONCES, isOK, respbuf, sizeof(mf_nonces_resp_t) + noncelen);
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
||||||
|
|||||||
@@ -131,11 +131,25 @@ function Config.detect(offline)
|
|||||||
.. 'Rebuild with `make client` and start a new pm3 session', 0)
|
.. 'Rebuild with `make client` and start a new pm3 session', 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local block0 = out:match('Block0%.+%s*(%x%x%x%x%x%x%x%x)')
|
-- Everything between the Block0 label and the next field. That covers both
|
||||||
if block0 == nil then return nil, out end
|
-- forms detect prints: one word, or `ambiguous, one of:` followed by a
|
||||||
|
-- candidate per line. PSK2 and PSK3 are the same waveform under a
|
||||||
|
-- different reading, so a candidate list is detect being honest, not
|
||||||
|
-- detect failing, and the suite has to be able to score it
|
||||||
|
local seg = out:match('Block0%.+(.-)Downlink mode') or out:match('Block0%.+([^\n]*)')
|
||||||
|
|
||||||
|
local cands = {}
|
||||||
|
if seg ~= nil then
|
||||||
|
for w in seg:gmatch('(%x%x%x%x%x%x%x%x)') do
|
||||||
|
table.insert(cands, w)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #cands == 0 then return nil, out end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
block0 = block0,
|
block0 = cands[1],
|
||||||
|
candidates = cands,
|
||||||
modulation = out:match('Modulation%.+%s*([^\n]-)%s*\n'),
|
modulation = out:match('Modulation%.+%s*([^\n]-)%s*\n'),
|
||||||
bitrate = out:match('Bit rate%.+%s*([^\n]-)%s*\n'),
|
bitrate = out:match('Bit rate%.+%s*([^\n]-)%s*\n'),
|
||||||
offset = out:match('Offset%.+%s*(%d+)'),
|
offset = out:match('Offset%.+%s*(%d+)'),
|
||||||
@@ -265,7 +279,26 @@ function Config.check(report, block0, opts)
|
|||||||
local found = Config.detect(opts.offline)
|
local found = Config.detect(opts.offline)
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
|
||||||
local res = report:add(block0, found and found.block0 or nil)
|
local got, extra = nil, {}
|
||||||
|
|
||||||
|
if found ~= nil then
|
||||||
|
|
||||||
|
got = found.block0
|
||||||
|
|
||||||
|
-- a word the tag could be holding counts as read back. Say how many
|
||||||
|
-- readings were live, so an ambiguous pass is not mistaken for a clean one
|
||||||
|
if #found.candidates > 1 then
|
||||||
|
|
||||||
|
for _, c in ipairs(found.candidates) do
|
||||||
|
if c:upper() == block0:upper() then got = c end
|
||||||
|
end
|
||||||
|
|
||||||
|
extra.ok = (got:upper() == block0:upper())
|
||||||
|
extra.note = extra.ok and ('ambiguous, 1 of ' .. #found.candidates) or 'MISMATCH'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local res = report:add(block0, got, extra)
|
||||||
|
|
||||||
if opts.verbose then
|
if opts.verbose then
|
||||||
core.console('lf t55xx info')
|
core.console('lf t55xx info')
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ A strict T55x7 test suite:
|
|||||||
|
|
||||||
lf t55xx wipe
|
lf t55xx wipe
|
||||||
lf t55xx write -b 1 -d 00000000
|
lf t55xx write -b 1 -d 00000000
|
||||||
lf t55xx write -b 2 -d ffffffff
|
lf t55xx write -b 2 -d aa5500ff
|
||||||
lf t55xx write -b 3 -d 80000000
|
lf t55xx write -b 3 -d 80000000
|
||||||
lf t55xx write -b 4 -d 00000001
|
lf t55xx write -b 4 -d 00000001
|
||||||
|
|
||||||
@@ -24,6 +24,14 @@ Each row names the configuration word, what it means, what `lf t55xx detect`
|
|||||||
made of it and how many of the four data blocks read back intact. Markers are
|
made of it and how many of the four data blocks read back intact. Markers are
|
||||||
also written into the session log ( `rem [ERR:...]` and `rem [SUMMARY:...]` )
|
also written into the session log ( `rem [ERR:...]` and `rem [SUMMARY:...]` )
|
||||||
|
|
||||||
|
Every block is read three times. A block that reads back differently between
|
||||||
|
those is marked `unstable`, which is the fault a single read cannot see: the
|
||||||
|
value is silently wrong rather than missing. A block that is wrong the same way
|
||||||
|
each time is named where it can be - `rol1`, `ror5`, `inverted`, `shr1` - because
|
||||||
|
a rotation points at the word boundary and an inversion at psk phase, and the two
|
||||||
|
want different fixes. Block 1 is `00000000`, which is equal to all of its own
|
||||||
|
rotations, so a rotated read of it cannot be told from a correct one.
|
||||||
|
|
||||||
Note: that the card is wiped before each modulation.
|
Note: that the card is wiped before each modulation.
|
||||||
|
|
||||||
Needs a T5577 in the field.
|
Needs a T5577 in the field.
|
||||||
@@ -161,30 +169,98 @@ local function prepare()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- a block is read this many times, so that a value which is silently wrong on
|
||||||
|
-- only some reads is not mistaken for one that is right
|
||||||
|
local READS = 3
|
||||||
|
|
||||||
|
local function rol32(v, n)
|
||||||
|
n = n % 32
|
||||||
|
if n == 0 then return v end
|
||||||
|
return ((v << n) | (v >> (32 - n))) & 0xFFFFFFFF
|
||||||
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Read blocks 1-4 back. Returns how many matched and a short note naming the
|
-- Name how `got` differs from `want`, when it can be named. A rotation says the
|
||||||
-- ones that did not.
|
-- word boundary moved, an inversion says psk picked the opposite phase, and a
|
||||||
|
-- shift says a demodulation opened a bit early and padded with zero - different
|
||||||
|
-- faults wanting different fixes, so worth telling apart. A word equal to all of
|
||||||
|
-- its own rotations carries no boundary information and only gets 'differs'.
|
||||||
|
local function classify(want, got)
|
||||||
|
|
||||||
|
if got == want then return 'ok' end
|
||||||
|
|
||||||
|
if rol32(want, 1) == want then return 'differs' end
|
||||||
|
|
||||||
|
for n = 1, 31 do
|
||||||
|
if rol32(want, n) == got then
|
||||||
|
return (n <= 16) and ('rol' .. n) or ('ror' .. (32 - n))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (want ~ 0xFFFFFFFF) == got then return 'inverted' end
|
||||||
|
|
||||||
|
for n = 1, 31 do
|
||||||
|
if (rol32(want, n) ~ 0xFFFFFFFF) == got then
|
||||||
|
return 'inv+' .. ((n <= 16) and ('rol' .. n) or ('ror' .. (32 - n)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for n = 1, 8 do
|
||||||
|
if ((want >> n) & 0xFFFFFFFF) == got then return 'shr' .. n end
|
||||||
|
if ((want << n) & 0xFFFFFFFF) == got then return 'shl' .. n end
|
||||||
|
end
|
||||||
|
|
||||||
|
return 'differs'
|
||||||
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Read blocks 1-4 back, READS times each. Returns how many matched on every
|
||||||
|
-- read and a short note naming what went wrong with the ones that did not.
|
||||||
local function read_back(config)
|
local function read_back(config)
|
||||||
|
|
||||||
local good, bad = 0, {}
|
local good, bad = 0, {}
|
||||||
|
|
||||||
for block, want in ipairs(DATA_BLOCKS) do
|
for block, want in ipairs(DATA_BLOCKS) do
|
||||||
|
|
||||||
local data = core.t55xx_readblock(block, '0', '0', '')
|
local wantv = tonumber(want, 16)
|
||||||
local got = data and ('%08X'):format(data) or ''
|
local seen, first, stable = {}, nil, true
|
||||||
|
|
||||||
if got:lower() == want:lower() then
|
for _ = 1, READS do
|
||||||
|
local data = core.t55xx_readblock(block, '0', '0', '')
|
||||||
|
local v = data and (data & 0xFFFFFFFF) or nil
|
||||||
|
table.insert(seen, v)
|
||||||
|
if first == nil then
|
||||||
|
first = v
|
||||||
|
elseif v ~= first then
|
||||||
|
stable = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if stable and first == wantv then
|
||||||
good = good + 1
|
good = good + 1
|
||||||
else
|
else
|
||||||
table.insert(bad, tostring(block))
|
local what
|
||||||
core.console(format('rem [ERR:READ:%s:%d] block %d: read %s instead of %s',
|
if stable == false then
|
||||||
config, block, block, got, want), false, true)
|
what = 'unstable'
|
||||||
|
else
|
||||||
|
what = classify(wantv, first)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(bad, format('b%d %s', block, what))
|
||||||
|
|
||||||
|
local reads = {}
|
||||||
|
for _, v in ipairs(seen) do
|
||||||
|
table.insert(reads, v and ('%08X'):format(v) or '----')
|
||||||
|
end
|
||||||
|
core.console(format('rem [ERR:READ:%s:%d] block %d: %s, wanted %s, read %s',
|
||||||
|
config, block, block, what, want,
|
||||||
|
table.concat(reads, ' ')), false, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local note = ''
|
local note = ''
|
||||||
if #bad > 0 then
|
if #bad > 0 then
|
||||||
note = 'block ' .. table.concat(bad, ',') .. ' bad'
|
note = table.concat(bad, ' ')
|
||||||
end
|
end
|
||||||
return good, note
|
return good, note
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -311,6 +311,14 @@
|
|||||||
"Description": "SMARTair Credential",
|
"Description": "SMARTair Credential",
|
||||||
"Type": "pacs"
|
"Type": "pacs"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"AID": "F70090",
|
||||||
|
"Vendor": "ASSA ABLOY (Timelox / VingCard Elsafe)",
|
||||||
|
"Country": "SE",
|
||||||
|
"Name": "Visionline",
|
||||||
|
"Description": "Hotel access credential",
|
||||||
|
"Type": "pacs"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"AID": "F51BC0",
|
"AID": "F51BC0",
|
||||||
"Vendor": "STid Group",
|
"Vendor": "STid Group",
|
||||||
@@ -873,9 +881,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AID": "008800",
|
"AID": "008800",
|
||||||
"Vendor": "Bank Mega",
|
"Vendor": "PT Bank Mega Tbk",
|
||||||
"Country": "ID",
|
"Country": "ID",
|
||||||
"Name": "MegaCash",
|
"Name": "MEGACASH",
|
||||||
"Description": "Indonesian stored-value card // FIDs 01: Card Identification; 02: Stored Value; 03: Transaction Records",
|
"Description": "Indonesian stored-value card // FIDs 01: Card Identification; 02: Stored Value; 03: Transaction Records",
|
||||||
"Type": "payment system"
|
"Type": "payment system"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2778,8 +2778,7 @@ static int try_detect_modulation(void) {
|
|||||||
clk = GetPskClock("", false);
|
clk = GetPskClock("", false);
|
||||||
if (clk > 0) {
|
if (clk > 0) {
|
||||||
// allow undo
|
// allow undo
|
||||||
buffer_savestate_t saveState = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
buffer_savestate_t saveState = save_graphbuffer();
|
||||||
saveState.offset = g_GridOffset;
|
|
||||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||||
CmdLtrim("-i 160");
|
CmdLtrim("-i 160");
|
||||||
if ((PSKDemod(0, 0, 6, false) == PM3_SUCCESS)) {
|
if ((PSKDemod(0, 0, 6, false) == PM3_SUCCESS)) {
|
||||||
@@ -2791,8 +2790,7 @@ static int try_detect_modulation(void) {
|
|||||||
tests[hits].carrier = GetPskCarrier(false);
|
tests[hits].carrier = GetPskCarrier(false);
|
||||||
}
|
}
|
||||||
//undo trim samples
|
//undo trim samples
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+43
-8
@@ -2468,15 +2468,28 @@ static void emrtd_print_cardaccess(const emrtd_cardaccess_t *ca) {
|
|||||||
PrintAndLogEx(SUCCESS, "");
|
PrintAndLogEx(SUCCESS, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->alg != NULL) {
|
char oidstr[64] = { 0x00 };
|
||||||
PrintAndLogEx(SUCCESS, "PACE algorithm........... " _YELLOW_("%s"), info->alg->name);
|
emrtd_oid_to_str(info->oid, info->oidlen, oidstr, sizeof(oidstr));
|
||||||
} else {
|
if (oidstr[0] == 0x00) {
|
||||||
PrintAndLogEx(SUCCESS, "PACE algorithm........... " _YELLOW_("unknown") " ( OID %s )",
|
snprintf(oidstr, sizeof(oidstr), "%s", sprint_hex_inrow((uint8_t *)info->oid, info->oidlen));
|
||||||
sprint_hex_inrow((uint8_t *)info->oid, info->oidlen));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_pace = ((info->kind == EMRTD_SI_PACE) || (info->kind == EMRTD_SI_PACE_DP));
|
||||||
|
|
||||||
|
if (info->protocol != NULL) {
|
||||||
|
PrintAndLogEx(SUCCESS, "%s " _YELLOW_("%s"),
|
||||||
|
is_pace ? "PACE algorithm..........." : "Protocol.................",
|
||||||
|
info->protocol);
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(SUCCESS, "Protocol................. " _YELLOW_("unknown"));
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "OID...................... %s", oidstr);
|
||||||
|
|
||||||
if (info->version != 0) {
|
if (info->version != 0) {
|
||||||
PrintAndLogEx(SUCCESS, "PACE version............. " _YELLOW_("%u"), info->version);
|
PrintAndLogEx(SUCCESS, "%s " _YELLOW_("%u"),
|
||||||
|
is_pace ? "PACE version............." : "Version..................",
|
||||||
|
info->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->has_param) {
|
if (info->has_param) {
|
||||||
@@ -2488,18 +2501,40 @@ static void emrtd_print_cardaccess(const emrtd_cardaccess_t *ca) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info->has_key_id) {
|
||||||
|
PrintAndLogEx(SUCCESS, "Key id................... " _YELLOW_("%u"), info->key_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (info->supported) {
|
if (info->supported) {
|
||||||
PrintAndLogEx(SUCCESS, "Supported by this client. " _GREEN_("yes")
|
PrintAndLogEx(SUCCESS, "Supported by this client. " _GREEN_("yes")
|
||||||
"%s", ((int)i == ca->best) ? _GREEN_(" (selected)") : "");
|
"%s", ((int)i == ca->best) ? _GREEN_(" (selected)") : "");
|
||||||
} else {
|
} else if (is_pace) {
|
||||||
PrintAndLogEx(SUCCESS, "Supported by this client. " _YELLOW_("no") " ( %s )",
|
PrintAndLogEx(SUCCESS, "Supported by this client. " _YELLOW_("no") " ( %s )",
|
||||||
(info->reason != NULL) ? info->reason : "unsupported");
|
(info->reason != NULL) ? info->reason : "unsupported");
|
||||||
|
} else {
|
||||||
|
// not a PACE protocol at all, "unsupported PACE algorithm" would be
|
||||||
|
// the wrong thing to tell the user
|
||||||
|
PrintAndLogEx(SUCCESS, "Note..................... %s",
|
||||||
|
(info->reason != NULL) ? info->reason : "not a PACE protocol");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ca->best < 0) {
|
if (ca->best < 0) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(WARNING, "None of the offered PACE algorithms is supported by this client");
|
|
||||||
|
bool pace_offered = false;
|
||||||
|
for (size_t i = 0; i < ca->count; i++) {
|
||||||
|
if (ca->infos[i].kind == EMRTD_SI_PACE) {
|
||||||
|
pace_offered = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pace_offered) {
|
||||||
|
PrintAndLogEx(WARNING, "None of the offered PACE algorithms is supported by this client");
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(WARNING, "EF_CardAccess does not offer any PACE algorithm");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+473
-328
File diff suppressed because it is too large.
Load diff
@@ -1733,9 +1733,18 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
|
|||||||
if (initialize == false) {
|
if (initialize == false) {
|
||||||
|
|
||||||
const mf_nonces_resp_t *nresp = (const mf_nonces_resp_t *)resp.data.asBytes;
|
const mf_nonces_resp_t *nresp = (const mf_nonces_resp_t *)resp.data.asBytes;
|
||||||
uint16_t num_sampled_nonces = nresp->num_nonces;
|
uint16_t num_sampled_nonces = nresp->num_nonces & ~1; // nonces come in pairs
|
||||||
const uint8_t *bufp = nresp->nonces;
|
const uint8_t *bufp = nresp->nonces;
|
||||||
|
|
||||||
|
if (resp.length < sizeof(mf_nonces_resp_t) + ((num_sampled_nonces / 2) * MFC_NONCE_PAIR_SIZE)) {
|
||||||
|
PrintAndLogEx(FAILED, "Truncated nonce reply, got %u bytes for %u nonces", resp.length, num_sampled_nonces);
|
||||||
|
if (nonce_file_write) {
|
||||||
|
fclose(fnonces);
|
||||||
|
}
|
||||||
|
DropField();
|
||||||
|
return PM3_ESOFT;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint16_t i = 0; i < num_sampled_nonces; i += 2) {
|
for (uint16_t i = 0; i < num_sampled_nonces; i += 2) {
|
||||||
uint32_t nt_enc1 = bytes_to_num(bufp, 4);
|
uint32_t nt_enc1 = bytes_to_num(bufp, 4);
|
||||||
uint32_t nt_enc2 = bytes_to_num(bufp + 4, 4);
|
uint32_t nt_enc2 = bytes_to_num(bufp + 4, 4);
|
||||||
@@ -1760,10 +1769,10 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
|
|||||||
num_acquired_nonces += add_res;
|
num_acquired_nonces += add_res;
|
||||||
|
|
||||||
if (nonce_file_write) {
|
if (nonce_file_write) {
|
||||||
fwrite(bufp, 1, 9, fnonces);
|
fwrite(bufp, 1, MFC_NONCE_PAIR_SIZE, fnonces);
|
||||||
fflush(fnonces);
|
fflush(fnonces);
|
||||||
}
|
}
|
||||||
bufp += 9;
|
bufp += MFC_NONCE_PAIR_SIZE;
|
||||||
}
|
}
|
||||||
//total_num_nonces += num_sampled_nonces;
|
//total_num_nonces += num_sampled_nonces;
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -1609,8 +1609,7 @@ static bool check_chiptype(bool getDeviceData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Save the state of the Graph and Demod Buffers
|
//Save the state of the Graph and Demod Buffers
|
||||||
buffer_savestate_t saveState_gb = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
buffer_savestate_t saveState_gb = save_graphbuffer();
|
||||||
saveState_gb.offset = g_GridOffset;
|
|
||||||
buffer_savestate_t saveState_db = save_buffer8(g_DemodBuffer, g_DemodBufferLen);
|
buffer_savestate_t saveState_db = save_buffer8(g_DemodBuffer, g_DemodBufferLen);
|
||||||
saveState_db.clock = g_DemodClock;
|
saveState_db.clock = g_DemodClock;
|
||||||
saveState_db.offset = g_DemodStartIdx;
|
saveState_db.offset = g_DemodStartIdx;
|
||||||
@@ -1683,12 +1682,12 @@ static bool check_chiptype(bool getDeviceData) {
|
|||||||
|
|
||||||
PrintAndLogEx(INFO, "Couldn't identify a chipset");
|
PrintAndLogEx(INFO, "Couldn't identify a chipset");
|
||||||
out:
|
out:
|
||||||
restore_buffer8(saveState_db, g_DemodBuffer);
|
// the detections above demodulate, so the length comes back with the contents
|
||||||
|
g_DemodBufferLen = restore_buffer8(saveState_db, g_DemodBuffer);
|
||||||
g_DemodClock = saveState_db.clock;
|
g_DemodClock = saveState_db.clock;
|
||||||
g_DemodStartIdx = saveState_db.offset;
|
g_DemodStartIdx = saveState_db.offset;
|
||||||
|
|
||||||
restore_bufferS32(saveState_gb, g_GraphBuffer);
|
restore_graphbuffer(saveState_gb);
|
||||||
g_GridOffset = saveState_gb.offset;
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
+542
-128
File diff suppressed because it is too large.
Load diff
@@ -20,6 +20,7 @@
|
|||||||
#define CMDLFT55XX_H__
|
#define CMDLFT55XX_H__
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define T55x7_CONFIGURATION_BLOCK 0x00
|
#define T55x7_CONFIGURATION_BLOCK 0x00
|
||||||
#define T55x7_PWD_BLOCK 0x07
|
#define T55x7_PWD_BLOCK 0x07
|
||||||
@@ -158,10 +159,13 @@ typedef struct {
|
|||||||
} bitrate;
|
} bitrate;
|
||||||
bool Q5;
|
bool Q5;
|
||||||
bool ST;
|
bool ST;
|
||||||
uint8_t psk_carrier; // observed psk subcarrier in field clocks, 2/4/8. 0 = not measured
|
int32_t anchor_sample;
|
||||||
uint8_t broadcast_blocks; // measured blocks per regular-read cycle. 0 = not measured
|
int32_t anchor_tracelen; // graph length it was taken on, so a loaded file
|
||||||
bool psk3_favoured; // data blocks lean psk3, but do not settle it
|
bool anchor_valid; // anchor_sample came from a live demodulation
|
||||||
bool pwd_known; // usepwd below reflects a live detect, not a default
|
uint8_t psk_carrier; // observed psk subcarrier in field clocks, 2/4/8. 0 = not measured
|
||||||
|
uint8_t broadcast_blocks; // measured blocks per regular-read cycle. 0 = not measured
|
||||||
|
bool psk3_favoured; // data blocks lean psk3, but do not settle it
|
||||||
|
bool pwd_known; // usepwd below reflects a live detect, not a default
|
||||||
bool usepwd;
|
bool usepwd;
|
||||||
uint32_t pwd;
|
uint32_t pwd;
|
||||||
enum {
|
enum {
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ int demodTI(bool verbose) {
|
|||||||
1, 1, 1, 1, 1, 1, 1, 1
|
1, 1, 1, 1, 1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
buffer_savestate_t saveState = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
buffer_savestate_t saveState = save_graphbuffer();
|
||||||
saveState.offset = g_GridOffset;
|
|
||||||
|
|
||||||
int lowLen = ARRAYLEN(LowTone);
|
int lowLen = ARRAYLEN(LowTone);
|
||||||
int highLen = ARRAYLEN(HighTone);
|
int highLen = ARRAYLEN(HighTone);
|
||||||
@@ -278,8 +277,7 @@ int demodTI(bool verbose) {
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (retval != PM3_SUCCESS) {
|
if (retval != PM3_SUCCESS) {
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ static uint8_t visa_parity(uint32_t id) {
|
|||||||
//see ASKDemod for what args are accepted
|
//see ASKDemod for what args are accepted
|
||||||
int demodVisa2k(bool verbose) {
|
int demodVisa2k(bool verbose) {
|
||||||
(void) verbose; // unused so far
|
(void) verbose; // unused so far
|
||||||
buffer_savestate_t saveState = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
buffer_savestate_t saveState = save_graphbuffer();
|
||||||
saveState.offset = g_GridOffset;
|
|
||||||
|
|
||||||
//CmdAskEdgeDetect("");
|
//CmdAskEdgeDetect("");
|
||||||
|
|
||||||
@@ -93,8 +92,7 @@ int demodVisa2k(bool verbose) {
|
|||||||
bool st = true;
|
bool st = true;
|
||||||
if (ASKDemod_ext(64, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) {
|
if (ASKDemod_ext(64, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ASK/Manchester Demod failed");
|
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ASK/Manchester Demod failed");
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
size_t size = g_DemodBufferLen;
|
size_t size = g_DemodBufferLen;
|
||||||
@@ -109,8 +107,7 @@ int demodVisa2k(bool verbose) {
|
|||||||
else
|
else
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ans: %d", ans);
|
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ans: %d", ans);
|
||||||
|
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||||
@@ -128,8 +125,7 @@ int demodVisa2k(bool verbose) {
|
|||||||
// test checksums
|
// test checksums
|
||||||
if (chk != calc) {
|
if (chk != calc) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: error: Visa2000 checksum (%s) %x - %x\n", _RED_("fail"), chk, calc);
|
PrintAndLogEx(DEBUG, "DEBUG: error: Visa2000 checksum (%s) %x - %x\n", _RED_("fail"), chk, calc);
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
// parity
|
// parity
|
||||||
@@ -137,8 +133,7 @@ int demodVisa2k(bool verbose) {
|
|||||||
uint8_t chk_par = (raw3 & 0xFF0) >> 4;
|
uint8_t chk_par = (raw3 & 0xFF0) >> 4;
|
||||||
if (calc_par != chk_par) {
|
if (calc_par != chk_par) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: error: Visa2000 parity (%s) %x - %x\n", _RED_("fail"), chk_par, calc_par);
|
PrintAndLogEx(DEBUG, "DEBUG: error: Visa2000 parity (%s) %x - %x\n", _RED_("fail"), chk_par, calc_par);
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(SUCCESS, "Visa2000 - Card " _GREEN_("%u") ", Raw: %08X%08X%08X", raw2, raw1, raw2, raw3);
|
PrintAndLogEx(SUCCESS, "Visa2000 - Card " _GREEN_("%u") ", Raw: %08X%08X%08X", raw2, raw1, raw2, raw3);
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ static int CmdHelp(const char *Cmd);
|
|||||||
// see ASKDemod for what args are accepted
|
// see ASKDemod for what args are accepted
|
||||||
int demodzx(bool verbose) {
|
int demodzx(bool verbose) {
|
||||||
(void) verbose; // unused so far
|
(void) verbose; // unused so far
|
||||||
buffer_savestate_t saveState = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
buffer_savestate_t saveState = save_graphbuffer();
|
||||||
saveState.offset = g_GridOffset;
|
|
||||||
|
|
||||||
// CmdAskEdgeDetect("");
|
// CmdAskEdgeDetect("");
|
||||||
|
|
||||||
@@ -50,8 +49,7 @@ int demodzx(bool verbose) {
|
|||||||
bool st = true;
|
bool st = true;
|
||||||
if (ASKDemod_ext(64, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) {
|
if (ASKDemod_ext(64, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: ASK/Manchester Demod failed");
|
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: ASK/Manchester Demod failed");
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
size_t size = g_DemodBufferLen;
|
size_t size = g_DemodBufferLen;
|
||||||
@@ -66,8 +64,7 @@ int demodzx(bool verbose) {
|
|||||||
else
|
else
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: ans: %d", ans);
|
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: ans: %d", ans);
|
||||||
|
|
||||||
restore_bufferS32(saveState, g_GraphBuffer);
|
restore_graphbuffer(saveState);
|
||||||
g_GridOffset = saveState.offset;
|
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||||
|
|||||||
+206
-31
@@ -26,6 +26,8 @@
|
|||||||
#include <mbedtls/cmac.h>
|
#include <mbedtls/cmac.h>
|
||||||
#include <mbedtls/cipher.h>
|
#include <mbedtls/cipher.h>
|
||||||
#include <mbedtls/bignum.h>
|
#include <mbedtls/bignum.h>
|
||||||
|
#include <mbedtls/asn1.h>
|
||||||
|
#include <mbedtls/oid.h>
|
||||||
|
|
||||||
#include "crypto/libpcrypto.h" // sha1hash, sha256hash, des_encrypt/decrypt, pcrypto_rng_*
|
#include "crypto/libpcrypto.h" // sha1hash, sha256hash, des_encrypt/decrypt, pcrypto_rng_*
|
||||||
#include "ui.h" // PrintAndLogEx
|
#include "ui.h" // PrintAndLogEx
|
||||||
@@ -86,6 +88,140 @@ static const emrtd_pacesdp_t pacesdp_table[] = {
|
|||||||
{32, NULL, 0, false, MBEDTLS_ECP_DP_NONE}
|
{32, NULL, 0, false, MBEDTLS_ECP_DP_NONE}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Every SecurityInfo protocol that can share EF_CardAccess / EF_DG14 with the
|
||||||
|
// PACE entries. EF_CardAccess is a SET OF SecurityInfo, so a document lists
|
||||||
|
// everything it supports in there, not just PACE. TR-03110 part 3, A.1.1.1
|
||||||
|
// covers the 0.4.0.127.0.7.2.2.x arcs, ICAO 9303-11 section 9 the ICAO ones.
|
||||||
|
// We do not run these protocols, but naming them beats printing a hex blob.
|
||||||
|
typedef struct {
|
||||||
|
size_t oidlen;
|
||||||
|
uint8_t oid[EMRTD_PACE_OID_MAXLEN];
|
||||||
|
emrtd_si_t kind;
|
||||||
|
const char *name;
|
||||||
|
} emrtd_secinfo_t;
|
||||||
|
|
||||||
|
// 0.4.0.127.0.7.2.2, bsi-de protocols(2) smartcard(2)
|
||||||
|
#define BSI_SC 0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02
|
||||||
|
// 2.23.136.1.1, id-icao-mrtd-security
|
||||||
|
#define ICAO_SEC 0x67, 0x81, 0x08, 0x01, 0x01
|
||||||
|
|
||||||
|
static const emrtd_secinfo_t secinfo_table[] = {
|
||||||
|
// len oid kind name
|
||||||
|
// id-PK, ChipAuthenticationPublicKeyInfo
|
||||||
|
{8, {BSI_SC, 0x01}, EMRTD_SI_PK, "Chip Authentication Public Key"},
|
||||||
|
{9, {BSI_SC, 0x01, 0x01}, EMRTD_SI_PK, "Chip Authentication Public Key, DH"},
|
||||||
|
{9, {BSI_SC, 0x01, 0x02}, EMRTD_SI_PK, "Chip Authentication Public Key, ECDH"},
|
||||||
|
|
||||||
|
// id-TA, TerminalAuthenticationInfo. The signature arcs below it show up in
|
||||||
|
// CV certificates rather than in EF_CardAccess, they are here for lookups.
|
||||||
|
{8, {BSI_SC, 0x02}, EMRTD_SI_TA, "Terminal Authentication"},
|
||||||
|
{9, {BSI_SC, 0x02, 0x01}, EMRTD_SI_TA, "Terminal Authentication, RSA"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x01, 0x01}, EMRTD_SI_TA, "Terminal Authentication, RSA PKCS#1 v1.5 SHA-1"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x01, 0x02}, EMRTD_SI_TA, "Terminal Authentication, RSA PKCS#1 v1.5 SHA-256"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x01, 0x03}, EMRTD_SI_TA, "Terminal Authentication, RSA PSS SHA-1"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x01, 0x04}, EMRTD_SI_TA, "Terminal Authentication, RSA PSS SHA-256"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x01, 0x05}, EMRTD_SI_TA, "Terminal Authentication, RSA PKCS#1 v1.5 SHA-512"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x01, 0x06}, EMRTD_SI_TA, "Terminal Authentication, RSA PSS SHA-512"},
|
||||||
|
{9, {BSI_SC, 0x02, 0x02}, EMRTD_SI_TA, "Terminal Authentication, ECDSA"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x02, 0x01}, EMRTD_SI_TA, "Terminal Authentication, ECDSA SHA-1"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x02, 0x02}, EMRTD_SI_TA, "Terminal Authentication, ECDSA SHA-224"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x02, 0x03}, EMRTD_SI_TA, "Terminal Authentication, ECDSA SHA-256"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x02, 0x04}, EMRTD_SI_TA, "Terminal Authentication, ECDSA SHA-384"},
|
||||||
|
{10, {BSI_SC, 0x02, 0x02, 0x05}, EMRTD_SI_TA, "Terminal Authentication, ECDSA SHA-512"},
|
||||||
|
|
||||||
|
// id-CA. The 9 byte arcs are ChipAuthenticationDomainParameterInfo, the
|
||||||
|
// 10 byte ones ChipAuthenticationInfo.
|
||||||
|
{8, {BSI_SC, 0x03}, EMRTD_SI_CA, "Chip Authentication"},
|
||||||
|
{9, {BSI_SC, 0x03, 0x01}, EMRTD_SI_CA_DP, "Chip Authentication, DH"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x01, 0x01}, EMRTD_SI_CA, "Chip Authentication, DH, 3DES-CBC-CBC"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x01, 0x02}, EMRTD_SI_CA, "Chip Authentication, DH, AES-CMAC-128"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x01, 0x03}, EMRTD_SI_CA, "Chip Authentication, DH, AES-CMAC-192"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x01, 0x04}, EMRTD_SI_CA, "Chip Authentication, DH, AES-CMAC-256"},
|
||||||
|
{9, {BSI_SC, 0x03, 0x02}, EMRTD_SI_CA_DP, "Chip Authentication, ECDH"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x02, 0x01}, EMRTD_SI_CA, "Chip Authentication, ECDH, 3DES-CBC-CBC"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x02, 0x02}, EMRTD_SI_CA, "Chip Authentication, ECDH, AES-CMAC-128"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x02, 0x03}, EMRTD_SI_CA, "Chip Authentication, ECDH, AES-CMAC-192"},
|
||||||
|
{10, {BSI_SC, 0x03, 0x02, 0x04}, EMRTD_SI_CA, "Chip Authentication, ECDH, AES-CMAC-256"},
|
||||||
|
|
||||||
|
// id-PACE. The leaves live in pacealg_table, these two are the
|
||||||
|
// PACEDomainParameterInfo arcs.
|
||||||
|
{8, {BSI_SC, 0x04}, EMRTD_SI_PACE, "PACE"},
|
||||||
|
{9, {BSI_SC, 0x04, 0x01}, EMRTD_SI_PACE_DP, "PACE, DH domain parameters"},
|
||||||
|
{9, {BSI_SC, 0x04, 0x02}, EMRTD_SI_PACE_DP, "PACE, ECDH domain parameters"},
|
||||||
|
|
||||||
|
// id-RI. 9 byte arcs are RestrictedIdentificationDomainParameterInfo.
|
||||||
|
{8, {BSI_SC, 0x05}, EMRTD_SI_RI, "Restricted Identification"},
|
||||||
|
{9, {BSI_SC, 0x05, 0x01}, EMRTD_SI_RI_DP, "Restricted Identification, DH"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x01, 0x01}, EMRTD_SI_RI, "Restricted Identification, DH, SHA-1"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x01, 0x02}, EMRTD_SI_RI, "Restricted Identification, DH, SHA-224"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x01, 0x03}, EMRTD_SI_RI, "Restricted Identification, DH, SHA-256"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x01, 0x04}, EMRTD_SI_RI, "Restricted Identification, DH, SHA-384"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x01, 0x05}, EMRTD_SI_RI, "Restricted Identification, DH, SHA-512"},
|
||||||
|
{9, {BSI_SC, 0x05, 0x02}, EMRTD_SI_RI_DP, "Restricted Identification, ECDH"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x02, 0x01}, EMRTD_SI_RI, "Restricted Identification, ECDH, SHA-1"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x02, 0x02}, EMRTD_SI_RI, "Restricted Identification, ECDH, SHA-224"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x02, 0x03}, EMRTD_SI_RI, "Restricted Identification, ECDH, SHA-256"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x02, 0x04}, EMRTD_SI_RI, "Restricted Identification, ECDH, SHA-384"},
|
||||||
|
{10, {BSI_SC, 0x05, 0x02, 0x05}, EMRTD_SI_RI, "Restricted Identification, ECDH, SHA-512"},
|
||||||
|
|
||||||
|
{8, {BSI_SC, 0x06}, EMRTD_SI_CI, "Card Info Locator"},
|
||||||
|
{8, {BSI_SC, 0x07}, EMRTD_SI_EIDSECURITY, "eID Security"},
|
||||||
|
{8, {BSI_SC, 0x08}, EMRTD_SI_PT, "Privileged Terminal"},
|
||||||
|
|
||||||
|
{5, {ICAO_SEC}, EMRTD_SI_UNKNOWN, "ICAO MRTD security"},
|
||||||
|
{6, {ICAO_SEC, 0x05}, EMRTD_SI_AA, "Active Authentication"},
|
||||||
|
{6, {ICAO_SEC, 0x0D}, EMRTD_SI_EFDIR, "EF.DIR"},
|
||||||
|
|
||||||
|
{0, {0}, EMRTD_SI_UNKNOWN, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef BSI_SC
|
||||||
|
#undef ICAO_SEC
|
||||||
|
|
||||||
|
const char *emrtd_secinfo_name(const uint8_t *oid, size_t oidlen, emrtd_si_t *kind) {
|
||||||
|
const emrtd_secinfo_t *best = NULL;
|
||||||
|
|
||||||
|
// longest prefix wins, so an arc we did not enumerate still resolves to its
|
||||||
|
// family instead of falling through to "unknown"
|
||||||
|
for (int i = 0; secinfo_table[i].name != NULL; i++) {
|
||||||
|
const emrtd_secinfo_t *e = &secinfo_table[i];
|
||||||
|
if ((e->oidlen > oidlen) || (memcmp(e->oid, oid, e->oidlen) != 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((best == NULL) || (e->oidlen > best->oidlen)) {
|
||||||
|
best = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (best == NULL) {
|
||||||
|
if (kind != NULL) {
|
||||||
|
*kind = EMRTD_SI_UNKNOWN;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kind != NULL) {
|
||||||
|
*kind = best->kind;
|
||||||
|
}
|
||||||
|
return best->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void emrtd_oid_to_str(const uint8_t *oid, size_t oidlen, char *out, size_t outlen) {
|
||||||
|
if ((out == NULL) || (outlen == 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out[0] = 0x00;
|
||||||
|
|
||||||
|
mbedtls_asn1_buf buf;
|
||||||
|
buf.tag = MBEDTLS_ASN1_OID;
|
||||||
|
buf.len = oidlen;
|
||||||
|
buf.p = (uint8_t *)oid;
|
||||||
|
|
||||||
|
if (mbedtls_oid_get_numeric_string(out, outlen, &buf) < 0) {
|
||||||
|
out[0] = 0x00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const emrtd_pacealg_t *emrtd_pace_alg_by_oid(const uint8_t *oid, size_t oidlen) {
|
const emrtd_pacealg_t *emrtd_pace_alg_by_oid(const uint8_t *oid, size_t oidlen) {
|
||||||
for (int i = 0; pacealg_table[i].name != NULL; i++) {
|
for (int i = 0; pacealg_table[i].name != NULL; i++) {
|
||||||
if (pacealg_table[i].oidlen == oidlen && memcmp(pacealg_table[i].oid, oid, oidlen) == 0) {
|
if (pacealg_table[i].oidlen == oidlen && memcmp(pacealg_table[i].oid, oid, oidlen) == 0) {
|
||||||
@@ -492,14 +628,51 @@ static bool emrtd_asn1_uint(const uint8_t *value, size_t valuelen, uint32_t *out
|
|||||||
|
|
||||||
// The PACEDomainParameterInfo protocol OIDs, TR-03110 part 3, A.1.1.
|
// The PACEDomainParameterInfo protocol OIDs, TR-03110 part 3, A.1.1.
|
||||||
// 0.4.0.127.0.7.2.2.4.1 (DH) and .2 (ECDH)
|
// 0.4.0.127.0.7.2.2.4.1 (DH) and .2 (ECDH)
|
||||||
|
// 0.4.0.127.0.7.2.2.4, id-PACE itself
|
||||||
|
static const uint8_t oid_pace[] = {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04};
|
||||||
static const uint8_t oid_pace_dh_dp[] = {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x01};
|
static const uint8_t oid_pace_dh_dp[] = {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x01};
|
||||||
static const uint8_t oid_pace_ecdh_dp[] = {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x02};
|
static const uint8_t oid_pace_ecdh_dp[] = {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x02};
|
||||||
|
|
||||||
static void emrtd_pace_classify(emrtd_paceinfo_t *info) {
|
static void emrtd_pace_classify(emrtd_paceinfo_t *info) {
|
||||||
info->supported = false;
|
info->supported = false;
|
||||||
|
|
||||||
|
// Only PACEInfo entries are candidates for the session. The rest of
|
||||||
|
// EF_CardAccess describes protocols this client does not run, say so
|
||||||
|
// instead of calling them unsupported PACE algorithms.
|
||||||
|
switch (info->kind) {
|
||||||
|
case EMRTD_SI_PACE:
|
||||||
|
break;
|
||||||
|
case EMRTD_SI_PACE_DP:
|
||||||
|
info->reason = "domain parameter definition, informational";
|
||||||
|
return;
|
||||||
|
case EMRTD_SI_CA:
|
||||||
|
case EMRTD_SI_CA_DP:
|
||||||
|
case EMRTD_SI_PK:
|
||||||
|
info->reason = "not a PACE protocol, EAC Chip Authentication is not implemented";
|
||||||
|
return;
|
||||||
|
case EMRTD_SI_TA:
|
||||||
|
info->reason = "not a PACE protocol, needs an EAC inspection system certificate";
|
||||||
|
return;
|
||||||
|
case EMRTD_SI_RI:
|
||||||
|
case EMRTD_SI_RI_DP:
|
||||||
|
info->reason = "not a PACE protocol, needs an EAC sector key";
|
||||||
|
return;
|
||||||
|
case EMRTD_SI_AA:
|
||||||
|
info->reason = "not a PACE protocol, uses the public key in EF_DG15";
|
||||||
|
return;
|
||||||
|
case EMRTD_SI_CI:
|
||||||
|
case EMRTD_SI_EIDSECURITY:
|
||||||
|
case EMRTD_SI_PT:
|
||||||
|
case EMRTD_SI_EFDIR:
|
||||||
|
info->reason = "informational, not a PACE protocol";
|
||||||
|
return;
|
||||||
|
case EMRTD_SI_UNKNOWN:
|
||||||
|
info->reason = "unknown protocol OID";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (info->alg == NULL) {
|
if (info->alg == NULL) {
|
||||||
info->reason = "unknown protocol OID";
|
info->reason = "unknown PACE algorithm OID";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,43 +774,45 @@ static void emrtd_pace_parse_securityinfo(const uint8_t *seq, size_t seqlen, emr
|
|||||||
memcpy(info->oid, val, vlen);
|
memcpy(info->oid, val, vlen);
|
||||||
info->oidlen = vlen;
|
info->oidlen = vlen;
|
||||||
info->alg = emrtd_pace_alg_by_oid(val, vlen);
|
info->alg = emrtd_pace_alg_by_oid(val, vlen);
|
||||||
|
info->protocol = emrtd_secinfo_name(val, vlen, &info->kind);
|
||||||
|
|
||||||
if (is_domain_param) {
|
if (info->alg != NULL) {
|
||||||
// SEQUENCE { OID, AlgorithmIdentifier, INTEGER parameterId OPTIONAL }
|
// a PACEInfo we can act on, pacealg_table has the better name
|
||||||
if (emrtd_tlv_next(&cur, end, &tag, &val, &vlen) == false) {
|
info->kind = EMRTD_SI_PACE;
|
||||||
return;
|
info->protocol = info->alg->name;
|
||||||
}
|
} else if (is_domain_param) {
|
||||||
if (emrtd_tlv_next(&cur, end, &tag, &val, &vlen) && (tag == ASN1_TAG_INTEGER)) {
|
info->kind = EMRTD_SI_PACE_DP;
|
||||||
uint32_t v = 0;
|
} else if ((vlen > sizeof(oid_pace)) && (memcmp(val, oid_pace, sizeof(oid_pace)) == 0)) {
|
||||||
if (emrtd_asn1_uint(val, vlen, &v) && (v <= 0xFF)) {
|
// an id-PACE arc we do not implement, still a PACEInfo and not a
|
||||||
info->has_param = true;
|
// domain parameter definition
|
||||||
info->param_id = (uint8_t)v;
|
info->kind = EMRTD_SI_PACE;
|
||||||
info->sdp = emrtd_pace_sdp_by_id(info->param_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
info->supported = false;
|
|
||||||
info->reason = "domain parameter definition, informational";
|
|
||||||
out->count++;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PACEInfo ::= SEQUENCE { protocol OID, version INTEGER, parameterId INTEGER OPTIONAL }
|
// Second element:
|
||||||
if (emrtd_tlv_next(&cur, end, &tag, &val, &vlen) == false) {
|
// PACEInfo / ChipAuthenticationInfo / TerminalAuthenticationInfo version INTEGER
|
||||||
return;
|
// PACEDomainParameterInfo / ChipAuthenticationPublicKeyInfo an AlgorithmIdentifier
|
||||||
}
|
// or SubjectPublicKeyInfo
|
||||||
if (tag != ASN1_TAG_INTEGER) {
|
// Take it as the version only when it really is an INTEGER.
|
||||||
return;
|
if (emrtd_tlv_next(&cur, end, &tag, &val, &vlen) && (tag == ASN1_TAG_INTEGER)) {
|
||||||
}
|
emrtd_asn1_uint(val, vlen, &info->version);
|
||||||
if (emrtd_asn1_uint(val, vlen, &info->version) == false) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Third element, an optional INTEGER. For the PACE entries that is the
|
||||||
|
// standardized domain parameter id of table A.2, for the Chip
|
||||||
|
// Authentication ones it is a keyId and must not be read as a curve.
|
||||||
if (emrtd_tlv_next(&cur, end, &tag, &val, &vlen) && (tag == ASN1_TAG_INTEGER)) {
|
if (emrtd_tlv_next(&cur, end, &tag, &val, &vlen) && (tag == ASN1_TAG_INTEGER)) {
|
||||||
uint32_t v = 0;
|
uint32_t v = 0;
|
||||||
if (emrtd_asn1_uint(val, vlen, &v) && (v <= 0xFF)) {
|
if (emrtd_asn1_uint(val, vlen, &v)) {
|
||||||
info->has_param = true;
|
if ((info->kind == EMRTD_SI_PACE) || (info->kind == EMRTD_SI_PACE_DP)) {
|
||||||
info->param_id = (uint8_t)v;
|
if (v <= 0xFF) {
|
||||||
info->sdp = emrtd_pace_sdp_by_id(info->param_id);
|
info->has_param = true;
|
||||||
|
info->param_id = (uint8_t)v;
|
||||||
|
info->sdp = emrtd_pace_sdp_by_id(info->param_id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info->has_key_id = true;
|
||||||
|
info->key_id = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,27 @@ typedef enum {
|
|||||||
EMRTD_PACE_CIPHER_AES256,
|
EMRTD_PACE_CIPHER_AES256,
|
||||||
} emrtd_pace_cipher_t;
|
} emrtd_pace_cipher_t;
|
||||||
|
|
||||||
|
// EF_CardAccess is a SET OF SecurityInfo, not a list of PACE algorithms. A
|
||||||
|
// document announces everything it can do in there, so Chip Authentication and
|
||||||
|
// Terminal Authentication share the file with the PACE entries. Only
|
||||||
|
// EMRTD_SI_PACE entries are candidates for the session we are about to open.
|
||||||
|
typedef enum {
|
||||||
|
EMRTD_SI_UNKNOWN = 0,
|
||||||
|
EMRTD_SI_PACE, // PACEInfo
|
||||||
|
EMRTD_SI_PACE_DP, // PACEDomainParameterInfo
|
||||||
|
EMRTD_SI_CA, // ChipAuthenticationInfo
|
||||||
|
EMRTD_SI_CA_DP, // ChipAuthenticationDomainParameterInfo
|
||||||
|
EMRTD_SI_PK, // ChipAuthenticationPublicKeyInfo
|
||||||
|
EMRTD_SI_TA, // TerminalAuthenticationInfo
|
||||||
|
EMRTD_SI_RI, // RestrictedIdentificationInfo
|
||||||
|
EMRTD_SI_RI_DP, // RestrictedIdentificationDomainParameterInfo
|
||||||
|
EMRTD_SI_CI, // CardInfoLocator
|
||||||
|
EMRTD_SI_EIDSECURITY, // eIDSecurityInfo
|
||||||
|
EMRTD_SI_PT, // PrivilegedTerminalInfo
|
||||||
|
EMRTD_SI_AA, // ActiveAuthenticationInfo
|
||||||
|
EMRTD_SI_EFDIR, // EFDIRInfo
|
||||||
|
} emrtd_si_t;
|
||||||
|
|
||||||
typedef struct emrtd_pacealg_s {
|
typedef struct emrtd_pacealg_s {
|
||||||
const char *name;
|
const char *name;
|
||||||
emrtd_pace_ka_t ka;
|
emrtd_pace_ka_t ka;
|
||||||
@@ -79,12 +100,16 @@ typedef struct emrtd_pacesdp_s {
|
|||||||
|
|
||||||
// One parsed SecurityInfo out of EF_CardAccess
|
// One parsed SecurityInfo out of EF_CardAccess
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const emrtd_pacealg_t *alg; // NULL when the OID is unknown to us
|
const emrtd_pacealg_t *alg; // NULL unless this is a PACEInfo we know
|
||||||
|
emrtd_si_t kind; // which SecurityInfo this is
|
||||||
|
const char *protocol; // pretty name, NULL when the OID is unknown
|
||||||
uint8_t oid[EMRTD_PACE_OID_MAXLEN];
|
uint8_t oid[EMRTD_PACE_OID_MAXLEN];
|
||||||
size_t oidlen;
|
size_t oidlen;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
bool has_param;
|
bool has_param;
|
||||||
uint8_t param_id;
|
uint8_t param_id;
|
||||||
|
bool has_key_id; // ChipAuthentication* keyId, not a PACE thing
|
||||||
|
uint32_t key_id;
|
||||||
const emrtd_pacesdp_t *sdp; // NULL when param_id is unknown/absent
|
const emrtd_pacesdp_t *sdp; // NULL when param_id is unknown/absent
|
||||||
bool supported;
|
bool supported;
|
||||||
const char *reason; // why not supported, NULL when it is
|
const char *reason; // why not supported, NULL when it is
|
||||||
@@ -151,6 +176,11 @@ int emrtd_retail_mac(const uint8_t *key, const uint8_t *input, size_t inputlen,
|
|||||||
// Table lookups
|
// Table lookups
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
const emrtd_pacealg_t *emrtd_pace_alg_by_oid(const uint8_t *oid, size_t oidlen);
|
const emrtd_pacealg_t *emrtd_pace_alg_by_oid(const uint8_t *oid, size_t oidlen);
|
||||||
|
// Names any SecurityInfo protocol OID, PACE or not. Longest prefix wins, so an
|
||||||
|
// arc we did not enumerate still resolves to its family. NULL when unknown.
|
||||||
|
const char *emrtd_secinfo_name(const uint8_t *oid, size_t oidlen, emrtd_si_t *kind);
|
||||||
|
// Dotted decimal form of a BER encoded OID body, for reporting
|
||||||
|
void emrtd_oid_to_str(const uint8_t *oid, size_t oidlen, char *out, size_t outlen);
|
||||||
const emrtd_pacesdp_t *emrtd_pace_sdp_by_id(uint8_t id);
|
const emrtd_pacesdp_t *emrtd_pace_sdp_by_id(uint8_t id);
|
||||||
const char *emrtd_pace_cipher_name(emrtd_pace_cipher_t cipher);
|
const char *emrtd_pace_cipher_name(emrtd_pace_cipher_t cipher);
|
||||||
|
|
||||||
|
|||||||
@@ -547,6 +547,67 @@ static bool test_cardaccess(void) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool test_cardaccess_secinfo(void) {
|
||||||
|
// EF_CardAccess is a SET OF SecurityInfo, not a list of PACE algorithms.
|
||||||
|
// This is the shape a document with EAC has:
|
||||||
|
// PACEInfo ECDH-GM-AES-CMAC-128, v2, BrainpoolP256r1
|
||||||
|
// TerminalAuthenticationInfo id-TA, v1
|
||||||
|
// ChipAuthenticationInfo id-CA-ECDH-AES-CBC-CMAC-128, v1, keyId 16
|
||||||
|
const char *blob =
|
||||||
|
"3137"
|
||||||
|
"3012" "060A04007F0007020204020202010202010D"
|
||||||
|
"300D" "060804007F0007020202" "020101"
|
||||||
|
"3012" "060A04007F00070202030202" "020101" "020110";
|
||||||
|
|
||||||
|
uint8_t data[128] = { 0x00 };
|
||||||
|
size_t datalen = unhex(blob, data, sizeof(data));
|
||||||
|
|
||||||
|
emrtd_cardaccess_t ca;
|
||||||
|
bool res = (datalen > 0);
|
||||||
|
res = res && (emrtd_pace_parse_cardaccess(data, datalen, &ca) == PM3_SUCCESS);
|
||||||
|
// the non-PACE entries must survive parsing, they used to be dropped or
|
||||||
|
// reported as unknown PACE algorithms
|
||||||
|
res = res && (ca.count == 3);
|
||||||
|
res = res && (ca.best == 0);
|
||||||
|
|
||||||
|
res = res && (ca.infos[0].kind == EMRTD_SI_PACE) && (ca.infos[0].supported);
|
||||||
|
res = res && (ca.infos[0].has_param) && (ca.infos[0].param_id == 13);
|
||||||
|
|
||||||
|
res = res && (ca.infos[1].kind == EMRTD_SI_TA);
|
||||||
|
res = res && (ca.infos[1].alg == NULL) && (ca.infos[1].supported == false);
|
||||||
|
res = res && (ca.infos[1].version == 1);
|
||||||
|
res = res && (ca.infos[1].protocol != NULL) &&
|
||||||
|
(strcmp(ca.infos[1].protocol, "Terminal Authentication") == 0);
|
||||||
|
|
||||||
|
res = res && (ca.infos[2].kind == EMRTD_SI_CA);
|
||||||
|
res = res && (ca.infos[2].alg == NULL) && (ca.infos[2].supported == false);
|
||||||
|
res = res && (ca.infos[2].version == 1);
|
||||||
|
res = res && (ca.infos[2].protocol != NULL) &&
|
||||||
|
(strcmp(ca.infos[2].protocol, "Chip Authentication, ECDH, AES-CMAC-128") == 0);
|
||||||
|
// a ChipAuthenticationInfo keyId is not a standardized domain parameter id
|
||||||
|
res = res && (ca.infos[2].has_param == false);
|
||||||
|
res = res && (ca.infos[2].has_key_id) && (ca.infos[2].key_id == 16);
|
||||||
|
res = res && (ca.infos[2].sdp == NULL);
|
||||||
|
|
||||||
|
// an id-TA arc we did not enumerate still resolves to its family
|
||||||
|
const uint8_t ta_odd[] = {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x7F};
|
||||||
|
emrtd_si_t kind = EMRTD_SI_UNKNOWN;
|
||||||
|
const char *name = emrtd_secinfo_name(ta_odd, sizeof(ta_odd), &kind);
|
||||||
|
res = res && (kind == EMRTD_SI_TA) && (name != NULL);
|
||||||
|
|
||||||
|
// and something outside both roots must stay unknown
|
||||||
|
const uint8_t bogus[] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D};
|
||||||
|
res = res && (emrtd_secinfo_name(bogus, sizeof(bogus), &kind) == NULL);
|
||||||
|
res = res && (kind == EMRTD_SI_UNKNOWN);
|
||||||
|
|
||||||
|
char oidstr[64] = { 0x00 };
|
||||||
|
emrtd_oid_to_str(ca.infos[1].oid, ca.infos[1].oidlen, oidstr, sizeof(oidstr));
|
||||||
|
res = res && (strcmp(oidstr, "0.4.0.127.0.7.2.2.2") == 0);
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "SecurityInfos.... ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// Chip Authentication Mapping.
|
// Chip Authentication Mapping.
|
||||||
//
|
//
|
||||||
// The chip sends t = SK.Map.IC * SK.CA.IC^-1 mod n encrypted with KSenc, so
|
// The chip sends t = SK.Map.IC * SK.CA.IC^-1 mod n encrypted with KSenc, so
|
||||||
@@ -667,6 +728,7 @@ bool emrtd_test(bool verbose) {
|
|||||||
res = test_kdf() && res;
|
res = test_kdf() && res;
|
||||||
res = test_nonce() && res;
|
res = test_nonce() && res;
|
||||||
res = test_cardaccess() && res;
|
res = test_cardaccess() && res;
|
||||||
|
res = test_cardaccess_secinfo() && res;
|
||||||
res = test_gm() && res;
|
res = test_gm() && res;
|
||||||
res = test_ec_keygen() && res;
|
res = test_ec_keygen() && res;
|
||||||
res = test_token() && res;
|
res = test_token() && res;
|
||||||
|
|||||||
@@ -982,6 +982,53 @@ int prepareJSON(json_t *root, JSONFileType ftype, uint8_t *data, size_t datalen,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case jsfMfDesfireKeys_v2: {
|
||||||
|
|
||||||
|
// key lengths and names, indexed by DesfireCryptoAlgorithm
|
||||||
|
static const char *algo_name[DESFIRE_MAX_ALGO_COUNT] = {"DES", "2TDEA", "3TDEA", "AES"};
|
||||||
|
static const uint8_t algo_keylen[DESFIRE_MAX_ALGO_COUNT] = {
|
||||||
|
DES_KEY_LEN, T2DES_KEY_LEN, T3DES_KEY_LEN, AES_KEY_LEN
|
||||||
|
};
|
||||||
|
|
||||||
|
desfire_keys_dump_t *dump = (desfire_keys_dump_t *)(void *)data;
|
||||||
|
|
||||||
|
JsonSaveStr(root, "FileType", "mfdes v2");
|
||||||
|
|
||||||
|
if (dump->card_info.uidlen > 0) {
|
||||||
|
JsonSaveBufAsHexCompact(root, "$.Card.UID", dump->card_info.uid, dump->card_info.uidlen);
|
||||||
|
JsonSaveBufAsHexCompact(root, "$.Card.SAK", &dump->card_info.sak, 1);
|
||||||
|
JsonSaveBufAsHexCompact(root, "$.Card.ATQA", dump->card_info.atqa, 2);
|
||||||
|
if (dump->card_info.ats_len > 0) {
|
||||||
|
JsonSaveBufAsHexCompact(root, "$.Card.ATS", dump->card_info.ats, dump->card_info.ats_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t appcount = dump->appcount;
|
||||||
|
if (appcount > DESFIRE_MAX_APP_COUNT) {
|
||||||
|
appcount = DESFIRE_MAX_APP_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < appcount; i++) {
|
||||||
|
|
||||||
|
desfire_app_keys_t *app = &dump->app[i];
|
||||||
|
|
||||||
|
for (uint8_t algo = 0; algo < DESFIRE_MAX_ALGO_COUNT; algo++) {
|
||||||
|
|
||||||
|
for (uint8_t keyno = 0; keyno < DESFIRE_MAX_KEY_COUNT; keyno++) {
|
||||||
|
|
||||||
|
if (app->keys[algo][keyno][0] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(path, sizeof(path), "$.Applications.%06X.%s.%u.Key",
|
||||||
|
app->aid, algo_name[algo], keyno);
|
||||||
|
|
||||||
|
JsonSaveBufAsHexCompact(root, path, &app->keys[algo][keyno][1], algo_keylen[algo]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case jsfCustom: {
|
case jsfCustom: {
|
||||||
(*callback)(root);
|
(*callback)(root);
|
||||||
break;
|
break;
|
||||||
@@ -2700,6 +2747,65 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(ctype, "mfdes v2")) {
|
||||||
|
|
||||||
|
if (maxdatalen < sizeof(desfire_keys_dump_t)) {
|
||||||
|
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu, need %zu for a mfdes v2 dump", maxdatalen, sizeof(desfire_keys_dump_t));
|
||||||
|
retval = PM3_EMALLOC;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonLoadBufAsHex(root, "$.Card.UID", udata.mfdes->card_info.uid, sizeof(udata.mfdes->card_info.uid), &len);
|
||||||
|
udata.mfdes->card_info.uidlen = len;
|
||||||
|
JsonLoadBufAsHex(root, "$.Card.SAK", &udata.mfdes->card_info.sak, 1, &len);
|
||||||
|
JsonLoadBufAsHex(root, "$.Card.ATQA", udata.mfdes->card_info.atqa, 2, &len);
|
||||||
|
JsonLoadBufAsHex(root, "$.Card.ATS", udata.mfdes->card_info.ats, sizeof(udata.mfdes->card_info.ats), &len);
|
||||||
|
udata.mfdes->card_info.ats_len = len;
|
||||||
|
|
||||||
|
// key lengths indexed by DesfireCryptoAlgorithm
|
||||||
|
static const char *algo_name[DESFIRE_MAX_ALGO_COUNT] = {"DES", "2TDEA", "3TDEA", "AES"};
|
||||||
|
static const uint8_t algo_keylen[DESFIRE_MAX_ALGO_COUNT] = {
|
||||||
|
DES_KEY_LEN, T2DES_KEY_LEN, T3DES_KEY_LEN, AES_KEY_LEN
|
||||||
|
};
|
||||||
|
|
||||||
|
json_t *apps = json_object_get(root, "Applications");
|
||||||
|
if (json_is_object(apps)) {
|
||||||
|
|
||||||
|
const char *aidstr = NULL;
|
||||||
|
json_t *value = NULL;
|
||||||
|
|
||||||
|
json_object_foreach(apps, aidstr, value) {
|
||||||
|
|
||||||
|
if (udata.mfdes->appcount >= DESFIRE_MAX_APP_COUNT) {
|
||||||
|
PrintAndLogEx(WARNING, "loadFileJSONex: more than %d applications in file, ignoring the rest", DESFIRE_MAX_APP_COUNT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
desfire_app_keys_t *app = &udata.mfdes->app[udata.mfdes->appcount];
|
||||||
|
app->aid = strtoul(aidstr, NULL, 16) & 0xFFFFFF;
|
||||||
|
|
||||||
|
for (uint8_t algo = 0; algo < DESFIRE_MAX_ALGO_COUNT; algo++) {
|
||||||
|
|
||||||
|
for (uint8_t keyno = 0; keyno < DESFIRE_MAX_KEY_COUNT; keyno++) {
|
||||||
|
|
||||||
|
snprintf(blocks, sizeof(blocks), "$.%s.%u.Key", algo_name[algo], keyno);
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
JsonLoadBufAsHex(value, blocks, &app->keys[algo][keyno][1], algo_keylen[algo], &len);
|
||||||
|
if (len == algo_keylen[algo]) {
|
||||||
|
app->keys[algo][keyno][0] = 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
udata.mfdes->appcount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*datalen = sizeof(desfire_keys_dump_t);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(ctype, "14b v2")) {
|
if (!strcmp(ctype, "14b v2")) {
|
||||||
size_t sptr = 0;
|
size_t sptr = 0;
|
||||||
for (int i = 0; i < (maxdatalen / 4); i++) {
|
for (int i = 0; i < (maxdatalen / 4); i++) {
|
||||||
|
|||||||
@@ -33,6 +33,14 @@
|
|||||||
#include "cmdhftopaz.h" // TOPAZ defines
|
#include "cmdhftopaz.h" // TOPAZ defines
|
||||||
#include "mifare/mifaredefault.h" // MFP / AES defines
|
#include "mifare/mifaredefault.h" // MFP / AES defines
|
||||||
#include "iso15.h" // iso15_tag_t
|
#include "iso15.h" // iso15_tag_t
|
||||||
|
#include "desfire.h" // desfire_app_keys_t
|
||||||
|
|
||||||
|
// keys recovered from a DESFire PICC by `hf mfdes chk`, one entry per application
|
||||||
|
typedef struct {
|
||||||
|
iso14a_card_select_t card_info;
|
||||||
|
uint8_t appcount;
|
||||||
|
desfire_app_keys_t app[DESFIRE_MAX_APP_COUNT];
|
||||||
|
} desfire_keys_dump_t;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
void *v;
|
void *v;
|
||||||
@@ -42,6 +50,7 @@ typedef union {
|
|||||||
iso14a_mf_extdump_t *mfc;
|
iso14a_mf_extdump_t *mfc;
|
||||||
iso14a_mf_dump_ev1_t *mfc_ev1;
|
iso14a_mf_dump_ev1_t *mfc_ev1;
|
||||||
iso15_tag_t *iso15;
|
iso15_tag_t *iso15;
|
||||||
|
desfire_keys_dump_t *mfdes;
|
||||||
} udata_t;
|
} udata_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -69,6 +78,7 @@ typedef enum {
|
|||||||
jsfMfPlusKeys,
|
jsfMfPlusKeys,
|
||||||
jsfCustom,
|
jsfCustom,
|
||||||
jsfMfDesfireKeys,
|
jsfMfDesfireKeys,
|
||||||
|
jsfMfDesfireKeys_v2,
|
||||||
jsfEM4x05,
|
jsfEM4x05,
|
||||||
jsfEM4x69,
|
jsfEM4x69,
|
||||||
jsfEM4x50,
|
jsfEM4x50,
|
||||||
|
|||||||
@@ -648,3 +648,21 @@ size_t restore_buffer8(buffer_savestate_t saveState, uint8_t *dest) {
|
|||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save/restore the graph buffer as a unit: contents, length and grid offset.
|
||||||
|
// A caller that drops restore_bufferS32()'s return leaves g_GraphTraceLen short.
|
||||||
|
buffer_savestate_t save_graphbuffer(void) {
|
||||||
|
buffer_savestate_t saveState = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
||||||
|
saveState.offset = g_GridOffset;
|
||||||
|
return saveState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore_graphbuffer(buffer_savestate_t saveState) {
|
||||||
|
size_t len = restore_bufferS32(saveState, g_GraphBuffer);
|
||||||
|
if (len == 0) {
|
||||||
|
// nothing was restored, so leave the buffer and its length alone
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_GraphTraceLen = len;
|
||||||
|
g_GridOffset = saveState.offset;
|
||||||
|
}
|
||||||
@@ -67,6 +67,9 @@ size_t restore_buffer32(buffer_savestate_t saveState, uint32_t *dest);
|
|||||||
size_t restore_bufferS32(buffer_savestate_t saveState, int32_t *dest);
|
size_t restore_bufferS32(buffer_savestate_t saveState, int32_t *dest);
|
||||||
size_t restore_buffer8(buffer_savestate_t saveState, uint8_t *dest);
|
size_t restore_buffer8(buffer_savestate_t saveState, uint8_t *dest);
|
||||||
|
|
||||||
|
buffer_savestate_t save_graphbuffer(void);
|
||||||
|
void restore_graphbuffer(buffer_savestate_t saveState);
|
||||||
|
|
||||||
#define MAX_GRAPH_TRACE_LEN (40000 * 32)
|
#define MAX_GRAPH_TRACE_LEN (40000 * 32)
|
||||||
#define GRAPH_SAVE 1
|
#define GRAPH_SAVE 1
|
||||||
#define GRAPH_RESTORE 0
|
#define GRAPH_RESTORE 0
|
||||||
|
|||||||
+41
-2
@@ -416,12 +416,51 @@ static int l_kbd_enter_pressed(lua_State *L) {
|
|||||||
/**
|
/**
|
||||||
* @brief Calls the command line parser to deal with the command. This enables
|
* @brief Calls the command line parser to deal with the command. This enables
|
||||||
* lua-scripts to do stuff like "core.console('hf mf mifare')"
|
* lua-scripts to do stuff like "core.console('hf mf mifare')"
|
||||||
|
* core.console(cmd [, capture [, quiet]])
|
||||||
|
*
|
||||||
|
* Same idea as the python binding
|
||||||
|
* `capture` hands the command's output back as a string,
|
||||||
|
* `quiet` keeps it off the// terminal
|
||||||
* @param L
|
* @param L
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static int l_CmdConsole(lua_State *L) {
|
static int l_CmdConsole(lua_State *L) {
|
||||||
CommandReceived((char *)luaL_checkstring(L, 1));
|
|
||||||
return 0;
|
const char *cmd = luaL_checkstring(L, 1);
|
||||||
|
|
||||||
|
const bool capture = (lua_isnoneornil(L, 2) == 0) && lua_toboolean(L, 2);
|
||||||
|
const bool quiet = (lua_isnoneornil(L, 3) == 0) && lua_toboolean(L, 3);
|
||||||
|
|
||||||
|
const uint8_t prev_printAndLog = g_printAndLog;
|
||||||
|
|
||||||
|
if (capture) {
|
||||||
|
g_printAndLog |= PRINTANDLOG_GRAB;
|
||||||
|
// anything left in the grabber belongs to an earlier call
|
||||||
|
g_grabbed_output.idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quiet) {
|
||||||
|
g_printAndLog &= ~PRINTANDLOG_PRINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandReceived((char *)cmd);
|
||||||
|
|
||||||
|
g_printAndLog = prev_printAndLog;
|
||||||
|
|
||||||
|
if (capture == false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_grabbed_output.ptr == NULL) {
|
||||||
|
lua_pushstring(L, "");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_grabbed_output.ptr[g_grabbed_output.idx] = 0;
|
||||||
|
lua_pushstring(L, g_grabbed_output.ptr);
|
||||||
|
|
||||||
|
g_grabbed_output.idx = 0;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_iso15693_crc(lua_State *L) {
|
static int l_iso15693_crc(lua_State *L) {
|
||||||
|
|||||||
+47
-15
@@ -547,13 +547,16 @@ size_t pskFindFirstPhaseShift(const uint8_t *samples, size_t size, uint8_t *curP
|
|||||||
|
|
||||||
uint16_t avgWaveVal = 0, lastAvgWaveVal;
|
uint16_t avgWaveVal = 0, lastAvgWaveVal;
|
||||||
size_t i = waveStart, waveEnd, waveLenCnt, firstFullWave;
|
size_t i = waveStart, waveEnd, waveLenCnt, firstFullWave;
|
||||||
|
// waveStart starts as wherever the caller began looking, so the first length is part of a wave,
|
||||||
|
// not a wave, and judging it accepts a shift that is not there. Baseline on the first peak.
|
||||||
|
bool wave_from_peak = false;
|
||||||
for (; i < loopCnt; i++) {
|
for (; i < loopCnt; i++) {
|
||||||
// find peak // was "samples[i] + fc" but why? must have been used to weed out some wave error... removed..
|
// find peak // was "samples[i] + fc" but why? must have been used to weed out some wave error... removed..
|
||||||
if (samples[i] < samples[i + 1] && samples[i + 1] >= samples[i + 2]) {
|
if (samples[i] < samples[i + 1] && samples[i + 1] >= samples[i + 2]) {
|
||||||
waveEnd = i + 1;
|
waveEnd = i + 1;
|
||||||
if (g_debugMode == 2) prnt("DEBUG PSK: waveEnd: %zu, waveStart: %zu", waveEnd, waveStart);
|
if (g_debugMode == 2) prnt("DEBUG PSK: waveEnd: %zu, waveStart: %zu", waveEnd, waveStart);
|
||||||
waveLenCnt = waveEnd - waveStart;
|
waveLenCnt = waveEnd - waveStart;
|
||||||
if (waveLenCnt > fc && waveStart > fc && !(waveLenCnt > fc + 8)) { //not first peak and is a large wave but not out of whack
|
if (wave_from_peak && waveLenCnt > fc && waveStart > fc && !(waveLenCnt > fc + 8)) { //not first peak and is a large wave but not out of whack
|
||||||
lastAvgWaveVal = avgWaveVal / (waveLenCnt);
|
lastAvgWaveVal = avgWaveVal / (waveLenCnt);
|
||||||
firstFullWave = waveStart;
|
firstFullWave = waveStart;
|
||||||
*fullWaveLen = waveLenCnt;
|
*fullWaveLen = waveLenCnt;
|
||||||
@@ -562,6 +565,7 @@ size_t pskFindFirstPhaseShift(const uint8_t *samples, size_t size, uint8_t *curP
|
|||||||
return firstFullWave;
|
return firstFullWave;
|
||||||
}
|
}
|
||||||
waveStart = i + 1;
|
waveStart = i + 1;
|
||||||
|
wave_from_peak = true;
|
||||||
avgWaveVal = 0;
|
avgWaveVal = 0;
|
||||||
}
|
}
|
||||||
avgWaveVal += samples[i + 2];
|
avgWaveVal += samples[i + 2];
|
||||||
@@ -1902,18 +1906,31 @@ int nrzRawDemod(uint8_t *dest, size_t *size, int *clk, const int *invert, int *s
|
|||||||
if (dest[i] <= low) bit = 0;
|
if (dest[i] <= low) bit = 0;
|
||||||
dest[i] = bit;
|
dest[i] = bit;
|
||||||
}
|
}
|
||||||
//now demod based on clock (rf/32 = 32 1's for one 1 bit, 32 0's for one 0 bit)
|
// start on the first level change: it is the earliest sample known to be a
|
||||||
|
// bit boundary. counting the samples before it as bits rotated the stream
|
||||||
|
// whenever that edge moved by one, and left startIdx naming no sample
|
||||||
size_t lastBit = 0;
|
size_t lastBit = 0;
|
||||||
size_t numBits = 0;
|
size_t numBits = 0;
|
||||||
|
bool anchored = false;
|
||||||
for (i = 21; i < *size - 20; i++) {
|
for (i = 21; i < *size - 20; i++) {
|
||||||
|
|
||||||
|
bool edge = (dest[i] != dest[i - 1]);
|
||||||
|
|
||||||
|
if (anchored == false) {
|
||||||
|
if (edge == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*startIdx = (int)i;
|
||||||
|
if (g_debugMode == 2) prnt("DEBUG NRZ: startIdx %i", *startIdx);
|
||||||
|
lastBit = i - 1;
|
||||||
|
anchored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//if transition detected or large number of same bits - store the passed bits
|
//if transition detected or large number of same bits - store the passed bits
|
||||||
if (dest[i] != dest[i - 1] || (i - lastBit) == (10 * *clk)) {
|
if (edge || (i - lastBit) == (10 * *clk)) {
|
||||||
memset(dest + numBits, dest[i - 1] ^ *invert, (i - lastBit + (*clk / 4)) / *clk);
|
memset(dest + numBits, dest[i - 1] ^ *invert, (i - lastBit + (*clk / 4)) / *clk);
|
||||||
numBits += (i - lastBit + (*clk / 4)) / *clk;
|
numBits += (i - lastBit + (*clk / 4)) / *clk;
|
||||||
if (lastBit == 0) {
|
|
||||||
*startIdx = i - (numBits * *clk);
|
|
||||||
if (g_debugMode == 2) prnt("DEBUG NRZ: startIdx %i", *startIdx);
|
|
||||||
}
|
|
||||||
lastBit = i - 1;
|
lastBit = i - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2038,6 +2055,13 @@ static size_t aggregate_bits(uint8_t *dest, size_t size, uint8_t clk, uint8_t in
|
|||||||
// 0->1 crossing
|
// 0->1 crossing
|
||||||
n = (n * fchigh + hclk) / clk;
|
n = (n * fchigh + hclk) / clk;
|
||||||
|
|
||||||
|
// A leading run that rounds to no bits is lead-in, not data. Forcing it to one fabricates
|
||||||
|
// a bit and shifts the word; mid-stream a zero would lose a bit the tag did send.
|
||||||
|
if (n == 0 && numBits == 0) {
|
||||||
|
lastval = dest[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
||||||
@@ -2141,14 +2165,22 @@ int pskRawDemod_ext(uint8_t *dest, size_t *size, int *clock, const int *invert,
|
|||||||
i = findModStart(dest, *size, fc);
|
i = findModStart(dest, *size, fc);
|
||||||
//find first phase shift
|
//find first phase shift
|
||||||
firstFullWave = pskFindFirstPhaseShift(dest, *size, &curPhase, i, fc, &fullWaveLen);
|
firstFullWave = pskFindFirstPhaseShift(dest, *size, &curPhase, i, fc, &fullWaveLen);
|
||||||
if (firstFullWave == 0) {
|
}
|
||||||
// no phase shift detected - could be all 1's or 0's - doesn't matter where we start
|
|
||||||
// so skip a little to ensure we are past any Start Signal
|
// A first shift less than a bit period in is lead-in, not data. Counting it toggles curPhase
|
||||||
firstFullWave = 160;
|
// once too often, and the emitted bit is the running phase, so the rest of the word inverts.
|
||||||
memset(dest, curPhase, firstFullWave / *clock);
|
const size_t bit_period = (size_t)(*clock);
|
||||||
} else {
|
if (firstFullWave != 0 && firstFullWave < bit_period) {
|
||||||
memset(dest, curPhase ^ 1, firstFullWave / *clock);
|
curPhase = *invert;
|
||||||
}
|
fullWaveLen = 0;
|
||||||
|
firstFullWave = pskFindFirstPhaseShift(dest, *size, &curPhase, bit_period, fc, &fullWaveLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstFullWave == 0) {
|
||||||
|
// no phase shift detected - could be all 1's or 0's - doesn't matter where we start
|
||||||
|
// so skip a little to ensure we are past any Start Signal
|
||||||
|
firstFullWave = 160;
|
||||||
|
memset(dest, curPhase, firstFullWave / *clock);
|
||||||
} else {
|
} else {
|
||||||
memset(dest, curPhase ^ 1, firstFullWave / *clock);
|
memset(dest, curPhase ^ 1, firstFullWave / *clock);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,6 +508,21 @@ int usb_write(const uint8_t *data, const size_t len) {
|
|||||||
// Have a cup of tea?
|
// Have a cup of tea?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End a packet-aligned CDC transfer with a zero-length packet. Without
|
||||||
|
// this short packet, a host read larger than this reply can remain pending.
|
||||||
|
// Use the low-level sender: usb_write() intentionally rejects len == 0.
|
||||||
|
// Keep this in the synchronous path, not the asynchronous sample stream.
|
||||||
|
if ((len % USBD_CDC_IN_MAXPACKET_SIZE) == 0) {
|
||||||
|
if (usb_vcp_send_data(udev, (uint8_t *) data, 0) != SUCCESS) {
|
||||||
|
return PM3_EIO;
|
||||||
|
}
|
||||||
|
while (pcdc->g_tx_completed != 1) {
|
||||||
|
if (usb_check() == false) {
|
||||||
|
return PM3_EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+225
-158
@@ -6223,7 +6223,7 @@
|
|||||||
},
|
},
|
||||||
"hf mf gdmgetblk": {
|
"hf mf gdmgetblk": {
|
||||||
"command": "hf mf gdmgetblk",
|
"command": "hf mf gdmgetblk",
|
||||||
"description": "Read public block(s) from a GDM card",
|
"description": "Read public block(s) from a GDM card. With no wakeup flag it auto-detects the card's access mode (WUPA magic auth, gen1a, or gdm alt).",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmgetblk --blk 0",
|
"hf mf gdmgetblk --blk 0",
|
||||||
"hf mf gdmgetblk --sec 1 --gdm"
|
"hf mf gdmgetblk --sec 1 --gdm"
|
||||||
@@ -6234,15 +6234,15 @@
|
|||||||
"--blk <dec> block to read",
|
"--blk <dec> block to read",
|
||||||
"--sec <dec> sector to read",
|
"--sec <dec> sector to read",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm use gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)"
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmgetblk [-h] [--blk <dec>] [--sec <dec>] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
"usage": "hf mf gdmgetblk [-h] [--blk <dec>] [--sec <dec>] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
||||||
},
|
},
|
||||||
"hf mf gdmgetcfg": {
|
"hf mf gdmgetcfg": {
|
||||||
"command": "hf mf gdmgetcfg",
|
"command": "hf mf gdmgetcfg",
|
||||||
"description": "Get configuration data from a GDM card. By default uses GDM alt wakeup (20/23). Use `--gen1a` or `--wupa` to override.",
|
"description": "Get configuration data from a GDM card. With no wakeup flag it auto-detects the card's access mode (tries WUPA magic auth, then gen1a, then gdm alt). Use `--gdm`/`--gen1a`/`--wupa` to force one.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmgetcfg",
|
"hf mf gdmgetcfg",
|
||||||
"hf mf gdmgetcfg --gen1a",
|
"hf mf gdmgetcfg --gen1a",
|
||||||
@@ -6252,15 +6252,15 @@
|
|||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm use gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)"
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmgetcfg [-h] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
"usage": "hf mf gdmgetcfg [-h] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
||||||
},
|
},
|
||||||
"hf mf gdmgethidblk": {
|
"hf mf gdmgethidblk": {
|
||||||
"command": "hf mf gdmgethidblk",
|
"command": "hf mf gdmgethidblk",
|
||||||
"description": "Read hidden block(s) from a GDM card",
|
"description": "Read hidden block(s) from a GDM card. With no wakeup flag it auto-detects the card's access mode (WUPA magic auth, gen1a, or gdm alt).",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmgethidblk --blk 0",
|
"hf mf gdmgethidblk --blk 0",
|
||||||
"hf mf gdmgethidblk --sec 1 --gdm"
|
"hf mf gdmgethidblk --sec 1 --gdm"
|
||||||
@@ -6271,9 +6271,9 @@
|
|||||||
"--blk <dec> block to read",
|
"--blk <dec> block to read",
|
||||||
"--sec <dec> sector to read",
|
"--sec <dec> sector to read",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm use gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)"
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmgethidblk [-h] [--blk <dec>] [--sec <dec>] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
"usage": "hf mf gdmgethidblk [-h] [--blk <dec>] [--sec <dec>] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
||||||
},
|
},
|
||||||
@@ -6292,7 +6292,7 @@
|
|||||||
},
|
},
|
||||||
"hf mf gdmsetblk": {
|
"hf mf gdmsetblk": {
|
||||||
"command": "hf mf gdmsetblk",
|
"command": "hf mf gdmsetblk",
|
||||||
"description": "Set public block data on a GDM card By default uses GDM alt wakeup (20/23). Use `--gen1a` or `--wupa` to override. `--force` param is used to override warnings like bad ACL writes. if not specified, it will exit if detected",
|
"description": "Set public block data on a GDM card With no wakeup flag it auto-detects the card's access mode (gen1a, gdm alt, or WUPA magic auth). `--force` param is used to override warnings like bad ACL writes. if not specified, it will exit if detected",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmsetblk --blk 1 -d 000102030405060708090a0b0c0d0e0f",
|
"hf mf gdmsetblk --blk 1 -d 000102030405060708090a0b0c0d0e0f",
|
||||||
"hf mf gdmsetblk --blk 1 -d 000102030405060708090a0b0c0d0e0f --gen1a",
|
"hf mf gdmsetblk --blk 1 -d 000102030405060708090a0b0c0d0e0f --gen1a",
|
||||||
@@ -6304,19 +6304,20 @@
|
|||||||
"--blk <dec> public block number",
|
"--blk <dec> public block number",
|
||||||
"-d, --data <hex> bytes to write, 16 hex bytes",
|
"-d, --data <hex> bytes to write, 16 hex bytes",
|
||||||
"-k, --key <hex> key, 6 hex bytes (only for --wupa mode)",
|
"-k, --key <hex> key, 6 hex bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm access: force gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)",
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)",
|
||||||
"--force override warnings"
|
"--force override warnings"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmsetblk [-h] --blk <dec> -d <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa] [--force]"
|
"usage": "hf mf gdmsetblk [-h] --blk <dec> -d <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa] [--force]"
|
||||||
},
|
},
|
||||||
"hf mf gdmsetcfg": {
|
"hf mf gdmsetcfg": {
|
||||||
"command": "hf mf gdmsetcfg",
|
"command": "hf mf gdmsetcfg",
|
||||||
"description": "Set configuration data on a GDM card Can either write raw 16 bytes (-d) or configure specific flags. If flags are provided, it will read the config, update flags, and write it back.",
|
"description": "Set configuration data on a GDM card Can either write raw 16 bytes (-d) or configure specific flags. If flags are provided, it will read the config, update flags, and write it back. With no wakeup flag it auto-detects the card's access mode (WUPA magic auth, gen1a, or gdm alt). `access:` flags select how this command talks to the card; `config:` flags change what is stored.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmsetcfg -d 850000000000000000005A5A00000008",
|
"hf mf gdmsetcfg -d 850000000000000000005A5A00000008",
|
||||||
"hf mf gdmsetcfg --cuid on --gen1 on",
|
"hf mf gdmsetcfg --cuid on --wakestyle gen1a",
|
||||||
|
"hf mf gdmsetcfg --wakestyle off",
|
||||||
"hf mf gdmsetcfg --shadow off --sigsec off --wupa -k FFFFFFFFFFFF"
|
"hf mf gdmsetcfg --shadow off --sigsec off --wupa -k FFFFFFFFFFFF"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
@@ -6324,22 +6325,22 @@
|
|||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-d, --data <hex> raw bytes to write, 16 hex bytes",
|
"-d, --data <hex> raw bytes to write, 16 hex bytes",
|
||||||
"-k, --key <hex> key 6 bytes (only for regular wakeup)",
|
"-k, --key <hex> key 6 bytes (only for regular wakeup)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm access: force gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)",
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)",
|
||||||
"--gen1 <on|off> Gen1 mode (7A FF)",
|
"--cuid <on|off> config: Gen2/CUID mode",
|
||||||
"--cuid <on|off> Gen2/CUID mode",
|
"--cl2 <on|off> config: CL2 mode (7-byte UID) - pair with `hf mf gdmsetuid -u <7-byte>`",
|
||||||
"--cl2 <on|off> CL2 mode (7-byte UID) - pair with `hf mf gdmsetuid -u <7-byte>` to set a valid UID",
|
"--shadow <on|off> config: Shadow mode",
|
||||||
"--shadow <on|off> Shadow mode",
|
"--magicauth <on|off> config: Magic auth (what --wupa uses)",
|
||||||
"--magicauth <on|off> Magic auth",
|
"--statenc <on|off> config: Static encrypted nonce",
|
||||||
"--statenc <on|off> Static encrypted nonce",
|
"--sigsec <on|off> config: Signature sector",
|
||||||
"--sigsec <on|off> Signature sector"
|
"--wakestyle <gdm|gen1a|off> config: backdoor - gdm (7AFF85), gen1a (7AFF00), or off (8500, seal)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmsetcfg [-h] [-d <hex>] [-k <hex>] [--gdm] [--gen1a] [--wupa] [--gen1 <on|off>] [--cuid <on|off>] [--cl2 <on|off>] [--shadow <on|off>] [--magicauth <on|off>] [--statenc <on|off>] [--sigsec <on|off>]"
|
"usage": "hf mf gdmsetcfg [-h] [-d <hex>] [-k <hex>] [--gdm] [--gen1a] [--wupa] [--cuid <on|off>] [--cl2 <on|off>] [--shadow <on|off>] [--magicauth <on|off>] [--statenc <on|off>] [--sigsec <on|off>] [--wakestyle <gdm|gen1a|off>]"
|
||||||
},
|
},
|
||||||
"hf mf gdmsethidblk": {
|
"hf mf gdmsethidblk": {
|
||||||
"command": "hf mf gdmsethidblk",
|
"command": "hf mf gdmsethidblk",
|
||||||
"description": "Write hidden block data on a GDM card. Hidden blocks 0-7 map to the card's hidden sector area. By default uses GDM alt wakeup (20/23). Use `--gen1a` or `--wupa` to override. `--force` param is used to override warnings like bad BCC or ACL writes. if not specified, it will exit if detected",
|
"description": "Write hidden block data on a GDM card. Hidden blocks 0-7 map to the card's hidden sector area. With no wakeup flag it auto-detects a backdoor (gen1a or gdm alt); a WUPA-only card is rejected. `--force` param is used to override warnings like bad BCC or ACL writes. if not specified, it will exit if detected",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmsethidblk --blk 0 -d 880494716904EA0C2394510800000000",
|
"hf mf gdmsethidblk --blk 0 -d 880494716904EA0C2394510800000000",
|
||||||
"hf mf gdmsethidblk --blk 0 -d 880494716904EA0C2394510800000000 --gen1a",
|
"hf mf gdmsethidblk --blk 0 -d 880494716904EA0C2394510800000000 --gen1a",
|
||||||
@@ -6352,16 +6353,16 @@
|
|||||||
"--blk <dec> hidden block number (0-7)",
|
"--blk <dec> hidden block number (0-7)",
|
||||||
"-d, --data <hex> bytes to write, 16 hex bytes",
|
"-d, --data <hex> bytes to write, 16 hex bytes",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm access: force gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)",
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)",
|
||||||
"--force override warnings"
|
"--force override warnings"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmsethidblk [-h] --blk <dec> -d <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa] [--force]"
|
"usage": "hf mf gdmsethidblk [-h] --blk <dec> -d <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa] [--force]"
|
||||||
},
|
},
|
||||||
"hf mf gdmsetsig": {
|
"hf mf gdmsetsig": {
|
||||||
"command": "hf mf gdmsetsig",
|
"command": "hf mf gdmsetsig",
|
||||||
"description": "Set MFC EV1 signature on a GDM card",
|
"description": "Set MFC EV1 signature on a GDM card. With no wakeup flag it auto-detects a backdoor (gen1a or gdm alt); a WUPA-only card is rejected.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmsetsig -s <64 hex chars>"
|
"hf mf gdmsetsig -s <64 hex chars>"
|
||||||
],
|
],
|
||||||
@@ -6370,15 +6371,15 @@
|
|||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-s, --sig <hex> 32-byte signature (64 hex characters)",
|
"-s, --sig <hex> 32-byte signature (64 hex characters)",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm access: force gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)"
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmsetsig [-h] -s <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
"usage": "hf mf gdmsetsig [-h] -s <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
||||||
},
|
},
|
||||||
"hf mf gdmsetuid": {
|
"hf mf gdmsetuid": {
|
||||||
"command": "hf mf gdmsetuid",
|
"command": "hf mf gdmsetuid",
|
||||||
"description": "Set UID on a GDM card",
|
"description": "Set UID on a GDM card. With no wakeup flag it auto-detects a backdoor (gen1a or gdm alt); a WUPA-only card is rejected.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmsetuid -u 01020304",
|
"hf mf gdmsetuid -u 01020304",
|
||||||
"hf mf gdmsetuid -u 01020304050607 --gen1a"
|
"hf mf gdmsetuid -u 01020304050607 --gen1a"
|
||||||
@@ -6388,16 +6389,16 @@
|
|||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-u, --uid <hex> UID to set (4 or 7 hex bytes)",
|
"-u, --uid <hex> UID to set (4 or 7 hex bytes)",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm access: force gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)",
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)",
|
||||||
"--f3d use F3 perso mode (writes to hidden block 1 instead of 0)"
|
"--f3d use F3 perso mode (writes to hidden block 1 instead of 0)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmsetuid [-h] -u <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa] [--f3d]"
|
"usage": "hf mf gdmsetuid [-h] -u <hex> [-k <hex>] [--gdm] [--gen1a] [--wupa] [--f3d]"
|
||||||
},
|
},
|
||||||
"hf mf gdmwipe": {
|
"hf mf gdmwipe": {
|
||||||
"command": "hf mf gdmwipe",
|
"command": "hf mf gdmwipe",
|
||||||
"description": "Wipe a GDM card to factory defaults",
|
"description": "Wipe a GDM card to factory defaults. With no wakeup flag it auto-detects a backdoor (gen1a or gdm alt); a WUPA-only card is rejected.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf gdmwipe --gdm"
|
"hf mf gdmwipe --gdm"
|
||||||
],
|
],
|
||||||
@@ -6405,9 +6406,9 @@
|
|||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
"-k, --key <hex> key 6 bytes (only for --wupa mode)",
|
||||||
"--gdm use gdm alt (20/23) magic wakeup (default)",
|
"--gdm access: force gdm alt (20/23) magic wakeup",
|
||||||
"--gen1a use gen1a (40/43) magic wakeup",
|
"--gen1a access: force gen1a (40/43) magic wakeup",
|
||||||
"--wupa use regular wakeup (WUPA + magic auth with key)",
|
"--wupa access: force regular wakeup (WUPA + magic auth with key)",
|
||||||
"-a, --all wipe 4K card (40 sectors) instead of 1K card (16 sectors)"
|
"-a, --all wipe 4K card (40 sectors) instead of 1K card (16 sectors)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gdmwipe [-ha] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
"usage": "hf mf gdmwipe [-ha] [-k <hex>] [--gdm] [--gen1a] [--wupa]"
|
||||||
@@ -7206,7 +7207,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7256,7 +7257,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number (default: 0 / PICC key)",
|
"-n, --keyno <dec> Key number (default: 0 / PICC key)",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7310,7 +7311,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7343,7 +7344,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7367,17 +7368,18 @@
|
|||||||
"command": "hf mfdes chk",
|
"command": "hf mfdes chk",
|
||||||
"description": "Checks keys with MIFARE DESFire card.",
|
"description": "Checks keys with MIFARE DESFire card.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mfdes chk --aid 123456 -k 000102030405060708090a0b0c0d0e0f -> check key on aid 0x123456",
|
"hf mfdes chk -f mfdes_default_keys -> check keys against all existing AID on card",
|
||||||
"hf mfdes chk -f mfdes_default_keys -> check keys against all existing aid on card",
|
"hf mfdes chk --aid 123456 -f mfdes_default_keys -> check keys against AID 0x123456",
|
||||||
"hf mfdes chk -f mfdes_default_keys --aid 123456 -> check keys against aid 0x123456",
|
"hf mfdes chk --aid 123456 --pattern1b -j keys -> check all 1-byte keys pattern on AID 0x123456 and save found keys to `keys.json`",
|
||||||
"hf mfdes chk --aid 123456 --pattern1b -j keys -> check all 1-byte keys pattern on aid 0x123456 and save found keys to `keys.json`",
|
"hf mfdes chk --aid 123456 --pattern2b --startp2b FA00 -> check all 2-byte keys pattern on AID 0x123456. Start from key FA00FA00...FA00",
|
||||||
"hf mfdes chk --aid 123456 --pattern2b --startp2b FA00 -> check all 2-byte keys pattern on aid 0x123456. Start from key FA00FA00...FA00"
|
"hf mfdes chk --aid 123456 -k 000102030405060708090a0b0c0d0e0f -> check key on AID 0x123456",
|
||||||
|
"hf mfdes chk -f mfdes_default_keys --schann lrp -> check keys, forcing the LRP secure channel"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"--aid <hex> Use specific AID (3 hex bytes, big endian)",
|
"--aid <hex> Use specific AID (3 hex bytes, big endian)",
|
||||||
"-k, --key <hex> Key for checking (HEX 16 bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"-f, --file <fn> Filename of dictionary",
|
"-f, --file <fn> Filename of dictionary",
|
||||||
"--pattern1b Check all 1-byte combinations of key (0000...0000, 0101...0101, 0202...0202, ...)",
|
"--pattern1b Check all 1-byte combinations of key (0000...0000, 0101...0101, 0202...0202, ...)",
|
||||||
"--pattern2b Check all 2-byte combinations of key (0000...0000, 0001...0001, 0002...0002, ...)",
|
"--pattern2b Check all 2-byte combinations of key (0000...0000, 0001...0001, 0002...0002, ...)",
|
||||||
@@ -7386,9 +7388,10 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"--kdf <0|1|2> Key Derivation Function (KDF) (0=None, 1=AN10922, 2=Gallagher)",
|
"--kdf <0|1|2> Key Derivation Function (KDF) (0=None, 1=AN10922, 2=Gallagher)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
|
"--schann <d40|ev1|ev2|lrp> Secure channel (default: detected per application)",
|
||||||
"-a, --apdu Show APDU requests and responses"
|
"-a, --apdu Show APDU requests and responses"
|
||||||
],
|
],
|
||||||
"usage": "hf mfdes chk [-hva] [--aid <hex>] [-k <hex>] [-f <fn>] [--pattern1b] [--pattern2b] [--startp2b <pattern>] [-j <fn>] [--kdf <0|1|2>] [-i <hex>]"
|
"usage": "hf mfdes chk [-hva] [--aid <hex>] [-k <hex>] [-f <fn>] [--pattern1b] [--pattern2b] [--startp2b <pattern>] [-j <fn>] [--kdf <0|1|2>] [-i <hex>] [--schann <d40|ev1|ev2|lrp>]"
|
||||||
},
|
},
|
||||||
"hf mfdes chkeysettings": {
|
"hf mfdes chkeysettings": {
|
||||||
"command": "hf mfdes chkeysettings",
|
"command": "hf mfdes chkeysettings",
|
||||||
@@ -7404,7 +7407,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7429,7 +7432,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7486,7 +7489,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7523,7 +7526,7 @@
|
|||||||
"-a, --apdu Show APDU requests and responses",
|
"-a, --apdu Show APDU requests and responses",
|
||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7567,7 +7570,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7611,7 +7614,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7647,7 +7650,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7684,7 +7687,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7723,7 +7726,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo (deft: 2TDEA)",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo (deft: 2TDEA)",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7756,7 +7759,7 @@
|
|||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7778,7 +7781,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7802,7 +7805,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7817,22 +7820,22 @@
|
|||||||
},
|
},
|
||||||
"hf mfdes detect": {
|
"hf mfdes detect": {
|
||||||
"command": "hf mfdes detect",
|
"command": "hf mfdes detect",
|
||||||
"description": "Detect key type and tries to find one from the list.",
|
"description": "Detect PICC master key, key type, communication mode, command set and channel mode. Uses `mfdes_default_keys.dic` per default `--save` it saves details to be used with `hf mfdes default`",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mfdes detect -> detect key 0 from PICC level",
|
"hf mfdes detect",
|
||||||
"hf mfdes detect --schann d40 -> detect key 0 from PICC level via secure channel D40",
|
"hf mfdes detect --schann d40 -> detect from PICC level via secure channel D40",
|
||||||
"hf mfdes detect -f mfdes_default_keys -> detect key 0 from PICC level with help of the standard dictionary",
|
"hf mfdes detect -f my_keys -> detect from PICC level with your own dictionary",
|
||||||
"hf mfdes detect --aid 123456 -n 2 --save -> detect key 2 from app 123456 and if succeed - save params to defaults (`default` command)",
|
"hf mfdes detect --aid 123456 -n 2 --save -> detect key 2 from app 123456 and save params to defaults",
|
||||||
"hf mfdes detect --isoid df01 --save -> detect key 0 and save to defaults with card in the LRP mode"
|
"hf mfdes detect --isoid df01 --save -> detect and save to defaults with card in the LRP mode"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-a, --apdu Show APDU requests and responses",
|
"-a, --apdu Show APDU requests and responses",
|
||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number (def: all)",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7841,7 +7844,7 @@
|
|||||||
"--aid <hex> Application ID (3 hex bytes, big endian)",
|
"--aid <hex> Application ID (3 hex bytes, big endian)",
|
||||||
"--isoid <hex> Application ISO ID (ISO DF ID) (2 hex bytes, big endian).",
|
"--isoid <hex> Application ISO ID (ISO DF ID) (2 hex bytes, big endian).",
|
||||||
"--dfname <hex> Application ISO DF Name (5-16 hex bytes, big endian)",
|
"--dfname <hex> Application ISO DF Name (5-16 hex bytes, big endian)",
|
||||||
"-f, --file <fn> Filename of dictionary",
|
"-f, --file <fn> Filename of dictionary (default: `mfdes_default_keys`)",
|
||||||
"--save Save found key and parameters to defaults"
|
"--save Save found key and parameters to defaults"
|
||||||
],
|
],
|
||||||
"usage": "hf mfdes detect [-hav] [-n <dec>] [-t <DES|2TDEA|3TDEA|AES>] [-k <hex>] [--kdf <none|AN10922|gallagher>] [-i <hex>] [-m <plain|mac|encrypt>] [-c <native|niso|iso>] [--schann <d40|ev1|ev2|lrp>] [--aid <hex>] [--isoid <hex>] [--dfname <hex>] [-f <fn>] [--save]"
|
"usage": "hf mfdes detect [-hav] [-n <dec>] [-t <DES|2TDEA|3TDEA|AES>] [-k <hex>] [--kdf <none|AN10922|gallagher>] [-i <hex>] [-m <plain|mac|encrypt>] [-c <native|niso|iso>] [--schann <d40|ev1|ev2|lrp>] [--aid <hex>] [--isoid <hex>] [--dfname <hex>] [-f <fn>] [--save]"
|
||||||
@@ -7859,7 +7862,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7886,7 +7889,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7909,7 +7912,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7933,7 +7936,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7956,7 +7959,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7982,7 +7985,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number (default: 0 / PICC key)",
|
"-n, --keyno <dec> Key number (default: 0 / PICC key)",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -7998,8 +8001,8 @@
|
|||||||
"description": "Get File IDs list from card. Master key needs to be provided or flag --no-auth set.",
|
"description": "Get File IDs list from card. Master key needs to be provided or flag --no-auth set.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mfdes getfileids --aid 123456 -> execute with defaults from `default` command",
|
"hf mfdes getfileids --aid 123456 -> execute with defaults from `default` command",
|
||||||
"hf mfdes getfileids -n 0 -t des -k 0000000000000000 --kdf none --aid 123456 -> execute with default factory setup",
|
"hf mfdes getfileids --dfname D2760000850100 -> select DF by name and get file IDs",
|
||||||
"hf mfdes getfileids --dfname D2760000850100 -> select DF by name and get file IDs"
|
"hf mfdes getfileids -n 0 -t des -k 0000000000000000 --aid 123456 -> execute with default factory setup"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
@@ -8008,7 +8011,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8038,7 +8041,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8067,7 +8070,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8096,7 +8099,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8124,7 +8127,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number for authentication",
|
"-n, --keyno <dec> Key number for authentication",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8154,7 +8157,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8256,7 +8259,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8284,7 +8287,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8315,7 +8318,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8338,7 +8341,7 @@
|
|||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-v, --verbose Show more output",
|
"-v, --verbose Show more output",
|
||||||
"-k, --key <hex> Key for computing the MAC, must be HEX 16(AES)",
|
"-k, --key <hex> Key for computing the MAC (16 hex bytes)",
|
||||||
"-b, --blk <num>[,<num>[,...]] The MFC blocks to map, must be given in ascending order (use the special value 'all' for all blocks)",
|
"-b, --blk <num>[,<num>[,...]] The MFC blocks to map, must be given in ascending order (use the special value 'all' for all blocks)",
|
||||||
"--ka Allow updating key A from inside sector trailers mapped to DESFire files",
|
"--ka Allow updating key A from inside sector trailers mapped to DESFire files",
|
||||||
"--kb Allow updating key B from inside sector trailers mapped to DESFire files",
|
"--kb Allow updating key B from inside sector trailers mapped to DESFire files",
|
||||||
@@ -8398,7 +8401,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8435,7 +8438,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8498,7 +8501,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8540,7 +8543,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo (deft: 2TDEA)",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo (deft: 2TDEA)",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -8604,7 +8607,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number for DESFire authentication",
|
"-n, --keyno <dec> Key number for DESFire authentication",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> DESFire auth crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> DESFire auth crypt algo",
|
||||||
"-k, --key <hex> DESFire authentication key",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communication mode",
|
"-m, --cmode <plain|mac|encrypt> Communication mode",
|
||||||
@@ -8652,7 +8655,7 @@
|
|||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"-n, --keyno <dec> Key number",
|
"-n, --keyno <dec> Key number",
|
||||||
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
"-t, --algo <DES|2TDEA|3TDEA|AES> Crypt algo",
|
||||||
"-k, --key <hex> Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)",
|
"-k, --key <hex> Key for authenticate (8|16|24 hex bytes)",
|
||||||
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
"--kdf <none|AN10922|gallagher> Key Derivation Function (KDF)",
|
||||||
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
"-i, --kdfi <hex> KDF input (1-31 hex bytes)",
|
||||||
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
"-m, --cmode <plain|mac|encrypt> Communicaton mode",
|
||||||
@@ -9416,6 +9419,30 @@
|
|||||||
],
|
],
|
||||||
"usage": "hf mfu keygen [-hr] [-u <hex>] [-b <dec>]"
|
"usage": "hf mfu keygen [-hr] [-u <hex>] [-b <dec>]"
|
||||||
},
|
},
|
||||||
|
"hf mfu ndefformat": {
|
||||||
|
"command": "hf mfu ndefformat",
|
||||||
|
"description": "Format a MIFARE Ultralight / NTAG tag for NDEF by writing the Capability Container to block 3, followed by an empty NDEF message. Writes NXP factory delivery content for the detected tag type. Block 3 is One Time Programmable; unknown types and unreachable CCs are refused. Note: the tag is re-selected and re-authenticated for each block written.",
|
||||||
|
"notes": [
|
||||||
|
"hf mfu ndefformat",
|
||||||
|
"hf mfu ndefformat -v",
|
||||||
|
"hf mfu ndefformat --erase",
|
||||||
|
"hf mfu ndefformat -k FFFFFFFF",
|
||||||
|
"hf mfu ndefformat -k 49454D4B41455242214E4143554F5946",
|
||||||
|
"hf mfu ndefformat -d E1101200 --force"
|
||||||
|
],
|
||||||
|
"offline": false,
|
||||||
|
"options": [
|
||||||
|
"-h, --help This help",
|
||||||
|
"-k, --key <hex> Authentication key (UL-C/UL-AES 16 bytes, EV1/NTAG 4 bytes)",
|
||||||
|
"-l Swap entered key endianness",
|
||||||
|
"-d, --data <hex> Capability Container to write, 4 bytes. Overrides the detected type",
|
||||||
|
"--erase Also zero the rest of the NDEF data area",
|
||||||
|
"--force Continue on an unknown tag type, or with an oversized -d value",
|
||||||
|
"-v, --verbose Verbose output",
|
||||||
|
"--schann use secure channel. Must have key"
|
||||||
|
],
|
||||||
|
"usage": "hf mfu ndefformat [-hlv] [-k <hex>] [-d <hex>] [--erase] [--force] [--schann]"
|
||||||
|
},
|
||||||
"hf mfu ndefread": {
|
"hf mfu ndefread": {
|
||||||
"command": "hf mfu ndefread",
|
"command": "hf mfu ndefread",
|
||||||
"description": "Prints NFC Data Exchange Format (NDEF)",
|
"description": "Prints NFC Data Exchange Format (NDEF)",
|
||||||
@@ -10874,83 +10901,92 @@
|
|||||||
],
|
],
|
||||||
"usage": "hw break [-h]"
|
"usage": "hw break [-h]"
|
||||||
},
|
},
|
||||||
"hw bwmautooff": {
|
"hw bwm charge": {
|
||||||
"command": "hw bwmautooff",
|
"command": "hw bwm charge",
|
||||||
"description": "Toggle automatic power-off when the PM5 is unplugged from USB (BWM only). Default is on. When on, the board powers itself down ~10s after USB is removed, so a BWM-equipped PM5 doesn't silently drain the battery. Button power-on is unaffected. Disable for standalone/BLE use on battery. Runtime only: resets to on at each boot.",
|
|
||||||
"notes": [
|
|
||||||
"hw bwmautooff --off -> disable auto power-off",
|
|
||||||
"hw bwmautooff --on -> re-enable auto power-off"
|
|
||||||
],
|
|
||||||
"offline": false,
|
|
||||||
"options": [
|
|
||||||
"-h, --help This help",
|
|
||||||
"--on enable auto power-off (default)",
|
|
||||||
"--off disable auto power-off"
|
|
||||||
],
|
|
||||||
"usage": "hw bwmautooff [-h] [--on] [--off]"
|
|
||||||
},
|
|
||||||
"hw bwmcharge": {
|
|
||||||
"command": "hw bwmcharge",
|
|
||||||
"description": "Enable or disable BWM battery charging by clearing/setting the AW32001E charge-enable bit (CEB, REG01[3]). PM5 only. One-shot: the charger watchdog reverts this after ~160 s unless serviced, so charging may stop on its own. Use to nudge a top-up.",
|
"description": "Enable or disable BWM battery charging by clearing/setting the AW32001E charge-enable bit (CEB, REG01[3]). PM5 only. One-shot: the charger watchdog reverts this after ~160 s unless serviced, so charging may stop on its own. Use to nudge a top-up.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hw bwmcharge -on -> enable charging",
|
"hw bwm charge off -> disable charging",
|
||||||
"hw bwmcharge --off -> disable charging"
|
"hw bwm charge on -> enable charging"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help"
|
||||||
"--on enable charging (default)",
|
|
||||||
"--off disable charging"
|
|
||||||
],
|
],
|
||||||
"usage": "hw bwmcharge [-h] [--on] [--off]"
|
"usage": "hw bwm charge [-h]"
|
||||||
},
|
},
|
||||||
"hw bwmsetcap": {
|
"hw bwm help": {
|
||||||
"command": "hw bwmsetcap",
|
"command": "hw bwm help",
|
||||||
|
"description": "help This help --------------------------------------------------------------------------------------- hw bwm autooff available offline: no Toggle automatic power-off when the PM5 is unplugged from USB (BWM only). Default is on. When on, the board powers itself down ~10s after USB is removed, so a BWM-equipped PM5 doesn't silently drain the battery. Button power-on is unaffected. Disable for standalone/BLE use on battery. Runtime only: resets to on at each boot.",
|
||||||
|
"notes": [
|
||||||
|
"hw bwm autooff off -> disable auto power-off",
|
||||||
|
"hw bwm autooff on -> re-enable auto power-off"
|
||||||
|
],
|
||||||
|
"offline": true,
|
||||||
|
"options": [
|
||||||
|
"-h, --help This help"
|
||||||
|
],
|
||||||
|
"usage": "hw bwm autooff [-h]"
|
||||||
|
},
|
||||||
|
"hw bwm setcap": {
|
||||||
|
"command": "hw bwm setcap",
|
||||||
"description": "Program the BWM fuel gauge (BQ27427) Design Capacity for the fitted cell. Run ONCE after fitting or replacing the battery. This triggers a gauge config-update; do not run it repeatedly, as that disrupts the Impedance Track learning cycle. PM5 only.",
|
"description": "Program the BWM fuel gauge (BQ27427) Design Capacity for the fitted cell. Run ONCE after fitting or replacing the battery. This triggers a gauge config-update; do not run it repeatedly, as that disrupts the Impedance Track learning cycle. PM5 only.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hw bwmsetcap -> set design capacity to default 500 mAh",
|
"hw bwm setcap -> set design capacity to default 500 mAh",
|
||||||
"hw bwmsetcap --cap 500 -> set design capacity to 500 mAh"
|
"hw bwm setcap --cap 500 -> set design capacity to 500 mAh"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"--cap <mAh> design capacity in mAh (default 500)"
|
"--cap <mAh> design capacity in mAh (default 500)"
|
||||||
],
|
],
|
||||||
"usage": "hw bwmsetcap [-h] [--cap <mAh>]"
|
"usage": "hw bwm setcap [-h] [--cap <mAh>]"
|
||||||
},
|
},
|
||||||
"hw bwmvchg": {
|
"hw bwm upgrade": {
|
||||||
"command": "hw bwmvchg",
|
"command": "hw bwm upgrade",
|
||||||
|
"description": "Reflash the BWM (ESP32) firmware over the BWM link - no header, no soldering. Requires a BWM that still responds; this updates a wrong-version ESP, it cannot recover a fully bricked one (that still needs the 5-pin header + esptool).",
|
||||||
|
"notes": [
|
||||||
|
"hw bwm upgrade -f bwm_esp32.bin"
|
||||||
|
],
|
||||||
|
"offline": false,
|
||||||
|
"options": [
|
||||||
|
"-h, --help This help",
|
||||||
|
"-f, --file <fn> ESP32 firmware image (.bin)",
|
||||||
|
"--delay <ms> per-chunk delay to pace the slow AT32<->ESP UART (default 20)"
|
||||||
|
],
|
||||||
|
"usage": "hw bwm upgrade [-h] -f <fn> [--delay <ms>]"
|
||||||
|
},
|
||||||
|
"hw bwm vchg": {
|
||||||
|
"command": "hw bwm vchg",
|
||||||
"description": "Set the BWM charger (AW32001E) charge-voltage regulation target. Lowering it below 4.2 V reduces top-of-charge stress and extends cell life. Snaps to the nearest 15 mV step; clamped to 3600..4200 mV. This is a runtime register write (reverts on the charger watchdog / POR); the firmware re-applies the 4100 mV default at every boot. PM5 only.",
|
"description": "Set the BWM charger (AW32001E) charge-voltage regulation target. Lowering it below 4.2 V reduces top-of-charge stress and extends cell life. Snaps to the nearest 15 mV step; clamped to 3600..4200 mV. This is a runtime register write (reverts on the charger watchdog / POR); the firmware re-applies the 4100 mV default at every boot. PM5 only.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hw bwmvchg -> set charge voltage to default 4100 mV (->4.095 V)",
|
"hw bwm vchg -> set charge voltage to default 4100 mV (->4.095 V)",
|
||||||
"hw bwmvchg --mv 4200 -> set charge voltage to 4200 mV"
|
"hw bwm vchg --mv 4200 -> set charge voltage to 4200 mV"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"--mv <mV> charge voltage in mV (default 4100, clamped 3600..4200)"
|
"--mv <mV> charge voltage in mV (default 4100, clamped 3600..4200)"
|
||||||
],
|
],
|
||||||
"usage": "hw bwmvchg [-h] [--mv <mV>]"
|
"usage": "hw bwm vchg [-h] [--mv <mV>]"
|
||||||
},
|
},
|
||||||
"hw bwmwifi": {
|
"hw bwm wifi": {
|
||||||
"command": "hw bwmwifi",
|
"command": "hw bwm wifi",
|
||||||
"description": "Bring up the BWM in STA + TCP-server mode: join a WiFi network and start a TCP server so the client can connect over WiFi. PM5 only.",
|
"description": "Bring up the BWM in STA + TCP-server mode: join a WiFi network and start a TCP server so the client can connect over WiFi. PM5 only. Sub-actions (no dashes): 'status' shows state, 'stop' tears WiFi down.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hw bwmwifi --ssid Home --pwd secret -> port 7777",
|
"hw bwm wifi status -> show connection state + IP",
|
||||||
"hw bwmwifi --ssid Home --pwd secret --port 9000",
|
"hw bwm wifi stop -> tear down WiFi, back to BLE-only",
|
||||||
"hw bwmwifi --status -> show connection state + IP"
|
"hw bwm wifi --ssid Home --pwd secret -> bring up, port 7777",
|
||||||
|
"hw bwm wifi --ssid Home --pwd secret --port 9000"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"--ssid <ssid> WiFi SSID to join (omit with --stop)",
|
"--ssid <ssid> WiFi SSID to join",
|
||||||
"--pwd <pwd> WiFi password (omit for open network)",
|
"--pwd <pwd> WiFi password (omit for open network)",
|
||||||
"--port <dec> TCP server listen port (default 7777)",
|
"--port <dec> TCP server listen port (default 7777)",
|
||||||
"--hostname <name> DHCP hostname (default Proxmark5)",
|
"--hostname <name> DHCP hostname (default Proxmark5)"
|
||||||
"--stop tear down WiFi and return to BLE-only",
|
|
||||||
"--status show current WiFi connection state + IP"
|
|
||||||
],
|
],
|
||||||
"usage": "hw bwmwifi [-h] [--ssid <ssid>] [--pwd <pwd>] [--port <dec>] [--hostname <name>] [--stop] [--status]"
|
"usage": "hw bwm wifi [-h] [--ssid <ssid>] [--pwd <pwd>] [--port <dec>] [--hostname <name>]"
|
||||||
},
|
},
|
||||||
"hw connect": {
|
"hw connect": {
|
||||||
"command": "hw connect",
|
"command": "hw connect",
|
||||||
@@ -11086,15 +11122,22 @@
|
|||||||
"command": "hw qc_pm5",
|
"command": "hw qc_pm5",
|
||||||
"description": "QC Test for the PM5",
|
"description": "QC Test for the PM5",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hw qc_pm5 -> run QC test with default 20 second timeout",
|
"hw qc_pm5 -> run hardware QC test with default 20 second timeout",
|
||||||
"hw qc_pm5 -t 3 -> run QC test with a 3 second timeout"
|
"hw qc_pm5 -t 3 -> run hardware QC test with a 3 second timeout",
|
||||||
|
"hw qc_pm5 --iolow <index> --pwd <hex> -> drive PM5 test IO <index> low",
|
||||||
|
"hw qc_pm5 --iohigh <index> --pwd <hex> -> drive PM5 test IO <index> high",
|
||||||
|
"hw qc_pm5 --ioreset <index> --pwd <hex> -> reset PM5 test IO <index> to default"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-t, --timeout <s> test sequence timeout in seconds (default 20)"
|
"-t, --timeout <s> test sequence timeout in seconds (default 20)",
|
||||||
|
"--iolow <index> drive PM5 test IO <index> low",
|
||||||
|
"--iohigh <index> drive PM5 test IO <index> high",
|
||||||
|
"--ioreset <index> reset PM5 test IO <index> to default",
|
||||||
|
"--pwd <hex> QC test password in hex (required for IO tests)"
|
||||||
],
|
],
|
||||||
"usage": "hw qc_pm5 [-h] [-t <s>]"
|
"usage": "hw qc_pm5 [-h] [-t <s>] [--iolow <index>] [--iohigh <index>] [--ioreset <index>] [--pwd <hex>]"
|
||||||
},
|
},
|
||||||
"hw readmem": {
|
"hw readmem": {
|
||||||
"command": "hw readmem",
|
"command": "hw readmem",
|
||||||
@@ -15407,21 +15450,27 @@
|
|||||||
},
|
},
|
||||||
"nfc type1 help": {
|
"nfc type1 help": {
|
||||||
"command": "nfc type1 help",
|
"command": "nfc type1 help",
|
||||||
"description": "-------- -------------- NFC Forum Tag Type 1 --------------- -------- --------------------- General --------------------- help This help ======================================================================================= nfc type2 { NFC Forum Tag Type 2... } --------------------------------------------------------------------------------------- nfc type2 read available offline: no Prints NFC Data Exchange Format (NDEF)",
|
"description": "-------- -------------- NFC Forum Tag Type 1 --------------- -------- --------------------- General --------------------- help This help ======================================================================================= nfc type2 { NFC Forum Tag Type 2... } --------------------------------------------------------------------------------------- nfc type2 format available offline: no Format a MIFARE Ultralight / NTAG tag for NDEF by writing the Capability Container to block 3, followed by an empty NDEF message. Writes NXP factory delivery content for the detected tag type. Block 3 is One Time Programmable; unknown types and unreachable CCs are refused. Note: the tag is re-selected and re-authenticated for each block written.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mfu ndefread -> shows NDEF data",
|
"hf mfu ndefformat",
|
||||||
"hf mfu ndefread -k ffffffff -> shows NDEF data with key",
|
"hf mfu ndefformat -v",
|
||||||
"hf mfu ndefread -f myfilename -> save raw NDEF to file"
|
"hf mfu ndefformat --erase",
|
||||||
|
"hf mfu ndefformat -k FFFFFFFF",
|
||||||
|
"hf mfu ndefformat -k 49454D4B41455242214E4143554F5946",
|
||||||
|
"hf mfu ndefformat -d E1101200 --force"
|
||||||
],
|
],
|
||||||
"offline": true,
|
"offline": true,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-l Swap entered key's endianness",
|
"-k, --key <hex> Authentication key (UL-C/UL-AES 16 bytes, EV1/NTAG 4 bytes)",
|
||||||
"-f, --file <fn> Save raw NDEF to file",
|
"-l Swap entered key endianness",
|
||||||
|
"-d, --data <hex> Capability Container to write, 4 bytes. Overrides the detected type",
|
||||||
|
"--erase Also zero the rest of the NDEF data area",
|
||||||
|
"--force Continue on an unknown tag type, or with an oversized -d value",
|
||||||
"-v, --verbose Verbose output",
|
"-v, --verbose Verbose output",
|
||||||
"--schann use secure channel. Must have key"
|
"--schann use secure channel. Must have key"
|
||||||
],
|
],
|
||||||
"usage": "hf mfu ndefread [-hlv] [-k Replace default key for NDEF] [-f <fn>] [--schann]"
|
"usage": "hf mfu ndefformat [-hlv] [-k <hex>] [-d <hex>] [--erase] [--force] [--schann]"
|
||||||
},
|
},
|
||||||
"nfc type1 read": {
|
"nfc type1 read": {
|
||||||
"command": "nfc type1 read",
|
"command": "nfc type1 read",
|
||||||
@@ -15451,6 +15500,24 @@
|
|||||||
],
|
],
|
||||||
"usage": "hf 14a ndefformat [-hv]"
|
"usage": "hf 14a ndefformat [-hv]"
|
||||||
},
|
},
|
||||||
|
"nfc type2 read": {
|
||||||
|
"command": "nfc type2 read",
|
||||||
|
"description": "Prints NFC Data Exchange Format (NDEF)",
|
||||||
|
"notes": [
|
||||||
|
"hf mfu ndefread -> shows NDEF data",
|
||||||
|
"hf mfu ndefread -k ffffffff -> shows NDEF data with key",
|
||||||
|
"hf mfu ndefread -f myfilename -> save raw NDEF to file"
|
||||||
|
],
|
||||||
|
"offline": false,
|
||||||
|
"options": [
|
||||||
|
"-h, --help This help",
|
||||||
|
"-l Swap entered key's endianness",
|
||||||
|
"-f, --file <fn> Save raw NDEF to file",
|
||||||
|
"-v, --verbose Verbose output",
|
||||||
|
"--schann use secure channel. Must have key"
|
||||||
|
],
|
||||||
|
"usage": "hf mfu ndefread [-hlv] [-k Replace default key for NDEF] [-f <fn>] [--schann]"
|
||||||
|
},
|
||||||
"nfc type2 write": {
|
"nfc type2 write": {
|
||||||
"command": "nfc type2 write",
|
"command": "nfc type2 write",
|
||||||
"description": "Write NFC Data Exchange Format (NDEF) records to a MIFARE Ultralight / NTAG tag. The tag must already be NDEF formatted, ie carry a Capability Container in block 3. Combine several of --uri, --text and --aar to build a multi record message, records are added in that order. Alternatively supply raw NDEF bytes with -d or -f, those get wrapped in a TLV container automatically when they are not already. Use `nfc encode` to build such raw bytes offline. Note: the tag is re-selected and re-authenticated for every block written, so a large message takes a while.",
|
"description": "Write NFC Data Exchange Format (NDEF) records to a MIFARE Ultralight / NTAG tag. The tag must already be NDEF formatted, ie carry a Capability Container in block 3. Combine several of --uri, --text and --aar to build a multi record message, records are added in that order. Alternatively supply raw NDEF bytes with -d or -f, those get wrapped in a TLV container automatically when they are not already. Use `nfc encode` to build such raw bytes offline. Note: the tag is re-selected and re-authenticated for every block written, so a large message takes a while.",
|
||||||
@@ -16427,8 +16494,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"commands_extracted": 912,
|
"commands_extracted": 918,
|
||||||
"extracted_by": "PM3Help2JSON v1.00",
|
"extracted_by": "PM3Help2JSON v1.00",
|
||||||
"extracted_on": "2026-09-04T11:31:07+00:00"
|
"extracted_on": "2026-09-11T13:13:54+00:00"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
-6
@@ -759,6 +759,7 @@ Check column "offline" for their availability.
|
|||||||
|`hf mfu dump `|N |`Dump MIFARE Ultralight family tag to binary file`
|
|`hf mfu dump `|N |`Dump MIFARE Ultralight family tag to binary file`
|
||||||
|`hf mfu incr `|N |`Increments Ev1/NTAG counter`
|
|`hf mfu incr `|N |`Increments Ev1/NTAG counter`
|
||||||
|`hf mfu info `|N |`Tag information`
|
|`hf mfu info `|N |`Tag information`
|
||||||
|
|`hf mfu ndefformat `|N |`Format tag as NDEF, writes the Capability Container`
|
||||||
|`hf mfu ndefread `|N |`Prints NDEF records from card`
|
|`hf mfu ndefread `|N |`Prints NDEF records from card`
|
||||||
|`hf mfu ndefwrite `|N |`Write NDEF records to card`
|
|`hf mfu ndefwrite `|N |`Write NDEF records to card`
|
||||||
|`hf mfu rdbl `|N |`Read block`
|
|`hf mfu rdbl `|N |`Read block`
|
||||||
@@ -1016,7 +1017,7 @@ Check column "offline" for their availability.
|
|||||||
|`hw fpga `|N |`Fpga commands`
|
|`hw fpga `|N |`Fpga commands`
|
||||||
|`hw fpgaoff `|N |`Turn off FPGA on device`
|
|`hw fpgaoff `|N |`Turn off FPGA on device`
|
||||||
|`hw ant_pm5 `|N |`Control the antennal of pm5`
|
|`hw ant_pm5 `|N |`Control the antennal of pm5`
|
||||||
|`hw qc_pm5 `|N |`Perform QC test for the PM5`
|
|`hw qc_pm5 `|N |`Perform QC test (hardware or IO) for the PM5`
|
||||||
|`hw factorydata `|N |`Get/Set the factory data for Device`
|
|`hw factorydata `|N |`Get/Set the factory data for Device`
|
||||||
|`hw lcd `|N |`Send command/data to LCD`
|
|`hw lcd `|N |`Send command/data to LCD`
|
||||||
|`hw lcdreset `|N |`Hardware reset LCD`
|
|`hw lcdreset `|N |`Hardware reset LCD`
|
||||||
@@ -1028,15 +1029,25 @@ Check column "offline" for their availability.
|
|||||||
|`hw setmux `|N |`Set the ADC mux to a specific value`
|
|`hw setmux `|N |`Set the ADC mux to a specific value`
|
||||||
|`hw standalone `|N |`Start installed standalone mode on device`
|
|`hw standalone `|N |`Start installed standalone mode on device`
|
||||||
|`hw tia `|N |`Trigger a Timing Interval Acquisition to re-adjust the RealTimeCounter divider`
|
|`hw tia `|N |`Trigger a Timing Interval Acquisition to re-adjust the RealTimeCounter divider`
|
||||||
|`hw bwmsetcap `|N |`Set BWM fuel-gauge design capacity (PM5, run once after battery change)`
|
|
||||||
|`hw bwmvchg `|N |`Set BWM charger charge-voltage target (PM5, default 4100 mV)`
|
|
||||||
|`hw bwmcharge `|N |`Enable/disable BWM battery charging (PM5, one-shot)`
|
|
||||||
|`hw bwmautooff `|N |`Toggle auto power-off on USB unplug (PM5, BWM)`
|
|
||||||
|`hw bwmwifi `|N |`Bring up BWM WiFi (STA + TCP server) for a tcp: connection (PM5)`
|
|
||||||
|`hw tune `|N |`Measure tuning of device antenna`
|
|`hw tune `|N |`Measure tuning of device antenna`
|
||||||
|`hw decay `|N |`Measure HF antenna decay after field-off`
|
|`hw decay `|N |`Measure HF antenna decay after field-off`
|
||||||
|
|
||||||
|
|
||||||
|
### hw bwm
|
||||||
|
|
||||||
|
{ BWM (battery/wireless module) commands... }
|
||||||
|
|
||||||
|
|command |offline |description
|
||||||
|
|------- |------- |-----------
|
||||||
|
|`hw bwm help `|Y |`This help`
|
||||||
|
|`hw bwm autooff `|N |`Toggle auto power-off on USB unplug`
|
||||||
|
|`hw bwm charge `|N |`Enable/disable battery charging (one-shot)`
|
||||||
|
|`hw bwm setcap `|N |`Set fuel-gauge design capacity (run once after battery change)`
|
||||||
|
|`hw bwm upgrade `|N |`Reflash BWM (ESP32) firmware over the BWM link, no header`
|
||||||
|
|`hw bwm vchg `|N |`Set charger charge-voltage target (default 4100 mV)`
|
||||||
|
|`hw bwm wifi `|N |`Bring up WiFi (STA + TCP server) for a tcp: connection`
|
||||||
|
|
||||||
|
|
||||||
### lf
|
### lf
|
||||||
|
|
||||||
{ Low frequency commands... }
|
{ Low frequency commands... }
|
||||||
@@ -1667,6 +1678,7 @@ Check column "offline" for their availability.
|
|||||||
|
|
||||||
|command |offline |description
|
|command |offline |description
|
||||||
|------- |------- |-----------
|
|------- |------- |-----------
|
||||||
|
|`nfc type2 format `|N |`format MIFARE Ultralight / NTAG as NFC Forum Tag Type 2`
|
||||||
|`nfc type2 read `|N |`read NFC Forum Tag Type 2`
|
|`nfc type2 read `|N |`read NFC Forum Tag Type 2`
|
||||||
|`nfc type2 write `|N |`write NFC Forum Tag Type 2`
|
|`nfc type2 write `|N |`write NFC Forum Tag Type 2`
|
||||||
|`nfc type2 help `|Y |`This help`
|
|`nfc type2 help `|Y |`This help`
|
||||||
|
|||||||
@@ -104,7 +104,23 @@ hf 14a read --drop
|
|||||||
## Do this exactly once.
|
## Do this exactly once.
|
||||||
* The very first time for a new battery:
|
* The very first time for a new battery:
|
||||||
```hw bwm setcap --cap 500```
|
```hw bwm setcap --cap 500```
|
||||||
* Do a full charge/discharge cycle for it to learn the real capacity.
|
* Your PM5 will learn about the battery through usage.
|
||||||
|
|
||||||
|
## Flash the BWM
|
||||||
|
* Make sure your BWM has enough charge in the battery `hw status` 50%+ should work.
|
||||||
|
* Get the latest firmware:
|
||||||
|
* Go [here](https://github.com/RfidResearchGroup/Proxmark5_BWM_esp32/actions/workflows/esp-idf-build.yml):
|
||||||
|
* Click on the latest workflow run (As of this writing that's "Merge pull request #3 from nieldk/master")
|
||||||
|
* Scroll all the way to the bottom, you'll see **Artifacts**
|
||||||
|
* Click on "proxmark5_bwm_master" which will start a download for `proxmark5_bwm_master.zip`
|
||||||
|
* Unzip this file somehwere, remember that location
|
||||||
|
* The upgrade command is: `hw bwm upgrade -f </path/to/unzipped/contents/>proxmark5_ble_wifi_module.bin`
|
||||||
|
* This will take some time, you'll see the Progress in % displayed on the screen until the process is done.
|
||||||
|
* Once you see "BWM Rebooting into the new image" you know the upgrade finished.
|
||||||
|
* Wait a few seconds (under 10) and unplug and replug the Proxmark5 back into the usb port.
|
||||||
|
* Once reconnected, you can run `hw status` and you'll see:
|
||||||
|
* `BWM fw version...... 1` where 1 is the current fw version. As of 2026-09-10, the most current version is 1.
|
||||||
|
* You have finished flashing the BWM.
|
||||||
|
|
||||||
|
|
||||||
### Operation
|
### Operation
|
||||||
|
|||||||
@@ -30,4 +30,16 @@ typedef enum {
|
|||||||
T_AES = 0x03
|
T_AES = 0x03
|
||||||
} DesfireCryptoAlgorithm;
|
} DesfireCryptoAlgorithm;
|
||||||
|
|
||||||
|
#define DESFIRE_MAX_ALGO_COUNT 4 // T_DES ... T_AES
|
||||||
|
#define DESFIRE_MAX_KEY_COUNT 0x0E // key numbers 0x00 ... 0x0D
|
||||||
|
#define DESFIRE_MAX_APP_COUNT 64 // applications we keep track of per PICC
|
||||||
|
|
||||||
|
// Keys recovered for one application.
|
||||||
|
// keys[algo][keyno][0] is the found flag, keys[algo][keyno][1..] the key itself.
|
||||||
|
// `algo` is a DesfireCryptoAlgorithm, `keyno` the DESFire key number.
|
||||||
|
typedef struct {
|
||||||
|
uint32_t aid;
|
||||||
|
uint8_t keys[DESFIRE_MAX_ALGO_COUNT][DESFIRE_MAX_KEY_COUNT][DESFIRE_MAX_KEY_SIZE + 1];
|
||||||
|
} desfire_app_keys_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -541,6 +541,14 @@ typedef struct {
|
|||||||
// most 4 byte nonces that fit alongside the reply header in one frame
|
// most 4 byte nonces that fit alongside the reply header in one frame
|
||||||
#define MFC_MAX_NONCES ((PM3_CMD_DATA_SIZE - sizeof(mf_nonces_resp_t)) / 4)
|
#define MFC_MAX_NONCES ((PM3_CMD_DATA_SIZE - sizeof(mf_nonces_resp_t)) / 4)
|
||||||
|
|
||||||
|
// ACQ_ENCRYPTED_NONCES does not store bare nonces. It stores pairs: two 4 byte
|
||||||
|
// encrypted nonces followed by one byte holding both their encrypted parity
|
||||||
|
// nibbles, high nibble first. num_nonces in the reply counts nonces, so the
|
||||||
|
// payload is always (num_nonces / 2) * MFC_NONCE_PAIR_SIZE bytes and
|
||||||
|
// num_nonces is always even.
|
||||||
|
#define MFC_NONCE_PAIR_SIZE 9
|
||||||
|
#define MFC_MAX_NONCE_PAIRS ((PM3_CMD_DATA_SIZE - sizeof(mf_nonces_resp_t)) / MFC_NONCE_PAIR_SIZE)
|
||||||
|
|
||||||
// CMD_HF_MIFARE_CHKKEYS_FAST payload.
|
// CMD_HF_MIFARE_CHKKEYS_FAST payload.
|
||||||
// Replaces three bit-packed oldargs:
|
// Replaces three bit-packed oldargs:
|
||||||
// arg0 = sectorcnt | firstchunk<<8 | lastchunk<<12 | singlesector_params<<16
|
// arg0 = sectorcnt | firstchunk<<8 | lastchunk<<12 | singlesector_params<<16
|
||||||
|
|||||||
@@ -468,6 +468,7 @@ while true; do
|
|||||||
if ! CheckExecute "data qrcode invalid hex" "$CLIENTBIN -c 'data qrcode -d zz' 2>&1" "QR data must contain only hex characters"; then break; fi
|
if ! CheckExecute "data qrcode invalid hex" "$CLIENTBIN -c 'data qrcode -d zz' 2>&1" "QR data must contain only hex characters"; then break; fi
|
||||||
if ! CheckExecute "data qrcode odd hex" "$CLIENTBIN -c 'data qrcode -d a' 2>&1" "QR data must contain an even number of hex digits"; then break; fi
|
if ! CheckExecute "data qrcode odd hex" "$CLIENTBIN -c 'data qrcode -d a' 2>&1" "QR data must contain an even number of hex digits"; then break; fi
|
||||||
if ! CheckExecute "data qrcode spaced hex" "$CLIENTBIN -c 'data qrcode -d \"aa bb\"' 2>&1" "Spaces are not supported; encode a space byte as 20"; then break; fi
|
if ! CheckExecute "data qrcode spaced hex" "$CLIENTBIN -c 'data qrcode -d \"aa bb\"' 2>&1" "Spaces are not supported; encode a space byte as 20"; then break; fi
|
||||||
|
if ! CheckExecute "data modulation keeps trace" "$CLIENTBIN -c 'data load -f traces/lf_Q5_mod-psk1-32-4.pm3; data modulation; data autocorr -w 99999'" "smaller than trace \\( 20000 samples \\)"; then break; fi
|
||||||
if ! CheckExecute "mfu pwdgen test" "$CLIENTBIN -c 'hf mfu pwdgen --test'" "Selftest ok"; then break; fi
|
if ! CheckExecute "mfu pwdgen test" "$CLIENTBIN -c 'hf mfu pwdgen --test'" "Selftest ok"; then break; fi
|
||||||
if ! CheckExecute "mfu keygen test" "$CLIENTBIN -c 'hf mfu keygen --uid 11223344556677'" "80 B1 C2 71 D8 A0"; then break; fi
|
if ! CheckExecute "mfu keygen test" "$CLIENTBIN -c 'hf mfu keygen --uid 11223344556677'" "80 B1 C2 71 D8 A0"; then break; fi
|
||||||
if ! CheckExecute "jooki encode test" "$CLIENTBIN -c 'hf jooki encode --test'" "04 28 F4 DA F0 4A 81 \( ok \)"; then break; fi
|
if ! CheckExecute "jooki encode test" "$CLIENTBIN -c 'hf jooki encode --test'" "04 28 F4 DA F0 4A 81 \( ok \)"; then break; fi
|
||||||
|
|||||||
Reference in new issue
Block a user