make style
This commit is contained in:
1 parent
a1eb8e78b6
commit
224cb2ffd7
38 files changed
+1531
-1550
No files matched your search
+10
-10
@@ -88,7 +88,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
char *cmd = (char *) ((*env)->GetStringUTFChars(env, cmd_, 0));
|
||||
char *cmd = (char *)((*env)->GetStringUTFChars(env, cmd_, 0));
|
||||
int ret = CommandReceived(cmd);
|
||||
if (ret == 99) {
|
||||
// exit / quit
|
||||
@@ -104,7 +104,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||
* Is client running!
|
||||
* */
|
||||
jboolean IsClientRunning(JNIEnv *env, jobject instance) {
|
||||
return (jboolean) ((jboolean) conn.run);
|
||||
return (jboolean)((jboolean) conn.run);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -116,7 +116,7 @@ jboolean TestPm3(JNIEnv *env, jobject instance) {
|
||||
return false;
|
||||
}
|
||||
bool ret = (TestProxmark() == PM3_SUCCESS);
|
||||
return (jboolean) (ret);
|
||||
return (jboolean)(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -129,8 +129,8 @@ void ClosePm3(JNIEnv *env, jobject instance) {
|
||||
/*
|
||||
* native function map to jvm
|
||||
* */
|
||||
|
||||
//iceman: todo, pm3:ify java class root. Return codes, should match PM3_E* codes.
|
||||
|
||||
//iceman: todo, pm3:ify java class root. Return codes, should match PM3_E* codes.
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
JNIEnv *jniEnv = NULL;
|
||||
if ((*vm)->GetEnv(vm, (void **) &jniEnv, JNI_VERSION_1_4) != JNI_OK) {
|
||||
@@ -143,14 +143,14 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
}
|
||||
jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4");
|
||||
JNINativeMethod methods[] = {
|
||||
{"startExecute", "(Ljava/lang/String;)I", (void *) Console},
|
||||
{"stopExecute", "()V", (void *) ClosePm3},
|
||||
{"isExecuting", "()Z", (void *) IsClientRunning}
|
||||
{"startExecute", "(Ljava/lang/String;)I", (void *) Console},
|
||||
{"stopExecute", "()V", (void *) ClosePm3},
|
||||
{"isExecuting", "()Z", (void *) IsClientRunning}
|
||||
};
|
||||
|
||||
JNINativeMethod methods1[] = {
|
||||
{"testPm3", "()Z", (void *) TestPm3},
|
||||
{"closePm3", "()V", ClosePm3}
|
||||
{"testPm3", "()Z", (void *) TestPm3},
|
||||
{"closePm3", "()V", ClosePm3}
|
||||
};
|
||||
|
||||
if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) != JNI_OK) {
|
||||
|
||||
@@ -558,9 +558,9 @@ enum CborPrettyFlags {
|
||||
/* cf https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ */
|
||||
typedef CborError(*CborStreamFunction)(void *token, const char *fmt, ...)
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
__attribute__((format (__MINGW_PRINTF_FORMAT, 2, 3)));
|
||||
__attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)));
|
||||
#elif defined(__GNUC__)
|
||||
__attribute__((__format__(printf, 2, 3)))
|
||||
__attribute__((__format__(printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ script run test_t55x7 [-h] [-t <modulation type>
|
||||
]]
|
||||
arguments = [[
|
||||
-h this help
|
||||
-t (optional, defaults to ASK) 'PSK1', 'PSK2', 'PSK3',
|
||||
-t (optional, defaults to ASK) 'PSK1', 'PSK2', 'PSK3',
|
||||
'FSK1', 'FSK2', 'FSK1A', 'FSK2A',
|
||||
'ASK', 'BI'
|
||||
]]
|
||||
|
||||
@@ -79,7 +79,7 @@ local function main(args)
|
||||
|
||||
local cmdDataLoad = 'data load %s';
|
||||
local cwd = core.cwd();
|
||||
|
||||
|
||||
local tracesEM = "find '"..cwd.."/traces/ ' -iname 'em*.pm3' -type f"
|
||||
local tracesMOD = "find '"..cwd.."/traces/' -iname 'modulation*.pm3' -type f"
|
||||
|
||||
|
||||
@@ -48,4 +48,4 @@ def main():
|
||||
print('\nTarget (%02X) requires final LRC XOR byte value: %02X\n' % (target,lrc))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
@@ -1683,7 +1683,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
|
||||
if ((datalen % blocksize) != 0) {
|
||||
PrintAndLogEx(WARNING, "Datalen %zu isn't dividable with blocksize %zu", datalen, blocksize);
|
||||
free(data);
|
||||
@@ -1704,7 +1704,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
if (addressed_mode) {
|
||||
char uidhex[17] = {0x00};
|
||||
hex_to_buffer((uint8_t *)uidhex, uid, sizeof(uid), sizeof(uidhex) - 1, 0, false, true);
|
||||
hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true);
|
||||
hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true);
|
||||
snprintf(tmpCmd, sizeof(tmpCmd), "%s %s %u %s", newPrefix, uidhex, i, hex);
|
||||
} else {
|
||||
hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true);
|
||||
@@ -1718,7 +1718,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tried >= retries) {
|
||||
free(data);
|
||||
PrintAndLogEx(FAILED, "Restore failed. Too many retries.");
|
||||
@@ -1729,7 +1729,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
}
|
||||
free(data);
|
||||
PrintAndLogEx(INFO, "done");
|
||||
PrintAndLogEx(HINT, "Try reading your card to verify with " _YELLOW_("`hf 15 dump`") );
|
||||
PrintAndLogEx(HINT, "Try reading your card to verify with " _YELLOW_("`hf 15 dump`"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -586,7 +586,7 @@ static int CmdHfLTRestore(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if (errors || strlen(Cmd) == 0 ) {
|
||||
if (errors || strlen(Cmd) == 0) {
|
||||
return usage_lto_restore();
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ static int CmdHfLTRestore(const char *Cmd) {
|
||||
if (str_endswith(lowstr, ".bin")) {
|
||||
|
||||
uint8_t *dump = NULL;
|
||||
if (loadFile_safe(filename, "", (void**)&dump, &dump_len) == PM3_SUCCESS) {
|
||||
if (loadFile_safe(filename, "", (void **)&dump, &dump_len) == PM3_SUCCESS) {
|
||||
restoreLTO(dump, true);
|
||||
}
|
||||
free(dump);
|
||||
@@ -605,7 +605,7 @@ static int CmdHfLTRestore(const char *Cmd) {
|
||||
} else if (str_endswith(lowstr, ".eml")) {
|
||||
|
||||
uint8_t *dump = NULL;
|
||||
if (loadFileEML_safe(filename, (void**)&dump, &dump_len) == PM3_SUCCESS) {
|
||||
if (loadFileEML_safe(filename, (void **)&dump, &dump_len) == PM3_SUCCESS) {
|
||||
restoreLTO(dump, true);
|
||||
}
|
||||
free(dump);
|
||||
|
||||
@@ -3533,7 +3533,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
size_t datalen = 0;
|
||||
//int res = loadFile(filename, ".bin", data, maxdatalen, &datalen);
|
||||
int res = loadFileEML(filename, data, &datalen);
|
||||
@@ -3552,24 +3552,24 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
// convert plain or old mfu format to new format
|
||||
if (blockWidth == 4) {
|
||||
|
||||
res = convert_mfu_dump_format(&data, &datalen, true);
|
||||
res = convert_mfu_dump_format(&data, &datalen, true);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format");
|
||||
free(data);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
mfu_dump_t *mfu_dump = (mfu_dump_t *)data;
|
||||
|
||||
PrintAndLogEx(INFO, _CYAN_("MFU dump file information"));
|
||||
PrintAndLogEx(INFO, " version %s", sprint_hex(mfu_dump->version, sizeof(mfu_dump->version)));
|
||||
PrintAndLogEx(INFO, " tb 0 %s", sprint_hex(mfu_dump->tbo, sizeof(mfu_dump->tbo)));
|
||||
PrintAndLogEx(INFO, " tb 1 %s", sprint_hex(mfu_dump->tbo1, sizeof(mfu_dump->tbo1)));
|
||||
for(uint8_t m = 0; m < 3; m++) {
|
||||
for (uint8_t m = 0; m < 3; m++) {
|
||||
PrintAndLogEx(INFO, " counter %d %s - tearing 0x%02x", m + 1, sprint_hex(mfu_dump->counter_tearing[m], 3), mfu_dump->counter_tearing[m][3]);
|
||||
}
|
||||
PrintAndLogEx(INFO, " signature %s", sprint_hex(mfu_dump->signature, sizeof(mfu_dump->signature)));
|
||||
PrintAndLogEx(INFO, " data %s... (only first 8 bytes showing)", sprint_hex(mfu_dump->data, 8));
|
||||
PrintAndLogEx(INFO, " data %s... (only first 8 bytes showing)", sprint_hex(mfu_dump->data, 8));
|
||||
PrintAndLogEx(INFO, " max data page %d, data len %d bytes", mfu_dump->pages, (mfu_dump->pages + 1) * 4);
|
||||
PrintAndLogEx(INFO, " file header size %d", MFU_DUMP_PREFIX_LENGTH);
|
||||
PrintAndLogEx(INFO, "----------------------------------------------");
|
||||
|
||||
+10
-10
@@ -3577,9 +3577,9 @@ static int CmdHF14ADesAuth(const char *Cmd) {
|
||||
}
|
||||
|
||||
static void DesFill2bPattern(
|
||||
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t *deskeyListLen,
|
||||
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t *aeskeyListLen,
|
||||
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t *k3kkeyListLen, uint32_t *startPattern) {
|
||||
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t *deskeyListLen,
|
||||
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t *aeskeyListLen,
|
||||
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t *k3kkeyListLen, uint32_t *startPattern) {
|
||||
|
||||
for (uint32_t pt = *startPattern; pt < 0x10000; pt++) {
|
||||
if (*deskeyListLen != MAX_KEYS_LIST_LEN) {
|
||||
@@ -3618,10 +3618,10 @@ static void DesFill2bPattern(
|
||||
}
|
||||
|
||||
static int AuthCheckDesfire(uint8_t *aid,
|
||||
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t deskeyListLen,
|
||||
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t aeskeyListLen,
|
||||
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t k3kkeyListLen,
|
||||
uint8_t foundKeys[4][0xE][24 + 1], bool *result) {
|
||||
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t deskeyListLen,
|
||||
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t aeskeyListLen,
|
||||
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t k3kkeyListLen,
|
||||
uint8_t foundKeys[4][0xE][24 + 1], bool *result) {
|
||||
|
||||
uint32_t curaid = (aid[0] & 0xFF) + ((aid[1] & 0xFF) << 8) + ((aid[2] & 0xFF) << 16);
|
||||
|
||||
@@ -4078,17 +4078,17 @@ static int CmdHF14aDesChk(const char *Cmd) {
|
||||
res = loadFileDICTIONARYEx((char *)dict_filename, deskeyList, sizeof(deskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
|
||||
if (res == PM3_SUCCESS && endFilePosition)
|
||||
deskeyListLen = keycnt;
|
||||
|
||||
|
||||
keycnt = 0;
|
||||
res = loadFileDICTIONARYEx((char *)dict_filename, aeskeyList, sizeof(aeskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
|
||||
if (res == PM3_SUCCESS && endFilePosition)
|
||||
aeskeyListLen = keycnt;
|
||||
|
||||
|
||||
keycnt = 0;
|
||||
res = loadFileDICTIONARYEx((char *)dict_filename, k3kkeyList, sizeof(k3kkeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
|
||||
if (res == PM3_SUCCESS && endFilePosition)
|
||||
k3kkeyListLen = keycnt;
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+35
-35
@@ -1055,39 +1055,39 @@ uint32_t GetHF14AMfU_Type(void) {
|
||||
case 0x0A: {
|
||||
/*
|
||||
MF0UL1001DUx 0004030100000B03
|
||||
MF0UL1101DUx 0004030101000B03
|
||||
MF0ULH1101DUx 0004030201000B03
|
||||
MF0UL1141DUF 0004030301000B03
|
||||
MF0UL2101Dxy 0004030101000E03
|
||||
MF0UL2101DUx 0004030201000E03
|
||||
MF0UL3101DUx 0004030101001103
|
||||
MF0ULH3101DUx 0004030201001103
|
||||
MF0UL5101DUx 0004030101001303
|
||||
NT2L1011F0DUx 0004040101000B03
|
||||
NT2H1011G0DUD 0004040201000B03
|
||||
NT2L1211F0DUx 0004040101000E03
|
||||
NT2H1311G0DUx 0004040201000F03
|
||||
NT2H1311F0Dxy 0004040401000F03
|
||||
NT2H1411G0DUx 0004040201011103
|
||||
NT2H1511G0DUx 0004040201001103
|
||||
NT2H1511F0Dxy 0004040401001103
|
||||
NT2H1611G0DUx 0004040201001303
|
||||
NT2H1611F0Dxy 0004040401001303
|
||||
NT2H1311C1DTL 0004040201010F03
|
||||
NT2H1311TTDUx 0004040203000F03
|
||||
NT3H1101W0FHK 0004040502001303
|
||||
NT3H1201W0FHK 0004040502001503
|
||||
NT3H1101W0FHK_Variant 0004040502011303
|
||||
NT3H1201 0004040502011503
|
||||
NT3H2111 0004040502021303
|
||||
NT3H2211 0004040502021503
|
||||
nhs 0004040600001303
|
||||
MF0UN0001DUx 0004030102000B03
|
||||
MF0UNH0001DUx 0004030202000B03
|
||||
MF0UN1001DUx 0004030103000B03
|
||||
MF0UNH1001DUx 0004030203000B03
|
||||
NT2L1001G0DUx 0004040102000B03
|
||||
NT2H1001G0DUx 0004040202000B03
|
||||
MF0UL1101DUx 0004030101000B03
|
||||
MF0ULH1101DUx 0004030201000B03
|
||||
MF0UL1141DUF 0004030301000B03
|
||||
MF0UL2101Dxy 0004030101000E03
|
||||
MF0UL2101DUx 0004030201000E03
|
||||
MF0UL3101DUx 0004030101001103
|
||||
MF0ULH3101DUx 0004030201001103
|
||||
MF0UL5101DUx 0004030101001303
|
||||
NT2L1011F0DUx 0004040101000B03
|
||||
NT2H1011G0DUD 0004040201000B03
|
||||
NT2L1211F0DUx 0004040101000E03
|
||||
NT2H1311G0DUx 0004040201000F03
|
||||
NT2H1311F0Dxy 0004040401000F03
|
||||
NT2H1411G0DUx 0004040201011103
|
||||
NT2H1511G0DUx 0004040201001103
|
||||
NT2H1511F0Dxy 0004040401001103
|
||||
NT2H1611G0DUx 0004040201001303
|
||||
NT2H1611F0Dxy 0004040401001303
|
||||
NT2H1311C1DTL 0004040201010F03
|
||||
NT2H1311TTDUx 0004040203000F03
|
||||
NT3H1101W0FHK 0004040502001303
|
||||
NT3H1201W0FHK 0004040502001503
|
||||
NT3H1101W0FHK_Variant 0004040502011303
|
||||
NT3H1201 0004040502011503
|
||||
NT3H2111 0004040502021303
|
||||
NT3H2211 0004040502021503
|
||||
nhs 0004040600001303
|
||||
MF0UN0001DUx 0004030102000B03
|
||||
MF0UNH0001DUx 0004030202000B03
|
||||
MF0UN1001DUx 0004030103000B03
|
||||
MF0UNH1001DUx 0004030203000B03
|
||||
NT2L1001G0DUx 0004040102000B03
|
||||
NT2H1001G0DUx 0004040202000B03
|
||||
*/
|
||||
|
||||
if (memcmp(version, "\x00\x04\x03\x01\x01\x00\x0B", 7) == 0) { tagtype = UL_EV1_48; break; }
|
||||
@@ -2189,7 +2189,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
||||
|
||||
uint8_t *dump = NULL;
|
||||
size_t bytes_read = 0;
|
||||
if (loadFile_safe(filename, "", (void**)&dump, &bytes_read) != PM3_SUCCESS) {
|
||||
if (loadFile_safe(filename, "", (void **)&dump, &bytes_read) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename);
|
||||
return PM3_EIO;
|
||||
}
|
||||
@@ -2200,7 +2200,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
int res = convert_mfu_dump_format(&dump, &bytes_read, verbose);
|
||||
int res = convert_mfu_dump_format(&dump, &bytes_read, verbose);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format");
|
||||
free(dump);
|
||||
|
||||
@@ -266,8 +266,8 @@ int demodFDX(void) {
|
||||
}
|
||||
|
||||
uint8_t bt_par = (extended & 0x100) >> 8;
|
||||
uint8_t bt_temperature = extended & 0xff;
|
||||
uint8_t bt_calc_parity = (bitcount(bt_temperature) & 0x1) ? 0 : 1;
|
||||
uint8_t bt_temperature = extended & 0xff;
|
||||
uint8_t bt_calc_parity = (bitcount(bt_temperature) & 0x1) ? 0 : 1;
|
||||
uint8_t is_bt_temperature = (bt_calc_parity == bt_par) && !(extended & 0xe00) ;
|
||||
|
||||
if (is_bt_temperature) {
|
||||
|
||||
@@ -84,7 +84,7 @@ static void set_python_path(char *path) {
|
||||
}
|
||||
|
||||
if (PySys_SetObject("path", syspath)) {
|
||||
PrintAndLogEx(WARNING,"Error setting sys.path object");
|
||||
PrintAndLogEx(WARNING, "Error setting sys.path object");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,10 +300,10 @@ static int CmdScriptRun(const char *Cmd) {
|
||||
wchar_t *py_args[argc];
|
||||
py_args[0] = Py_DecodeLocale(preferredName, NULL);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
py_args[i+1] = Py_DecodeLocale(argv[i], NULL);
|
||||
py_args[i + 1] = Py_DecodeLocale(argv[i], NULL);
|
||||
}
|
||||
|
||||
PySys_SetArgv(argc+1, py_args);
|
||||
PySys_SetArgv(argc + 1, py_args);
|
||||
|
||||
// clean up
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
|
||||
@@ -509,11 +509,11 @@ static int CmdSmartRaw(const char *Cmd) {
|
||||
TLVPrintFromBuffer(buf, len - 2);
|
||||
else {
|
||||
if (len > 16) {
|
||||
for (int i=0; i<len; i += 16) {
|
||||
for (int i = 0; i < len; i += 16) {
|
||||
PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf + i, 16)) ;
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf, len)) ;
|
||||
PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf, len)) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||
// load firmware file
|
||||
size_t firmware_size = 0;
|
||||
uint8_t *firmware = NULL;
|
||||
if (loadFile_safe(filename, "", (void**)&firmware, &firmware_size) != PM3_SUCCESS) {
|
||||
if (loadFile_safe(filename, "", (void **)&firmware, &firmware_size) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Firmware file " _YELLOW_("%s") " not found or locked.", filename);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
@@ -585,7 +585,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||
// load sha512 file
|
||||
size_t sha512_size = 0;
|
||||
char *hashstring = NULL;
|
||||
if (loadFile_safe(sha512filename, "", (void**)&hashstring, &sha512_size) != PM3_SUCCESS) {
|
||||
if (loadFile_safe(sha512filename, "", (void **)&hashstring, &sha512_size) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "SHA-512 file not found or locked.");
|
||||
free(firmware);
|
||||
return PM3_EFILE;
|
||||
|
||||
+12
-12
@@ -95,7 +95,7 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
|
||||
while (!is_last_record(*tracepos, traceLen) && !next_record_is_response(*tracepos, trace)) {
|
||||
|
||||
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + *tracepos);
|
||||
|
||||
|
||||
*tracepos += TRACELOG_HDR_LEN + hdr->data_len;
|
||||
|
||||
if ((hdr->data_len == 1) && (*data_len + hdr->data_len <= MAX_TOPAZ_READER_CMD_LEN)) {
|
||||
@@ -153,7 +153,7 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
|
||||
char data_len_str[5];
|
||||
char temp_str1[3] = {0};
|
||||
char temp_str2[3] = {0};
|
||||
|
||||
|
||||
sprintf(data_len_str, "%04x", hdr->data_len);
|
||||
strncat(temp_str1, data_len_str, 2);
|
||||
temp_str1[2] = '\0';
|
||||
@@ -257,10 +257,10 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
//1 CRC-command, CRC ok
|
||||
//2 Not crc-command
|
||||
|
||||
//--- Draw the data column
|
||||
//--- Draw the data column
|
||||
char line[18][120] = {{0}};
|
||||
|
||||
if (data_len == 0) {
|
||||
if (data_len == 0) {
|
||||
sprintf(line[0], "<empty trace - possible error>");
|
||||
return tracepos;
|
||||
}
|
||||
@@ -401,9 +401,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
if (is_last_record(tracepos, traceLen)) return traceLen;
|
||||
|
||||
if (showWaitCycles && !hdr->isResponse && next_record_is_response(tracepos, trace)) {
|
||||
|
||||
|
||||
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d",
|
||||
(EndOfTransmissionTimestamp - first_hdr->timestamp),
|
||||
(next_hdr->timestamp - first_hdr->timestamp),
|
||||
@@ -415,7 +415,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
}
|
||||
|
||||
static int download_trace(void) {
|
||||
|
||||
|
||||
if (!IfPm3Present()) {
|
||||
PrintAndLogEx(FAILED, "You requested a trace upload in offline mode, consider using parameter '1' for working from Tracebuffer");
|
||||
return PM3_EINVARG;
|
||||
@@ -487,23 +487,23 @@ static int CmdTraceLoad(const char *Cmd) {
|
||||
free(g_trace);
|
||||
|
||||
size_t len = 0;
|
||||
if (loadFile_safe(filename, ".trace", (void**)&g_trace, &len) != PM3_SUCCESS) {
|
||||
if (loadFile_safe(filename, ".trace", (void **)&g_trace, &len) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Could not open file " _YELLOW_("%s"), filename);
|
||||
return PM3_EIO;
|
||||
}
|
||||
|
||||
|
||||
g_traceLen = (long)len;
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = " _YELLOW_("%lu") " bytes) loaded from " _YELLOW_("%s"), g_traceLen, filename);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdTraceSave(const char *Cmd) {
|
||||
|
||||
|
||||
if (g_traceLen == 0) {
|
||||
download_trace();
|
||||
}
|
||||
|
||||
|
||||
if (g_traceLen == 0) {
|
||||
PrintAndLogEx(WARNING, "trace is empty, nothing to save");
|
||||
return PM3_SUCCESS;
|
||||
|
||||
+54
-54
@@ -1380,7 +1380,7 @@ static int CmdEMVScan(const char *Cmd) {
|
||||
uint8_t buf[APDU_RES_LEN] = {0};
|
||||
size_t len = 0;
|
||||
uint8_t ODAI_list[4096];
|
||||
size_t ODAI_listlen = 0;
|
||||
size_t ODAI_listlen = 0;
|
||||
uint16_t sw = 0;
|
||||
int res;
|
||||
json_t *root;
|
||||
@@ -1683,24 +1683,24 @@ static int CmdEMVScan(const char *Cmd) {
|
||||
}
|
||||
|
||||
// Build Input list for Offline Data Authentication
|
||||
// EMV 4.3 book3 10.3, page 96
|
||||
if (first_time && SFIoffline) {
|
||||
if (SFI < 11) {
|
||||
const unsigned char *abuf = buf;
|
||||
size_t elmlen = len;
|
||||
struct tlv e;
|
||||
if (tlv_parse_tl(&abuf, &elmlen, &e)) {
|
||||
memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen);
|
||||
ODAI_listlen += elmlen;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI);
|
||||
}
|
||||
} else {
|
||||
memcpy(ODAI_list + ODAI_listlen, buf, len);
|
||||
ODAI_listlen += len;
|
||||
}
|
||||
first_time = false;
|
||||
}
|
||||
// EMV 4.3 book3 10.3, page 96
|
||||
if (first_time && SFIoffline) {
|
||||
if (SFI < 11) {
|
||||
const unsigned char *abuf = buf;
|
||||
size_t elmlen = len;
|
||||
struct tlv e;
|
||||
if (tlv_parse_tl(&abuf, &elmlen, &e)) {
|
||||
memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen);
|
||||
ODAI_listlen += elmlen;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI);
|
||||
}
|
||||
} else {
|
||||
memcpy(ODAI_list + ODAI_listlen, buf, len);
|
||||
ODAI_listlen += len;
|
||||
}
|
||||
first_time = false;
|
||||
}
|
||||
|
||||
if (decodeTLV) {
|
||||
TLVPrintFromBuffer(buf, len);
|
||||
@@ -1720,18 +1720,18 @@ static int CmdEMVScan(const char *Cmd) {
|
||||
else
|
||||
JsonSaveTLVTreeElm(jsonelm, "$.Data", rsfi, true, true, false);
|
||||
|
||||
tlvdb_free(rsfi);
|
||||
tlvdb_free(rsfi);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// copy Input list for Offline Data Authentication
|
||||
if (ODAI_listlen) {
|
||||
struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag
|
||||
tlvdb_add(tlvRoot, oda);
|
||||
PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen);
|
||||
}
|
||||
if (ODAI_listlen) {
|
||||
struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag
|
||||
tlvdb_add(tlvRoot, oda);
|
||||
PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen);
|
||||
}
|
||||
|
||||
// getting certificates
|
||||
if (tlvdb_get(tlvRoot, 0x90, NULL)) {
|
||||
@@ -1791,7 +1791,7 @@ static int CmdEMVRoca(const char *Cmd) {
|
||||
size_t len = 0;
|
||||
uint16_t sw = 0;
|
||||
uint8_t ODAI_list[4096];
|
||||
size_t ODAI_listlen = 0;
|
||||
size_t ODAI_listlen = 0;
|
||||
int res;
|
||||
|
||||
CLIParserContext *ctx;
|
||||
@@ -1955,26 +1955,26 @@ static int CmdEMVRoca(const char *Cmd) {
|
||||
PrintAndLogEx(ERR, "SFI[%02x]. APDU error %4x", SFI, sw);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Build Input list for Offline Data Authentication
|
||||
// EMV 4.3 book3 10.3, page 96
|
||||
if (SFIoffline > 0) {
|
||||
if (SFI < 11) {
|
||||
const unsigned char *abuf = buf;
|
||||
size_t elmlen = len;
|
||||
struct tlv e;
|
||||
if (tlv_parse_tl(&abuf, &elmlen, &e)) {
|
||||
memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen);
|
||||
ODAI_listlen += elmlen;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI);
|
||||
}
|
||||
} else {
|
||||
memcpy(ODAI_list + ODAI_listlen, buf, len);
|
||||
ODAI_listlen += len;
|
||||
}
|
||||
SFIoffline--;
|
||||
}
|
||||
|
||||
// Build Input list for Offline Data Authentication
|
||||
// EMV 4.3 book3 10.3, page 96
|
||||
if (SFIoffline > 0) {
|
||||
if (SFI < 11) {
|
||||
const unsigned char *abuf = buf;
|
||||
size_t elmlen = len;
|
||||
struct tlv e;
|
||||
if (tlv_parse_tl(&abuf, &elmlen, &e)) {
|
||||
memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen);
|
||||
ODAI_listlen += elmlen;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI);
|
||||
}
|
||||
} else {
|
||||
memcpy(ODAI_list + ODAI_listlen, buf, len);
|
||||
ODAI_listlen += len;
|
||||
}
|
||||
SFIoffline--;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1982,14 +1982,14 @@ static int CmdEMVRoca(const char *Cmd) {
|
||||
|
||||
// getting certificates
|
||||
int ret = PM3_SUCCESS;
|
||||
|
||||
|
||||
// copy Input list for Offline Data Authentication
|
||||
if (ODAI_listlen) {
|
||||
struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag
|
||||
tlvdb_add(tlvRoot, oda);
|
||||
PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen);
|
||||
}
|
||||
|
||||
if (ODAI_listlen) {
|
||||
struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag
|
||||
tlvdb_add(tlvRoot, oda);
|
||||
PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen);
|
||||
}
|
||||
|
||||
if (tlvdb_get(tlvRoot, 0x90, NULL)) {
|
||||
PrintAndLogEx(INFO, "Recovering certificates");
|
||||
PKISetStrictExecution(false);
|
||||
@@ -2025,7 +2025,7 @@ static int CmdEMVRoca(const char *Cmd) {
|
||||
ret = PM3_ESOFT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "ICC Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(icc_pk->rid, 5),
|
||||
icc_pk->index,
|
||||
|
||||
+27
-27
@@ -309,7 +309,7 @@ static int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool Lea
|
||||
res = 1;
|
||||
if (IfPm3Smartcard())
|
||||
res = ExchangeAPDUSC(true, data, datalen, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||
|
||||
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
@@ -677,12 +677,12 @@ int trSDA(struct tlvdb *tlv) {
|
||||
PrintAndLogEx(ERR, "Error: Issuer certificate not found, exiting");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
|
||||
const struct tlv *sda_tlv = tlvdb_get(tlv, 0x21, NULL);
|
||||
if (!sda_tlv || sda_tlv->len < 1) {
|
||||
@@ -736,12 +736,12 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
||||
PrintAndLogEx(ERR, "Error: Issuer certificate not found, exiting");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
|
||||
struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv);
|
||||
if (!icc_pk) {
|
||||
@@ -765,7 +765,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
||||
PrintAndLogEx(SUCCESS, "ICC PE Public key recovered. RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(icc_pe_pk->rid, 5),
|
||||
icc_pe_pk->index,
|
||||
sprint_hex(icc_pe_pk->serial,3)
|
||||
sprint_hex(icc_pe_pk->serial, 3)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -943,12 +943,12 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
|
||||
emv_pk_free(pk);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
|
||||
struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv);
|
||||
if (!icc_pk) {
|
||||
@@ -961,7 +961,7 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
|
||||
PrintAndLogEx(SUCCESS, "ICC Public key recovered. RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(icc_pk->rid, 5),
|
||||
icc_pk->index,
|
||||
sprint_hex(icc_pk->serial,3)
|
||||
sprint_hex(icc_pk->serial, 3)
|
||||
);
|
||||
|
||||
struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv);
|
||||
@@ -1013,10 +1013,10 @@ int RecoveryCertificates(struct tlvdb *tlvRoot, json_t *root) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
sprint_hex(issuer_pk->rid, 5),
|
||||
issuer_pk->index,
|
||||
sprint_hex(issuer_pk->serial, 3)
|
||||
);
|
||||
|
||||
JsonSaveBufAsHex(root, "$.ApplicationData.RID", issuer_pk->rid, 5);
|
||||
|
||||
@@ -1033,12 +1033,12 @@ int RecoveryCertificates(struct tlvdb *tlvRoot, json_t *root) {
|
||||
PrintAndLogEx(WARNING, "WARNING: ICC certificate not found, exiting");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "ICC Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
|
||||
sprint_hex(icc_pk->rid, 5),
|
||||
icc_pk->index,
|
||||
sprint_hex(icc_pk->serial, 3)
|
||||
);
|
||||
sprint_hex(icc_pk->rid, 5),
|
||||
icc_pk->index,
|
||||
sprint_hex(icc_pk->serial, 3)
|
||||
);
|
||||
|
||||
char *icc_pk_c = emv_pk_dump_pk(icc_pk);
|
||||
JsonSaveStr(root, "$.ApplicationData.ICCPublicKeyDec", icc_pk_c);
|
||||
|
||||
@@ -219,7 +219,7 @@ static int sda_test_pk(bool verbose) {
|
||||
|
||||
struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db);
|
||||
if (!ipk) {
|
||||
PrintAndLogEx(WARNING, "Could not recover Issuer certificate!");
|
||||
PrintAndLogEx(WARNING, "Could not recover Issuer certificate!");
|
||||
tlvdb_free(db);
|
||||
return 2;
|
||||
}
|
||||
@@ -269,4 +269,4 @@ int exec_sda_test(bool verbose) {
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "SDA test pk: %s", _GREEN_("passed"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+19
-19
@@ -832,7 +832,7 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
|
||||
continue;
|
||||
|
||||
strcleanrn(line, sizeof(line));
|
||||
|
||||
|
||||
int res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen);
|
||||
if (res == 0) {
|
||||
memcpy(udata + counter, buf, hexlen);
|
||||
@@ -884,7 +884,7 @@ int loadFileEML_safe(const char *preferredName, void **pdata, size_t *datalen) {
|
||||
fclose(f);
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
// 128 + 2 newline chars + 1 null terminator
|
||||
char line[131];
|
||||
memset(line, 0, sizeof(line));
|
||||
@@ -911,10 +911,10 @@ int loadFileEML_safe(const char *preferredName, void **pdata, size_t *datalen) {
|
||||
continue;
|
||||
|
||||
strcleanrn(line, sizeof(line));
|
||||
|
||||
|
||||
res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen);
|
||||
if (res == 0) {
|
||||
memcpy( tmp + counter, buf, hexlen);
|
||||
memcpy(tmp + counter, buf, hexlen);
|
||||
counter += hexlen;
|
||||
} else {
|
||||
retval = PM3_ESOFT;
|
||||
@@ -1286,11 +1286,11 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
mfu_df_e retval = MFU_DF_UNKNOWN;
|
||||
uint8_t bcc0, bcc1;
|
||||
uint8_t ct = 0x88;
|
||||
|
||||
|
||||
// detect new
|
||||
mfu_dump_t *new = (mfu_dump_t *)*dump;
|
||||
bcc0 = ct ^ new->data[0] ^ new->data[1] ^ new->data[2];
|
||||
bcc1 = new->data[4] ^ new->data[5] ^ new->data[6] ^ new->data[7];
|
||||
bcc1 = new->data[4] ^ new->data[5] ^ new->data[6] ^ new->data[7];
|
||||
if (bcc0 == new->data[3] && bcc1 == new->data[8]) {
|
||||
retval = MFU_DF_NEWBIN;
|
||||
}
|
||||
@@ -1316,8 +1316,8 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
switch(retval) {
|
||||
case MFU_DF_NEWBIN:
|
||||
switch (retval) {
|
||||
case MFU_DF_NEWBIN:
|
||||
PrintAndLogEx(INFO, "detected " _GREEN_("new") " mfu dump format");
|
||||
break;
|
||||
case MFU_DF_OLDBIN:
|
||||
@@ -1335,8 +1335,8 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
}
|
||||
|
||||
static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
|
||||
mfu_dump_t *mfu = (mfu_dump_t *) calloc( sizeof(mfu_dump_t), sizeof(uint8_t));
|
||||
|
||||
mfu_dump_t *mfu = (mfu_dump_t *) calloc(sizeof(mfu_dump_t), sizeof(uint8_t));
|
||||
if (mfu == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
@@ -1344,11 +1344,11 @@ static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose)
|
||||
memcpy(mfu->data, *dump, *dumplen);
|
||||
|
||||
mfu->pages = *dumplen / 4 - 1;
|
||||
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(SUCCESS, "plain mfu dump format was converted to " _GREEN_("%d") " blocks", mfu->pages + 1);
|
||||
}
|
||||
|
||||
|
||||
*dump = (uint8_t *)mfu;
|
||||
*dumplen += MFU_DUMP_PREFIX_LENGTH ;
|
||||
return PM3_SUCCESS;
|
||||
@@ -1361,8 +1361,8 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
|
||||
size_t old_data_len = *dumplen - OLD_MFU_DUMP_PREFIX_LENGTH;
|
||||
size_t new_dump_len = old_data_len + MFU_DUMP_PREFIX_LENGTH;
|
||||
|
||||
mfu_dump_t *mfu_dump = (mfu_dump_t *) calloc( sizeof(mfu_dump_t), sizeof(uint8_t));
|
||||
|
||||
mfu_dump_t *mfu_dump = (mfu_dump_t *) calloc(sizeof(mfu_dump_t), sizeof(uint8_t));
|
||||
if (mfu_dump == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
@@ -1370,7 +1370,7 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
memcpy(mfu_dump->version, old_mfu_dump->version, sizeof(mfu_dump->version));
|
||||
memcpy(mfu_dump->tbo, old_mfu_dump->tbo, sizeof(mfu_dump->tbo));
|
||||
memcpy(mfu_dump->signature, old_mfu_dump->signature, sizeof(mfu_dump->signature));
|
||||
|
||||
|
||||
mfu_dump->tbo1[0] = old_mfu_dump->tbo1[0];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -1381,7 +1381,7 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
|
||||
mfu_dump->pages = old_data_len / 4 - 1;
|
||||
|
||||
if (verbose) {
|
||||
if (verbose) {
|
||||
PrintAndLogEx(SUCCESS, "old mfu dump format was converted to " _GREEN_("%d") " blocks", mfu_dump->pages + 1);
|
||||
}
|
||||
|
||||
@@ -1396,11 +1396,11 @@ int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
if (!dump || !dumplen || *dumplen < OLD_MFU_DUMP_PREFIX_LENGTH) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
mfu_df_e res = detect_mfu_dump_format(dump, dumplen, verbose);
|
||||
|
||||
switch(res) {
|
||||
case MFU_DF_NEWBIN:
|
||||
switch (res) {
|
||||
case MFU_DF_NEWBIN:
|
||||
return PM3_SUCCESS;
|
||||
case MFU_DF_OLDBIN:
|
||||
return convert_old_mfu_dump(dump, dumplen, verbose);
|
||||
|
||||
@@ -264,7 +264,7 @@ typedef enum {
|
||||
* @return PM3_SUCCESS for ok, PM3_ESOFT for fails
|
||||
*/
|
||||
int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
|
||||
mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
|
||||
mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
|
||||
|
||||
int searchAndList(const char *pm3dir, const char *ext);
|
||||
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent);
|
||||
|
||||
@@ -85,8 +85,8 @@ static void jsonp_error_init(json_error_t *error, const char *source) {
|
||||
}
|
||||
|
||||
static void jsonp_error_vset(json_error_t *error, int line, int column,
|
||||
size_t position, enum json_error_code code,
|
||||
const char *msg, va_list ap) {
|
||||
size_t position, enum json_error_code code,
|
||||
const char *msg, va_list ap) {
|
||||
if (!error)
|
||||
return;
|
||||
|
||||
@@ -105,8 +105,8 @@ static void jsonp_error_vset(json_error_t *error, int line, int column,
|
||||
}
|
||||
|
||||
static void jsonp_error_set(json_error_t *error, int line, int column,
|
||||
size_t position, enum json_error_code code,
|
||||
const char *msg, ...) {
|
||||
size_t position, enum json_error_code code,
|
||||
const char *msg, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
jsonp_error_vset(error, line, column, position, code, msg, ap);
|
||||
|
||||
@@ -174,7 +174,7 @@ void printarr_human_readable(const char *title, uint8_t *arr, int len) {
|
||||
PrintAndLogEx(INFO, "%s", title);
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i % 16 == 0) {
|
||||
|
||||
|
||||
if (i == 0)
|
||||
cx += snprintf(output + cx, outsize - cx, "%02x| ", i);
|
||||
else
|
||||
@@ -204,9 +204,9 @@ static int testBitStream(void) {
|
||||
}
|
||||
|
||||
if (memcmp(input, output, sizeof(input)) == 0) {
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok") );
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok"));
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed") );
|
||||
PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed"));
|
||||
uint8_t i;
|
||||
for (i = 0 ; i < ARRAYLEN(input) ; i++) {
|
||||
PrintAndLogEx(NORMAL, " IN %02x, OUT %02x", input[i], output[i]);
|
||||
@@ -234,9 +234,9 @@ static int testReversedBitstream(void) {
|
||||
}
|
||||
|
||||
if (memcmp(input, output, sizeof(input)) == 0) {
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok") );
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok"));
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed") );
|
||||
PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed"));
|
||||
uint8_t i;
|
||||
for (i = 0 ; i < ARRAYLEN(input) ; i++) {
|
||||
PrintAndLogEx(NORMAL, " IN %02x, MIDDLE: %02x, OUT %02x", input[i], reverse[i], output[i]);
|
||||
@@ -251,7 +251,7 @@ int testCipherUtils(void) {
|
||||
int retval = testBitStream();
|
||||
if (retval == PM3_SUCCESS)
|
||||
retval = testReversedBitstream();
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
@@ -481,7 +481,7 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[]) {
|
||||
if (memcmp(z_0, result, 4) != 0) {
|
||||
PrintAndLogEx(WARNING, _RED_("Failed to verify") " calculated master key (k_cus)! Something is wrong.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!"));
|
||||
return PM3_SUCCESS;
|
||||
@@ -501,9 +501,9 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
|
||||
dumpdata *attack = (dumpdata *) calloc(itemsize, sizeof(uint8_t));
|
||||
if (attack == NULL) {
|
||||
PrintAndLogEx(WARNING, "failed to allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
int res = 0;
|
||||
for (i = 0 ; i * itemsize < dumpsize ; i++) {
|
||||
memcpy(attack, dump + i * itemsize, itemsize);
|
||||
@@ -670,13 +670,13 @@ int testElite(bool slowtests) {
|
||||
int res = PM3_SUCCESS;
|
||||
PrintAndLogEx(INFO, "Testing hash1...");
|
||||
res += _testHash1();
|
||||
PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") );
|
||||
PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(INFO, "Testing key diversification...");
|
||||
res += _test_iclass_key_permutation();
|
||||
if (res == PM3_SUCCESS)
|
||||
PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") );
|
||||
|
||||
PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
|
||||
|
||||
if (slowtests)
|
||||
res += _testBruteforce();
|
||||
|
||||
|
||||
@@ -228,13 +228,13 @@ static void printState(const char *desc, uint64_t c) {
|
||||
return;
|
||||
char s[60] = {0};
|
||||
snprintf(s, sizeof(s), "%s : ", desc);
|
||||
|
||||
|
||||
uint8_t x = (c & 0xFF00000000000000) >> 56;
|
||||
uint8_t y = (c & 0x00FF000000000000) >> 48;
|
||||
|
||||
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x %02x", x, y);
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x", getSixBitByte(c, i));
|
||||
|
||||
PrintAndLogEx(DEBUG, "%s", s);
|
||||
@@ -353,7 +353,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
|
||||
* @param key
|
||||
* @param div_key
|
||||
*/
|
||||
void diversifyKey(uint8_t* csn, uint8_t* key, uint8_t* div_key) {
|
||||
void diversifyKey(uint8_t *csn, uint8_t *key, uint8_t *div_key) {
|
||||
// Prepare the DES key
|
||||
mbedtls_des_setkey_enc(&ctx_enc, key);
|
||||
|
||||
@@ -581,7 +581,7 @@ static int testCryptedCSN(uint64_t crypted_csn, uint64_t expected) {
|
||||
PrintAndLogEx(DEBUG, "");
|
||||
PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypted_csn);
|
||||
PrintAndLogEx(DEBUG, " {csn-revz} %"PRIx64, crypted_csn_swapped);
|
||||
PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL") );
|
||||
PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL"));
|
||||
|
||||
if (resultbyte != expected) {
|
||||
PrintAndLogEx(DEBUG, " expected " _YELLOW_("%"PRIx64), expected);
|
||||
@@ -602,7 +602,7 @@ static int testDES2(uint64_t csn, uint64_t expected) {
|
||||
uint64_t crypt_csn = x_bytes_to_num(result, 8);
|
||||
|
||||
PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypt_csn);
|
||||
PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL") );
|
||||
PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL"));
|
||||
|
||||
if (expected != crypt_csn)
|
||||
return PM3_ESOFT;
|
||||
@@ -635,7 +635,7 @@ static int doTestsWithKnownInputs(void) {
|
||||
res += testCryptedCSN(0x21ba6565071f9299, 0x34e80f88d5cf39ea);
|
||||
res += testCryptedCSN(0x14e2adfc5bb7e134, 0x6ac90c6508bd9ea3);
|
||||
|
||||
if (res != PM3_SUCCESS) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "%d res occurred (9 testcases)", res);
|
||||
res = PM3_ESOFT;
|
||||
} else {
|
||||
|
||||
@@ -912,7 +912,7 @@ static int CmdPrefShow(const char *Cmd) {
|
||||
char *fn = prefGetFilename();
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, _CYAN_("Preferences loaded from " _YELLOW_("%s")), fn);
|
||||
free(fn);
|
||||
free(fn);
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Preferences not loaded");
|
||||
return PM3_ESOFT;
|
||||
|
||||
Reference in new issue
Block a user