make style

This commit is contained in:
iceman1001 2021-12-27 19:36:42 +01:00
commit 0d38da5de2
14 changed files with 205 additions and 75 deletions

View file

@ -24,22 +24,22 @@ local DEBUG = true
-- SPEEDTEST
-------------------------------------------------------------------------------------------------------------
-- BRUTEFORCE ALL HEX COMBINATIONS:
--
--
-- With the -t 10 ( lowest possible delay ) and FFFFFFFF attempts or in decimal 4.294.967.295 combinations
--
--
-- My test showed that this script can do 255 password attempts in approxemately 170 seconds
--
-- That is : 255 / 170 = 1,5 attempt/second
--
-- So .. 4.294.967.295 combinations / 1,5 per second = 2.863.311.530 seconds and it is roughly 90 years
--
-------------------------------------------------------------------------------------------------------------
-- PASSWORD LISTS:
--
-- That is : 255 / 170 = 1,5 attempt/second
--
-- So .. 4.294.967.295 combinations / 1,5 per second = 2.863.311.530 seconds and it is roughly 90 years
--
-------------------------------------------------------------------------------------------------------------
-- Crunch can generate all (14.776.336) combinations of 4 chars with a-z + A-Z + 0-9 like this:
-- PASSWORD LISTS:
-------------------------------------------------------------------------------------------------------------
-- Crunch can generate all (14.776.336) combinations of 4 chars with a-z + A-Z + 0-9 like this:
--
-- crunch 4 4 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -o keys/4_chars_and_digits.list
--
--
-- for LINE in $(cat keys/4_chars_and_digits.list) ; do echo -n ${LINE} |xxd -p -u;done > keys/4_chars_and_digits_hex.list
--
-------------------------------------------------------------------------------------------------------------
@ -79,11 +79,11 @@ desc = [[Description : Bruteforces 7 byte UID NTAG protected with a 32 bit
example = [[
Example of how to run the script with bruteforcing of continuously HEX numbers with 1 secound delay between tests:
script run ntag_bruteforce -s 00000000 -e FFFFFFFF -t 1000 -o /var/log/ntag_bruteforce.log
script run ntag_bruteforce -s 00000000 -e FFFFFFFF -t 1000 -o /var/log/ntag_bruteforce.log
Example of how to run the script and bruteforc the card using passwords from the input file with 1s delay between tests
script run ntag_bruteforce -i /home/my_4_char_passwords_list.txt -o /var/log/ntag_bruteforce.log
script run ntag_bruteforce -i /home/my_4_char_passwords_list.txt -o /var/log/ntag_bruteforce.log
]]
-------------------------------------------------------------------------------------------------------------
@ -91,7 +91,7 @@ usage = [[
script run ntag_bruteforce [-s <start_id>] [-e <end_id>] [-t <timeout>] [ -o <output_file> ] [ -p ] [ -h for help ]
script run ntag_bruteforce [-i <input_file>] [-t <timeout>] [ -o <output_file> ] [ -n | -x ] [ -p ] [ -h for help ]
DESCRIPTION
DESCRIPTION
This script will test either an 8 digit hexadecimal code or 4 char stings (will be converted to an 8 digit hex string )
against NFC cards of the type NTAG21x protected by a 32 bit password.
Read more about NTAGs here: https://www.nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf
@ -109,9 +109,9 @@ arguments = [[
-s 0-0xFFFFFFFF Start HEX value
-e 0-0xFFFFFFFF End HEX value
# Or use a list of passwords from a file:
# Or use a list of passwords from a file:
-x Passwords in HEX Password file (-i) contains HEX values (4 x 2hex -> 32 bit/line like: 00112233)
-n NTAG Tools format Bruteforce with first 8 hex values of a md5 hash of the password
-n NTAG Tools format Bruteforce with first 8 hex values of a md5 hash of the password
The password will be prefixed with hex value 20 (space) if the string/password is < 4 chars
]]
-------------------------------------------------------------------------------------------------------------
@ -132,7 +132,7 @@ end
local function read_lines_from(file)
print(ansicolors.yellow..'\nPlease wait while loading password file..'..ansicolors.reset)
readlines = {}
for line in io.lines(file) do
for line in io.lines(file) do
readlines[#readlines + 1] = line
end
print(ansicolors.yellow..'\nLoading password file finished'..ansicolors.reset)
@ -142,7 +142,7 @@ end
-- write to file
local function writeOutputBytes(bytes, outfile)
local fileout,err = io.open(outfile,"wb")
if err then
if err then
print("### ERROR - Faild to open output-file "..outfile)
return false
end
@ -265,34 +265,34 @@ local function main(args)
return help()
end
-- start hex value
if option == 's' then
if option == 's' then
start_id = argument
end
-- end hex value
if option == 'e' then
if option == 'e' then
end_id = argument
end
-- timeout
if option == 't' then
if option == 't' then
timeout = argument
end
-- input file
if option == 'i' then
if option == 'i' then
infile = argument
if (file_check(infile) == false) then
return oops('Input file: '..infile..' not found')
if (file_check(infile) == false) then
return oops('Input file: '..infile..' not found')
else
input_file_valid = true
end
bruteforce = false
end
-- skip ping
if option == 'p' then
if option == 'p' then
use_ping = false
end
-- passwordlist is hex values
if option == 'x' then
password_is_ascii = false
if option == 'x' then
password_is_ascii = false
pass_text = "Passwords in file is treated as: HEX"
bruteforce = false
end
@ -301,8 +301,8 @@ local function main(args)
outfile = argument
if (file_check(argument)) then
local answer = utils.confirm('\nThe output-file '..argument..' already exists!\nthis will delete the previous content!\ncontinue?')
if (answer == false) then
return oops('Quiting')
if (answer == false) then
return oops('Quiting')
end
end
end
@ -312,21 +312,21 @@ local function main(args)
bruteforce = false
end
-- help
if option == 'h' then
if option == 'h' then
return help()
end
end
-- min timeout is set to 1 sec if it is empty
timeout = tonumber(timeout)
if timeout < 10 then
timeout = 10
end
if timeout < 10 then
timeout = 10
end
-------------------------------------------------------------------------------------------------------------
-- BRUTEFORCE
-------------------------------------------------------------------------------------------------------------
-- select bruteforce method
if bruteforce then
if not check_if_number_is_hex(start_id) then
if not check_if_number_is_hex(start_id) then
print(ansicolors.red..'\n### ERROR - start_id value '..start_id..' is out of the range of a 32-bit integer (0 to 0xFFFFFFFF) - Did you forget to add 0x ?'..ansicolors.reset)
return
end
@ -346,7 +346,7 @@ local function main(args)
end
local cmd = string.format( command, hexvalue )
core.console(cmd)
print('[=] Tested password '..ansicolors.yellow..ansicolors.bright..string.format("%08X",hexvalue)..ansicolors.reset)
print('[=] Tested password '..ansicolors.yellow..ansicolors.bright..string.format("%08X",hexvalue)..ansicolors.reset)
print('[=] Ran command: "'..cmd..'"')
--core.console('msleep -t'..timeout);
if use_ping then
@ -359,8 +359,8 @@ local function main(args)
-- END BRUTEFORCE WITH CONTINUOUSLY HEX NUMBERS --
-----------------------------------------------------
else
if not input_file_valid then
return oops('Can not bruteforce without a password list file ( -i password_list_file.txt ) ')
if not input_file_valid then
return oops('Can not bruteforce without a password list file ( -i password_list_file.txt ) ')
end
-----------------------------------------------------
-- START BRUTEFORCE WITH PASSWORDS FROM A FILE --
@ -385,7 +385,7 @@ local function main(args)
else
if password_is_ascii then
------------
-- ASCII
-- ASCII
------------
if string.len(password) > 4 then
print('[!] Skipping password to long: '..password)

View file

@ -1391,7 +1391,7 @@ static int CmdHF15Dump(const char *Cmd) {
retry = 0;
blocknum++;
PrintAndLogEx(INPLACE, "blk %3d", blocknum );
PrintAndLogEx(INPLACE, "blk %3d", blocknum);
}
}

View file

@ -72,7 +72,7 @@ static int CmdHFKSX6924Balance(const char *Cmd) {
CLIParserFree(ctx);
SetAPDULogging(APDULogging);
if ( KSX6924TrySelect()) {
if (KSX6924TrySelect()) {
get_and_print_balance();
}
@ -272,7 +272,7 @@ static int CmdHFKSX6924Initialize(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Initialize Card : Mpda -> %02X %02X %02X %02X", data[0], data[1], data[2], data[3]);
uint8_t response[25] = {0};
if (KSX6924InitializeCard(data[0], data[1], data[2], data[3], response) ) {
if (KSX6924InitializeCard(data[0], data[1], data[2], data[3], response)) {
PrintAndLogEx(SUCCESS, "Response : %s", sprint_hex(response, sizeof(response)));
} else {
PrintAndLogEx(FAILED, "Initialize Card Error");

View file

@ -288,14 +288,14 @@ int CmdLFCommandRead(const char *Cmd) {
uint8_t n = 0;
crc_init_ref(&crc, 8, 0x1d, 0xff, 0, false, false);
uint8_t i;
for (i=0;i<cmd_len;i++) {
for (i = 0; i < cmd_len; i++) {
if ((cmd[i] != '0') && (cmd[i] != '1')) {
continue;
}
data <<= 1;
data += cmd[i] - '0';
n += 1;
if (n==8) {
if (n == 8) {
crc_update2(&crc, data, n);
n = 0;
data = 0;
@ -305,7 +305,7 @@ int CmdLFCommandRead(const char *Cmd) {
crc_update2(&crc, data, n);
}
uint8_t crc_final = crc_finish(&crc);
for (int j=7; j>=0; j--) {
for (int j = 7; j >= 0; j--) {
cmd[cmd_len] = ((crc_final >> j) & 1) ? '1' : '0';
cmd_len++;
}

View file

@ -216,6 +216,12 @@ const static vocabulory_t vocabulory[] = {
{ 0, "hf fido auth" },
{ 0, "hf fido make" },
{ 0, "hf fido assert" },
{ 1, "hf ksx6924 help" },
{ 0, "hf ksx6924 balance" },
{ 0, "hf ksx6924 info" },
{ 0, "hf ksx6924 initialize" },
{ 0, "hf ksx6924 prec" },
{ 0, "hf ksx6924 select" },
{ 1, "hf jooki help" },
{ 0, "hf jooki clone" },
{ 1, "hf jooki decode" },
@ -635,6 +641,9 @@ const static vocabulory_t vocabulory[] = {
{ 0, "lf visa2000 reader" },
{ 0, "lf visa2000 clone" },
{ 0, "lf visa2000 sim" },
{ 1, "lf zx help" },
{ 1, "lf zx demod" },
{ 0, "lf zx reader" },
{ 1, "mem help" },
{ 0, "mem baudrate" },
{ 0, "mem dump" },