fix workflow yaml
[RRG-proxmark3.git] / client / luascripts / mfc_hammerlite.lua
blob6ae0da47fdbbf3f76966cba1d5843cbdf939ac75
1 local getopt = require('getopt')
2 local lib14a = require('read14a')
3 local cmds = require('commands')
4 local ansicolors = require('ansicolors')
6 copyright = 'Copyright 2020 A. Ozkal, released under GPLv2+.'
7 author = 'Ave'
8 version = 'v0.1.2'
9 desc = [[
10 This script writes a bunch of random blocks to a Mifare Classic card
12 example = [[
13 script run mfc_hammerlite -w 1000 -k FFFFFFFFFFFF
15 usage = [[
16 script run mfc_hammerlite [-h] [-w <writecount>] [-k <key>]
18 arguments = [[
19 -h : This help
20 -w <writeroundcount> : Amount of write rounds to be done to each block (optional, default: 100)
21 -k <key> : A key for the sectors
24 local function help()
25 print(author)
26 print(version)
27 print(desc)
28 print(ansicolors.cyan..'Usage'..ansicolors.reset)
29 print(usage)
30 print(ansicolors.cyan..'Arguments'..ansicolors.reset)
31 print(arguments)
32 print(ansicolors.cyan..'Example usage'..ansicolors.reset)
33 print(example)
34 end
36 function randhex(len)
37 result = ""
38 for i = 1,len,1
40 -- 48-57 numbers, 65-70 a-f
41 hex = math.random(0, 15)
42 if hex >= 10 then
43 hex = hex + 7
44 end
45 result = result..string.char(48 + hex)
46 end
47 return result
48 end
50 ---
51 -- The main entry point
52 function main(args)
53 -- param defaults
54 loopcount = 100
55 verifyevery = 10
56 key = "FFFFFFFFFFFF"
58 -- Read the parameters
59 for o, a in getopt.getopt(args, 'hw:k:') do
60 if o == 'h' then return help() end
61 if o == 'w' then loopcount = tonumber(a) end
62 if o == 'k' then key = a end
63 end
65 starttime = os.time()
67 for i = 1,loopcount,1
69 for a = 1,63,1
71 if ((a + 1) % 4 ~= 0) and a ~= 0 then -- :)
72 data = randhex(32)
73 -- core.console('hf mf rdbl --blk '..a..' -k FFFFFFFFFFFF')
74 core.console('hf mf wrbl --blk '..a..' -k '..key..' -d '..data)
75 end
76 end
77 end
79 print("Hammering complete.")
80 end
82 main(args)