From f4f8636b8660a50673aff93fcd77e1b05f924ed5 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 28 Apr 2019 19:51:25 +0200 Subject: [PATCH] more converting scripts --- client/scripts/read_pwd_mem.lua | 60 ++++++++++++++-------------- client/scripts/remagic.lua | 70 +++++++++++++++++++++------------ 2 files changed, 75 insertions(+), 55 deletions(-) diff --git a/client/scripts/read_pwd_mem.lua b/client/scripts/read_pwd_mem.lua index 4611c32cc..783a53b12 100644 --- a/client/scripts/read_pwd_mem.lua +++ b/client/scripts/read_pwd_mem.lua @@ -2,8 +2,8 @@ local getopt = require('getopt') local bin = require('bin') copyright = 'Copyright (c) 2018 Bogito. All rights reserved.' -author = "Bogito" -version = 'v1.0.1' +author = 'Bogito' +version = 'v1.0.2' desc = [[ This script will read the flash memory of RDV4 and print the stored passwords. @@ -11,20 +11,6 @@ It was meant to be used as a help tool after using the BogRun standalone mode. (Iceman) script adapted to read and print keys in the default dictionary flashmemory sections. ]] -usage = -[[ -Usage: - script run read_pwd_mem -h -o -l -k - -Arguments: - -h : this help - -o : memory offset, default is 0 - -l : length in bytes, default is 256 - -k : key length in bytes <4|6|8> , default is 4 - -m : print Mifare dictionary keys - -t : print t55xx dictionary passwords - -i : print iClass dictionary keys -]] example = [[ -- This will scan the first 256 bytes of flash memory for stored passwords @@ -39,21 +25,37 @@ example = -- This will print found script run read_pwd_mem -o 241664 -k 6 ]] +usage = +[[ +Usage: + script run read_pwd_mem -h -o -l -k + +Arguments: + -h : this help + -o : memory offset, default is 0 + -l : length in bytes, default is 256 + -k : key length in bytes <4|6|8> , default is 4 + -m : print Mifare dictionary keys + -t : print t55xx dictionary passwords + -i : print iClass dictionary keys +]] --- -- This is only meant to be used when errors occur local function oops(err) - print("ERROR: ", err) + print('ERROR:', err) + core.clearCommandBuffer() return nil, err end --- -- Usage help local function help() print(copyright) + print(author) print(version) print(desc) - print(usage) - print('Example usage:') + print('Example usage') print(example) + print(usage) end --- -- The main entry point @@ -73,20 +75,20 @@ local function main(args) for o, a in getopt.getopt(args, 'ho:l:k:mti') do -- help - if o == "h" then return help() end + if o == 'h' then return help() end -- offset - if o == "o" then offset = tonumber(a) end + if o == 'o' then offset = tonumber(a) end -- num of bytes to read - if o == "l" then length = tonumber(a) end + if o == 'l' then length = tonumber(a) end -- keylength - if o == "k" then keylength = tonumber(a); usedkey = true end + if o == 'k' then keylength = tonumber(a); usedkey = true end - if o == "m" then keylength =6; usedkey = true; offset = 0x3F000-0x4000; end - if o == "t" then keylength =4; usedkey = true; offset = 0x3F000-0x3000; end - if o == "i" then keylength =8; usedkey = true; offset = 0x3F000-0x5000; end + if o == 'm' then keylength =6; usedkey = true; offset = 0x3F000-0x4000; end + if o == 't' then keylength =4; usedkey = true; offset = 0x3F000-0x3000; end + if o == 'i' then keylength =8; usedkey = true; offset = 0x3F000-0x5000; end end if length < 0 or length > 256 then @@ -116,7 +118,7 @@ local function main(args) for i = 1, keys do key = string.sub(s, (i - 1) * kl + 1, i * kl ) - print(string.format("[%02d] %s",i, key)) + print(string.format('[%02d] %s',i, key)) end print( string.rep('--',20) ) print( ('[+] found %d passwords'):format(keys)) @@ -128,8 +130,8 @@ local function main(args) for i = 1, (length/keylength) do key = string.sub(s, (i-1)*8+1, i*8) - if key == "FFFFFFFF" then break end - print(string.format("[%02d] %s",i, key)) + if key == 'FFFFFFFF' then break end + print(string.format('[%02d] %s',i, key)) cnt = cnt + 1 end print( string.rep('--',20) ) diff --git a/client/scripts/remagic.lua b/client/scripts/remagic.lua index 29e9a2c56..096fcfa27 100644 --- a/client/scripts/remagic.lua +++ b/client/scripts/remagic.lua @@ -1,12 +1,21 @@ local getopt = require('getopt') -example = "script run remagic" -author = "Iceman" +copyright = '' +author = 'Iceman' +version = 'v1.0.1' desc = [[ This is a script that tries to bring back a chinese magic card (1k generation1) from the dead when it's block 0 has been written with bad values. or mifare Ultralight magic card which answers to chinese backdoor commands +]] +example = [[ + -- target a Ultralight based card + 1. script run remagic -u + +]] +usage = [[ +script run remagic Arguments: -h this help @@ -15,55 +24,64 @@ Arguments: --- -- A debug printout-function local function dbg(args) - if DEBUG then + if not DEBUG then return end + if type(args) == 'table' then + local i = 1 + while result[i] do + dbg(result[i]) + i = i+1 + end + else print('###', args) end end --- -- This is only meant to be used when errors occur local function oops(err) - print('ERROR: ',err) + print('ERROR:', err) + core.clearCommandBuffer() + return nil, err end --- -- Usage help local function help() + print(copyright) + print(author) + print(version) print(desc) print('Example usage') print(example) + print(usage) end local function cmdUltralight() return { - --[[ - --]] - [0] = "hf 14a raw -p -a -b 7 40", - [1] = "hf 14a raw -p -a 43", - [2] = "hf 14a raw -c -a A2005380712A", - [3] = "hf 14a raw -p -a -b 7 40", - [4] = "hf 14a raw -p -a 43", - [5] = "hf 14a raw -c -a A2010200D980", - [6] = "hf 14a raw -p -a -b 7 40", - [7] = "hf 14a raw -p -a 43", - [8] = "hf 14a raw -c -a A2025B480000", - [9] = "hf 14a raw -c -a 5000", + [0] = 'hf 14a raw -p -a -b 7 40', + [1] = 'hf 14a raw -p -a 43', + [2] = 'hf 14a raw -c -a A2005380712A', + [3] = 'hf 14a raw -p -a -b 7 40', + [4] = 'hf 14a raw -p -a 43', + [5] = 'hf 14a raw -c -a A2010200D980', + [6] = 'hf 14a raw -p -a -b 7 40', + [7] = 'hf 14a raw -p -a 43', + [8] = 'hf 14a raw -c -a A2025B480000', + [9] = 'hf 14a raw -c -a 5000', } end local function cmdClassic() return { - --[[ - --]] - [0] = "hf 14a raw -p -a -b 7 40", - [1] = "hf 14a raw -p -a 43", - [2] = "hf 14a raw -c -p -a A000", - [3] = "hf 14a raw -c -p -a 01020304049802000000000000001001", - [4] = "hf 14a raw -c -a 5000", + [0] = 'hf 14a raw -p -a -b 7 40', + [1] = 'hf 14a raw -p -a 43', + [2] = 'hf 14a raw -c -p -a A000', + [3] = 'hf 14a raw -c -p -a 01020304049802000000000000001001', + [4] = 'hf 14a raw -c -a 5000', } end local function cmdRestoreST() local arr = {} for i = 0, 15 do local blk = 3 + (4*i) - arr[i] = "hf mf csetbl "..blk.." FFFFFFFFFFFFFF078000FFFFFFFFFFFF" + arr[i] = 'hf mf csetbl '..blk..' FFFFFFFFFFFFFF078000FFFFFFFFFFFF' end return arr end @@ -86,8 +104,8 @@ function main(args) -- Read the parameters for o, a in getopt.getopt(args, 'hu') do - if o == "h" then return help() end - if o == "u" then isUltralight = true end + if o == 'h' then return help() end + if o == 'u' then isUltralight = true end end core.clearCommandBuffer()