From 7454a4dcf23471952e1bf1c21182794cddc45c0e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 29 Apr 2019 02:07:40 +0200 Subject: [PATCH] chg: 'hf mf chkkeys' - now uses NG --- armsrc/appmain.c | 2 +- armsrc/apps.h | 2 +- armsrc/mifarecmd.c | 9 +++++++-- client/lualibs/read14a.lua | 7 +++++-- client/scripts/mfkeys.lua | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index c3a52bc93..b7c167730 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -949,7 +949,7 @@ static void PacketReceived(PacketCommandNG *packet) { MifareNested(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes); break; case CMD_MIFARE_CHKKEYS: { - MifareChkKeys(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes); + MifareChkKeys(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes, packet->ng); break; } case CMD_MIFARE_CHKKEYS_FAST: { diff --git a/armsrc/apps.h b/armsrc/apps.h index 07a646a03..d2fdf5bac 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -153,7 +153,7 @@ void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain); void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain); void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *datain); void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *datain); -void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain); +void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain, bool ng); void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain); void MifareSetDbgLvl(uint16_t arg0); void MifareEMemClr(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 52645d627..0e21a9736 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1516,7 +1516,7 @@ OUT: } } -void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) { +void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain, bool ng) { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); @@ -1592,8 +1592,13 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) { } LED_B_ON(); - reply_old(CMD_ACK, isOK, 0, 0, datain + i * 6, 6); + if (ng) { + reply_ng(CMD_MIFARE_CHKKEYS, PM3_SUCCESS, datain + i * 6, 6); + } else { + reply_mix(CMD_ACK, isOK, 0, 0, datain + i * 6, 6); + } +// reply_old(CMD_ACK, isOK, 0, 0, datain + i * 6, 6); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); diff --git a/client/lualibs/read14a.lua b/client/lualibs/read14a.lua index 012102931..8473278f8 100644 --- a/client/lualibs/read14a.lua +++ b/client/lualibs/read14a.lua @@ -13,7 +13,10 @@ -- Loads the commands-library local taglib = require('taglib') local cmds = require('commands') -local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds + +-- Shouldn't take longer than 2 seconds +local TIMEOUT = 2000 + local ISO14A_COMMAND = { ISO14A_CONNECT = 1, ISO14A_NO_DISCONNECT = 2, @@ -99,7 +102,7 @@ local function read14443a(dont_disconnect, no_rats) if arg0 == 0 then return nil, 'iso14443a card select failed' end - data = string.sub(result,count) + data = string.sub(result, count) info, err = parse14443a(data) else err = 'No response from card' diff --git a/client/scripts/mfkeys.lua b/client/scripts/mfkeys.lua index b077a6cbf..7d39db5a5 100644 --- a/client/scripts/mfkeys.lua +++ b/client/scripts/mfkeys.lua @@ -84,11 +84,11 @@ local function checkBlock(blockno, testkeys, keytype) core.clearCommandBuffer() print(("Testing block %d, keytype %d, with %d keys"):format(blockno, keytype, chunksize)) - local c = Command:newMIX{cmd = cmds.CMD_MIFARE_CHKKEYS, + local c = Command:newNG{cmd = cmds.CMD_MIFARE_CHKKEYS, arg1 = arg1, arg3 = chunksize, data = d1} - status, err = checkCommand(c:sendMIX(false, TIMEOUT)) + status, err = checkCommand(c:sendNG(false, TIMEOUT)) if status then return status, blockno end start = start + chunksize