more converting scripts

This commit is contained in:
iceman1001 2019-04-28 19:51:25 +02:00
commit f4f8636b86
2 changed files with 75 additions and 55 deletions

View file

@ -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 <offset> -l <length> -k <keylength>
Arguments:
-h : this help
-o <offset> : memory offset, default is 0
-l <length> : length in bytes, default is 256
-k <keylen> : 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 <offset> -l <length> -k <keylength>
Arguments:
-h : this help
-o <offset> : memory offset, default is 0
-l <length> : length in bytes, default is 256
-k <keylen> : 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) )