helptext, syntax

This commit is contained in:
iceman1001 2018-05-28 21:34:58 +02:00
commit d2d126878e

View file

@ -1,27 +1,59 @@
local cmds = require('commands') local cmds = require('commands')
local lib14a = require('read14a') local lib14a = require('read14a')
local getopt = require('getopt')
SIXTEEN_BYTES_ZEROS = "00000000000000000000000000000000" copyright = ''
author = 'Dominic Celiano'
version = 'v1.0.0'
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.
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 keys are hardcoded in the script to "00...". Unless you change this, only use this script for testing purposes.
- Make sure you choose your card size correctly (2kB or 4kB).
Small changes can be to made this script to communicate with the Mifare Plus S, X, or SE.
]]
usage = [[
script run mifareplus -h
Arguments:
-h : this help
]]
GETVERS_INIT = "0360" -- Begins the GetVersion command
GETVERS_CONT = "03AF" -- Continues the GetVersion command -- Default
POWEROFF = "OFF" SIXTEEN_BYTES_ZEROS = '00000000000000000000000000000000'
WRITEPERSO = "03A8"
COMMITPERSO = "03AA" -- ISO7816 commands used
AUTH_FIRST = "0370" GETVERS_INIT = '0360' -- Begins the GetVersion command
AUTH_CONT = "0372" GETVERS_CONT = '03AF' -- Continues the GetVersion command
AUTH_NONFIRST = "0376" POWEROFF = 'OFF'
PREPAREPC = "03F0" WRITEPERSO = '03A8'
PROXIMITYCHECK = "03F2" COMMITPERSO = '03AA'
VERIFYPC = "03FD" AUTH_FIRST = '0370'
READPLAINNOMACUNMACED = "0336" AUTH_CONT = '0372'
AUTH_NONFIRST = '0376'
PREPAREPC = '03F0'
PROXIMITYCHECK = '03F2'
VERIFYPC = '03FD'
READPLAINNOMACUNMACED = '0336'
--- ---
-- This is only meant to be used when errors occur -- This is only meant to be used when errors occur
local function oops(err) local function oops(err)
print("ERROR: ",err) print('ERROR: ',err)
return nil, err
end
---
-- Usage help
local function help()
print(copyright)
print(author)
print(version)
print(desc)
print('Example usage')
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.
local function sendRaw(rawdata, crc, power) local function sendRaw(rawdata, crc, power)
@ -157,7 +189,7 @@ end
local function authenticateAES() local function authenticateAES()
-- Used to try to authenticate with the AES keys we programmed into the card, to ensure the authentication works correctly. -- Used to try to authenticate with the AES keys we programmed into the card, to ensure the authentication works correctly.
commandString = AUTH_FIRST commandString = AUTH_FIRST
commandString = commandString .. "" commandString = commandString .. ''
end end
local function getVersion() local function getVersion()
@ -271,6 +303,11 @@ end
-- The main entry point -- The main entry point
function main(args) function main(args)
local o, a
for o, a in getopt.getopt(args, 'h') do -- Populate command line arguments
if o == "h" then return help() end
end
-- Initialize the card using the already-present read14a library -- Initialize the card using the already-present read14a library
-- Perform RATS and PPS (Protocol and Parameter Selection) check to finish the ISO 14443-4 protocol. -- Perform RATS and PPS (Protocol and Parameter Selection) check to finish the ISO 14443-4 protocol.
info,err = lib14a.read(true, false) info,err = lib14a.read(true, false)
@ -309,4 +346,4 @@ function main(args)
disconnect() disconnect()
end end
main(args) -- Call the main function main(args)