This commit is contained in:
iceman1001 2021-04-08 11:08:39 +02:00
parent 27184d7f5b
commit 007b916643
21 changed files with 226 additions and 226 deletions

View file

@ -89,7 +89,7 @@ int rdv4_validate(rdv40_validation_t *mem) {
return PM3_EFAILED;
}
static int rdv4_sign_write(uint8_t *signature, uint8_t slen){
static int rdv4_sign_write(uint8_t *signature, uint8_t slen) {
// save to mem
clearCommandBuffer();
PacketResponseNG resp;
@ -439,14 +439,14 @@ static int CmdFlashMemInfo(const char *Cmd) {
// shall_write = arg_get_lit(ctx, 5);
CLIParserFree(ctx);
if (res || (dlen > 0 && dlen < sizeof(id)) ) {
if (res || (dlen > 0 && dlen < sizeof(id))) {
PrintAndLogEx(FAILED, "Error parsing flash memory id, expect 8, got %d", dlen);
return PM3_EINVARG;
}
// set up PK key context now.
mbedtls_pk_context pkctx;
mbedtls_pk_init( &pkctx );
mbedtls_pk_init(&pkctx);
bool got_private = false;
// PEM
if (pemlen) {
@ -472,7 +472,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
return PM3_EFILE;
}
mbedtls_rsa_context *rsa = (mbedtls_rsa_context*)pkctx.pk_ctx;
mbedtls_rsa_context *rsa = (mbedtls_rsa_context *)pkctx.pk_ctx;
if (rsa == NULL) {
PrintAndLogEx(FAILED, "failed to allocate rsa context memory");
return PM3_EMALLOC;
@ -482,7 +482,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
} else {
// it not loaded, we need to setup the context manually
if (mbedtls_pk_setup( &pkctx, mbedtls_pk_info_from_type( (mbedtls_pk_type_t) MBEDTLS_PK_RSA ) ) != 0 ) {
if (mbedtls_pk_setup(&pkctx, mbedtls_pk_info_from_type((mbedtls_pk_type_t) MBEDTLS_PK_RSA)) != 0) {
PrintAndLogEx(FAILED, "failed, mbedtls_pk_setup returned ");
return PM3_ESOFT;
}
@ -521,7 +521,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
mbedtls_rsa_context *rsa = NULL;
if (got_private) {
rsa = mbedtls_pk_rsa( pkctx );
rsa = mbedtls_pk_rsa(pkctx);
rsa->padding = MBEDTLS_RSA_PKCS_V15;
rsa->hash_id = 0;
rsa->len = RRG_RSA_KEY_LEN;

View file

@ -1171,7 +1171,7 @@ static int CmdHF15FindAfi(const char *Cmd) {
break;
}
if (WaitForResponseTimeout(CMD_HF_ISO15693_FINDAFI, &resp, 2000)){
if (WaitForResponseTimeout(CMD_HF_ISO15693_FINDAFI, &resp, 2000)) {
if (resp.status == PM3_EOPABORTED) {
PrintAndLogEx(DEBUG, "Button pressed, user aborted");
}

View file

@ -1217,7 +1217,7 @@ static void emrtd_mrz_replace_pad(char *data, int datalen, char newchar) {
static void emrtd_print_optional_elements(char *mrz, int offset, int length, bool verify_check_digit) {
int i = emrtd_mrz_determine_length(mrz, offset, length);
if (i == -1){
if (i == -1) {
return;
}

View file

@ -1383,7 +1383,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
bool custom_IDm = false;
uint16_t datalen = 13; // length (1) + CMD (1) + IDm(8) + Node Number (1) + Node Code List (2)
/*
/*
case 'i':
custom_IDm = true;
@ -1417,7 +1417,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
PrintAndLogEx(ERR, "Incorrect parameter length!");
return PM3_EINVARG;
}
*/
*/
uint8_t flags = FELICA_APPEND_CRC;
if (custom_IDm) {
@ -1480,20 +1480,20 @@ static int CmdHFFelicaSniff(const char *Cmd) {
payload.triggers = arg_get_u32_def(ctx, 2, 5000);
CLIParserFree(ctx);
if (payload.samples > 9999 ){
if (payload.samples > 9999) {
payload.samples = 9999;
PrintAndLogEx(INFO, "Too large samples to skip value, using max value 9999");
return PM3_EINVARG;
}
if (payload.triggers > 9999 ){
if (payload.triggers > 9999) {
payload.triggers = 9999;
PrintAndLogEx(INFO, "Too large trigger to skip value, using max value 9999");
return PM3_EINVARG;
}
PrintAndLogEx(INFO, "Sniff Felica, getting first %" PRIu32 " frames, skipping after %" PRIu32 " triggers", payload.samples, payload.triggers );
PrintAndLogEx(INFO, "Sniff Felica, getting first %" PRIu32 " frames, skipping after %" PRIu32 " triggers", payload.samples, payload.triggers);
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " or pm3-button to abort sniffing");
clearCommandBuffer();
SendCommandNG(CMD_HF_FELICA_SNIFF, (uint8_t *)&payload, sizeof(payload));
@ -1720,12 +1720,12 @@ static uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace, uint16_t trac
static int CmdHFFelicaDumpLite(const char *Cmd) {
/*
iceman 2021,
Why does this command say it dumps a FeliCa lite card
and then tries to print a trace?!?
Is this a trace list or a feclia dump cmd?
*/
/*
iceman 2021,
Why does this command say it dumps a FeliCa lite card
and then tries to print a trace?!?
Is this a trace list or a feclia dump cmd?
*/
CLIParserContext *ctx;
@ -1837,7 +1837,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
bool active = arg_get_lit(ctx, 1);
bool crc = arg_get_lit(ctx, 2);
bool keep_field_on = arg_get_lit(ctx, 3);
uint16_t numbits = arg_get_u32_def(ctx, 4, 0) &0xFFFF;
uint16_t numbits = arg_get_u32_def(ctx, 4, 0) & 0xFFFF;
bool reply = (arg_get_lit(ctx, 5) == false);
bool active_select = arg_get_lit(ctx, 6);

View file

@ -134,7 +134,7 @@ uint8_t card_app2_limit[] = {
0xff,
};
iclass_config_card_item_t iclass_config_types[14]= {
iclass_config_card_item_t iclass_config_types[14] = {
{"", ""},
{"", ""},
{"", ""},
@ -274,7 +274,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
return PM3_ENODATA;
}
uint8_t ffs[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
uint8_t ffs[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
if (Encrypt(ffs, ffs) == false) {
PrintAndLogEx(WARNING, "failed to encrypt FF");
}
@ -291,7 +291,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
memcpy(data + (0xD * 8), enckey1, sizeof(enckey1));
// encrypted 0xFF
for (uint8_t i = 0xe; i < 0x14; i++) {
memcpy(data + (i*8), ffs, sizeof(ffs));
memcpy(data + (i * 8), ffs, sizeof(ffs));
}
// encrypted partial keyroll key 14
@ -322,7 +322,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
} else {
memcpy(data, &iclass_last_known_card, sizeof(picopass_hdr_t));
memcpy(data + (6*8), o->data, sizeof(o->data));
memcpy(data + (6 * 8), o->data, sizeof(o->data));
}
// create filename
@ -3711,7 +3711,7 @@ static int CmdHFiClassAutopwn(const char *Cmd) {
}
*/
static int CmdHFiClassConfigCard(const char * Cmd) {
static int CmdHFiClassConfigCard(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf iclass configcard",

View file

@ -1338,7 +1338,7 @@ void annotateMifare(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, uint8
}
static void mf_get_paritybinstr(char *s, uint32_t val, uint8_t par) {
uint8_t foo[4] = {0,0,0,0};
uint8_t foo[4] = {0, 0, 0, 0};
num_to_bytes(val, sizeof(uint32_t), foo);
for (uint8_t i = 0; i < 4; i++) {
if (oddparity8(foo[i]) != ((par >> (7 - (i & 0x0007))) & 0x01))
@ -1444,11 +1444,11 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, uint8_t *parity, bool isRes
//PrintAndLogEx(NORMAL, "hardnested not implemented. uid:%x nt:%x ar_enc:%x at_enc:%x\n", AuthData.uid, AuthData.nt, AuthData.ar_enc, AuthData.at_enc);
char snt[5] = {0,0,0,0,0};
char snt[5] = {0, 0, 0, 0, 0};
mf_get_paritybinstr(snt, AuthData.nt_enc, AuthData.nt_enc_par);
char sar[5] = {0,0,0,0,0};
char sar[5] = {0, 0, 0, 0, 0};
mf_get_paritybinstr(sar, AuthData.ar_enc, AuthData.ar_enc_par);
char sat[5] = {0,0,0,0,0};
char sat[5] = {0, 0, 0, 0, 0};
mf_get_paritybinstr(sat, AuthData.at_enc, AuthData.at_enc_par);
PrintAndLogEx(NORMAL, "Nested authentication detected. ");

View file

@ -1251,7 +1251,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
if (use_keyfile_for_auth) {
for (uint8_t kt=0; kt < 2; kt++) {
for (uint8_t kt = 0; kt < 2; kt++) {
if (kt == 0)
memcpy(data, keyA[sectorNo], 6);

View file

@ -1075,7 +1075,7 @@ static mfu_identify_t mfu_ident_table[] = {
{NULL, NULL, 0, 0, NULL, NULL, NULL, NULL}
};
static mfu_identify_t* mfu_match_fingerprint(uint8_t *version, uint8_t *data) {
static mfu_identify_t *mfu_match_fingerprint(uint8_t *version, uint8_t *data) {
uint8_t i = 0;
do {
@ -1184,7 +1184,7 @@ static int mfu_fingerprint(void) {
uint8_t version[8] = {0};
uint8_t uid[7] = {0};
if (mfu_get_version_uid(version, uid) == PM3_SUCCESS) {
mfu_identify_t* item = mfu_match_fingerprint(version, data);
mfu_identify_t *item = mfu_match_fingerprint(version, data);
if (item) {
PrintAndLogEx(SUCCESS, "Found " _GREEN_("%s"), item->desc);
@ -3294,16 +3294,16 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
lock_on = true;
if ((phase_begin_clear == -1) && (bitcount32(*(uint32_t*)pre) > bitcount32(*(uint32_t*)post)))
if ((phase_begin_clear == -1) && (bitcount32(*(uint32_t *)pre) > bitcount32(*(uint32_t *)post)))
phase_begin_clear = current;
if ((phase_begin_clear > -1) && (phase_end_clear == -1) && (bitcount32(*(uint32_t*)post) == 0))
if ((phase_begin_clear > -1) && (phase_end_clear == -1) && (bitcount32(*(uint32_t *)post) == 0))
phase_end_clear = current;
if ((current == start) && (phase_end_clear > -1))
skip_phase1 = true;
// new write phase must be atleast 100us later..
if (((bitcount32(*(uint32_t*)pre) == 0) || (phase_end_clear > -1)) && (phase_begin_newwr == -1) && (bitcount32(*(uint32_t*)post) != 0) && (skip_phase1 || (current > (phase_end_clear + 100))))
if (((bitcount32(*(uint32_t *)pre) == 0) || (phase_end_clear > -1)) && (phase_begin_newwr == -1) && (bitcount32(*(uint32_t *)post) != 0) && (skip_phase1 || (current > (phase_end_clear + 100))))
phase_begin_newwr = current;
if ((phase_begin_newwr > -1) && (phase_end_newwr == -1) && (memcmp(post, teardata, sizeof(teardata)) == 0))
@ -3346,7 +3346,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
if ((phase_begin_clear > - 1) && (phase_begin_clear != start)) {
PrintAndLogEx(INFO, "Erase phase start boundary around " _YELLOW_("%5d") " us", phase_begin_clear);
}
if ((phase_end_clear > - 1) && (phase_end_clear != start)){
if ((phase_end_clear > - 1) && (phase_end_clear != start)) {
PrintAndLogEx(INFO, "Erase phase end boundary around " _YELLOW_("%5d") " us", phase_end_clear);
}
if (phase_begin_newwr > - 1) {
@ -3889,7 +3889,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
}
}
}
char *mattel = strstr((char*)records, ".pid.mattel/");
char *mattel = strstr((char *)records, ".pid.mattel/");
if (mattel) {
mattel += 12;
while (mattel) {

View file

@ -562,7 +562,7 @@ int CmdLFConfig(const char *Cmd) {
config.decimation = 8;
}
if (divisor> -1) {
if (divisor > -1) {
config.divisor = divisor;
if (config.divisor < 19) {
PrintAndLogEx(ERR, "divisor must be between 19 and 255");

View file

@ -470,7 +470,7 @@ int CmdEM4x50Chk(const char *Cmd) {
// upload to flash.
datalen = MIN(bytes_remaining, keyblock);
res = flashmem_spiffs_load((char*)destfn, keys, datalen);
res = flashmem_spiffs_load((char *)destfn, keys, datalen);
if (res != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "SPIFFS upload failed");
return res;

View file

@ -388,7 +388,7 @@ static int CmdHIDClone(const char *Cmd) {
packed.Mid = mid;
packed.Bot = bot;
} else if (bin_len) {
int res = binstring_to_u96(&top, &mid, &bot, (const char*)bin);
int res = binstring_to_u96(&top, &mid, &bot, (const char *)bin);
if (res != bin_len) {
PrintAndLogEx(ERR, "Binary string contains none <0|1> chars");
return PM3_EINVARG;

View file

@ -368,7 +368,7 @@ static int CmdLFHitagSim(const char *Cmd) {
bool use_hts = arg_get_lit(ctx, 3);
CLIParserFree(ctx);
if ((use_ht1 + use_ht2 + use_hts) > 1 ) {
if ((use_ht1 + use_ht2 + use_hts) > 1) {
PrintAndLogEx(ERR, "error, Only specify one Hitag type");
return PM3_EINVARG;
}
@ -659,10 +659,10 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
size_t datalen = 0;
int res = loadFile_safe(filename, ".cc", (void **)&data, &datalen);
if (res == PM3_SUCCESS) {
if (datalen == (8 * 60) ) {
if (datalen == (8 * 60)) {
SendCommandOLD(CMD_LF_HITAGS_TEST_TRACES, 1, 0, 0, data, datalen);
} else {
PrintAndLogEx(ERR, "Error, file length mismatch. Expected %d, got %zu", 8*60, datalen);
PrintAndLogEx(ERR, "Error, file length mismatch. Expected %d, got %zu", 8 * 60, datalen);
}
}
if (data) {

View file

@ -516,7 +516,7 @@ static int CmdT55xxSetConfig(const char *Cmd) {
break;
}
}
if (i == 9){
if (i == 9) {
PrintAndLogEx(FAILED, "Error select a valid bitrate");
return PM3_EINVARG;
}
@ -557,7 +557,7 @@ static int CmdT55xxSetConfig(const char *Cmd) {
config.downlink_mode = downlink_mode;
// validate user specific modulation
if (mods[0]){
if (mods[0]) {
config.modulation = DEMOD_FSK;
} else if (mods[1]) {
config.modulation = DEMOD_FSK1;
@ -1731,7 +1731,7 @@ static int CmdT55xxReadTrace(const char *Cmd) {
}
}
if (DemodBufferLen == 0){
if (DemodBufferLen == 0) {
return PM3_ESOFT;
}

View file

@ -330,7 +330,7 @@ static int smart_responseEx(uint8_t *out, int maxoutlen, bool verbose) {
memcpy(payload->data, cmd_getresp, sizeof(cmd_getresp));
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + sizeof(cmd_getresp));
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + sizeof(cmd_getresp));
free(payload);
datalen = smart_wait(out, maxoutlen, verbose);
@ -439,7 +439,7 @@ static int CmdSmartRaw(const char *Cmd) {
}
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + dlen);
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + dlen);
if (reply == false) {
goto out;
@ -459,7 +459,7 @@ static int CmdSmartRaw(const char *Cmd) {
data[4] = buf[1];
memcpy(payload->data, data, dlen);
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + dlen);
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + dlen);
len = smart_response(buf, PM3_CMD_DATA_SIZE);
@ -858,7 +858,7 @@ static void smart_brute_prim(void) {
memcpy(payload->data, get_card_data + i, 5);
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + 5);
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + 5);
free(payload);
int len = smart_responseEx(buf, PM3_CMD_DATA_SIZE, false);
@ -901,7 +901,7 @@ static int smart_brute_sfi(bool decodeTLV) {
memcpy(payload->data, READ_RECORD, sizeof(READ_RECORD));
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + sizeof(READ_RECORD));
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + sizeof(READ_RECORD));
len = smart_responseEx(buf, PM3_CMD_DATA_SIZE, false);
@ -910,7 +910,7 @@ static int smart_brute_sfi(bool decodeTLV) {
memcpy(payload->data, READ_RECORD, sizeof(READ_RECORD));
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + sizeof(READ_RECORD));
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + sizeof(READ_RECORD));
len = smart_responseEx(buf, PM3_CMD_DATA_SIZE, false);
READ_RECORD[4] = 0;
@ -952,7 +952,7 @@ static void smart_brute_options(bool decodeTLV) {
memcpy(payload->data, GET_PROCESSING_OPTIONS, sizeof(GET_PROCESSING_OPTIONS));
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + sizeof(GET_PROCESSING_OPTIONS));
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + sizeof(GET_PROCESSING_OPTIONS));
free(payload);
int len = smart_responseEx(buf, PM3_CMD_DATA_SIZE, false);
@ -1054,7 +1054,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
memcpy(payload->data, cmddata, hexlen);
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + hexlen);
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + hexlen);
free(payload);
int len = smart_responseEx(buf, PM3_CMD_DATA_SIZE, false);
@ -1138,7 +1138,7 @@ int ExchangeAPDUSC(bool verbose, uint8_t *datain, int datainlen, bool activateCa
memcpy(payload->data, datain, datainlen);
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + datainlen);
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + datainlen);
int len = smart_responseEx(dataout, maxdataoutlen, verbose);
if (len < 0) {
@ -1155,7 +1155,7 @@ int ExchangeAPDUSC(bool verbose, uint8_t *datain, int datainlen, bool activateCa
datain[4] = dataout[len - 1];
memcpy(payload->data, datain, 5);
clearCommandBuffer();
SendCommandNG(CMD_SMART_RAW, (uint8_t*)payload, sizeof(smart_card_raw_t) + 5);
SendCommandNG(CMD_SMART_RAW, (uint8_t *)payload, sizeof(smart_card_raw_t) + 5);
datain[4] = 0;
len = smart_responseEx(dataout, maxdataoutlen, verbose);
}

View file

@ -695,7 +695,7 @@ int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBl
mem[4] = (chunk & 0xFF);
// upload to flash.
res = flashmem_spiffs_load((char*)destfn, mem, 5 + (chunk * 6));
res = flashmem_spiffs_load((char *)destfn, mem, 5 + (chunk * 6));
if (res != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "\nSPIFFS upload failed");
free(mem);
@ -1226,7 +1226,7 @@ int detect_mfc_ev1_signature(uint8_t *signature) {
uint8_t sign[32] = {0};
uint8_t key[] = {0x4b, 0x79, 0x1b, 0xea, 0x7b, 0xcc};
int res = mfReadBlock(69, 1, key, sign);
if ( res == PM3_SUCCESS) {
if (res == PM3_SUCCESS) {
res = mfReadBlock(70, 1, key, sign + 16);
if (res == PM3_SUCCESS) {
memcpy(signature, sign, sizeof(sign));