This commit is contained in:
Philippe Teuwen 2019-04-29 22:41:28 +02:00
commit 56f92348ea
8 changed files with 58 additions and 58 deletions

View file

@ -949,7 +949,7 @@ static void PacketReceived(PacketCommandNG *packet) {
MifareNested(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes); MifareNested(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes);
break; break;
case CMD_MIFARE_CHKKEYS: { case CMD_MIFARE_CHKKEYS: {
MifareChkKeys(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes, packet->ng); MifareChkKeys(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes, packet->ng);
break; break;
} }
case CMD_MIFARE_CHKKEYS_FAST: { case CMD_MIFARE_CHKKEYS_FAST: {

View file

@ -697,34 +697,34 @@ static int ndef_print_CC(uint8_t *data) {
uint8_t minor = (data[1] & 0x30) >> 4; uint8_t minor = (data[1] & 0x30) >> 4;
uint8_t major = (data[1] & 0xC0) >> 6; uint8_t major = (data[1] & 0xC0) >> 6;
char wStr[50]; char wStr[50];
switch ( write ) { switch (write) {
case 0: case 0:
sprintf(wStr, "Write access granted without any security"); sprintf(wStr, "Write access granted without any security");
break; break;
case 1: case 1:
sprintf(wStr, "RFU"); sprintf(wStr, "RFU");
break; break;
case 2: case 2:
sprintf(wStr, "Proprietary"); sprintf(wStr, "Proprietary");
break; break;
case 3: case 3:
sprintf(wStr, "No write access"); sprintf(wStr, "No write access");
break; break;
} }
char rStr[46]; char rStr[46];
switch ( read ) { switch (read) {
case 0: case 0:
sprintf(rStr, "Read access granted without any security"); sprintf(rStr, "Read access granted without any security");
break; break;
case 1: case 1:
case 3: case 3:
sprintf(rStr, "RFU"); sprintf(rStr, "RFU");
break; break;
case 2: case 2:
sprintf(rStr, "Proprietary"); sprintf(rStr, "Proprietary");
break; break;
} }
PrintAndLogEx(NORMAL, "--- NDEF Message"); PrintAndLogEx(NORMAL, "--- NDEF Message");
@ -734,7 +734,7 @@ static int ndef_print_CC(uint8_t *data) {
// PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], (data[1] & 0xF0) >> 4, data[1] & 0x0F); // PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], (data[1] & 0xF0) >> 4, data[1] & 0x0F);
PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], major, minor); PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], major, minor);
PrintAndLogEx(NORMAL, " : %s / %s", rStr, wStr); PrintAndLogEx(NORMAL, " : %s / %s", rStr, wStr);
PrintAndLogEx(NORMAL, " %02X : Physical Memory Size: %d bytes", data[2], data[2] * 8); PrintAndLogEx(NORMAL, " %02X : Physical Memory Size: %d bytes", data[2], data[2] * 8);
if (data[2] == 0x96) if (data[2] == 0x96)
PrintAndLogEx(NORMAL, " %02X : NDEF Memory Size: %d bytes", data[2], 48); PrintAndLogEx(NORMAL, " %02X : NDEF Memory Size: %d bytes", data[2], 48);
@ -749,11 +749,11 @@ static int ndef_print_CC(uint8_t *data) {
uint8_t sf = (data[3] & 0x10) >> 4; uint8_t sf = (data[3] & 0x10) >> 4;
uint8_t lb = (data[3] & 0x08) >> 3; uint8_t lb = (data[3] & 0x08) >> 3;
uint8_t mlrule = (data[3] & 0x06) >> 1; uint8_t mlrule = (data[3] & 0x06) >> 1;
uint8_t mbread = (data[3] & 0x01); uint8_t mbread = (data[3] & 0x01);
PrintAndLogEx(NORMAL, " Additional feature information"); PrintAndLogEx(NORMAL, " Additional feature information");
PrintAndLogEx(NORMAL, " %02X", data[3]); PrintAndLogEx(NORMAL, " %02X", data[3]);
PrintAndLogEx(NORMAL, " 00000000"); PrintAndLogEx(NORMAL, " 00000000");
PrintAndLogEx(NORMAL, " xxx - %02X : RFU (%s)", msb3, (msb3 == 0) ? _GREEN_("OK") : _RED_("Fail")); PrintAndLogEx(NORMAL, " xxx - %02X : RFU (%s)", msb3, (msb3 == 0) ? _GREEN_("OK") : _RED_("Fail"));
PrintAndLogEx(NORMAL, " x - %02X : %s special frame", sf, (sf) ? "support" : "don\'t support"); PrintAndLogEx(NORMAL, " x - %02X : %s special frame", sf, (sf) ? "support" : "don\'t support");
PrintAndLogEx(NORMAL, " x - %02X : %s lock block", lb, (lb) ? "support" : "don\'t support"); PrintAndLogEx(NORMAL, " x - %02X : %s lock block", lb, (lb) ? "support" : "don\'t support");

View file

@ -196,7 +196,7 @@ function Command:sendNG( ignore_response, timeout )
--[[ uncomment if you want to debug --[[ uncomment if you want to debug
-- lets digest response NG package. -- lets digest response NG package.
local data local data
local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response) local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response)
count, data, ng = bin.unpack('H'..length..'C', response, count) count, data, ng = bin.unpack('H'..length..'C', response, count)

View file

@ -67,7 +67,7 @@ local function parse14443a(data)
uid = uid:sub(1, 2 * uidlen) uid = uid:sub(1, 2 * uidlen)
local man_byte = tonumber(uid:sub(1,2), 16) local man_byte = tonumber(uid:sub(1,2), 16)
return { return {
uid = uid, uid = uid,
atqa = atqa, atqa = atqa,
sak = sak, sak = sak,

View file

@ -226,11 +226,11 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
if (!strncmp((char *)ndef->Type, "U", ndef->TypeLen)) { if (!strncmp((char *)ndef->Type, "U", ndef->TypeLen)) {
PrintAndLogEx(NORMAL PrintAndLogEx(NORMAL
, "\turi : %s%.*s" , "\turi : %s%.*s"
, (ndef->Payload[0] <= 0x23 ? URI_s[ndef->Payload[0]] : "[err]") , (ndef->Payload[0] <= 0x23 ? URI_s[ndef->Payload[0]] : "[err]")
, ndef->PayloadLen-1 , ndef->PayloadLen - 1
, &ndef->Payload[1] , &ndef->Payload[1]
); );
} }
if (!strncmp((char *)ndef->Type, "Sig", ndef->TypeLen)) { if (!strncmp((char *)ndef->Type, "Sig", ndef->TypeLen)) {

View file

@ -969,11 +969,11 @@ static int l_ndefparse(lua_State *L) {
if (data == 0) { if (data == 0) {
return returnToLuaWithError(L, "Allocating memory failed"); return returnToLuaWithError(L, "Allocating memory failed");
} }
// data // data
const char *p_data = luaL_checklstring(L, 3, &size); const char *p_data = luaL_checklstring(L, 3, &size);
if (size) { if (size) {
if (size > (datalen << 1) ) if (size > (datalen << 1))
size = (datalen << 1); size = (datalen << 1);
uint32_t tmp; uint32_t tmp;
@ -983,7 +983,7 @@ static int l_ndefparse(lua_State *L) {
len++; len++;
} }
} }
int res = NDEFDecodeAndPrint(data, datalen, verbose); int res = NDEFDecodeAndPrint(data, datalen, verbose);
lua_pushinteger(L, res); lua_pushinteger(L, res);
return 1; return 1;
@ -1048,7 +1048,7 @@ int set_pm3_libraries(lua_State *L) {
{"keygen_algo_d", l_keygen_algoD}, {"keygen_algo_d", l_keygen_algoD},
{"t55xx_readblock", l_T55xx_readblock}, {"t55xx_readblock", l_T55xx_readblock},
{"t55xx_detect", l_T55xx_detect}, {"t55xx_detect", l_T55xx_detect},
{"ndefparse" , l_ndefparse}, {"ndefparse", l_ndefparse},
{NULL, NULL} {NULL, NULL}
}; };

View file

@ -57,7 +57,7 @@ local function checkCommand(response)
print("Timeout while waiting for response. Increase TIMEOUT in mfkeys.lua to wait longer") print("Timeout while waiting for response. Increase TIMEOUT in mfkeys.lua to wait longer")
return nil, "Timeout while waiting for device to respond" return nil, "Timeout while waiting for device to respond"
end end
local data local data
local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response) local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response)
count, data, ng = bin.unpack('H'..length..'C', response, count) count, data, ng = bin.unpack('H'..length..'C', response, count)
@ -66,7 +66,7 @@ local function checkCommand(response)
key = data:sub(1, 12) key = data:sub(1, 12)
return key return key
end end
return nil return nil
end end
@ -83,20 +83,20 @@ local function checkBlock(blockno, testkeys, keytype)
local chunksize = remaining local chunksize = remaining
if remaining > maxchunk then chunksize = maxchunk end if remaining > maxchunk then chunksize = maxchunk end
local n = chunksize local n = chunksize
while remaining > 0 do while remaining > 0 do
-- print('start', start, 'chunksize', chunksize, 'testkeys kvar', remaining, 'N-index=', n) -- print('start', start, 'chunksize', chunksize, 'testkeys kvar', remaining, 'N-index=', n)
local d0 = ('%04X%02X%02X'):format(arg1, arg2, chunksize) local d0 = ('%04X%02X%02X'):format(arg1, arg2, chunksize)
local d1 = table.concat(testkeys, "", start, n) local d1 = table.concat(testkeys, "", start, n)
core.clearCommandBuffer() core.clearCommandBuffer()
print(("Testing block %d, keytype %d, with %d keys"):format(blockno, keytype, chunksize)) print(("Testing block %d, keytype %d, with %d keys"):format(blockno, keytype, chunksize))
local c = Command:newNG{cmd = cmds.CMD_MIFARE_CHKKEYS, data = d0..d1} local c = Command:newNG{cmd = cmds.CMD_MIFARE_CHKKEYS, data = d0..d1}
key, err = checkCommand(c:sendNG(false, TIMEOUT)) key, err = checkCommand(c:sendNG(false, TIMEOUT))
if key then return key, blockno end if key then return key, blockno end
start = start + chunksize start = start + chunksize

View file

@ -80,7 +80,7 @@ local function getblockdata(response)
if not response then if not response then
return nil, 'No response from device' return nil, 'No response from device'
end end
local count, cmd, arg0, arg1, arg2, data = bin.unpack('LLLLH40', response) local count, cmd, arg0, arg1, arg2, data = bin.unpack('LLLLH40', response)
if arg0 == 1 then if arg0 == 1 then
return data:sub(1, 32) return data:sub(1, 32)
@ -96,7 +96,7 @@ local function getBlock(blockno)
local c = Command:newMIX{cmd = cmds.CMD_MIFAREU_READBL, arg1 = blockno, data = 0} local c = Command:newMIX{cmd = cmds.CMD_MIFAREU_READBL, arg1 = blockno, data = 0}
block, err = getblockdata(c:sendMIX(false)) block, err = getblockdata(c:sendMIX(false))
if not block then return oops(err) end if not block then return oops(err) end
if #block < 32 then if #block < 32 then
return nil, ('Expected at least 16 bytes, got %d - this tag is not NDEF-compliant'):format(string.len(data)) return nil, ('Expected at least 16 bytes, got %d - this tag is not NDEF-compliant'):format(string.len(data))
end end
@ -115,7 +115,7 @@ local function main( args)
print( string.rep('--',20) ) print( string.rep('--',20) )
print( string.rep('--',20) ) print( string.rep('--',20) )
local err, data, data2, k, v, i local err, data, data2, k, v, i
local verbose = 0 local verbose = 0
-- Read the parameters -- Read the parameters
@ -127,7 +127,7 @@ local function main( args)
-- First of all, connect -- First of all, connect
info, err = lib14a.read(true, true) info, err = lib14a.read(true, true)
if err then if err then
disconnect(); disconnect();
return oops(err) return oops(err)
end end
@ -139,7 +139,7 @@ local function main( args)
disconnect() disconnect()
return oops('[!] Not a Ultralightbased card. This script reads NDEF formatted UL/NTAGS') return oops('[!] Not a Ultralightbased card. This script reads NDEF formatted UL/NTAGS')
end end
-- Info contained within the tag (block 0 example) -- Info contained within the tag (block 0 example)
-- 0534 00B9 049C AD7F 4A00 0000 E110 1000 2155 -- 0534 00B9 049C AD7F 4A00 0000 E110 1000 2155
-- b0b0 b0b0 b1b1 b1b1 b2b2 b2b2 b3b3 b3b3 CRCC -- b0b0 b0b0 b1b1 b1b1 b2b2 b2b2 b3b3 b3b3 CRCC
@ -176,8 +176,8 @@ local function main( args)
print('[=] Dumping data...') print('[=] Dumping data...')
for i = 4, t5tarea_blocks - 1, 1 do for i = 4, t5tarea_blocks - 1, 1 do
blocks, err = getBlock(i) blocks, err = getBlock(i)
if err then if err then
disconnect(); disconnect();
return oops(err) return oops(err)
end end
table.insert(blockData, blocks[1]) table.insert(blockData, blocks[1])
@ -196,7 +196,7 @@ local function main( args)
local vLow = band(b3[2], 0xF) local vLow = band(b3[2], 0xF)
local vHi = band(rshift(b3[2], 4), 0xF) local vHi = band(rshift(b3[2], 4), 0xF)
print(('[=] %02X : version %d.%d supported by tag'):format(b3[2], vHi, vLow) ) print(('[=] %02X : version %d.%d supported by tag'):format(b3[2], vHi, vLow) )
print(('[=] %02X : Physical Memory Size: %d bytes'):format(b3[3], t5tarea) ) print(('[=] %02X : Physical Memory Size: %d bytes'):format(b3[3], t5tarea) )
if b3[3] == 0x96 then if b3[3] == 0x96 then
print((' %02X : NDEF Memory Size: %d bytes'):format(b3[3], 48)) print((' %02X : NDEF Memory Size: %d bytes'):format(b3[3], 48))
@ -242,11 +242,11 @@ local function main( args)
print(string.format(' %02x | %s', k-1, v) ) print(string.format(' %02x | %s', k-1, v) )
end end
print('|---|-------------------|') print('|---|-------------------|')
local filename, err = utils.WriteDumpFile(info.uid, blockData) local filename, err = utils.WriteDumpFile(info.uid, blockData)
if err then return oops(err) end if err then return oops(err) end
print(string.format('[+] Dumped data into %s', filename)) print(string.format('[+] Dumped data into %s', filename))
end end
main(args) main(args)