This commit is contained in:
iceman1001 2020-04-05 12:41:38 +02:00
commit 95bc1230d7
9 changed files with 118 additions and 68 deletions

View file

@ -1,7 +1,7 @@
local getopt = require('getopt') local getopt = require('getopt')
local bin = require('bin') local bin = require('bin')
local dumplib = require('html_dumplib') local dumplib = require('html_dumplib')
local ansicolors = require('ansicolors') local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = 'Iceman' author = 'Iceman'

View file

@ -12,9 +12,9 @@ local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = '0xdrrb' author = '0xdrrb'
version = 'v0.1.0' version = 'v0.1.1'
desc = [[ desc = [[
This is a script to dump and decrypt the data of a specific type of Mifare laundromat token. This is a script that tries to dump and decrypt the data of a specific type of Mifare laundromat token. OBS! Tag must be on the antenna.
]] ]]
example = [[ example = [[
script run luxeodump script run luxeodump
@ -22,7 +22,9 @@ example = [[
usage = [[ usage = [[
script run luxeodump script run luxeodump
]] ]]
arguments = [[
-h This help
]]
local PM3_SUCCESS = 0 local PM3_SUCCESS = 0
-- Some shortcuts -- Some shortcuts
@ -48,7 +50,22 @@ local function oops(err)
core.clearCommandBuffer() core.clearCommandBuffer()
return nil, err return nil, err
end end
---
-- Usage help
local function help()
print(copyright)
print(author)
print(version)
print(desc)
print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end
---
--
local function setdevicedebug( status ) local function setdevicedebug( status )
local c = 'hw dbg ' local c = 'hw dbg '
if status then if status then
@ -72,8 +89,8 @@ local function xteaCrypt(num_rounds, v, key)
-- v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]); -- v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]);
v1 = band(bxor(bxor(lsh(v0,4), rsh(v0,5)) + v0, sum + key[band(rsh(sum,11),3)]) + v1, 0xFFFFFFFF) v1 = band(bxor(bxor(lsh(v0,4), rsh(v0,5)) + v0, sum + key[band(rsh(sum,11),3)]) + v1, 0xFFFFFFFF)
end end
v[0]=v0 v[0] = v0
v[1]=v1 v[1] = v1
end end
local function xteaDecrypt(num_rounds, v, key) local function xteaDecrypt(num_rounds, v, key)
@ -89,8 +106,8 @@ local function xteaDecrypt(num_rounds, v, key)
-- v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]); -- v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]);
v0 = band(v0 - bxor(bxor(lsh(v1,4), rsh(v1,5)) + v1, sum + key[band(sum,3)]), 0xFFFFFFFF) v0 = band(v0 - bxor(bxor(lsh(v1,4), rsh(v1,5)) + v1, sum + key[band(sum,3)]), 0xFFFFFFFF)
end end
v[0]=v0 v[0] = v0
v[1]=v1 v[1] = v1
end end
local function createxteakey(mfuid) local function createxteakey(mfuid)
@ -150,7 +167,7 @@ local function readtag(mfkey,xteakey)
-- Read 4 sectors and build table -- Read 4 sectors and build table
for sect = 8, 11 do for sect = 8, 11 do
for blockn = sect*4, (sect*4)+2 do for blockn = sect * 4, (sect * 4) + 2 do
local blockdata = readblock(blockn, mfkey) local blockdata = readblock(blockn, mfkey)
if not blockdata then return oops('[!] failed reading block') end if not blockdata then return oops('[!] failed reading block') end
table.insert(tagdata, blockdata) table.insert(tagdata, blockdata)
@ -160,17 +177,17 @@ local function readtag(mfkey,xteakey)
-- Decrypt data and build clear table -- Decrypt data and build clear table
for key,value in ipairs(tagdata) do for key,value in ipairs(tagdata) do
local clearblockdata local clearblockdata
v[0]=utils.SwapEndianness(value:sub(1,8),32) v[0] = utils.SwapEndianness(value:sub(1, 8), 32)
v[1]=utils.SwapEndianness(value:sub(9,16),32) v[1] = utils.SwapEndianness(value:sub(9, 16), 32)
xteaDecrypt(16, v, xteakey) xteaDecrypt(16, v, xteakey)
vv[0]=utils.SwapEndianness(value:sub(17,24),32) vv[0] = utils.SwapEndianness(value:sub(17, 24), 32)
vv[1]=utils.SwapEndianness(value:sub(25,32),32) vv[1] = utils.SwapEndianness(value:sub(25, 32), 32)
xteaDecrypt(16, vv, xteakey) xteaDecrypt(16, vv, xteakey)
clearblockdata=string.format("%08X%08X%08X%08X", clearblockdata=string.format("%08X%08X%08X%08X",
utils.SwapEndianness(string.format("%08X", v[0]),32), utils.SwapEndianness(string.format("%08X", v[0]), 32),
utils.SwapEndianness(string.format("%08X", v[1]),32), utils.SwapEndianness(string.format("%08X", v[1]), 32),
utils.SwapEndianness(string.format("%08X", vv[0]),32), utils.SwapEndianness(string.format("%08X", vv[0]), 32),
utils.SwapEndianness(string.format("%08X", vv[1]),32)) utils.SwapEndianness(string.format("%08X", vv[1]), 32))
table.insert(cleardata, clearblockdata) table.insert(cleardata, clearblockdata)
end end
@ -180,6 +197,12 @@ end
local function main(args) local function main(args)
-- Arguments for the script
for o, a in getopt.getopt(args, 'h') do
if o == 'h' then return help() end
end
local xteakey = {} local xteakey = {}
-- local v = {} -- local v = {}
local edata = {} local edata = {}
@ -207,7 +230,7 @@ local function main(args)
print(acblue.."UID: "..tag.uid..acoff) print(acblue.."UID: "..tag.uid..acoff)
print(acblue..string.format("XTEA key: %08X %08X %08X %08X", xteakey[0], xteakey[1], xteakey[2], xteakey[3])..acoff) print(acblue..string.format("XTEA key: %08X %08X %08X %08X", xteakey[0], xteakey[1], xteakey[2], xteakey[3])..acoff)
edata, cdata = readtag("415A54454B4D",xteakey) edata, cdata = readtag("415A54454B4D", xteakey)
if edata == nil or cdata == nil then if edata == nil or cdata == nil then
print("ERROR Reading tag!") print("ERROR Reading tag!")

