Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update t55_chk_date.lua #2737

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions client/luascripts/t55_chk_date.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,28 @@ local getopt = require('getopt')
local dash = string.rep('--', 32)

author = ' Author: jareckib - created 01.02.2025'
version = ' version v1.00'
version = ' version v1.01'
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 minutes and 50 seconds. Date from 1900 to 2100. The script may be
useful if the password is for example date of birth.

]]
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.
]]
usage = [[
script run t55_chk_date
]]
arguments = [[
script run t55_chk_date -h : this help
]]

local debug = true
local DEBUG = true

local function dbg(args)
if not DEBUG then return end
if type(args) == 'table' then
local i = 1
while args[i] do
dbg(args[i])
i = i+1
for _, v in ipairs(args) do
dbg(v)
end
else
print('###', args)
Expand Down Expand Up @@ -130,6 +127,19 @@ local function get_valid_ending_year_input(start_year)
return end_year
end

local function get_valid_mode_input()
local mode
while true do
io.write(' Choose the searching mode ('..ac.cyan..'1'..ac.reset..' - YYYYMMDD '..ac.cyan..'2'..ac.reset..' - DDMMYYYY): ')
mode = io.read()
if mode == "1" or mode == "2" then
return mode
else
print(ac.yellow .. ' ERROR: ' .. ac.reset .. 'Invalid choice. Please enter 1 or 2.')
end
end
end

local function main(args)
for o, a in getopt.getopt(args, 'h') do
if o == 'h' then return help() end
Expand All @@ -140,12 +150,8 @@ local function main(args)
local start_year = get_valid_year_input(" Enter the starting year: " .. ac.yellow)
io.write(ac.reset..'')
local end_year = get_valid_ending_year_input(start_year)
io.write(' Choose the searching mode ('..ac.cyan..'1'..ac.reset..' - YYYYMMDD '..ac.cyan..'2'..ac.reset..' - DDMMYYYY): ')
local mode = io.read()
if mode ~= "1" and mode ~= "2" then
print(ac.yellow .. ' ERROR: ' .. ac.reset .. 'Invalid choice.')
return
end
local mode = get_valid_mode_input()

if generate_dictionary(start_year, end_year, mode) then
print(ac.green .. " File created: " .. dictionary_path .. ac.reset)
print(ac.cyan .. " Starting password testing on T5577..." .. ac.reset)
Expand All @@ -155,4 +161,4 @@ local function main(args)
end
end

main(args)
main(args)
Loading