make style

This commit is contained in:
Philippe Teuwen 2022-01-23 20:02:57 +01:00
commit 140a7f34a4
9 changed files with 53 additions and 50 deletions

View file

@ -1128,7 +1128,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_r
} }
// if uid not supplied then get from emulator memory // if uid not supplied then get from emulator memory
if ( (memcmp(data, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10) == 0) || ((flags & FLAG_UID_IN_EMUL) == FLAG_UID_IN_EMUL)) { if ((memcmp(data, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10) == 0) || ((flags & FLAG_UID_IN_EMUL) == FLAG_UID_IN_EMUL)) {
if (tagType == 2 || tagType == 7) { if (tagType == 2 || tagType == 7) {
uint16_t start = MFU_DUMP_PREFIX_LENGTH; uint16_t start = MFU_DUMP_PREFIX_LENGTH;
uint8_t emdata[8]; uint8_t emdata[8];

View file

@ -271,7 +271,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
gs_ntag_i2c_state = 1; gs_ntag_i2c_state = 1;
} else { } else {
snprintf(exp, size, "RESTORE(%d)", cmd[1]); snprintf(exp, size, "RESTORE(%d)", cmd[1]);
} }
} else { } else {
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -832,7 +832,7 @@ void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
// it's basically a ISO14443a tag, so try annotation from there // it's basically a ISO14443a tag, so try annotation from there
if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS ) { if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS) {
// S-block 11xxx010 // S-block 11xxx010
if ((cmd[0] & 0xC0) && (cmdsize == 3)) { if ((cmd[0] & 0xC0) && (cmdsize == 3)) {
@ -1182,14 +1182,14 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS) { if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS) {
// switch (cmd[0]) { // switch (cmd[0]) {
// default: // default:
// break; // break;
// }; // };
// apply ISO7816 annotations? // apply ISO7816 annotations?
// if (annotateIso7816(exp, size, cmd, cmdsize) == 0) { // if (annotateIso7816(exp, size, cmd, cmdsize) == 0) {
// } // }
// apply SEOS annotations? // apply SEOS annotations?
} }
} }

View file