View file

@ -13,10 +13,11 @@ local keylist = require('mfc_default_keys')
local lib14a = require('read14a') local lib14a = require('read14a')
local getopt = require('getopt') local getopt = require('getopt')
local utils = require('utils') local utils = require('utils')
local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = "Holiman" author = "Holiman"
version = 'v1.0.1' version = 'v1.0.2'
desc = ("This script implements Mifare check keys.\ desc = ("This script implements Mifare check keys.\
It utilises a large list of default keys (currently %d keys).\ It utilises a large list of default keys (currently %d keys).\
If you want to add more, just put them inside /lualibs/mfc_default_keys.lua\n"):format(#keylist) If you want to add more, just put them inside /lualibs/mfc_default_keys.lua\n"):format(#keylist)
@ -24,7 +25,9 @@ example = [[
1. script run mfckeys 1. script run mfckeys
]] ]]
usage = [[ usage = [[
Arguments: script run mfckeys [-p]
]]
arguments = [[
-h : this help -h : this help
-p : print keys -p : print keys
]] ]]
@ -46,9 +49,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
-- --
-- waits for answer from pm3 device -- waits for answer from pm3 device
@ -269,8 +275,6 @@ end
-- The main entry point -- The main entry point
local function main(args) local function main(args)
local numSectors = 16
-- Arguments for the script -- Arguments for the script
for o, a in getopt.getopt(args, 'hp') do for o, a in getopt.getopt(args, 'hp') do
if o == 'h' then return help() end if o == 'h' then return help() end
@ -280,6 +284,8 @@ local function main(args)
tag, err = lib14a.read(false, true) tag, err = lib14a.read(false, true)
if not tag then return oops(err) end if not tag then return oops(err) end
local numSectors = 16
-- detect sectors and print taginfo -- detect sectors and print taginfo
numsectors = taginfo(tag) numsectors = taginfo(tag)

View file

