1 local getopt
= require('getopt')
2 local bin
= require('bin')
3 local ansicolors
= require('ansicolors')
5 copyright
= 'Copyright (c) 2019 Bogito. All rights reserved.'
9 This script will read the flash memory of RDV4 using SPIFFS and print the stored passwords.
10 It was meant to be used as a help tool after using the BogRun standalone mode.
13 -- This will read the hf_bog.log file in SPIFFS and print the stored passwords
14 script run mem_spiffs_readpwd
16 -- This will read the other.log file in SPIFFS and print the stored passwords
17 script run mem_spiffs_readpwd -f other.log
19 -- This will delete the hf_bog.log file from SPIFFS
20 script run mem_spiffs_readpwd -r
23 script run mem_spiffs_readpwd [-h] [-f <filename>] [-r]
27 -f <filename> : filename in SPIFFS
28 -r : delete filename from SPIFFS
31 -- This is only meant to be used when errors occur
32 local function oops(err
)
34 core
.clearCommandBuffer()
44 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
46 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
48 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
52 -- The main entry point
53 local function main(args
)
55 print( string.rep('--',20) )
56 print('Read passwords stored in memory (SPIFFS)')
57 print( string.rep('--',20) )
60 local data
, length
, err
, removeflag
61 local filename
= 'hf_bog.log'
64 for o
, a
in getopt
.getopt(args
, 'rf:h') do
67 if o
== 'h' then return help() end
70 if o
== 'f' then filename
= a
end
73 if o
== 'r' then removeflag
= true end
78 print('Deleting file '..filename
.. ' from SPIFFS if exists')
79 core
.console("mem spiffs remove -f " ..filename
)
83 data
, length
, err
= core
.GetFromFlashMemSpiffs(filename
)
84 if data
== nil then return oops('Problem while reading file from SPIFFS') end
86 --print('Filename', filename)
87 --print('Filesize (B)', length)
89 _
, s
= bin
.unpack('H'..length
, data
)
92 for i
= 1, length
/keylength
do
93 key
= string.sub(s
, (i
-1)*8+1, i
*8)
94 print(string.format('[%02d] %s',i
, key
))
97 print( string.rep('--',20) )
98 print( ('[+] found %d passwords'):format(cnt
))