From 56f92348ea3dac026cb4fd1897c1278ab286eeb4 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 29 Apr 2019 22:41:28 +0200 Subject: [PATCH] style --- armsrc/appmain.c | 2 +- client/cmdhfmfu.c | 62 ++++++++++++++++++------------------ client/lualibs/commands.lua | 2 +- client/lualibs/read14a.lua | 2 +- client/mifare/ndef.c | 10 +++--- client/scripting.c | 8 ++--- client/scripts/mfkeys.lua | 10 +++--- client/scripts/ndef_dump.lua | 20 ++++++------ 8 files changed, 58 insertions(+), 58 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index b7c167730..ce716f026 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, packet->ng); + MifareChkKeys(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes, packet->ng); break; } case CMD_MIFARE_CHKKEYS_FAST: { diff --git a/client/cmdhfmfu.c b/client/cmdhfmfu.c index ab805020e..3246960d6 100644 --- a/client/cmdhfmfu.c +++ b/client/cmdhfmfu.c @@ -697,34 +697,34 @@ static int ndef_print_CC(uint8_t *data) { uint8_t minor = (data[1] & 0x30) >> 4; uint8_t major = (data[1] & 0xC0) >> 6; - char wStr[50]; - switch ( write ) { - case 0: - sprintf(wStr, "Write access granted without any security"); - break; - case 1: - sprintf(wStr, "RFU"); - break; - case 2: - sprintf(wStr, "Proprietary"); - break; - case 3: - sprintf(wStr, "No write access"); - break; - } - char rStr[46]; - switch ( read ) { - case 0: - sprintf(rStr, "Read access granted without any security"); - break; - case 1: - case 3: - sprintf(rStr, "RFU"); - break; - case 2: - sprintf(rStr, "Proprietary"); - break; - } + char wStr[50]; + switch (write) { + case 0: + sprintf(wStr, "Write access granted without any security"); + break; + case 1: + sprintf(wStr, "RFU"); + break; + case 2: + sprintf(wStr, "Proprietary"); + break; + case 3: + sprintf(wStr, "No write access"); + break; + } + char rStr[46]; + switch (read) { + case 0: + sprintf(rStr, "Read access granted without any security"); + break; + case 1: + case 3: + sprintf(rStr, "RFU"); + break; + case 2: + sprintf(rStr, "Proprietary"); + break; + } 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], major, minor); PrintAndLogEx(NORMAL, " : %s / %s", rStr, wStr); - + PrintAndLogEx(NORMAL, " %02X : Physical Memory Size: %d bytes", data[2], data[2] * 8); if (data[2] == 0x96) 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 lb = (data[3] & 0x08) >> 3; 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, " %02X", data[3]); - PrintAndLogEx(NORMAL, " 00000000"); + PrintAndLogEx(NORMAL, " 00000000"); 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 lock block", lb, (lb) ? "support" : "don\'t support"); diff --git a/client/lualibs/commands.lua b/client/lualibs/commands.lua index a9a2a95e9..8f87d81fb 100644 --- a/client/lualibs/commands.lua +++ b/client/lualibs/commands.lua @@ -196,7 +196,7 @@ function Command:sendNG( ignore_response, timeout ) --[[ uncomment if you want to debug - -- lets digest response NG package. + -- lets digest response NG package. local data local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response) count, data, ng = bin.unpack('H'..length..'C', response, count) diff --git a/client/lualibs/read14a.lua b/client/lualibs/read14a.lua index 8473278f8..60c904d4a 100644 --- a/client/lualibs/read14a.lua +++ b/client/lualibs/read14a.lua @@ -67,7 +67,7 @@ local function parse14443a(data) uid = uid:sub(1, 2 * uidlen) local man_byte = tonumber(uid:sub(1,2), 16) - return { + return { uid = uid, atqa = atqa, sak = sak, diff --git a/client/mifare/ndef.c b/client/mifare/ndef.c index df4741dbc..7d0100d70 100644 --- a/client/mifare/ndef.c +++ b/client/mifare/ndef.c @@ -226,11 +226,11 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) { if (!strncmp((char *)ndef->Type, "U", ndef->TypeLen)) { PrintAndLogEx(NORMAL - , "\turi : %s%.*s" - , (ndef->Payload[0] <= 0x23 ? URI_s[ndef->Payload[0]] : "[err]") - , ndef->PayloadLen-1 - , &ndef->Payload[1] - ); + , "\turi : %s%.*s" + , (ndef->Payload[0] <= 0x23 ? URI_s[ndef->Payload[0]] : "[err]") + , ndef->PayloadLen - 1 + , &ndef->Payload[1] + ); } if (!strncmp((char *)ndef->Type, "Sig", ndef->TypeLen)) { diff --git a/client/scripting.c b/client/scripting.c index 59a03025f..cb086832d 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -969,11 +969,11 @@ static int l_ndefparse(lua_State *L) { if (data == 0) { return returnToLuaWithError(L, "Allocating memory failed"); } - + // data const char *p_data = luaL_checklstring(L, 3, &size); if (size) { - if (size > (datalen << 1) ) + if (size > (datalen << 1)) size = (datalen << 1); uint32_t tmp; @@ -983,7 +983,7 @@ static int l_ndefparse(lua_State *L) { len++; } } - + int res = NDEFDecodeAndPrint(data, datalen, verbose); lua_pushinteger(L, res); return 1; @@ -1048,7 +1048,7 @@ int set_pm3_libraries(lua_State *L) { {"keygen_algo_d", l_keygen_algoD}, {"t55xx_readblock", l_T55xx_readblock}, {"t55xx_detect", l_T55xx_detect}, - {"ndefparse" , l_ndefparse}, + {"ndefparse", l_ndefparse}, {NULL, NULL} }; diff --git a/client/scripts/mfkeys.lua b/client/scripts/mfkeys.lua index a8426fda5..bfc221ca1 100644 --- a/client/scripts/mfkeys.lua +++ b/client/scripts/mfkeys.lua @@ -57,7 +57,7 @@ local function checkCommand(response) print("Timeout while waiting for response. Increase TIMEOUT in mfkeys.lua to wait longer") return nil, "Timeout while waiting for device to respond" end - + local data local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response) count, data, ng = bin.unpack('H'..length..'C', response, count) @@ -66,7 +66,7 @@ local function checkCommand(response) key = data:sub(1, 12) return key end - + return nil end @@ -83,20 +83,20 @@ local function checkBlock(blockno, testkeys, keytype) local chunksize = remaining if remaining > maxchunk then chunksize = maxchunk end local n = chunksize - + while remaining > 0 do -- print('start', start, 'chunksize', chunksize, 'testkeys kvar', remaining, 'N-index=', n) local d0 = ('%04X%02X%02X'):format(arg1, arg2, chunksize) local d1 = table.concat(testkeys, "", start, n) - + core.clearCommandBuffer() 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} key, err = checkCommand(c:sendNG(false, TIMEOUT)) - + if key then return key, blockno end start = start + chunksize diff --git a/client/scripts/ndef_dump.lua b/client/scripts/ndef_dump.lua index 7bdbd5e1e..d162e35cf 100644 --- a/client/scripts/ndef_dump.lua +++ b/client/scripts/ndef_dump.lua @@ -80,7 +80,7 @@ local function getblockdata(response) if not response then return nil, 'No response from device' end - + local count, cmd, arg0, arg1, arg2, data = bin.unpack('LLLLH40', response) if arg0 == 1 then 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} block, err = getblockdata(c:sendMIX(false)) if not block then return oops(err) end - + if #block < 32 then return nil, ('Expected at least 16 bytes, got %d - this tag is not NDEF-compliant'):format(string.len(data)) end @@ -115,7 +115,7 @@ local function main( args) print( string.rep('--',20) ) print( string.rep('--',20) ) - + local err, data, data2, k, v, i local verbose = 0 -- Read the parameters @@ -127,7 +127,7 @@ local function main( args) -- First of all, connect info, err = lib14a.read(true, true) - if err then + if err then disconnect(); return oops(err) end @@ -139,7 +139,7 @@ local function main( args) disconnect() return oops('[!] Not a Ultralightbased card. This script reads NDEF formatted UL/NTAGS') end - + -- Info contained within the tag (block 0 example) -- 0534 00B9 049C AD7F 4A00 0000 E110 1000 2155 -- b0b0 b0b0 b1b1 b1b1 b2b2 b2b2 b3b3 b3b3 CRCC @@ -176,8 +176,8 @@ local function main( args) print('[=] Dumping data...') for i = 4, t5tarea_blocks - 1, 1 do blocks, err = getBlock(i) - if err then - disconnect(); + if err then + disconnect(); return oops(err) end table.insert(blockData, blocks[1]) @@ -196,7 +196,7 @@ local function main( args) local vLow = band(b3[2], 0xF) local vHi = band(rshift(b3[2], 4), 0xF) print(('[=] %02X : version %d.%d supported by tag'):format(b3[2], vHi, vLow) ) - + print(('[=] %02X : Physical Memory Size: %d bytes'):format(b3[3], t5tarea) ) if b3[3] == 0x96 then 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) ) end print('|---|-------------------|') - + local filename, err = utils.WriteDumpFile(info.uid, blockData) if err then return oops(err) end print(string.format('[+] Dumped data into %s', filename)) end -main(args) \ No newline at end of file +main(args)