@ -2,6 +2,7 @@ local cmds = require('commands')
local getopt = require('getopt') local getopt = require('getopt')
local lib14a = require('read14a') local lib14a = require('read14a')
local utils = require('utils') local utils = require('utils')
local ansicolors = require('ansicolors')
-- global -- global
local DEBUG = false -- the debug flag local DEBUG = false -- the debug flag
@ -11,10 +12,9 @@ local err_lock = 'use -k or change cfg0 block'
copyright = 'Copyright (c) 2017 IceSQL AB. All rights reserved.' copyright = 'Copyright (c) 2017 IceSQL AB. All rights reserved.'
author = 'Christian Herrmann' author = 'Christian Herrmann'
version = 'v1.1.2' version = 'v1.1.3'
desc = 'This script enables easy programming of a MAGIC NTAG 21* card' desc = 'This script enables easy programming of a MAGIC NTAG 21* card'
example = example = [[
[[
-- wipe tag -- wipe tag
script run mfu_magic -w script run mfu_magic -w
@ -36,12 +36,10 @@ example =
-- set signature -- set signature
script run mfu_magic -s 1122334455667788990011223344556677889900112233445566778899001122 script run mfu_magic -s 1122334455667788990011223344556677889900112233445566778899001122
]] ]]
usage = usage = [[
[[
Usage:
script run mfu_magic -h -k <passwd> -c -w -u <uid> -t <type> -p <passwd> -a <pack> -s <signature> -o <otp> -v <version> script run mfu_magic -h -k <passwd> -c -w -u <uid> -t <type> -p <passwd> -a <pack> -s <signature> -o <otp> -v <version>
]]
Arguments: arguments = [[
-h this help -h this help
-c read magic configuration -c read magic configuration
-u UID (14 hexsymbols), set UID on tag -u UID (14 hexsymbols), set UID on tag
@ -94,9 +92,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
--- ---
-- set the global password variable -- set the global password variable

View file

@ -1,8 +1,9 @@
local getopt = require('getopt') local getopt = require('getopt')
local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = "Neuromancer" author = "Neuromancer"
version = 'v1.0.1' version = 'v1.0.2'
desc = [[ desc = [[
This script tries to decode Mifare Classic Access bytes This script tries to decode Mifare Classic Access bytes
]] ]]
@ -10,9 +11,9 @@ example = [[
1. script run mifare_access -a 7F0F0869 1. script run mifare_access -a 7F0F0869
]] ]]
usage = [[ usage = [[
script run mifare_access -h -a <access bytes> script run mifare_access [-h] [-a <access bytes>]
]]
Arguments: arguments = [[
-h : this help -h : this help
-a <access bytes> : 4 bytes ACCESS CONDITIONS -a <access bytes> : 4 bytes ACCESS CONDITIONS
]] ]]
@ -50,9 +51,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
local access_condition_sector_trailer = {} local access_condition_sector_trailer = {}

View file

@ -2,20 +2,23 @@ local getopt = require('getopt')
local lib14a = require('read14a') local lib14a = require('read14a')
local cmds = require('commands') local cmds = require('commands')
local utils = require('utils') local utils = require('utils')
local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = "Martin Holst Swende" author = "Martin Holst Swende"
version = 'v1.0.2' version = 'v1.0.3'
desc = [[ desc = [[
This is a script which automates cracking and dumping mifare classic cards. It sets itself into This is a script which automates cracking and dumping mifare classic cards. It sets itself into
'listening'-mode, after which it cracks and dumps any mifare classic card that you 'listening'-mode, after which it cracks and dumps any mifare classic card that you
place by the device. place by the device.
]] ]]
example = [[ example = [[
script run mifare_autopwn 1. script run mifare_autopwn
]] ]]
usage = [[ usage = [[
Arguments: script run mifare_autopwn [-h] [-d] [-k <key>]
]]
arguments = [[
-h this help -h this help
-d debug logging on -d debug logging on
-k known key for Sector 0 , keytype A -k known key for Sector 0 , keytype A
@ -61,9 +64,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
--- ---
-- Waits for a mifare card to be placed within the vicinity of the reader. -- Waits for a mifare card to be placed within the vicinity of the reader.

View file

@ -1,12 +1,12 @@
local cmds = require('commands') local cmds = require('commands')
local lib14a = require('read14a') local lib14a = require('read14a')
local getopt = require('getopt') local getopt = require('getopt')
local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = 'Dominic Celiano' author = 'Dominic Celiano'
version = 'v1.0.1' version = 'v1.0.2'
desc = desc = [[
[[
Purpose: Lua script to communicate with the Mifare Plus EV1, including personalization (setting the keys) and proximity check. Manually edit the file to add to the commands you can send the card. Purpose: Lua script to communicate with the Mifare Plus EV1, including personalization (setting the keys) and proximity check. Manually edit the file to add to the commands you can send the card.
Please read the NXP manual before running this script to prevent making irreversible changes. Also note: Please read the NXP manual before running this script to prevent making irreversible changes. Also note:
- The Mifare Plus must start in SL0 for personalization. Card can then be moved to SL1 or SL3. - The Mifare Plus must start in SL0 for personalization. Card can then be moved to SL1 or SL3.
@ -15,13 +15,12 @@ Please read the NXP manual before running this script to prevent making irrevers
Small changes can be to made this script to communicate with the Mifare Plus S, X, or SE. Small changes can be to made this script to communicate with the Mifare Plus S, X, or SE.
]] ]]
example = [[ example = [[
-- default 1. script run mifareplus
script run mifareplus
]] ]]
usage = [[ usage = [[
script run mifareplus -h script run mifareplus [-h]
]]
Arguments: arguments = [[
-h : this help -h : this help
]] ]]
@ -57,9 +56,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
--- ---
-- Used to send raw data to the firmware to subsequently forward the data to the card. -- Used to send raw data to the firmware to subsequently forward the data to the card.

View file

@ -2,11 +2,12 @@ local getopt = require('getopt')
local cmds = require('commands') local cmds = require('commands')
local lib14a = require('read14a') local lib14a = require('read14a')
local utils = require('utils') local utils = require('utils')
local ansicolors = require('ansicolors')
-- --
-- Refactored iceman, 2019 -- Refactored iceman, 2019
copyright = '' copyright = ''
author = 'Martin Holst Swende & Asper' author = 'Martin Holst Swende & Asper'
version = 'v1.0.1' version = 'v1.0.2'
desc = [[ desc = [[
This script will automatically recognize and dump full content of a NFC NDEF Initialized tag; non-initialized tags will be ignored. This script will automatically recognize and dump full content of a NFC NDEF Initialized tag; non-initialized tags will be ignored.
@ -23,9 +24,9 @@ example = [[
1. script run ndef_dump 1. script run ndef_dump
]] ]]
usage = [[ usage = [[
script run ndef_dump script run ndef_dump [-h] [-d] [-v]
]]
Arguments: arguments = [[
-h this help -h this help
-d debug logging on -d debug logging on
-v verbose output (from ndef parsing) -v verbose output (from ndef parsing)
@ -63,9 +64,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
-- --
-- Sends an instruction to do nothing, only disconnect -- Sends an instruction to do nothing, only disconnect

View file

@ -1,10 +1,11 @@
local getopt = require('getopt') local getopt = require('getopt')
local lib14a = require('read14a') local lib14a = require('read14a')
local utils = require('utils') local utils = require('utils')
local ansicolors = require('ansicolors')
copyright = 'Copyright (c) 2017 IceSQL AB. All rights reserved.' copyright = 'Copyright (c) 2017 IceSQL AB. All rights reserved.'
author = "Christian Herrmann" author = "Christian Herrmann"
version = 'v1.0.4' version = 'v1.0.5'
desc = [[ desc = [[
This script writes a empty template for 3D printing system onto a empty NTAG213 or MAGIC NTAG21* This script writes a empty template for 3D printing system onto a empty NTAG213 or MAGIC NTAG21*
@ -21,9 +22,9 @@ example =[[
script run ntag_3d -u 11223344556677 -c 46 -m 50 -p 5448 -s 4555 -l 200 -1 script run ntag_3d -u 11223344556677 -c 46 -m 50 -p 5448 -s 4555 -l 200 -1
]] ]]
usage = [[ usage = [[
script run ntag_3d -h -t -u <uid> -c <color> -m <material> -p <region> -s <region> -l <length> script run ntag_3d [-h] [-t] [-u <uid>] [-c <color>] [-m <material>] [-p <region>] [-s <region>] [-l <length>]
]]
Arguments: arguments = [[
-h : this help -h : this help
-t : selftest -t : selftest
-u <UID> : UID -u <UID> : UID
@ -168,9 +169,12 @@ local function help()
print(author) print(author)
print(version) print(version)
print(desc) print(desc)
print('Example usage') print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(example)
print(usage) print(usage)
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end end
-- --
-- Exit message -- Exit message