code style, code clean up of redundant functions, comments, its many minor fixes across the platform. Sorry for not making 20 commits
This commit is contained in:
1 parent
6bb7199a7b
commit
cef07dedf6
57 files changed
+672
-521
No files matched your search
@@ -10,7 +10,7 @@ local green = ac.green
|
||||
|
||||
author = ' Author: jareckib - created 04.02.2025'
|
||||
version = ' version v1.05'
|
||||
desc = [[
|
||||
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
|
||||
@@ -102,11 +102,11 @@ local function main(args)
|
||||
|
||||
for o, a in getopt.getopt(args, 'hs:e:dy') do
|
||||
if o == 'h' then return help() end
|
||||
if o == 's' then
|
||||
if o == 's' then
|
||||
start_year = tonumber(a)
|
||||
if not start_year then return oops(' Invalid start year') end
|
||||
end
|
||||
if o == 'e' then
|
||||
if o == 'e' then
|
||||
end_year = tonumber(a)
|
||||
if not end_year then return oops(' Invalid end year') end
|
||||
end
|
||||
@@ -115,13 +115,13 @@ local function main(args)
|
||||
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')
|
||||
if start_year < 1900 or start_year > 2100 then
|
||||
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 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')
|
||||
if end_year < 1900 or end_year > 2100 then
|
||||
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
|
||||
@@ -130,7 +130,7 @@ local function main(args)
|
||||
if generate_dictionary(start_year, end_year, mode) then
|
||||
print(ac.green .. " File created: " .. dictionary_path .. res)
|
||||
print(cyan .. " Starting password testing on T5577..." .. res)
|
||||
core.console('lf t55 chk -f ' .. dictionary_path)
|
||||
core.console('lf t55 chk -f ' .. dictionary_path)
|
||||
else
|
||||
return oops('Problem saving the file')
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ local dash = string.rep('--', 32)
|
||||
|
||||
author = ' Author: jareckib - created 01.02.2025'
|
||||
version = ' version v1.01'
|
||||
desc = [[
|
||||
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
|
||||
@@ -84,11 +84,11 @@ local function get_valid_year_input(prompt)
|
||||
local year
|
||||
while true do
|
||||
io.write(prompt)
|
||||
local input = io.read()
|
||||
local input = io.read()
|
||||
if input == "" then
|
||||
print(ac.yellow .. ' ERROR: ' .. ac.reset .. 'Year cannot be empty')
|
||||
else
|
||||
year = tonumber(input)
|
||||
year = tonumber(input)
|
||||
if not year then
|
||||
print(ac.yellow .. ' ERROR: ' .. ac.reset .. 'Invalid input (digits only)')
|
||||
elseif year < 1900 then
|
||||
@@ -155,7 +155,7 @@ local function main(args)
|
||||
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)
|
||||
core.console('lf t55 chk -f ' .. dictionary_path)
|
||||
core.console('lf t55 chk -f ' .. dictionary_path)
|
||||
else
|
||||
print(ac.yellow .. ' ERROR: ' .. ac.reset .. 'Problem saving the file.')
|
||||
end
|
||||
|
||||
@@ -9,11 +9,11 @@ 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
|
||||
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 = [[
|
||||
@@ -91,7 +91,7 @@ end
|
||||
local function main(args)
|
||||
for o, a in getopt.getopt(args, 'h') do
|
||||
if o == 'h' then return help() end
|
||||
end
|
||||
end
|
||||
command('lf t55 chk')
|
||||
local log_content = read_log_file(logfile)
|
||||
local password = log_content and extract_password(log_content) or nil
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# paxton_net.py - Convert Paxton Net2 to EM4102
|
||||
# Author jareckib <jareckib@hotmail.com>
|
||||
# Author jareckib <jareckib@hotmail.com>
|
||||
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
||||
#
|
||||
# This code is copyright (c) jareckib, 2025, All rights reserved.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# paxton_convert.py - Convert Paxton Net2 and Switch2 to EM4102
|
||||
# Author jareckib <jareckib@hotmail.com>
|
||||
# Author jareckib <jareckib@hotmail.com>
|
||||
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
||||
#
|
||||
# This code is copyright (c) jareckib, 2025, All rights reserved.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# paxton_switch.py - Convert Paxton Switch2 to EM4102
|
||||
# Author jareckib <jareckib@hotmail.com>
|
||||
# Author jareckib <jareckib@hotmail.com>
|
||||
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
||||
#
|
||||
# This code is copyright (c) jareckib, 2025, All rights reserved.
|
||||
|
||||
@@ -194,7 +194,7 @@ def Describe_Usage_2_1(Usage, ContractMediumEndDate, Certificate):
|
||||
EventGeoRoute_Direction = Usage.nom(2)
|
||||
EventGeoVehicleId = Usage.nom(16)
|
||||
EventCountPassengers_mb = Usage.nom(4)
|
||||
|
||||
|
||||
EventValidityTimeFirstStamp = Usage.nom(11)
|
||||
|
||||
print(' EventDateStamp : {} ({})'.format(EventDateStamp, (datetime(1997, 1, 1) + timedelta(days = ContractMediumEndDate - EventDateStamp)).strftime('%Y-%m-%d')))
|
||||
@@ -446,7 +446,7 @@ def main():
|
||||
oa = MAR_OrganizationalAuthority_Contract_Provider.get(OrganizationalAuthority)
|
||||
else:
|
||||
oa = None
|
||||
|
||||
|
||||
if (oa is not None):
|
||||
s = oa.get(ContractProvider)
|
||||
if (s is not None):
|
||||
|
||||
+10
-7
@@ -3784,22 +3784,22 @@ int CmdHF14AAIDSim(const char *Cmd) {
|
||||
|
||||
if (ats_len > sizeof(ats)) {
|
||||
PrintAndLogEx(ERR, "Provided ATS too long");
|
||||
return PM3_EINVARG;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (aid_len > sizeof(aid)) {
|
||||
PrintAndLogEx(ERR, "Provided AID too long");
|
||||
return PM3_EINVARG;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (selectaid_response_len > sizeof(selectaid_response)) {
|
||||
PrintAndLogEx(ERR, "Provided SelectAID response too long");
|
||||
return PM3_EINVARG;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (getdata_response_len > sizeof(getdata_response)) {
|
||||
PrintAndLogEx(ERR, "Provided GetData response too long");
|
||||
return PM3_EINVARG;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (ats_len > 0) {
|
||||
@@ -3857,14 +3857,17 @@ int CmdHF14AAIDSim(const char *Cmd) {
|
||||
bool keypress = kbd_enter_pressed();
|
||||
while (keypress == false) {
|
||||
|
||||
if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0)
|
||||
if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS)
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK)
|
||||
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) {
|
||||
break;
|
||||
}
|
||||
|
||||
keypress = kbd_enter_pressed();
|
||||
}
|
||||
|
||||
@@ -282,9 +282,9 @@ static const productName_t uidmapping[] = {
|
||||
static int CmdHF15Help(const char *Cmd);
|
||||
|
||||
static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
||||
|
||||
int reason = 0;
|
||||
int index = -1;
|
||||
index = originality_check_verify(uid, 8, signature, 32, PK_MFC);
|
||||
int index = originality_check_verify(uid, 8, signature, 32, PK_MFC);
|
||||
if (index >= 0) {
|
||||
reason = 1;
|
||||
} else {
|
||||
@@ -306,11 +306,12 @@ static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
||||
}
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
int ret = originality_check_print(signature, 32, index);
|
||||
if (ret != PM3_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (reason) {
|
||||
case 1:
|
||||
PrintAndLogEx(INFO, " Params used: UID and signature, plain");
|
||||
|
||||
+11
-11
@@ -3246,14 +3246,14 @@ void print_iclass_sio(uint8_t *iclass_dump, size_t dump_len, bool verbose) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---------------------------- " _CYAN_("SIO - RAW") " ----------------------------");
|
||||
PrintAndLogEx(INFO, "--------------------------- " _CYAN_("SIO - RAW") " -----------------------------");
|
||||
print_hex_noascii_break(sio_start, sio_length, 32);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "----------------------- " _CYAN_("SIO - ASN1 TLV") " ---------------------------");
|
||||
asn1_print(sio_start, sio_length, " ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
asn1_print(sio_start, sio_length, " ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
}
|
||||
|
||||
void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize, bool dense_output) {
|
||||
@@ -3869,7 +3869,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
arg_lit0(NULL, "vb6kdf", "use the VB6 elite KDF instead of a file"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
||||
int fnlen = 0;
|
||||
char filename[FILE_PATH_SIZE] = {0};
|
||||
@@ -5425,7 +5425,7 @@ static int CmdHFiClassSAM(const char *Cmd) {
|
||||
data[0] = flags;
|
||||
|
||||
int cmdlen = 0;
|
||||
if (CLIParamHexToBuf(arg_get_str(ctx, 8), data+1, PM3_CMD_DATA_SIZE-1, &cmdlen) != PM3_SUCCESS){
|
||||
if (CLIParamHexToBuf(arg_get_str(ctx, 8), data + 1, PM3_CMD_DATA_SIZE - 1, &cmdlen) != PM3_SUCCESS) {
|
||||
CLIParserFree(ctx);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
@@ -5437,7 +5437,7 @@ static int CmdHFiClassSAM(const char *Cmd) {
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_SAM_PICOPASS, data, cmdlen+1);
|
||||
SendCommandNG(CMD_HF_SAM_PICOPASS, data, cmdlen + 1);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_HF_SAM_PICOPASS, &resp, 4000) == false) {
|
||||
PrintAndLogEx(WARNING, "SAM timeout");
|
||||
@@ -5495,11 +5495,11 @@ static int CmdHFiClassSAM(const char *Cmd) {
|
||||
const uint8_t *mediaType = oid + 2 + oid_length;
|
||||
const uint8_t mediaType_data = mediaType[2];
|
||||
PrintAndLogEx(SUCCESS, "SIO Media Type: " _GREEN_("%s"), getSioMediaTypeInfo(mediaType_data));
|
||||
} else if(breakOnNrMac && d[0] == 0x05) {
|
||||
PrintAndLogEx(SUCCESS, "Nr-MAC: " _GREEN_("%s"), sprint_hex_inrow(d+1, 8));
|
||||
if(verbose){
|
||||
} else if (breakOnNrMac && d[0] == 0x05) {
|
||||
PrintAndLogEx(SUCCESS, "Nr-MAC: " _GREEN_("%s"), sprint_hex_inrow(d + 1, 8));
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "Replay Nr-MAC to dump SIO:");
|
||||
PrintAndLogEx(SUCCESS, " hf iclass dump -k \"%s\" --nr", sprint_hex_inrow(d+1, 8));
|
||||
PrintAndLogEx(SUCCESS, " hf iclass dump -k \"%s\" --nr", sprint_hex_inrow(d + 1, 8));
|
||||
}
|
||||
} else {
|
||||
print_hex(d, resp.length);
|
||||
|
||||
+46
-35
@@ -70,7 +70,6 @@ static int usage_hf14_keybrute(void) {
|
||||
|
||||
int mfc_ev1_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len) {
|
||||
int index = originality_check_verify(uid, uidlen, signature, signature_len, PK_MFC);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return originality_check_print(signature, signature_len, index);
|
||||
}
|
||||
|
||||
@@ -306,31 +305,31 @@ static void mf_print_block(uint8_t blockno, uint8_t *d, bool verbose) {
|
||||
ascii_to_buffer((uint8_t *)ascii, d, MFBLOCK_SIZE, sizeof(ascii) - 1, 1);
|
||||
|
||||
if (blockno >= MIFARE_1K_MAXBLOCK) {
|
||||
PrintAndLogEx(INFO,
|
||||
_BACK_BLUE_("%s| %3d | " _YELLOW_("%s"))
|
||||
_BACK_BLUE_(_MAGENTA_("%s"))
|
||||
_BACK_BLUE_("%02X ")
|
||||
_BACK_BLUE_(_YELLOW_("%s"))
|
||||
_BACK_BLUE_("| " _YELLOW_("%s"))
|
||||
,
|
||||
secstr,
|
||||
blockno,
|
||||
keya,
|
||||
acl,
|
||||
d[9],
|
||||
keyb,
|
||||
ascii
|
||||
);
|
||||
PrintAndLogEx(INFO,
|
||||
_BACK_BLUE_("%s| %3d | " _YELLOW_("%s"))
|
||||
_BACK_BLUE_(_MAGENTA_("%s"))
|
||||
_BACK_BLUE_("%02X ")
|
||||
_BACK_BLUE_(_YELLOW_("%s"))
|
||||
_BACK_BLUE_("| " _YELLOW_("%s"))
|
||||
,
|
||||
secstr,
|
||||
blockno,
|
||||
keya,
|
||||
acl,
|
||||
d[9],
|
||||
keyb,
|
||||
ascii
|
||||
);
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "%s| %3d | " _YELLOW_("%s") _MAGENTA_("%s") "%02X " _YELLOW_("%s") "| " _YELLOW_("%s"),
|
||||
secstr,
|
||||
blockno,
|
||||
keya,
|
||||
acl,
|
||||
d[9],
|
||||
keyb,
|
||||
ascii
|
||||
);
|
||||
secstr,
|
||||
blockno,
|
||||
keya,
|
||||
acl,
|
||||
d[9],
|
||||
keyb,
|
||||
ascii
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -746,6 +745,7 @@ static int mfc_read_tag(iso14a_card_select_t *card, uint8_t *carddata, uint8_t n
|
||||
free(fptr);
|
||||
free(keyA);
|
||||
free(keyB);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "\nSucceeded in dumping all blocks");
|
||||
return PM3_SUCCESS ;
|
||||
}
|
||||
@@ -2138,7 +2138,7 @@ static int CmdHF14AMfNestedStatic(const char *Cmd) {
|
||||
e_sector[sectorNo].foundKey[trgKeyType] = 1;
|
||||
e_sector[sectorNo].Key[trgKeyType] = bytes_to_num(keyBlock, 6);
|
||||
|
||||
// mfCheckKeys_fast(SectorsCnt, true, true, 2, 1, keyBlock, e_sector, false, false);
|
||||
// mf_check_keys_fast(SectorsCnt, true, true, 2, 1, keyBlock, e_sector, false, false);
|
||||
continue;
|
||||
default :
|
||||
PrintAndLogEx(ERR, "unknown error.\n");
|
||||
@@ -2955,7 +2955,7 @@ noValidKeyFound:
|
||||
|
||||
// Try the found keys are reused
|
||||
if (bytes_to_num(tmp_key, MIFARE_KEY_SIZE) != 0) {
|
||||
// <!> The fast check --> mfCheckKeys_fast(sector_cnt, true, true, 2, 1, tmp_key, e_sector, false, verbose);
|
||||
// <!> The fast check --> mf_check_keys_fast(sector_cnt, true, true, 2, 1, tmp_key, e_sector, false, verbose);
|
||||
// <!> Returns false keys, so we just stick to the slower mfchk.
|
||||
for (int i = 0; i < sector_cnt; i++) {
|
||||
for (int j = MF_KEY_A; j <= MF_KEY_B; j++) {
|
||||
@@ -4251,6 +4251,7 @@ static int CmdHF14AMfSim(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "Note: option -e implies -i");
|
||||
flags |= FLAG_INTERACTIVE;
|
||||
}
|
||||
|
||||
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) {
|
||||
PrintAndLogEx(WARNING, "Option -e requires -x or -y");
|
||||
return PM3_EINVARG;
|
||||
@@ -4278,22 +4279,27 @@ static int CmdHF14AMfSim(const char *Cmd) {
|
||||
|
||||
payload.flags = flags;
|
||||
payload.exitAfter = exitAfterNReads;
|
||||
|
||||
memcpy(payload.uid, uid, uidlen);
|
||||
|
||||
payload.atqa = (atqa[1] << 8) | atqa[0];
|
||||
payload.sak = sak[0];
|
||||
|
||||
clearCommandBuffer();
|
||||
|
||||
if (flags & FLAG_INTERACTIVE) {
|
||||
if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) {
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " or a key to abort simulation");
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " or send another cmd to abort simulation");
|
||||
}
|
||||
|
||||
bool cont;
|
||||
do {
|
||||
|
||||
cont = false;
|
||||
SendCommandNG(CMD_HF_MIFARE_SIMULATE, (uint8_t *)&payload, sizeof(payload));
|
||||
if (flags & FLAG_INTERACTIVE) {
|
||||
|
||||
if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) {
|
||||
PacketResponseNG resp;
|
||||
sector_t *k_sector = NULL;
|
||||
|
||||
@@ -4305,19 +4311,24 @@ static int CmdHF14AMfSim(const char *Cmd) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS)
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK)
|
||||
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) {
|
||||
break;
|
||||
}
|
||||
|
||||
const nonces_t *data = (nonces_t *)resp.data.asBytes;
|
||||
readerAttack(k_sector, k_sectors_cnt, data[0], setEmulatorMem, verbose);
|
||||
|
||||
if (setEmulatorMem) {
|
||||
cont = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (keypress) {
|
||||
if ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) {
|
||||
// inform device to break the sim loop since client has exited
|
||||
@@ -7851,7 +7862,7 @@ static int CmdHF14AMfView(const char *Cmd) {
|
||||
if (bytes_read == MIFARE_MINI_MAX_BYTES)
|
||||
block_cnt = MIFARE_MINI_MAXBLOCK;
|
||||
else if (bytes_read == MIFARE_1K_EV1_MAX_BYTES)
|
||||
block_cnt = MIFARE_1K_EV1_MAXBLOCK;
|
||||
block_cnt = MIFARE_1K_EV1_MAXBLOCK;
|
||||
else if (bytes_read == MIFARE_2K_MAX_BYTES)
|
||||
block_cnt = MIFARE_2K_MAXBLOCK;
|
||||
else if (bytes_read == MIFARE_4K_MAX_BYTES)
|
||||
@@ -9623,7 +9634,7 @@ static int CmdHF14AMfInfo(const char *Cmd) {
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) {
|
||||
PrintAndLogEx(DEBUG, "iso14443a card select timeout");
|
||||
return 0;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
iso14a_card_select_t card;
|
||||
@@ -9721,9 +9732,9 @@ static int CmdHF14AMfInfo(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t k08s[6] = {0xA3, 0x96, 0xEF, 0xA4, 0xE2, 0x4F};
|
||||
uint8_t k08[6] = {0xA3, 0x16, 0x67, 0xA8, 0xCE, 0xC1};
|
||||
uint8_t k32[6] = {0x51, 0x8B, 0x33, 0x54, 0xE7, 0x60};
|
||||
uint8_t k08s[MIFARE_KEY_SIZE] = {0xA3, 0x96, 0xEF, 0xA4, 0xE2, 0x4F};
|
||||
uint8_t k08[MIFARE_KEY_SIZE] = {0xA3, 0x16, 0x67, 0xA8, 0xCE, 0xC1};
|
||||
uint8_t k32[MIFARE_KEY_SIZE] = {0x51, 0x8B, 0x33, 0x54, 0xE7, 0x60};
|
||||
if (mf_read_block(0, 4, k08s, blockdata) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Backdoor key..... " _YELLOW_("%s"), sprint_hex_inrow(k08s, sizeof(k08s)));
|
||||
fKeyType = MF_KEY_BD;
|
||||
|
||||
@@ -192,7 +192,6 @@ static nxp_cardtype_t getCardType(uint8_t type, uint8_t major, uint8_t minor) {
|
||||
// --- GET SIGNATURE
|
||||
static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len) {
|
||||
int index = originality_check_verify(uid, uidlen, signature, signature_len, PK_MFP);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return originality_check_print(signature, signature_len, index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1417,7 +1417,6 @@ static int ulev1_print_signature(uint64_t tagtype, uint8_t *uid, uint8_t *signat
|
||||
} else if (signature_len == 48) {
|
||||
index = originality_check_verify(uid, 7, signature, signature_len, PK_MFULAES);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return originality_check_print(signature, signature_len, index);
|
||||
}
|
||||
|
||||
@@ -2451,7 +2450,6 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
||||
}
|
||||
// check signature
|
||||
int index = originality_check_verify_ex(card.uid, 7, signature, sizeof(signature), PK_ST25TN, false, true);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
originality_check_print(signature, sizeof(signature), index);
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -453,7 +453,7 @@ static int seos_challenge_get(uint8_t *RNDICC, uint8_t RNDICC_len, uint8_t keysl
|
||||
|
||||
char getChallengePre[21];
|
||||
strcpy(getChallengePre, "008700");
|
||||
|
||||
|
||||
// const char keyslot_str[3] = "01";
|
||||
//strcat(getChallengePre, keyslot_str);
|
||||
snprintf(getChallengePre + strlen(getChallengePre), 3, "%02u", keyslot);
|
||||
@@ -547,7 +547,7 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t
|
||||
// Response is an ASN.1 encoded structure
|
||||
// Extract everything before the 8E tag
|
||||
|
||||
int res = PM3_EWRONGANSWER;
|
||||
int res = PM3_EWRONGANSWER;
|
||||
for (int i = 0; i < response_length; i++) {
|
||||
// extract MAC
|
||||
if (response[i] == 0x8E) {
|
||||
@@ -558,7 +558,7 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t
|
||||
}
|
||||
}
|
||||
if (res != PM3_SUCCESS) {
|
||||
goto out;
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------- MAC Key Generation -----------------
|
||||
@@ -579,7 +579,6 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t
|
||||
// PrintAndLogEx(INFO, "Supp MAC......................... " _YELLOW_("%s"), sprint_hex_inrow(MAC_value, MAC_value_len));
|
||||
// PrintAndLogEx(INFO, "Calc MAC......................... " _YELLOW_("%s"), sprint_hex_inrow(cmac, sizeof(cmac)));
|
||||
|
||||
out:
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("MAC") " ---------------------------");
|
||||
PrintAndLogEx(ERR, _RED_("MAC Verification Failed"));
|
||||
return PM3_ESOFT;
|
||||
@@ -760,9 +759,8 @@ static int seos_mutual_auth(uint8_t *randomICC, uint8_t *CRYPTOGRAM_Diversifier,
|
||||
uint8_t response[PM3_CMD_DATA_SIZE];
|
||||
|
||||
// ---------------- Diversify Keys ----------------
|
||||
uint8_t undiversified_key[16] = { 0x00 };
|
||||
memcpy(undiversified_key, keys[key_index].readKey, 16);
|
||||
|
||||
uint8_t mk[16] = { 0x00 };
|
||||
memcpy(mk, keys[key_index].readKey, 16);
|
||||
uint8_t keyslot = 0x01; // up to 0x0F
|
||||
uint8_t AES_key[24] = {0x00};
|
||||
uint8_t MAC_key[24] = {0x00};
|
||||
@@ -776,8 +774,8 @@ static int seos_mutual_auth(uint8_t *randomICC, uint8_t *CRYPTOGRAM_Diversifier,
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
seos_kdf(true, undiversified_key, keyslot, adfOID, sizeof(adfOID), CRYPTOGRAM_Diversifier, diversifier_len, AES_key, encryption_algorithm, hash_algorithm);
|
||||
seos_kdf(false, undiversified_key, keyslot, adfOID, sizeof(adfOID), CRYPTOGRAM_Diversifier, diversifier_len, MAC_key, encryption_algorithm, hash_algorithm);
|
||||
seos_kdf(true, mk, keyslot, adfOID, sizeof(adfOID), CRYPTOGRAM_Diversifier, diversifier_len, AES_key, encryption_algorithm, hash_algorithm);
|
||||
seos_kdf(false, mk, keyslot, adfOID, sizeof(adfOID), CRYPTOGRAM_Diversifier, diversifier_len, MAC_key, encryption_algorithm, hash_algorithm);
|
||||
|
||||
memcpy(&MAC_key[16], &MAC_key[0], 8);
|
||||
memcpy(&AES_key[16], &AES_key[0], 8);
|
||||
@@ -976,7 +974,9 @@ static int seos_aid_select(void) {
|
||||
// if we made it here, its a success and we break :)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == ARRAYLEN(known_AID_map)) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -1668,7 +1668,7 @@ static int CmdHfSeosSAM(const char *Cmd) {
|
||||
data[0] = flags;
|
||||
|
||||
int cmdlen = 0;
|
||||
if (CLIParamHexToBuf(arg_get_str(ctx, 5), data+1, PM3_CMD_DATA_SIZE-1, &cmdlen) != PM3_SUCCESS){
|
||||
if (CLIParamHexToBuf(arg_get_str(ctx, 5), data + 1, PM3_CMD_DATA_SIZE - 1, &cmdlen) != PM3_SUCCESS) {
|
||||
CLIParserFree(ctx);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
@@ -1680,7 +1680,7 @@ static int CmdHfSeosSAM(const char *Cmd) {
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_SAM_SEOS, data, cmdlen+1);
|
||||
SendCommandNG(CMD_HF_SAM_SEOS, data, cmdlen + 1);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_HF_SAM_SEOS, &resp, 4000) == false) {
|
||||
PrintAndLogEx(WARNING, "SAM timeout");
|
||||
|
||||
@@ -150,7 +150,6 @@ static void print_st25ta_system_info(uint8_t *d, uint8_t n) {
|
||||
|
||||
static int print_st25ta_signature(uint8_t *uid, uint8_t *signature) {
|
||||
int index = originality_check_verify_ex(uid, 7, signature, 32, PK_ST25TA, false, true);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return originality_check_print(signature, 32, index);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,25 +136,28 @@ const ecdsa_publickey_ng_t manufacturer_public_keys[] = {
|
||||
};
|
||||
|
||||
|
||||
// return pk if match index else -1
|
||||
// returns index of pk if match else -1
|
||||
int originality_check_verify(uint8_t *data, uint8_t data_len, uint8_t *signature, uint8_t signature_len, pk_type_t type) {
|
||||
return originality_check_verify_ex(data, data_len, signature, signature_len, type, false, false);
|
||||
}
|
||||
|
||||
int originality_check_verify_ex(uint8_t *data, uint8_t data_len, uint8_t *signature, uint8_t signature_len, pk_type_t type, bool reverse, bool hash) {
|
||||
// test if signature is null
|
||||
// test if signature is all zeros
|
||||
bool is_zero = true;
|
||||
for (uint8_t i = 0; i < signature_len; i++) {
|
||||
if (signature[i] != 0) {
|
||||
is_zero = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_zero) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t tmp_data[data_len];
|
||||
uint8_t tmp_signature[signature_len];
|
||||
|
||||
if (reverse) {
|
||||
reverse_array_copy(data, data_len, tmp_data);
|
||||
reverse_array_copy(signature, signature_len, tmp_signature);
|
||||
@@ -180,17 +183,24 @@ int originality_check_verify_ex(uint8_t *data, uint8_t data_len, uint8_t *signat
|
||||
}
|
||||
|
||||
int originality_check_print(uint8_t *signature, int signature_len, int index) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
if ((index < 0) || (index >= ARRAYLEN(manufacturer_public_keys))) {
|
||||
|
||||
PrintAndLogEx(INFO, " TAG IC Signature: %s", sprint_hex_inrow(signature, 16));
|
||||
if (signature_len > 16) {
|
||||
PrintAndLogEx(INFO, " : %s", sprint_hex_inrow(signature + 16, 16));
|
||||
}
|
||||
|
||||
if (signature_len > 32) {
|
||||
PrintAndLogEx(INFO, " : %s", sprint_hex_inrow(signature + 32, 16));
|
||||
}
|
||||
|
||||
if (signature_len > 48) {
|
||||
PrintAndLogEx(INFO, " : %s", sprint_hex_inrow(signature + 48, signature_len - 48));
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Signature verification: " _RED_("failed"));
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
@@ -200,23 +210,30 @@ int originality_check_print(uint8_t *signature, int signature_len, int index) {
|
||||
if (manufacturer_public_keys[index].keylen > 16) {
|
||||
PrintAndLogEx(INFO, " : %.32s", manufacturer_public_keys[index].value + 32);
|
||||
}
|
||||
|
||||
if (manufacturer_public_keys[index].keylen > 32) {
|
||||
PrintAndLogEx(INFO, " : %.32s", manufacturer_public_keys[index].value + 64);
|
||||
}
|
||||
|
||||
if (manufacturer_public_keys[index].keylen > 48) {
|
||||
PrintAndLogEx(INFO, " : %.32s", manufacturer_public_keys[index].value + 96);
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, " Elliptic curve parameters: %s", mbedtls_ecp_curve_info_from_grp_id(manufacturer_public_keys[index].grp_id)->name);
|
||||
PrintAndLogEx(INFO, " TAG IC Signature: %s", sprint_hex_inrow(signature, 16));
|
||||
|
||||
if (signature_len > 16) {
|
||||
PrintAndLogEx(INFO, " : %s", sprint_hex_inrow(signature + 16, 16));
|
||||
}
|
||||
|
||||
if (signature_len > 32) {
|
||||
PrintAndLogEx(INFO, " : %s", sprint_hex_inrow(signature + 32, 16));
|
||||
}
|
||||
|
||||
if (signature_len > 48) {
|
||||
PrintAndLogEx(INFO, " : %s", sprint_hex_inrow(signature + 48, signature_len - 48));
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Signature verification: " _GREEN_("successful"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -1031,7 +1031,7 @@ int DesfireSelectAndAuthenticateEx(DesfireContext_t *dctx, DesfireSecureChannel
|
||||
isosw = true;
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "Switch to " _CYAN_("native") " for select");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int res;
|
||||
@@ -1055,7 +1055,7 @@ int DesfireSelectAndAuthenticateEx(DesfireContext_t *dctx, DesfireSecureChannel
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "App %06x " _GREEN_("selected"), aid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isosw) {
|
||||
@@ -1124,7 +1124,7 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "Application %s file iso id %04x is " _GREEN_("selected"), DesfireWayIDStr(way, id), isofileid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!noauth) {
|
||||
|
||||
+15
-12
@@ -188,7 +188,7 @@ static uint16_t madGetAID(const uint8_t *sector, bool swapmad, int MADver, int s
|
||||
}
|
||||
}
|
||||
|
||||
int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) {
|
||||
int MADCheck(uint8_t *sector0, uint8_t *sector16, bool verbose, bool *haveMAD2) {
|
||||
|
||||
if (sector0 == NULL)
|
||||
return PM3_EINVARG;
|
||||
@@ -222,13 +222,13 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
|
||||
PrintAndLogEx(SUCCESS, "CRC8...... 0x%02X ( %s )", sector0[16], _GREEN_("ok"));
|
||||
}
|
||||
|
||||
if (mad_ver == 2 && sector10) {
|
||||
int res2 = madCRCCheck(sector10, true, 2);
|
||||
if (mad_ver == 2 && sector16) {
|
||||
int res2 = madCRCCheck(sector16, true, 2);
|
||||
if (res == PM3_SUCCESS)
|
||||
res = res2;
|
||||
|
||||
if (verbose && !res2)
|
||||
PrintAndLogEx(SUCCESS, "CRC8...... 0x%02X ( %s )", sector10[0], _GREEN_("ok"));
|
||||
PrintAndLogEx(SUCCESS, "CRC8...... 0x%02X ( %s )", sector16[0], _GREEN_("ok"));
|
||||
}
|
||||
|
||||
// MA (multi-application card)
|
||||
@@ -241,27 +241,30 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
|
||||
return res;
|
||||
}
|
||||
|
||||
int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen, bool swapmad) {
|
||||
int MADDecode(uint8_t *sector0, uint8_t *sector16, uint16_t *mad, size_t *madlen, bool swapmad) {
|
||||
*madlen = 0;
|
||||
bool haveMAD2 = false;
|
||||
int res = MADCheck(sector0, sector10, false, &haveMAD2);
|
||||
int res = MADCheck(sector0, sector16, false, &haveMAD2);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Not a valid MAD");
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i = 1; i < 16; i++) {
|
||||
// 7 + 8 == 15
|
||||
for (int i = 1; i <= 16; i++) {
|
||||
mad[*madlen] = madGetAID(sector0, swapmad, 1, i);
|
||||
(*madlen)++;
|
||||
}
|
||||
|
||||
if (haveMAD2) {
|
||||
// mad2 sector (0x10 == 16dec) here
|
||||
// mad2 sector (0x10 == 16) here
|
||||
mad[*madlen] = 0x0005;
|
||||
(*madlen)++;
|
||||
|
||||
// 7 + 8 + 8 == 23
|
||||
for (int i = 1; i < 24; i++) {
|
||||
mad[*madlen] = madGetAID(sector10, swapmad, 2, i);
|
||||
mad[*madlen] = madGetAID(sector16, swapmad, 2, i);
|
||||
|
||||
(*madlen)++;
|
||||
}
|
||||
}
|
||||
@@ -462,16 +465,16 @@ int convert_mad_to_arr(uint8_t *in, uint16_t ilen, uint8_t *out, uint16_t *olen)
|
||||
}
|
||||
|
||||
uint8_t sector0[MFBLOCK_SIZE * 4] = {0};
|
||||
uint8_t sector10[MFBLOCK_SIZE * 4] = {0};
|
||||
uint8_t sector16[MFBLOCK_SIZE * 4] = {0};
|
||||
|
||||
memcpy(sector0, in, sizeof(sector0));
|
||||
if (ilen == MIFARE_4K_MAX_BYTES) {
|
||||
memcpy(sector10, in + (MF_MAD2_SECTOR * 4 * MFBLOCK_SIZE), sizeof(sector10));
|
||||
memcpy(sector16, in + (MF_MAD2_SECTOR * 4 * MFBLOCK_SIZE), sizeof(sector16));
|
||||
}
|
||||
|
||||
uint16_t mad[7 + 8 + 8 + 8 + 8] = {0};
|
||||
size_t madlen = 0;
|
||||
if (MADDecode(sector0, sector10, mad, &madlen, false)) {
|
||||
if (MADDecode(sector0, sector16, mad, &madlen, false)) {
|
||||
PrintAndLogEx(ERR, "can't decode MAD");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2);
|
||||
int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen, bool swapmad);
|
||||
int MADCheck(uint8_t *sector0, uint8_t *sector16, bool verbose, bool *haveMAD2);
|
||||
int MADDecode(uint8_t *sector0, uint8_t *sector16, uint16_t *mad, size_t *madlen, bool swapmad);
|
||||
int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMAD2);
|
||||
int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose);
|
||||
int MADDFDecodeAndPrint(uint32_t short_aid, bool verbose);
|
||||
|
||||
@@ -1036,19 +1036,25 @@ int mf_write_sector(uint8_t sectorNo, uint8_t keyType, const uint8_t *key, uint8
|
||||
|
||||
// EMULATOR
|
||||
int mf_eml_get_mem(uint8_t *data, int blockNum, int blocksCount) {
|
||||
return mf_eml_get_mem_xt(data, blockNum, blocksCount, MFBLOCK_SIZE);
|
||||
}
|
||||
|
||||
size_t size = blocksCount * MFBLOCK_SIZE;
|
||||
int mf_eml_get_mem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {
|
||||
|
||||
size_t size = ((size_t) blocksCount) * blockBtWidth;
|
||||
if (size > PM3_CMD_DATA_SIZE) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
struct {
|
||||
uint8_t blockno;
|
||||
uint16_t blockno;
|
||||
uint8_t blockcnt;
|
||||
uint8_t blockwidth;
|
||||
} PACKED payload;
|
||||
|
||||
payload.blockno = blockNum;
|
||||
payload.blockcnt = blocksCount;
|
||||
payload.blockwidth = blockBtWidth;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFARE_EML_MEMGET, (uint8_t *)&payload, sizeof(payload));
|
||||
@@ -1059,8 +1065,9 @@ int mf_eml_get_mem(uint8_t *data, int blockNum, int blocksCount) {
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status == PM3_SUCCESS)
|
||||
if (resp.status == PM3_SUCCESS) {
|
||||
memcpy(data, resp.data.asBytes, size);
|
||||
}
|
||||
|
||||
return resp.status;
|
||||
}
|
||||
@@ -1072,7 +1079,7 @@ int mf_elm_set_mem(uint8_t *data, int blockNum, int blocksCount) {
|
||||
int mf_eml_set_mem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {
|
||||
|
||||
struct p {
|
||||
uint8_t blockno;
|
||||
uint16_t blockno;
|
||||
uint8_t blockcnt;
|
||||
uint8_t blockwidth;
|
||||
uint8_t data[];
|
||||
@@ -1226,7 +1233,7 @@ int mf_chinese_set_block(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t p
|
||||
if (!isOK) {
|
||||
|
||||
uint8_t reason = (resp.oldarg[1] & 0xFF);
|
||||
if ( reason == 4) {
|
||||
if (reason == 4) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(WARNING, "GDM magic write signature block failed");
|
||||
} else if (reason == 5) {
|
||||
|
||||
@@ -92,6 +92,7 @@ int mf_write_block(uint8_t blockno, uint8_t keyType, const uint8_t *key, uint8_t
|
||||
int mf_write_sector(uint8_t sectorNo, uint8_t keyType, const uint8_t *key, uint8_t *sector);
|
||||
|
||||
int mf_eml_get_mem(uint8_t *data, int blockNum, int blocksCount);
|
||||
int mf_eml_get_mem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
|
||||
int mf_elm_set_mem(uint8_t *data, int blockNum, int blocksCount);
|
||||
int mf_eml_set_mem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
|
||||
|
||||
|
||||
@@ -883,7 +883,7 @@ static bool Pack_H800002(int format_idx, wiegand_card_t *card,
|
||||
memset(packed, 0, sizeof(wiegand_message_t));
|
||||
|
||||
if (!validate_card_limit(format_idx, card)) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
packed->Length = 46;
|
||||
@@ -896,7 +896,7 @@ static bool Pack_H800002(int format_idx, wiegand_card_t *card,
|
||||
// Invert parity for setting odd parity
|
||||
set_bit_by_position(packed, even_parity ^ 1, 45);
|
||||
if (preamble) {
|
||||
return add_HID_header(packed);
|
||||
return add_HID_header(packed);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -906,7 +906,7 @@ static bool Unpack_H800002(wiegand_message_t *packed, wiegand_card_t *card) {
|
||||
memset(card, 0, sizeof(wiegand_card_t));
|
||||
|
||||
if (packed->Length != 46) {
|
||||
return false; // Wrong length? Stop here.
|
||||
return false; // Wrong length? Stop here.
|
||||
}
|
||||
|
||||
card->FacilityCode = get_linear_field(packed, 1, 14);
|
||||
@@ -1528,7 +1528,7 @@ int HIDFindCardFormat(const char *format) {
|
||||
static bool validate_card_limit(int format_idx, wiegand_card_t *card) {
|
||||
cardformatdescriptor_t card_descriptor = FormatTable[format_idx].Fields;
|
||||
return !((card->FacilityCode > card_descriptor.MaxFC) ||
|
||||
(card->CardNumber > card_descriptor.MaxCN)||
|
||||
(card->CardNumber > card_descriptor.MaxCN) ||
|
||||
(card->IssueLevel > card_descriptor.MaxIL) ||
|
||||
(card->OEM > card_descriptor.MaxOEM));
|
||||
}
|
||||
@@ -1586,7 +1586,7 @@ bool HIDTryUnpack(wiegand_message_t *packed) {
|
||||
if (found_cnt) {
|
||||
PrintAndLogEx(INFO, "found %u matching format%c with bit len %d", found_cnt, (found_cnt > 1) ? 's' : ' ', packed->Length);
|
||||
}
|
||||
|
||||
|
||||
if (packed->Length && ((found_cnt - found_invalid_par) == 0)) { // if length > 0 and no valid parity matches
|
||||
PrintAndLogEx(WARNING, "Wiegand unknown bit len %d", packed->Length);
|
||||
PrintAndLogEx(HINT, "Try 0xFFFF's http://cardinfo.barkweb.com.au/");
|
||||
@@ -1607,7 +1607,7 @@ void HIDUnpack(int idx, wiegand_message_t *packed) {
|
||||
// return true if at least one valid matching formats found
|
||||
bool decode_wiegand(uint32_t top, uint32_t mid, uint32_t bot, int n) {
|
||||
bool decode_result;
|
||||
|
||||
|
||||
if (top == 0 && mid == 0 && bot == 0) {
|
||||
decode_result = false;
|
||||
} else if ((n > 0) || ((mid & 0xFFFFFFC0) > 0)) { // if n > 0 or there's more than 38 bits
|
||||
|
||||
@@ -134,7 +134,7 @@ static uint8_t get_length_from_header(wiegand_message_t *data) {
|
||||
* Right now we just calculate the highest bit set
|
||||
* 38 bits format is handled by directly setting n=38 in initialize_message_object()
|
||||
* since it's hard to distinguish 38 bits with formats with preamble bit (26-36 bits)
|
||||
*
|
||||
*
|
||||
* (from http://www.proxmark.org/forum/viewtopic.php?pid=5368#p5368)
|
||||
* 0000 0010 0000 0000 01xx xxxx xxxx xxxx xxxx xxxx xxxx 26-bit
|
||||
* 0000 0010 0000 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx 27-bit
|
||||
@@ -156,7 +156,7 @@ static uint8_t get_length_from_header(wiegand_message_t *data) {
|
||||
if ((data->Top & 0x000FFFFF) > 0) { // > 64 bits
|
||||
hfmt = data->Top & 0x000FFFFF;
|
||||
len = 64;
|
||||
} else if (data->Mid > 0) {
|
||||
} else if (data->Mid > 0) {
|
||||
// detect HID format b38 set
|
||||
if (data->Mid & 0xFFFFFFC0) { // 39-64 bits
|
||||
hfmt = data->Mid;
|
||||
@@ -165,14 +165,14 @@ static uint8_t get_length_from_header(wiegand_message_t *data) {
|
||||
PrintAndLogEx(DEBUG, "hid preamble detected");
|
||||
|
||||
// if bit 38 is set: => 26-36 bits
|
||||
if (((data->Mid >> 5) & 1) == 1) {
|
||||
if (((data->Mid >> 5) & 1) == 1) {
|
||||
hfmt = (((data->Mid & 31) << 12) | (data->Bot >> 26)); //get bits 27-37 to check for format len bit
|
||||
len = 19;
|
||||
} else { // if bit 38 is not set => 37 bits
|
||||
hfmt = 0;
|
||||
len = 37;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hfmt = data->Bot;
|
||||
len = 0;
|
||||
|
||||
Reference in new issue
Block a user