make style

This commit is contained in:
Philippe Teuwen
2021-10-16 23:44:53 +02:00
parent 232843477c
commit dbec6edfa7
14 changed files with 164 additions and 131 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ const char *getAtrInfo(const char *atr_str) {
}
for (int j = 0; j < slen; j++) {
tmp_atr[j] = AtrTable[i].bytes[j]=='.' ? '.' : atr_str[j];
tmp_atr[j] = AtrTable[i].bytes[j] == '.' ? '.' : atr_str[j];
}
if (strncmp(tmp_atr, AtrTable[i].bytes, slen) == 0) {
+6 -6
View File
@@ -1012,7 +1012,7 @@ static int CmdAnalyseFreq(const char *Cmd) {
PrintAndLogEx(INFO, " 13.56 mHz has %f m, rf range %f m", len_1356, rf_range_1356);
if (F == 0 && C == 0 && L == 0)
if (F == 0 && C == 0 && L == 0)
return PM3_SUCCESS;
@@ -1021,22 +1021,22 @@ static int CmdAnalyseFreq(const char *Cmd) {
// From https://goodcalculators.com/resonant-frequency-calculator/
// Calc Resonant Frequency [Hz]
// f = 1 / (2π √L C)
// f = 1 / (2π √L C)
if (F == 0) {
double calc_freq = 1 / (2 * M_PI * sqrtf((L * C)) );
double calc_freq = 1 / (2 * M_PI * sqrtf((L * C)));
PrintAndLogEx(INFO, "Resonating Frequency %lf Hz", calc_freq);
}
// Calc Inductance [H]
// L = 1 / (4π2 f2 C)
// L = 1 / (4π2 f2 C)
if (L == 0) {
double calc_inductance = 1 / (4 * (M_PI * M_PI) * (F * F) * C );
double calc_inductance = 1 / (4 * (M_PI * M_PI) * (F * F) * C);
PrintAndLogEx(INFO, "Inductance %lf Henries", calc_inductance);
}
// Capacitance [F]
// C = 1 / (4π2 f2 L)
if (C == 0) {
double calc_capacitance = 1 / (4 * (M_PI * M_PI) * (F * F) * L);
double calc_capacitance = 1 / (4 * (M_PI * M_PI) * (F * F) * L);
PrintAndLogEx(INFO, "Capacitance %lf Farads", calc_capacitance);
}
return PM3_SUCCESS;
+1 -1
View File
@@ -454,7 +454,7 @@ static int CmdrevengSearch(const char *Cmd) {
memset(result, 0, 30);
char *inCRC = calloc(crcChars + 1, sizeof(char));
if (inCRC == NULL) {
return 0;
return 0;
}
memcpy(inCRC, inHexStr + (dataLen - crcChars), crcChars);
+16 -16
View File
@@ -2479,9 +2479,9 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
PrintAndLogEx(INFO, " block# | data | ascii |lck| info");
PrintAndLogEx(INFO, "---------+-------------------------+----------+---+--------------");
PrintAndLogEx(INFO, " 0/0x00 | " _GREEN_("%s") "| " _GREEN_("%s") " | | CSN "
, sprint_hex(iclass_dump, 8)
, sprint_ascii(iclass_dump, 8)
);
, sprint_hex(iclass_dump, 8)
, sprint_ascii(iclass_dump, 8)
);
if (i != 1)
PrintAndLogEx(INFO, "....");
@@ -2535,12 +2535,12 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
}
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s "
, i
, i
, sprint_hex_ascii(blk, 8)
, lockstr
, s
);
, i
, i
, sprint_hex_ascii(blk, 8)
, lockstr
, s
);
} else {
const char *info_ks[] = {"CSN", "Config", "E-purse", "Debit", "Credit", "AIA", "User"};
@@ -2550,13 +2550,13 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
}
if (i >= 6 && i <= 9) {
PrintAndLogEx(INFO, "%3d/0x%02X | " _YELLOW_("%s") "| " _YELLOW_("%s") " | %s | %s "
, i
, i
, sprint_hex(blk, 8)
, sprint_ascii(blk, 8)
, lockstr
, s
);
, i
, i
, sprint_hex(blk, 8)
, sprint_ascii(blk, 8)
, lockstr
, s
);
} else {
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s ", i, i, sprint_hex_ascii(blk, 8), lockstr, s);
}
+9 -9
View File
@@ -288,7 +288,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
snprintf(exp, size, "AUTH-1 ");
break;
case MIFARE_ULC_AUTH_2:
if ((gs_mfuc_state == 2) && (cmdsize==19)){
if ((gs_mfuc_state == 2) && (cmdsize == 19)) {
memcpy(gs_mfuc_authdata[1], &cmd[1], 16);
if (trace_mfuc_try_default_3des_keys(&gs_mfuc_key, gs_mfuc_state, gs_mfuc_authdata) == PM3_SUCCESS) {
// buffer too small to print the full key,
@@ -371,26 +371,26 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
return 0;
}
} else {
if (gs_mfuc_state==1) {
if ((cmd[0]==0xAF) && (cmdsize==11)) {
if (gs_mfuc_state == 1) {
if ((cmd[0] == 0xAF) && (cmdsize == 11)) {
// register RndB
memcpy(gs_mfuc_authdata[0], &cmd[1], 8);
gs_mfuc_state=2;
gs_mfuc_state = 2;
} else {
gs_mfuc_state=0;
gs_mfuc_state = 0;
}
}
if (gs_mfuc_state==3) {
if ((cmd[0]==0x00) && (cmdsize==11)) {
if (gs_mfuc_state == 3) {
if ((cmd[0] == 0x00) && (cmdsize == 11)) {
// register RndA'
memcpy(gs_mfuc_authdata[2], &cmd[1], 8);
if (trace_mfuc_try_default_3des_keys(&gs_mfuc_key, gs_mfuc_state, gs_mfuc_authdata) == PM3_SUCCESS) {
snprintf(exp, size, "AUTH-2 ANSW OK");
gs_mfuc_state=0;
gs_mfuc_state = 0;
return 1;
}
}
gs_mfuc_state=0;
gs_mfuc_state = 0;
}
return 0;
}
+4 -4
View File
@@ -822,7 +822,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
xdump.card_info = card;
xdump.dump = (uint8_t *)carddata;
xdump.dumplen = bytes;
saveFileJSON(dataFilename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(dataFilename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
return PM3_SUCCESS;
}
@@ -2603,7 +2603,7 @@ all_found:
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
// Generate and show statistics
t1 = msclock() - t1;
@@ -4008,7 +4008,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
}
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
free(dump);
return PM3_SUCCESS;
}
@@ -4845,7 +4845,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
free(dump);
return PM3_SUCCESS;
}
+4 -4
View File
@@ -269,8 +269,8 @@ static int trace_mfuc_try_key(uint8_t *key, int state, uint8_t (*authdata)[16])
mbedtls_des3_crypt_cbc(&ctx_des3, MBEDTLS_DES_DECRYPT,
16, iv, authdata[1], RndARndB);
if ((memcmp(&RndB[1], &RndARndB[8], 7) == 0) &&
(RndB[0] == RndARndB[15])) {
return PM3_SUCCESS;
(RndB[0] == RndARndB[15])) {
return PM3_SUCCESS;
}
break;
case 3:
@@ -284,8 +284,8 @@ static int trace_mfuc_try_key(uint8_t *key, int state, uint8_t (*authdata)[16])
mbedtls_des3_crypt_cbc(&ctx_des3, MBEDTLS_DES_DECRYPT,
8, iv, authdata[2], RndA);
if ((memcmp(&RndARndB[1], RndA, 7) == 0) &&
(RndARndB[0] == RndA[7])) {
return PM3_SUCCESS;
(RndARndB[0] == RndA[7])) {
return PM3_SUCCESS;
}
break;
default:
+1 -1
View File
@@ -87,7 +87,7 @@ static int CmdNfcDecode(const char *Cmd) {
bool verbose = arg_get_lit(ctx, 3);
CLIParserFree(ctx);
if (((datalen != 0) && (fnlen != 0)) || ((datalen == 0) && (fnlen == 0))){
if (((datalen != 0) && (fnlen != 0)) || ((datalen == 0) && (fnlen == 0))) {
PrintAndLogEx(ERR, "You must provide either data in hex or a filename");
return PM3_EINVARG;
}
+1 -1
View File
@@ -368,7 +368,7 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
break;
}
case jsfCardMemory: {
iso14a_mf_extdump_t* xdump = (iso14a_mf_extdump_t*) data;
iso14a_mf_extdump_t *xdump = (iso14a_mf_extdump_t *) data;
JsonSaveStr(root, "FileType", "mfcard");
JsonSaveBufAsHexCompact(root, "$.Card.UID", xdump->card_info.uid, xdump->card_info.uidlen);
JsonSaveBufAsHexCompact(root, "$.Card.ATQA", xdump->card_info.atqa, 2);
+2 -2
View File
@@ -662,9 +662,9 @@ int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBl
uint32_t max_keys_chunk = keycnt > maxkeysinblock ? maxkeysinblock : keycnt;
uint8_t *mem = NULL;
uint8_t *p_keyblock = NULL;
uint8_t *p_keyblock = NULL;
if (IfPm3Flash()) {
if (IfPm3Flash()) {
// used for mfCheckKeys_file, which needs a header
mem = calloc((maxkeysinblock * 6) + 5, sizeof(uint8_t));
+113 -80
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -358,7 +358,7 @@ Check column "offline" for their availability.
|`hf iclass encrypt `|Y |`Encrypt given block data`
|`hf iclass decrypt `|Y |`Decrypt given block data or tag dump file`
|`hf iclass managekeys `|Y |`Manage keys to use with iclass commands`
|`hf iclass permutekey `|N |`Permute function from 'heart of darkness' paper`
|`hf iclass permutekey `|Y |`Permute function from 'heart of darkness' paper`
|`hf iclass view `|Y |`Display content from tag dump file`
@@ -630,7 +630,7 @@ Check column "offline" for their availability.
|`hw tearoff `|N |`Program a tearoff hook for the next command supporting tearoff`
|`hw tia `|N |`Trigger a Timing Interval Acquisition to re-adjust the RealTimeCounter divider`
|`hw tune `|N |`Measure antenna tuning`
|`hw version `|N |`Show version information about the connected Proxmark3`
|`hw version `|Y |`Show version information about the client and the connected Proxmark3, if any`
### lf
+3 -3
View File
@@ -135,7 +135,7 @@ function get_pm3_list_macOS {
function get_pm3_list_Windows {
N=$1
PM3LIST=()
# Normal SERIAL PORTS (COM)
for DEV in $(wmic /locale:ms_409 path Win32_SerialPort Where "PNPDeviceID LIKE '%VID_9AC4&PID_4B8F%' Or PNPDeviceID LIKE '%VID_2D2D&PID_504D%'" Get DeviceID 2>/dev/null | awk -b '/^COM/{print $1}'); do
DEV=${DEV/ */}
@@ -151,7 +151,7 @@ function get_pm3_list_Windows {
return
fi
done
#BT direct SERIAL PORTS (COM)
if $FINDBTRFCOMM; then
for DEV in $(wmic /locale:ms_409 path Win32_PnPEntity Where "Caption LIKE '%Bluetooth%(COM%'" Get Name 2> /dev/null | awk -b 'match($0,/(COM[0-9]+)/,m){print m[1]}'); do
@@ -178,7 +178,7 @@ function get_pm3_list_Windows {
function get_pm3_list_WSL {
N=$1
PM3LIST=()
# Normal SERIAL PORTS (COM)
for DEV in $($PSHEXE -command "Get-CimInstance -ClassName Win32_serialport | Where-Object {\$_.PNPDeviceID -like '*VID_9AC4&PID_4B8F*' -or \$_.PNPDeviceID -like '*VID_2D2D&PID_504D*'} | Select -expandproperty DeviceID" 2>/dev/null | tr -dc '[:print:]'); do
_comport=$DEV
+1 -1
View File
@@ -442,7 +442,7 @@ static void score_traces(struct guess *g, unsigned int size) {
// then shift by size - 16, insert upper key XOR enc_nonce XOR bitstream,
// and calc new bit b
uint64_t lfsr = (uid >> (size - 16)) | ((g->key << (48 - size)) ^
((nonces[i].enc_nR ^ g->b0to31[i]) << (64 - size)));
((nonces[i].enc_nR ^ g->b0to31[i]) << (64 - size)));
g->b0to31[i] = g->b0to31[i] | (ht2crypt(lfsr) << (size - 16));
// create lfsr - lower 16 bits are lower 16 bits of key