From 5a2f2e51eac03b25ddcaaee772299b1581bb9d52 Mon Sep 17 00:00:00 2001 From: Jarek Barwinski <116510448+jareckib@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:11:41 +0000 Subject: [PATCH 1/2] t55_chk corrected options -y or -d Signed-off-by: Jarek Barwinski <116510448+jareckib@users.noreply.github.com> --- client/luascripts/t55_chk.lua | 98 ++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/client/luascripts/t55_chk.lua b/client/luascripts/t55_chk.lua index 1cc8d69c2..3133e3a81 100644 --- a/client/luascripts/t55_chk.lua +++ b/client/luascripts/t55_chk.lua @@ -5,46 +5,67 @@ local dir = os.getenv('HOME') .. '/proxmark3/client/dictionaries/' local dictionary_path = dir .. 'T5577date.dic' local cyan = ac.cyan local res = ac.reset +local red = ac.red +local green = ac.green -author = ' Author: jareckib - created 02.02.2025' -version = ' version v1.00' +author = ' Author: jareckib - created 04.02.2025' +version = ' version v1.05' desc = [[ A simple script for searching the password for T5577. The script creates a dictionary starting from the entered starting year to the entered ending year. There are two search methods - DDMMYYYY or YYYYMMDD. Checking the entire year takes about 1 minute and 50 seconds. Date from 1900 to 2100. The script may be - useful if the password is, for example, a date of birth. + useful if the password is for example a date of birth. ]] usage = [[ script run t55_chk [-s start_year] [-e end_year] [-d | -y] ]] options = [[ - -h Show this help message - -s Starting year (required) - -e Ending year (default: current year) - -d Search method: DDMMYYYY - -y Search method: YYYYMMDD + -h this help + -s start_year starting year (required) + -e end_year ending year (optional, default: current year) + -d search method: DDMMYYYY + -y search method: YYYYMMDD ]] examples = [[ - script run t55_chk -s 1999 -d - start from 1999, end year is current year, method 01011999 - script run t55_chk -s 1999 -y - start from 1999, end year is current year, method 19990101 - script run t55_chk -s 1999 -e 2001 -y - start from 1999, end year 2001, method 19990101 - script run t55_chk -s 1999 -e 2001 -d - start from 1999, end year 2001, method 01011999 + script run t55_chk -s 1999 -d -> start 1999, end is current year, method 01011999 + script run t55_chk -s 1999 -y -> start 1999, end is current year, method 19990101 + script run t55_chk -s 1999 -e 2001 -y -> start 1999, end year 2001, method 19990101 + script run t55_chk -s 1999 -e 2001 -d -> start 1999, end year 2001, method 01011999 ]] local function help() - print(ac.green..author..res) + print() + print(ac.yellow..author) print(version) - print(desc) - print(cyan..' Usage:'..res) + print(res..desc) + print(green..' Usage:'..res) print(usage) - print(cyan..' Options:'..res) + print(green..' Options:'..res) print(options) - print(cyan..' Examples:'..res) + print(green..' Examples:'..res) print(examples) end +local function oops(err) + core.console('clear') + print( string.rep('--',39) ) + print( string.rep('--',39) ) + print(ac.red..' ERROR:'..res.. err) + print( string.rep('--',39) ) + print( string.rep('--',39) ) + return nil, err +end + +local dir = os.getenv('HOME') .. '/proxmark3/client/dictionaries/' +local dictionary_path = dir .. 'T5577date.dic' + +local days_in_month = { + [1] = 31, [2] = 28, [3] = 31, [4] = 30, [5] = 31, [6] = 30, + [7] = 31, [8] = 31, [9] = 30, [10] = 31, [11] = 30, [12] = 31 +} + local function generate_dictionary(start_year, end_year, mode) local file = io.open(dictionary_path, "w") if not file then @@ -54,10 +75,16 @@ local function generate_dictionary(start_year, end_year, mode) for year = start_year, end_year do for month = 1, 12 do - for day = 1, 31 do - local entry = (mode == "y") and - (string.format("%04d%02d%02d", year, month, day)) or - (string.format("%02d%02d%04d", day, month, year)) + local days_in_current_month = days_in_month[month] + if month == 2 and ((year % 4 == 0 and year % 100 ~= 0) or (year % 400 == 0)) then + days_in_current_month = 29 + end + + for day = 1, days_in_current_month do + local month_str = string.format("%02d", month) + local day_str = string.format("%02d", day) + local year_str = tostring(year) + local entry = (mode == "y") and (year_str .. month_str .. day_str) or (day_str .. month_str .. year_str) file:write(entry .. "\n") end end @@ -67,16 +94,6 @@ local function generate_dictionary(start_year, end_year, mode) return true end -local function oops(err) - core.console('clear') - print( string.rep('--',39) ) - print( string.rep('--',39) ) - print(ac.red..' ERROR:'..res.. err) - print( string.rep('--',39) ) - print( string.rep('--',39) ) - return nil, err -end - local function main(args) if #args == 0 then return help() end @@ -87,28 +104,28 @@ local function main(args) if o == 'h' then return help() end if o == 's' then start_year = tonumber(a) - if not start_year then return oops('Invalid start year') end + if not start_year then return oops(' Invalid start year') end end if o == 'e' then end_year = tonumber(a) - if not end_year then return oops('Invalid end year (-e)') end + if not end_year then return oops(' Invalid end year') end end if o == 'd' then mode = "d" end if o == 'y' then mode = "y" end end - if not start_year then return oops('Starting year is required') end + if not start_year then return oops(' Starting year is required') end if start_year < 1900 or start_year > 2100 then - return oops('Start year must be between 1900 and 2100') + return oops(' Start year must be between 1900 and 2100') end - if args[#args] == "-e" then return oops('Ending year cannot be empty') end + if args[#args] == "-e" then return oops(' Ending year cannot be empty') end if not end_year then end_year = current_year end if end_year < 1900 or end_year > 2100 then - return oops('End year must be between 1900 and 2100') + return oops(' End year must be between 1900 and 2100') end - if end_year < start_year then return oops('End year cannot be earlier than start year') end - if not mode then return oops('You must select searching method'..cyan..' -d'..res.. ' or '..cyan.. '-y'..res) end + if end_year < start_year then return oops(' End year cannot be earlier than start year') end + if not mode then return oops(' You must select searching method'..cyan..' d'..res.. ' or '..cyan.. 'y'..res) end if generate_dictionary(start_year, end_year, mode) then print(ac.green .. " File created: " .. dictionary_path .. res) @@ -118,5 +135,4 @@ local function main(args) return oops('Problem saving the file') end end - -main(args) \ No newline at end of file + main(args) \ No newline at end of file From 70ca100e29037cd49e478069b9a4bec57f34492e Mon Sep 17 00:00:00 2001 From: Jarek Barwinski <116510448+jareckib@users.noreply.github.com> Date: Sun, 16 Feb 2025 19:44:15 +0000 Subject: [PATCH 2/2] t55_fix This simple script first checks if a password has been set for the T5577. It uses the dictionary t55xx_default_pwds.dic for this purpose. If a password is found, it uses the wipe command to erase the T5577. Then the reanimation procedure is applied. If the password is not found or doesn't exist the script only performs the reanimation procedure. The script revives 99% of blocked tags. Signed-off-by: Jarek Barwinski <116510448+jareckib@users.noreply.github.com> --- client/luascripts/t55_fix.lua | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 client/luascripts/t55_fix.lua diff --git a/client/luascripts/t55_fix.lua b/client/luascripts/t55_fix.lua new file mode 100644 index 000000000..354cf8dfc --- /dev/null +++ b/client/luascripts/t55_fix.lua @@ -0,0 +1,101 @@ +local getopt = require('getopt') +local utils = require('utils') +local ac = require('ansicolors') +local os = require('os') +local dash = string.rep('--', 32) +local dir = os.getenv('HOME') .. '/.proxmark3/logs/' +local logfile = (io.popen('dir /a-d /o-d /tw /b/s "' .. dir .. '" 2>nul:'):read("*a"):match("%C+")) +local command = core.console + +author = ' Author: jareckib - 15.02.2025' +version = ' version v1.00' +desc = [[ + This simple script first checks if a password has been set for the T5577. + It uses the dictionary t55xx_default_pwds.dic for this purpose. If a password + is found, it uses the wipe command to erase the T5577. Then the reanimation + procedure is applied. If the password is not found or doesn't exist the script + only performs the reanimation procedure. The script revives 99% of blocked tags. + ]] +usage = [[ + script run t55_fix +]] +arguments = [[ + script run t55_fix -h : this help +]] + +local function help() + print() + print(author) + print(version) + print(desc) + print(ac.cyan..' Usage'..ac.reset) + print(usage) + print(ac.cyan..' Arguments'..ac.reset) + print(arguments) +end + +local function read_log_file(logfile) + local file = io.open(logfile, "r") + if not file then + return nil + end + local content = file:read("*all") + file:close() + return content +end + +local function extract_password(log_content) + for line in log_content:gmatch("[^\r\n]+") do + local password = line:match('%[%+%] found valid password: %[ (%x%x%x%x%x%x%x%x) %]') + if password then + return password + end + end + return nil +end + +local function reanimate_t5577(password) + if password then + command('clear') + print(dash) + print(" Using found password to wipe: " .. password) + print(dash) + command('lf t55 wipe -p ' .. password) + else + command('clear') + print(dash) + print(ac.yellow.." No valid password found, proceeding with reanimation."..ac.reset) + print(dash) + end + command('lf t55 write -b 0 -d 000880E8 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r0 -t -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r1 -t -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r2 -t -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r3 -t -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --r0 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --r1 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --r2 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --r3 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r0 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r1 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r2 -p 00000000') + command('lf t55 write -b 0 -d 000880E0 --pg1 --r3 -p 00000000') + command('lf t55 detect') + local file = io.open(logfile, "w+") + file:write("") + file:close() + print(dash) + print('all done!') +end + +local function main(args) + for o, a in getopt.getopt(args, 'h') do + if o == 'h' then return help() end + end + command('lf t55 chk') + local log_content = read_log_file(logfile) + local password = log_content and extract_password(log_content) or nil + reanimate_t5577(password) +end + +main(args)