@ -420,7 +420,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
annotateCryptoRF(explanation, sizeof(explanation), frame, data_len); annotateCryptoRF(explanation, sizeof(explanation), frame, data_len);
break; break;
case SEOS: case SEOS:
annotateSeos(explanation, sizeof(explanation), frame, data_len); annotateSeos(explanation, sizeof(explanation), frame, data_len);
break; break;
default: default:
break; break;
@ -724,7 +724,7 @@ int CmdTraceList(const char *Cmd) {
"trace list -t mf -> interpret as " _YELLOW_("MIFARE Classic") " and decrypt crypto1 stream\n" "trace list -t mf -> interpret as " _YELLOW_("MIFARE Classic") " and decrypt crypto1 stream\n"
"trace list -t seos -> interpret as " _YELLOW_("SEOS") "\n" "trace list -t seos -> interpret as " _YELLOW_("SEOS") "\n"
"trace list -t thinfilm -> interpret as " _YELLOW_("Thinfilm") "\n" "trace list -t thinfilm -> interpret as " _YELLOW_("Thinfilm") "\n"
"trace list -t topaz -> interpret as " _YELLOW_("Topaz") "\n" "trace list -t topaz -> interpret as " _YELLOW_("Topaz") "\n"
"\n" "\n"
"trace list -t mf --dict <mfc_default_keys> -> use dictionary keys file\n" "trace list -t mf --dict <mfc_default_keys> -> use dictionary keys file\n"
"trace list -t 14a -f -> show frame delay times\n" "trace list -t 14a -f -> show frame delay times\n"
@ -773,7 +773,7 @@ int CmdTraceList(const char *Cmd) {
uint8_t protocol = -1; uint8_t protocol = -1;
// validate type of output // validate type of output
if (strcmp(type, "14a") == 0) protocol = ISO_14443A; if (strcmp(type, "14a") == 0) protocol = ISO_14443A;
else if (strcmp(type, "14b") == 0) protocol = ISO_14443B; else if (strcmp(type, "14b") == 0) protocol = ISO_14443B;
else if (strcmp(type, "15") == 0) protocol = ISO_15693; else if (strcmp(type, "15") == 0) protocol = ISO_15693;
else if (strcmp(type, "7816") == 0) protocol = ISO_7816_4; else if (strcmp(type, "7816") == 0) protocol = ISO_7816_4;

View file

@ -529,14 +529,14 @@ static int ndefDecodeMime_vcard(NDEFHeader_t *ndef) {
PrintAndLogEx(INFO, ""); PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, "%.*s", (int)ndef->PayloadLen, ndef->Payload); PrintAndLogEx(INFO, "%.*s", (int)ndef->PayloadLen, ndef->Payload);
char *s = strstr((char*)ndef->Payload, "PHOTO"); char *s = strstr((char *)ndef->Payload, "PHOTO");
if (s) { if (s) {
s = strtok(s, ";"); s = strtok(s, ";");
while (s) { while (s) {
char *tmp = s; char *tmp = s;
if (strncmp(tmp, "ENCODING", 8) == 0) { if (strncmp(tmp, "ENCODING", 8) == 0) {
} else if (strncmp(tmp, "TYPE", 4) == 0) { } else if (strncmp(tmp, "TYPE", 4) == 0) {
char *part = strtok(tmp + 4, ":"); char *part = strtok(tmp + 4, ":");
while (part) { while (part) {

View file

@ -32,7 +32,7 @@
#if defined(HAVE_READLINE) #if defined(HAVE_READLINE)
static char* rl_command_generator(const char *text, int state) { static char *rl_command_generator(const char *text, int state) {
static int index; static int index;
static size_t len; static size_t len;
size_t rlen = strlen(rl_line_buffer); size_t rlen = strlen(rl_line_buffer);
@ -48,14 +48,14 @@ static char* rl_command_generator(const char *text, int state) {
// When no pm3 device present // When no pm3 device present
// and the command is not available offline, // and the command is not available offline,
// we skip it. // we skip it.
if ((g_session.pm3_present == false) && (vocabulory[index].offline == false )) { if ((g_session.pm3_present == false) && (vocabulory[index].offline == false)) {
index++; index++;
continue; continue;
} }
index++; index++;
if (strncmp (command, rl_line_buffer, rlen) == 0) { if (strncmp(command, rl_line_buffer, rlen) == 0) {
const char *next = command + (rlen - len); const char *next = command + (rlen - len);
const char *space = strstr(next, " "); const char *space = strstr(next, " ");
if (space != NULL) { if (space != NULL) {
@ -70,7 +70,7 @@ static char* rl_command_generator(const char *text, int state) {
static char **rl_command_completion(const char *text, int start, int end) { static char **rl_command_completion(const char *text, int start, int end) {
rl_attempted_completion_over = 0; rl_attempted_completion_over = 0;
return rl_completion_matches (text, rl_command_generator); return rl_completion_matches(text, rl_command_generator);
} }
#endif // HAVE_READLINE #endif // HAVE_READLINE
@ -94,7 +94,7 @@ static void sigint_handler(int signum) {
} }
#endif #endif
void pm3line_install_signals(void){ void pm3line_install_signals(void) {
# if defined(_WIN32) # if defined(_WIN32)
// SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true); // SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true);
# else # else

View file

@ -21,7 +21,7 @@
void pm3line_init(void); void pm3line_init(void);
void pm3line_install_signals(void); void pm3line_install_signals(void);
char *pm3line_read(const char* s); char *pm3line_read(const char *s);
void pm3line_free(void *ref); void pm3line_free(void *ref);
void pm3line_update_prompt(const char *prompt); void pm3line_update_prompt(const char *prompt);
int pm3line_load_history(const char *path); int pm3line_load_history(const char *path);

View file

@ -177,7 +177,7 @@ void ProxGuiQT::_ShowBase64PictureWindow(char *b64) {
if (slen == 0) if (slen == 0)
return; return;
char *myb64data = (char *)calloc(slen + 1, sizeof(uint8_t)); char *myb64data = (char *)calloc(slen + 1, sizeof(uint8_t));
if (myb64data == NULL) if (myb64data == NULL)
return; return;

View file

@ -165,10 +165,10 @@ uint32_t ul_ev1_pwdgenE(const uint8_t *uid) {
uint8_t hash[20]; uint8_t hash[20];
mbedtls_sha1(uid, 7, hash); mbedtls_sha1(uid, 7, hash);
uint32_t pwd = 0; uint32_t pwd = 0;
pwd |= ( hash[ hash[0] % 20 ] ) << 24 ; pwd |= (hash[ hash[0] % 20 ]) << 24 ;
pwd |= ( hash[ (hash[0] + 5 ) % 20 ] ) << 16; pwd |= (hash[(hash[0] + 5) % 20 ]) << 16;
pwd |= ( hash[ (hash[0] + 13) % 20 ] ) << 8; pwd |= (hash[(hash[0] + 13) % 20 ]) << 8;
pwd |= ( hash[ (hash[0] + 17) % 20 ] ); pwd |= (hash[(hash[0] + 17) % 20 ]);
return pwd; return pwd;
} }
@ -205,7 +205,7 @@ uint16_t ul_ev1_packgenD(const uint8_t *uid) {
uint16_t ul_ev1_packgenE(const uint8_t *uid) { uint16_t ul_ev1_packgenE(const uint8_t *uid) {
uint32_t pwd = ul_ev1_pwdgenE(uid); uint32_t pwd = ul_ev1_pwdgenE(uid);
return (0xAD << 8 | ((pwd >> 24) & 0xFF) ); return (0xAD << 8 | ((pwd >> 24) & 0xFF));
} }

View file

@ -4339,9 +4339,9 @@
"0..3: number of keys stored within the application (max. 14 keys)", "0..3: number of keys stored within the application (max. 14 keys)",
"4: ks3 is present", "4: ks3 is present",
"5: use of 2 byte iso fid, 0: no, 1: yes", "5: use of 2 byte iso fid, 0: no, 1: yes",
"6..7: crypto method 00: des/2tdea, 01: 3tdea, 10: aes, 11: rfu", "6..7: crypto method 00: des|2tdea, 01: 3tdea, 10: aes, 11: rfu",
"example:", "example:",
"2e = with fid, des/2tdea, 14 keys", "2e = with fid, des|2tdea, 14 keys",
"6e = with fid, 3tdea, 14 keys", "6e = with fid, 3tdea, 14 keys",
"ae = with fid, aes, 14 keys", "ae = with fid, aes, 14 keys",
"", "",
@ -4354,25 +4354,25 @@
"-h, --help this help", "-h, --help this help",
"-a, --apdu show apdu requests and responses", "-a, --apdu show apdu requests and responses",
"-v, --verbose show technical data", "-v, --verbose show technical data",
"-n, --keyno <keyno> key number", "-n, --keyno <dec> key number",
"-t, --algo <des/2tdea/3tdea/aes> crypt algo: des, 2tdea, 3tdea, aes", "-t, --algo <des|2tdea|3tdea|aes> crypt algo: des, 2tdea, 3tdea, aes",
"-k, --key <key> key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)", "-k, --key <hex> key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)",
"-f, --kdf <none/an10922/gallagher> key derivation function (kdf): none, an10922, gallagher", "-f, --kdf <none|an10922|gallagher> key derivation function (kdf): none, an10922, gallagher",
"-i, --kdfi <kdfi> kdf input (hex 1-31 bytes)", "-i, --kdfi <kdfi> kdf input (hex 1-31 bytes)",
"-m, --cmode <plain/mac/encrypt> communicaton mode: plain/mac/encrypt", "-m, --cmode <plain|mac|encrypt> communicaton mode: plain/mac/encrypt",
"-c, --ccset <native/niso/iso> communicaton command set: native/niso/iso", "-c, --ccset <native|niso|iso> communicaton command set: native/niso/iso",
"-s, --schann <d40/ev1/ev2/lrp> secure channel: d40/ev1/ev2/lrp", "-s, --schann <d40|ev1|ev2|lrp> secure channel: d40/ev1/ev2/lrp",
"--rawdata <rawdata hex> rawdata that sends to command", "--rawdata <hex> raw data that sends to command",
"--aid <app id hex> application id for create. mandatory. (3 hex bytes, big endian)", "--aid <hex> application id for create. mandatory. (3 hex bytes, big endian)",
"--fid <file id hex> iso file id. forbidden values: 0000 3f00, 3fff, ffff. (2 hex bytes, big endian). if specified - enable iso file id over all the files in the app.", "--fid <hex> iso file id. forbidden values: 0000 3f00, 3fff, ffff. (2 hex bytes, big endian). if specified - enable iso file id over all the files in the app.",
"--dfname <df name str> iso df name 1..16 chars string", "--dfname <string> iso df name 1..16 chars string",
"--ks1 <key settings hex> key settings 1 (hex 1 byte). application master key settings. default 0x0f", "--ks1 <hex> key settings 1 (hex 1 byte). application master key settings. default 0x0f",
"--ks2 <key settings hex> key settings 2 (hex 1 byte). default 0x0e", "--ks2 <hex> key settings 2 (hex 1 byte). default 0x0e",
"--dstalgo <des/2tdea/3tdea/aes> application key crypt algo: des, 2tdea, 3tdea, aes. default des", "--dstalgo <des|2tdea|3tdea|aes> application key crypt algo: des, 2tdea, 3tdea, aes. default des",
"--numkeys <number of keys> keys count. 0x00..0x0e. default 0x0e", "--numkeys <dec> number of keys 0x00..0x0e. default 0x0e",
"--no-auth execute without authentication" "--no-auth execute without authentication"
], ],
"usage": "hf mfdes createapp [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2/lrp>] [--rawdata <rawdata hex>] [--aid <app id hex>] [--fid <file id hex>] [--dfname <df name str>] [--ks1 <key settings hex>] [--ks2 <key settings hex>] [--dstalgo <des/2tdea/3tdea/aes>] [--numkeys <number of keys>] [--no-auth]" "usage": "hf mfdes createapp [-hav] [-n <dec>] [-t <des|2tdea|3tdea|aes>] [-k <hex>] [-f <none|an10922|gallagher>] [-i <kdfi>] [-m <plain|mac|encrypt>] [-c <native|niso|iso>] [-s <d40|ev1|ev2|lrp>] [--rawdata <hex>] [--aid <hex>] [--fid <hex>] [--dfname <string>] [--ks1 <hex>] [--ks2 <hex>] [--dstalgo <des|2tdea|3tdea|aes>] [--numkeys <dec>] [--no-auth]"
}, },
"hf mfdes createfile": { "hf mfdes createfile": {
"command": "hf mfdes createfile", "command": "hf mfdes createfile",
@ -9983,22 +9983,25 @@
"description": "help this help list list protocol data in trace buffer load load trace from file save save trace buffer to file --------------------------------------------------------------------------------------- trace list available offline: yes annotate trace buffer with selected protocol data you can load a trace from file (see `trace load -h`) or it be downloaded from device by default", "description": "help this help list list protocol data in trace buffer load load trace from file save save trace buffer to file --------------------------------------------------------------------------------------- trace list available offline: yes annotate trace buffer with selected protocol data you can load a trace from file (see `trace load -h`) or it be downloaded from device by default",
"notes": [ "notes": [
"trace list -t raw -> just show raw data without annotations", "trace list -t raw -> just show raw data without annotations",
"",
"trace list -t 14a -> interpret as iso14443-a", "trace list -t 14a -> interpret as iso14443-a",
"trace list -t thinfilm -> interpret as thinfilm",
"trace list -t topaz -> interpret as topaz",
"trace list -t mf -> interpret as mifare classic and decrypt crypto1 stream",
"trace list -t des -> interpret as mifare desfire",
"trace list -t 14b -> interpret as iso14443-b", "trace list -t 14b -> interpret as iso14443-b",
"trace list -t 7816 -> interpret as iso7816-4",
"trace list -t 15 -> interpret as iso15693", "trace list -t 15 -> interpret as iso15693",
"trace list -t iclass -> interpret as iclass", "trace list -t 7816 -> interpret as iso7816-4",
"trace list -t legic -> interpret as legic", "trace list -t cryptorf -> interpret as cryptorf",
"",
"trace list -t des -> interpret as mifare desfire",
"trace list -t felica -> interpret as iso18092 / felica", "trace list -t felica -> interpret as iso18092 / felica",
"trace list -t hitag1 -> interpret as hitag1", "trace list -t hitag1 -> interpret as hitag1",
"trace list -t hitag2 -> interpret as hitag2", "trace list -t hitag2 -> interpret as hitag2",
"trace list -t hitags -> interpret as hitags", "trace list -t hitags -> interpret as hitags",
"trace list -t iclass -> interpret as iclass",
"trace list -t legic -> interpret as legic",
"trace list -t lto -> interpret as lto-cm", "trace list -t lto -> interpret as lto-cm",
"trace list -t cryptorf -> interpret as cryptorf", "trace list -t mf -> interpret as mifare classic and decrypt crypto1 stream",
"trace list -t seos -> interpret as seos",
"trace list -t thinfilm -> interpret as thinfilm",
"trace list -t topaz -> interpret as topaz",
"", "",
"trace list -t mf --dict <mfc_default_keys> -> use dictionary keys file", "trace list -t mf --dict <mfc_default_keys> -> use dictionary keys file",
"trace list -t 14a -f -> show frame delay times", "trace list -t 14a -f -> show frame delay times",
@ -10205,6 +10208,6 @@
"metadata": { "metadata": {
"commands_extracted": 598, "commands_extracted": 598,
"extracted_by": "PM3Help2JSON v1.00", "extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2022-01-17T10:37:00" "extracted_on": "2022-01-23T19:02:27"
} }
} }