updated commands and text

This commit is contained in:
iceman1001 2023-10-15 17:11:36 +02:00
commit 12fc664870

View file

@ -7,7 +7,7 @@ local ansicolors = require('ansicolors')
copyright = '' copyright = ''
author = "Michael Micsen" author = "Michael Micsen"
version = 'v0.0.1' version = 'v0.0.2'
desc = [[ desc = [[
Perform simulation of Mifare credentials with HID encoding Perform simulation of Mifare credentials with HID encoding
This script only supports: H10301 This script only supports: H10301
@ -17,12 +17,12 @@ example = [[
script run hf_mf_sim_hid.lua -f 1 -c 10000 script run hf_mf_sim_hid.lua -f 1 -c 10000
]] ]]
usage = [[ usage = [[
script run hf_mf_sim_hid.lua -f facility -c card_number script run hf_mf_sim_hid.lua -f <dec> -c <dec>
]] ]]
arguments = [[ arguments = [[
-h : this help -h : this help
-f : facility id -f : facility code
-c : starting card id -c : card number
]] ]]
local DEBUG = true local DEBUG = true
--local bxor = bit32.bxor --local bxor = bit32.bxor
@ -126,7 +126,6 @@ local function cardHex(i, f)
sentinel = lshift(1, 26) sentinel = lshift(1, 26)
bits = bor(bits, sentinel) bits = bor(bits, sentinel)
return ('%08x'):format(bits) return ('%08x'):format(bits)
end end
--- ---
@ -146,15 +145,14 @@ local function main(args)
if o == 'h' then return help() end if o == 'h' then return help() end
if o == 'f' then if o == 'f' then
if isempty(a) then if isempty(a) then
print('You did not supply a facility code, using 0') print('Defaulting to facility code 0')
facility = 0 facility = 0
else else
facility = a facility = a
end end
end end
if o == 'c' then if o == 'c' then
print(a) if isempty(a) then return oops('You must supply a card number') end
if isempty(a) then return oops('You must supply the flag -c (card number)1') end
cardnum = a cardnum = a
end end
end end
@ -162,23 +160,27 @@ local function main(args)
--Due to my earlier complaints about how this specific getopt library --Due to my earlier complaints about how this specific getopt library
--works, specifying ':' does not enforce supplying a value, thus we --works, specifying ':' does not enforce supplying a value, thus we
--need to do these checks all over again. --need to do these checks all over again.
if isempty(cardnum) then return oops('You must supply the flag -c (card number)2') end if isempty(cardnum) then return oops('You must supply a card number') end
--If the facility ID is non specified, ensure we code it as zero --If the facility ID is non specified, ensure we code it as zero
if isempty(facility) then if isempty(facility) then
print('Using 0 for the facility code as -f was not supplied') print('Defaulting to facility code 0')
facility = 0 facility = 0
end end
-- Write the MAD to read for a Mifare HID credential -- Write the MAD to read for a Mifare HID credential
core.console('hf mf esetblk -b 1 -d 1B014D48000000000000000000000000') core.console('hf mf esetblk --blk 1 -d 1B014D48000000000000000000000000')
core.console('hf mf esetblk -b 3 -d A0A1A2A3A4A5787788C189ECA97F8C2A') core.console('hf mf esetblk --blk 3 -d A0A1A2A3A4A5787788C189ECA97F8C2A')
--Write the sector trailer for the credential sector --Write the sector trailer for the credential sector
core.console('hf mf esetblk -b 7 -d 484944204953787788AA204752454154') core.console('hf mf esetblk --blk 7 -d 484944204953787788AA204752454154')
local cardh = cardHex(cardnum, facility) local cardh = cardHex(cardnum, facility)
print('Hex')
print(cardh) print('Facility Code... ' .. facility)
core.console( ('hf mf esetblk -b 5 -d 020000000000000000000000%s'):format(cardh) ) print('Card number..... ' .. cardnum)
print('Hex............. ' .. cardh)
print('')
core.console( ('hf mf esetblk --blk 5 -d 020000000000000000000000%s'):format(cardh) )
core.console('hf mf sim --1k -i') core.console('hf mf sim --1k -i')
end end