mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
style
This commit is contained in:
@@ -285,12 +285,12 @@ static int ExecuteMode(int mode, int slot) {
|
||||
case LF_RWSB_MODE_WRITE:
|
||||
Dbprintf("[!!] >> Write mode started <<");
|
||||
copy_em410x_to_t55xx(LF_RWSB_T55XX_TYPE
|
||||
, LF_CLOCK
|
||||
, (uint32_t)(em4100rswb_low[slot] >> 32)
|
||||
, (uint32_t)(em4100rswb_low[slot] & 0xffffffff)
|
||||
, false
|
||||
, true
|
||||
);
|
||||
, LF_CLOCK
|
||||
, (uint32_t)(em4100rswb_low[slot] >> 32)
|
||||
, (uint32_t)(em4100rswb_low[slot] & 0xffffffff)
|
||||
, false
|
||||
, true
|
||||
);
|
||||
return LF_RWSB_UNKNOWN_RESULT;
|
||||
case LF_RWSB_MODE_BRUTE:
|
||||
Dbprintf("[=] >> Bruteforce mode started <<");
|
||||
|
||||
@@ -167,12 +167,12 @@ static void Wipe(void) {
|
||||
LED_C_ON();
|
||||
LED_D_ON();
|
||||
copy_em410x_to_t55xx(LF_RWSB_T55XX_TYPE
|
||||
, LF_CLOCK
|
||||
, (uint32_t) 0
|
||||
, (uint32_t) 0
|
||||
, false
|
||||
, false
|
||||
);
|
||||
, LF_CLOCK
|
||||
, (uint32_t) 0
|
||||
, (uint32_t) 0
|
||||
, false
|
||||
, false
|
||||
);
|
||||
SpinDelay(60);
|
||||
LEDsoff();
|
||||
LED_D_ON();
|
||||
@@ -290,12 +290,12 @@ static void Write(void) {
|
||||
LED_A_ON();
|
||||
LED_B_ON();
|
||||
copy_em410x_to_t55xx(LF_RWSB_T55XX_TYPE
|
||||
, LF_CLOCK
|
||||
, (uint32_t)(low >> 32)
|
||||
, (uint32_t)(low & 0xffffffff)
|
||||
, false
|
||||
, false
|
||||
);
|
||||
, LF_CLOCK
|
||||
, (uint32_t)(low >> 32)
|
||||
, (uint32_t)(low & 0xffffffff)
|
||||
, false
|
||||
, false
|
||||
);
|
||||
SpinDelay(75);
|
||||
LEDsoff();
|
||||
|
||||
|
||||
@@ -218,12 +218,12 @@ void RunMod(void) {
|
||||
} else if (button_pressed == BUTTON_SINGLE_CLICK) {
|
||||
// Click - write ID to tag
|
||||
copy_em410x_to_t55xx(0
|
||||
, LF_CLOCK
|
||||
, (uint32_t)(em4100rwc_low[selected] >> 32)
|
||||
, (uint32_t)(em4100rwc_low[selected] & 0xffffffff)
|
||||
, false
|
||||
, true
|
||||
);
|
||||
, LF_CLOCK
|
||||
, (uint32_t)(em4100rwc_low[selected] >> 32)
|
||||
, (uint32_t)(em4100rwc_low[selected] & 0xffffffff)
|
||||
, false
|
||||
, true
|
||||
);
|
||||
led_slot(selected);
|
||||
state = 0; // Switch to select mode
|
||||
}
|
||||
|
||||
+4
-4
@@ -2450,10 +2450,10 @@ int copy_em410x_to_t55xx(uint8_t card, uint8_t clock, uint32_t id_hi, uint32_t i
|
||||
if (ledcontrol) LEDsoff();
|
||||
|
||||
Dbprintf("Tag %s written with 0x%08x%08x",
|
||||
card == 0 ? "T5555" : (card == 1 ? "T55x7" : "EM4x05"),
|
||||
(uint32_t)(id >> 32),
|
||||
(uint32_t)id
|
||||
);
|
||||
card == 0 ? "T5555" : (card == 1 ? "T55x7" : "EM4x05"),
|
||||
(uint32_t)(id >> 32),
|
||||
(uint32_t)id
|
||||
);
|
||||
|
||||
if (add_electra) {
|
||||
Dbprintf("Electra 0x%08x%08x\n", electra[0], electra[1]);
|
||||
|
||||
+1
-1
@@ -438,7 +438,7 @@ int mifare_ultra_aes_auth(uint8_t keyno, uint8_t *keybytes) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("Cmd Error: %02x - expected 19 got " _RED_("%u"), resp[0], len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
memset(IV, 0, 16);
|
||||
mbedtls_aes_setkey_dec(&actx, key, 128);
|
||||
mbedtls_aes_crypt_cbc(&actx, MBEDTLS_AES_DECRYPT, sizeof(random_b), IV, resp + 1, random_b);
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
#define HOOKKEY "_HKEY"
|
||||
|
||||
static void checkstack (lua_State *L, lua_State *L1, int n) {
|
||||
if (L != L1 && !lua_checkstack(L1, n))
|
||||
luaL_error(L, "stack overflow");
|
||||
static void checkstack(lua_State *L, lua_State *L1, int n) {
|
||||
if (L != L1 && !lua_checkstack(L1, n))
|
||||
luaL_error(L, "stack overflow");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
static const char *getfuncname(lua_State *L, CallInfo *ci, const char **name);
|
||||
|
||||
static void swapextra (lua_State *L) {
|
||||
static void swapextra(lua_State *L) {
|
||||
if (L->status == LUA_YIELD) {
|
||||
CallInfo *ci = L->ci; /* get function that yielded */
|
||||
StkId temp = ci->func; /* exchange its 'func' and 'extra' values */
|
||||
@@ -337,11 +337,11 @@ static void kname(Proto *p, int pc, int c, const char **name) {
|
||||
*name = "?"; /* no reasonable name found */
|
||||
}
|
||||
|
||||
static int filterpc (int pc, int jmptarget) {
|
||||
if (pc < jmptarget) /* is code conditional (inside a jump)? */
|
||||
return -1; /* cannot know who sets that register */
|
||||
else
|
||||
return pc; /* current position sets that register */
|
||||
static int filterpc(int pc, int jmptarget) {
|
||||
if (pc < jmptarget) /* is code conditional (inside a jump)? */
|
||||
return -1; /* cannot know who sets that register */
|
||||
else
|
||||
return pc; /* current position sets that register */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -350,7 +350,7 @@ static int filterpc (int pc, int jmptarget) {
|
||||
static int findsetreg(Proto *p, int lastpc, int reg) {
|
||||
int pc;
|
||||
int setreg = -1; /* keep last instruction that changed 'reg' */
|
||||
int jmptarget = 0; /* any code before this address is conditional */
|
||||
int jmptarget = 0; /* any code before this address is conditional */
|
||||
for (pc = 0; pc < lastpc; pc++) {
|
||||
Instruction i = p->code[pc];
|
||||
OpCode op = GET_OPCODE(i);
|
||||
|
||||
@@ -330,8 +330,7 @@ Cfunc:
|
||||
if (!p->is_vararg) {
|
||||
func = restorestack(L, funcr);
|
||||
base = func + 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
base = adjust_varargs(L, p, n);
|
||||
func = restorestack(L, funcr); /* previous call can change stack */
|
||||
}
|
||||
|
||||
@@ -506,9 +506,9 @@ static lu_mem traversestack(global_State *g, lua_State *th) {
|
||||
} else { /* count call infos to compute size */
|
||||
CallInfo *ci;
|
||||
for (ci = &th->base_ci; ci != th->ci; ci = ci->next)
|
||||
n++;
|
||||
n++;
|
||||
}
|
||||
return sizeof(lua_State) + sizeof(TValue) * th->stacksize + sizeof(CallInfo) * n;
|
||||
return sizeof(lua_State) + sizeof(TValue) * th->stacksize + sizeof(CallInfo) * n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ typedef struct {
|
||||
|
||||
local function calypso_parse(result)
|
||||
if result.Length >= 0 then
|
||||
local response_byte = string.sub(result.Data, 0, 1);
|
||||
local datalen = string.sub(result.Data, 2, 5);
|
||||
local response_byte = string.sub(result.Data, 0, 1);
|
||||
local datalen = string.sub(result.Data, 2, 5);
|
||||
local d = string.sub(result.Data, 6, datalen * 2);
|
||||
return {
|
||||
response_byte = response_byte,
|
||||
|
||||
@@ -33,8 +33,8 @@ device-side.
|
||||
-- iceman, todo: return payload from ISO14b APDU is a struct now. iso14b_raw_apdu_response_t
|
||||
local function mobib_parse(result)
|
||||
if result.Length >= 0 then
|
||||
local response_byte = string.sub(result.Data, 0, 1);
|
||||
local datalen = string.sub(result.Data, 2, 5);
|
||||
local response_byte = string.sub(result.Data, 0, 1);
|
||||
local datalen = string.sub(result.Data, 2, 5);
|
||||
local d = string.sub(result.Data, 6, datalen * 2);
|
||||
return {
|
||||
response_byte = response_byte,
|
||||
|
||||
@@ -3709,13 +3709,13 @@ static int CmdCryptography(const char *Cmd) {
|
||||
}
|
||||
|
||||
// Encrypt(0) or decrypt(1)?
|
||||
if ((type & 0x8) >> 3) {
|
||||
if ((type & 0x8) >> 3) {
|
||||
|
||||
if ((type & 0x4) >> 2) { // AES or DES?
|
||||
|
||||
if (keylen > 8) {
|
||||
|
||||
PrintAndLogEx(INFO, "Called 3DES decrypt");
|
||||
PrintAndLogEx(INFO, "Called 3DES decrypt");
|
||||
des3_decrypt(dato, dati, key, keylen / 8);
|
||||
|
||||
} else {
|
||||
@@ -3728,8 +3728,8 @@ static int CmdCryptography(const char *Cmd) {
|
||||
des_decrypt_cbc(dato, dati, datilen, key, iv);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Called AES decrypt");
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Called AES decrypt");
|
||||
aes_decode(iv, key, dati, dato, datilen);
|
||||
}
|
||||
|
||||
@@ -3766,7 +3766,7 @@ static int CmdCryptography(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "Called DES encrypt");
|
||||
|
||||
if (ivlen == 0) {
|
||||
// If there's an IV, use ECB
|
||||
// If there's an IV, use ECB
|
||||
des_encrypt_ecb(dato, dati, datilen, key);
|
||||
} else {
|
||||
des_encrypt_cbc(dato, dati, datilen, key, iv);
|
||||
@@ -3780,8 +3780,8 @@ static int CmdCryptography(const char *Cmd) {
|
||||
} else {
|
||||
|
||||
if (type & 0x02) {
|
||||
PrintAndLogEx(INFO, "Called AES CMAC");
|
||||
// If we will calculate a MAC
|
||||
PrintAndLogEx(INFO, "Called AES CMAC");
|
||||
// If we will calculate a MAC
|
||||
aes_cmac8(iv, key, dati, dato, datilen);
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Called AES encrypt");
|
||||
@@ -3860,7 +3860,7 @@ static int CmdBinaryMap(const char *Cmd) {
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"},
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"},
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Modulation") "-------------------------"},
|
||||
{"biphaserawdecode", CmdBiphaseDecodeRaw, AlwaysAvailable, "Biphase decode bin stream in DemodBuffer"},
|
||||
|
||||
+77
-77
@@ -87,12 +87,12 @@ static int derive_app_key(uint8_t *uid, uint8_t *app_key) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
/*
|
||||
c = b'\x88' + uid
|
||||
ch, cl = c[0:4], c[4:8]
|
||||
payload = (ch + cl + cl + ch) * 2
|
||||
AES.new(ICT_DESFIRE_MASTER_APPKEY, AES.MODE_CBC, iv=b'\0'*16).decrypt(payload)[16:]
|
||||
*/
|
||||
/*
|
||||
c = b'\x88' + uid
|
||||
ch, cl = c[0:4], c[4:8]
|
||||
payload = (ch + cl + cl + ch) * 2
|
||||
AES.new(ICT_DESFIRE_MASTER_APPKEY, AES.MODE_CBC, iv=b'\0'*16).decrypt(payload)[16:]
|
||||
*/
|
||||
uint8_t input[] = {0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
memcpy(input + 1, uid, 7);
|
||||
|
||||
@@ -105,16 +105,16 @@ static int derive_app_key(uint8_t *uid, uint8_t *app_key) {
|
||||
|
||||
uint8_t iv[16] = {0};
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128)) {
|
||||
return PM3_ESOFT;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
uint8_t output[8];
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, sizeof(input), iv, input, output)) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
mbedtls_aes_free(&aes);
|
||||
mbedtls_aes_free(&aes);
|
||||
memcpy(app_key, output, sizeof(output));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -133,21 +133,21 @@ static int diversify_mifare_key(uint8_t *uid, uint8_t *app_key) {
|
||||
num_to_bytes(big, 4, input + 4);
|
||||
|
||||
uint8_t key[AES_KEY_LEN];
|
||||
memset(key, 0 , sizeof(key));
|
||||
memset(key, 0, sizeof(key));
|
||||
// memcpy(key, ICT_DESFIRE_FILEKEY, AES_KEY_LEN);
|
||||
|
||||
uint8_t iv[16] = {0};
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128)) {
|
||||
return PM3_ESOFT;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
uint8_t output[8];
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, sizeof(input), iv, input, output)) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
mbedtls_aes_free(&aes);
|
||||
mbedtls_aes_free(&aes);
|
||||
memcpy(app_key, output, sizeof(output));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -165,16 +165,16 @@ static int decrypt_card_sector(uint8_t *uid, uint8_t *sector_data, uint8_t len,
|
||||
|
||||
uint8_t iv[16] = {0};
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128)) {
|
||||
return PM3_ESOFT;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
uint8_t output[len];
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, sizeof(input), iv, input, output)) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
mbedtls_aes_free(&aes);
|
||||
mbedtls_aes_free(&aes);
|
||||
|
||||
memcpy(plain, output, sizeof(output));
|
||||
return PM3_SUCCESS;
|
||||
@@ -184,11 +184,11 @@ static int derive_mifare_key(uint8_t *uid, const uint8_t *base_key, uint8_t *app
|
||||
if (uid == NULL || base_key == NULL || app_key == NULL) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
uint8_t diverse[MIFARE_KEY_SIZE];
|
||||
diversify_mifare_key(uid, diverse);
|
||||
|
||||
for (uint8_t i=0; i < MIFARE_KEY_SIZE; i++) {
|
||||
for (uint8_t i = 0; i < MIFARE_KEY_SIZE; i++) {
|
||||
app_key[i] = base_key[i] ^ diverse[i];
|
||||
}
|
||||
|
||||
@@ -204,10 +204,10 @@ static int derive_mifare_key_b(uint8_t *uid, uint8_t *app_key) {
|
||||
}
|
||||
|
||||
static int decrypt_card_file(uint8_t *card_file, uint8_t len, uint8_t *plain) {
|
||||
if (card_file == NULL || plain == NULL) {
|
||||
if (card_file == NULL || plain == NULL) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
uint8_t input[ICT_FILE_SIZE];
|
||||
memcpy(input, card_file, len);
|
||||
|
||||
@@ -216,11 +216,11 @@ static int decrypt_card_file(uint8_t *card_file, uint8_t len, uint8_t *plain) {
|
||||
|
||||
uint8_t iv[16] = {0};
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128)) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
uint8_t output[ICT_FILE_SIZE];
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, ICT_FILE_SIZE, iv, input, output)) {
|
||||
return PM3_ESOFT;
|
||||
@@ -248,16 +248,16 @@ static int encrypt_card_file(uint8_t *card_file, uint8_t len, bool padding, uint
|
||||
|
||||
uint8_t iv[16] = {0};
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128)) {
|
||||
return PM3_ESOFT;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
uint8_t output[ICT_FILE_SIZE];
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, ICT_FILE_SIZE, iv, input, output)) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
mbedtls_aes_free(&aes);
|
||||
mbedtls_aes_free(&aes);
|
||||
memcpy(enc, output, sizeof(output));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -266,56 +266,56 @@ static void itc_decode_card_blob(uint8_t *data, uint8_t card_type) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
uint8_t block[16];
|
||||
if (card_type == ICT_CT_NFC)
|
||||
memcpy(block, data+16, sizeof(block));
|
||||
else
|
||||
memcpy(block, data, sizeof(block));
|
||||
/*
|
||||
uint8_t block[16];
|
||||
if (card_type == ICT_CT_NFC)
|
||||
memcpy(block, data+16, sizeof(block));
|
||||
else
|
||||
memcpy(block, data, sizeof(block));
|
||||
|
||||
uint8_t bit_count = data[8];
|
||||
uint8_t bit_count = data[8];
|
||||
|
||||
uint8_t wiegand[32];
|
||||
uint8_t wiegand[32];
|
||||
|
||||
if (card_type == ICT_CT_DESFIRE || card_type == ICT_CT_NFC) {
|
||||
memcpy(wiegand, data + 11, 32-11);
|
||||
}
|
||||
if (card_type == ICT_CT_DESFIRE || card_type == ICT_CT_NFC) {
|
||||
memcpy(wiegand, data + 11, 32-11);
|
||||
}
|
||||
|
||||
if (card_type == ICT_CT_CLASSIC) {
|
||||
memcpy(wiegand, data + 9, 32-9);
|
||||
}
|
||||
if (card_type == ICT_CT_CLASSIC) {
|
||||
memcpy(wiegand, data + 9, 32-9);
|
||||
}
|
||||
|
||||
if (bit_count == 26) {
|
||||
fc, cn = decode_wiegand_26(wiegand_payload)
|
||||
ct = "Wiegand 26-bit"
|
||||
}
|
||||
if (bit_count == 34) {
|
||||
fc, cn = decode_wiegand_34(wiegand_payload)
|
||||
ct = "Wiegand 34-bit"
|
||||
}else {
|
||||
return f"Unknown format (bitlength={bit_count})", None, None
|
||||
}
|
||||
if (bit_count == 26) {
|
||||
fc, cn = decode_wiegand_26(wiegand_payload)
|
||||
ct = "Wiegand 26-bit"
|
||||
}
|
||||
if (bit_count == 34) {
|
||||
fc, cn = decode_wiegand_34(wiegand_payload)
|
||||
ct = "Wiegand 34-bit"
|
||||
}else {
|
||||
return f"Unknown format (bitlength={bit_count})", None, None
|
||||
}
|
||||
|
||||
return ct, fc, cn
|
||||
*/
|
||||
return ct, fc, cn
|
||||
*/
|
||||
}
|
||||
static void itc_encode_card_blob(uint8_t facility_code, uint16_t card_number, uint8_t bit_count) {
|
||||
/*
|
||||
// encode wiegand ..
|
||||
uint8_t wiegand[] = {0,0,0,0,0};
|
||||
if (bit_count == 26) {
|
||||
// wiegand_data = encode_wiegand_26(facility_code, card_number)
|
||||
}
|
||||
if (bit_count == 34) {
|
||||
// wiegand_data = encode_wiegand_34(facility_code, card_number)
|
||||
}
|
||||
/*
|
||||
// encode wiegand ..
|
||||
uint8_t wiegand[] = {0,0,0,0,0};
|
||||
if (bit_count == 26) {
|
||||
// wiegand_data = encode_wiegand_26(facility_code, card_number)
|
||||
}
|
||||
if (bit_count == 34) {
|
||||
// wiegand_data = encode_wiegand_34(facility_code, card_number)
|
||||
}
|
||||
|
||||
// card binary blog
|
||||
uint8_t blob[] = {
|
||||
'@', 'I', 'C', 'T', 0x00, 0x80, 0x00, 0x00, bit_count, 0x00, bit_count
|
||||
};
|
||||
// return b'@ICT' + bytes([0,128,0,0,bit_count, 0, bit_count]) + wiegand_data
|
||||
*/
|
||||
// card binary blog
|
||||
uint8_t blob[] = {
|
||||
'@', 'I', 'C', 'T', 0x00, 0x80, 0x00, 0x00, bit_count, 0x00, bit_count
|
||||
};
|
||||
// return b'@ICT' + bytes([0,128,0,0,bit_count, 0, bit_count]) + wiegand_data
|
||||
*/
|
||||
}
|
||||
|
||||
static int ict_select(void) {
|
||||
@@ -463,13 +463,13 @@ static int CmdHfIctRead(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdHfIctCredential(const char * Cmd) {
|
||||
static int CmdHfIctCredential(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf ict credential",
|
||||
"Read ICT sector from tag and decode",
|
||||
"hf ict credential\n"
|
||||
);
|
||||
"Read ICT sector from tag and decode",
|
||||
"hf ict credential\n"
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("v", "verbose", "verbose output"),
|
||||
@@ -491,14 +491,14 @@ static int CmdHfIctCredential(const char * Cmd) {
|
||||
if ((card.sak & 0x24) == 0x24) {
|
||||
isdesfire = true;
|
||||
} else if ((card.sak & 0x20) == 0x20) {
|
||||
if (card.atqa[0] == 0x003&& card.atqa[1] == 0x40) {
|
||||
if (card.atqa[0] == 0x003 && card.atqa[1] == 0x40) {
|
||||
isdesfire = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isdesfire) {
|
||||
|
||||
// read file in desfire application
|
||||
// read file in desfire application
|
||||
// add decrypt sector
|
||||
|
||||
} else {
|
||||
@@ -510,7 +510,7 @@ static int CmdHfIctCredential(const char * Cmd) {
|
||||
}
|
||||
|
||||
// diversified key A?
|
||||
int res = mfReadSector(ICT_MIFARE_SECTOR, MF_KEY_A, ICT_MIFARE_A_KEY, data);
|
||||
int res = mfReadSector(ICT_MIFARE_SECTOR, MF_KEY_A, ICT_MIFARE_A_KEY, data);
|
||||
if (res != PM3_SUCCESS) {
|
||||
free(data);
|
||||
return res;
|
||||
|
||||
@@ -9344,7 +9344,7 @@ static int CmdHF14AMfInfo(const char *Cmd) {
|
||||
|
||||
if (e_sector[1].foundKey[MF_KEY_A] && (e_sector[1].Key[MF_KEY_A] == 0x2A2C13CC242A)) {
|
||||
PrintAndLogEx(SUCCESS, "Dorma Kaba SAFLOK detected");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "<N/A>");
|
||||
|
||||
+12
-12
@@ -336,7 +336,7 @@ static int ulaes_requestAuthentication(uint8_t *key, uint8_t keyno, bool switch_
|
||||
memcpy(payload.key, key, sizeof(payload.key));
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFAREULAES_AUTH, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_MIFAREULAES_AUTH, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_HF_MIFAREULAES_AUTH, &resp, 1500) == false) {
|
||||
return PM3_ETIMEOUT;
|
||||
@@ -456,7 +456,7 @@ static int try_default_3des_keys(bool override, uint8_t **correct_key) {
|
||||
|
||||
// param override, means we override hw debug levels.
|
||||
static int try_default_aes_keys(bool override) {
|
||||
|
||||
|
||||
uint8_t dbg_curr = DBG_NONE;
|
||||
if (override) {
|
||||
if (getDeviceDebugLevel(&dbg_curr) != PM3_SUCCESS) {
|
||||
@@ -481,7 +481,7 @@ static int try_default_aes_keys(bool override) {
|
||||
if (ulaes_requestAuthentication(key, keyno, true) == PM3_SUCCESS) {
|
||||
|
||||
char keystr[20] = {0};
|
||||
switch(keyno) {
|
||||
switch (keyno) {
|
||||
case 0:
|
||||
sprintf(keystr, "Data key");
|
||||
break;
|
||||
@@ -495,10 +495,10 @@ static int try_default_aes_keys(bool override) {
|
||||
break;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "%02X " _YELLOW_("%s") " - %s ( "_GREEN_("ok") " )"
|
||||
, keyno
|
||||
, keystr
|
||||
, sprint_hex_inrow(key, 16)
|
||||
);
|
||||
, keyno
|
||||
, keystr
|
||||
, sprint_hex_inrow(key, 16)
|
||||
);
|
||||
|
||||
res = PM3_SUCCESS;
|
||||
}
|
||||
@@ -1586,7 +1586,7 @@ static mfu_otp_identify_t *mfu_match_otp_fingerprint(uint8_t *uid, uint8_t *data
|
||||
PrintAndLogEx(DEBUG, "uid.... %s", sprint_hex_inrow(uid, 7));
|
||||
PrintAndLogEx(DEBUG, "calc... %s", sprint_hex_inrow(mtmp, 4));
|
||||
PrintAndLogEx(DEBUG, "dump... %s", sprint_hex_inrow(data + mfu_otp_ident_table[i].mpos, min));
|
||||
|
||||
|
||||
bool m2 = (memcmp(mtmp, data + mfu_otp_ident_table[i].mpos, min) == 0);
|
||||
if (m2) {
|
||||
PrintAndLogEx(DEBUG, "(fingerprint) found %s", mfu_otp_ident_table[i].desc);
|
||||
@@ -1781,12 +1781,12 @@ static int mfu_fingerprint(uint64_t tagtype, bool hasAuthKey, uint8_t *authkey,
|
||||
|
||||
if (getDeviceDebugLevel(&dbg_curr) != PM3_SUCCESS) {
|
||||
res = PM3_ESOFT;
|
||||
goto out;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (setDeviceDebugLevel(DBG_NONE, false) != PM3_SUCCESS) {
|
||||
res = PM3_ESOFT;
|
||||
goto out;
|
||||
goto out;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
@@ -2958,7 +2958,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
|
||||
if (setDeviceDebugLevel(DBG_NONE, false) != PM3_SUCCESS) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_MIFAREU_READCARD, start_page, pages, keytype, authKeyPtr, ak_len);
|
||||
PacketResponseNG resp;
|
||||
@@ -3071,7 +3071,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
|
||||
ulev1_readSignature(get_signature, sizeof(get_signature));
|
||||
DropField();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// format and add keys to block dump output
|
||||
// only add keys if not partial read, and complete pages read
|
||||
|
||||
@@ -99,13 +99,13 @@ static void print_st25ta_system_info(uint8_t *d, uint8_t n) {
|
||||
if (d[2] == 0x80) {
|
||||
PrintAndLogEx(SUCCESS, " ....%02X.............................. - ST reserved", d[2]);
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, " ....%02X.............................. - GPO config" , d[2]);
|
||||
PrintAndLogEx(SUCCESS, " ....%02X.............................. - GPO config", d[2]);
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, " ......%02X............................ - Event counter config", d[3]);
|
||||
|
||||
uint32_t counter = (d[4] << 16 | d[5] << 8 | d[6]);
|
||||
PrintAndLogEx(SUCCESS, " ........%02X%02X%02X...................... - 20 bit counter ( %u )", d[4],d[5],d[6], (counter & 0xFFFFF));
|
||||
PrintAndLogEx(SUCCESS, " ........%02X%02X%02X...................... - 20 bit counter ( %u )", d[4], d[5], d[6], (counter & 0xFFFFF));
|
||||
PrintAndLogEx(SUCCESS, " ..............%02X.................... - Product version", d[7]);
|
||||
PrintAndLogEx(SUCCESS, " ................%s...... - UID", sprint_hex_inrow(d + 8, 7));
|
||||
|
||||
|
||||
@@ -2597,7 +2597,7 @@ static int CmdEM4x05Config(const char *Cmd) {
|
||||
static command_t CommandTable[] = {
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("General") " -----------------------"},
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("Operations") " -----------------------"},
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("Operations") " -----------------------"},
|
||||
{"brute", CmdEM4x05Brute, IfPm3Lf, "Bruteforce password"},
|
||||
{"chk", CmdEM4x05Chk, IfPm3Lf, "Check passwords from dictionary"},
|
||||
{"config", CmdEM4x05Config, AlwaysAvailable, "Create common configuration words"},
|
||||
|
||||
@@ -1305,12 +1305,12 @@ static int CmdPCSC(const char *Cmd) {
|
||||
uint8_t atr[50] = {0};
|
||||
int atrLen = 0;
|
||||
|
||||
switch(card_type) {
|
||||
switch (card_type) {
|
||||
case CC_CONTACT: {
|
||||
memcpy(atr, card.atr, card.atr_len);
|
||||
atrLen = card.atr_len;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case CC_CONTACTLESS: {
|
||||
|
||||
if (cl_proto == ISODEP_NFCA) {
|
||||
@@ -1335,7 +1335,7 @@ static int CmdPCSC(const char *Cmd) {
|
||||
mbedtls_net_send(&netCtx, res, 2 + atrLen);
|
||||
|
||||
} else if (cmdbuf[1] != 0x01) { // vpcd APDU
|
||||
int apduLen = (cmdbuf[0] << 8)+ cmdbuf[1];
|
||||
int apduLen = (cmdbuf[0] << 8) + cmdbuf[1];
|
||||
|
||||
uint8_t apduRes[APDU_RES_LEN] = {0};
|
||||
int apduResLen = 0;
|
||||
@@ -1361,9 +1361,9 @@ static int CmdPCSC(const char *Cmd) {
|
||||
mbedtls_net_close(&netCtx);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cl_proto == ISODEP_NFCB) {
|
||||
|
||||
|
||||
if (exchange_14b_apdu(cmdbuf + 2, apduLen, !field_activated, true, apduRes, sizeof(apduRes), &apduResLen, 0)) {
|
||||
have_card = false;
|
||||
mbedtls_net_close(&netCtx);
|
||||
@@ -1373,14 +1373,14 @@ static int CmdPCSC(const char *Cmd) {
|
||||
if (cl_proto == ISODEP_NFCV) {
|
||||
// Not implemented
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
field_activated = true;
|
||||
|
||||
if (verbose) {
|
||||
@@ -1407,7 +1407,7 @@ static int CmdPCSC(const char *Cmd) {
|
||||
card_type = CC_CONTACTLESS;
|
||||
cl_proto = ISODEP_NFCB;
|
||||
}
|
||||
|
||||
|
||||
// ISO 15.
|
||||
|
||||
if (use_contact && IfPm3Iso14443() && smart_select(false, &card) == PM3_SUCCESS) {
|
||||
|
||||
@@ -431,17 +431,17 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 0, "hf mfu setuid" },
|
||||
{ 0, "hf mfu amiibo" },
|
||||
{ 1, "hf mfdes help" },
|
||||
{ 0, "hf mfdes info" },
|
||||
{ 0, "hf mfdes getuid" },
|
||||
{ 0, "hf mfdes default" },
|
||||
{ 1, "hf mfdes list" },
|
||||
{ 0, "hf mfdes auth" },
|
||||
{ 0, "hf mfdes chk" },
|
||||
{ 0, "hf mfdes default" },
|
||||
{ 0, "hf mfdes detect" },
|
||||
{ 0, "hf mfdes freemem" },
|
||||
{ 0, "hf mfdes setconfig" },
|
||||
{ 0, "hf mfdes formatpicc" },
|
||||
{ 1, "hf mfdes list" },
|
||||
{ 0, "hf mfdes freemem" },
|
||||
{ 0, "hf mfdes getuid" },
|
||||
{ 0, "hf mfdes info" },
|
||||
{ 0, "hf mfdes mad" },
|
||||
{ 0, "hf mfdes setconfig" },
|
||||
{ 0, "hf mfdes lsapp" },
|
||||
{ 0, "hf mfdes getaids" },
|
||||
{ 0, "hf mfdes getappnames" },
|
||||
@@ -814,13 +814,13 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "piv list" },
|
||||
{ 1, "smart help" },
|
||||
{ 1, "smart list" },
|
||||
{ 0, "smart brute" },
|
||||
{ 0, "smart info" },
|
||||
{ 0, "smart relay" },
|
||||
{ 1, "smart pcsc" },
|
||||
{ 0, "smart reader" },
|
||||
{ 0, "smart raw" },
|
||||
{ 1, "smart upgrade" },
|
||||
{ 0, "smart setclock" },
|
||||
{ 0, "smart brute" },
|
||||
{ 1, "script help" },
|
||||
{ 1, "script list" },
|
||||
{ 1, "script run" },
|
||||
|
||||
+58
-51
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user