mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-24 09:16:13 +08:00
commit
efb919f529
|
@ -9,10 +9,10 @@
|
|||
#define lconfig_h
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
|
||||
#define system(s) ((s)==NULL ? 0 : -1)
|
||||
#endif // end iOS
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
|
||||
#define system(s) ((s)==NULL ? 0 : -1)
|
||||
#endif // end iOS
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
|
|
@ -1064,7 +1064,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
|||
memcpy(bldata, dump, MFBLOCK_SIZE);
|
||||
|
||||
// if sector trailer
|
||||
if (mfNumBlocksPerSector(s)-1 == b) {
|
||||
if (mfNumBlocksPerSector(s) - 1 == b) {
|
||||
if (use_keyfile_for_auth == false) {
|
||||
// replace KEY A
|
||||
bldata[0] = (keyA[s][0]);
|
||||
|
|
|
@ -3404,7 +3404,7 @@ static int DesfireCreateFileParameters(
|
|||
uint8_t pfileid, uint8_t pisofileid,
|
||||
uint8_t amodeid, uint8_t frightsid,
|
||||
uint8_t r_modeid, uint8_t w_modeid, uint8_t rw_modeid, uint8_t ch_modeid,
|
||||
uint8_t *data, size_t *datalen ) {
|
||||
uint8_t *data, size_t *datalen) {
|
||||
|
||||
*datalen = 0;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
|
|||
|
||||
return true;
|
||||
}
|
||||
static uint8_t calc_pos(uint8_t *d){
|
||||
static uint8_t calc_pos(uint8_t *d) {
|
||||
// PCB [CID] [NAD] [INF] CRC CRC
|
||||
uint8_t pos = 1;
|
||||
if ((d[0] & 0x08) == 0x08) // cid byte following
|
||||
|
@ -208,7 +208,7 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
if (extract_uidlen == 8) {
|
||||
PrintAndLogEx(INFO, "hf iclass lookup --csn %s " NOLF, sprint_hex_inrow(extract_uid, extract_uidlen));
|
||||
PrintAndLogEx(NORMAL, "--epurse %s " NOLF, sprint_hex_inrow(extract_epurse, 8));
|
||||
PrintAndLogEx(NORMAL, "--macs %s " NOLF, sprint_hex_inrow(frame + 1, 8) );
|
||||
PrintAndLogEx(NORMAL, "--macs %s " NOLF, sprint_hex_inrow(frame + 1, 8));
|
||||
PrintAndLogEx(NORMAL, "-f iclass_default_keys.dic");
|
||||
return tracepos;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
|
||||
if (next_hdr->frame[pos] == MFDES_ADDITIONAL_FRAME) {
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex_inrow(next_hdr->frame + pos + long_jmp, (tdea<<1)));
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex_inrow(next_hdr->frame + pos + long_jmp, (tdea << 1)));
|
||||
}
|
||||
return tracepos;
|
||||
}
|
||||
|
|
|
@ -87,17 +87,17 @@ static void ln_command_completion(const char *text, linenoiseCompletions *lc) {
|
|||
// When no pm3 device present
|
||||
// and the command is not available offline,
|
||||
// we skip it.
|
||||
if ((g_session.pm3_present == false) && (vocabulory[index].offline == false )) {
|
||||
if ((g_session.pm3_present == false) && (vocabulory[index].offline == false)) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (strncmp (command, text, len) == 0) {
|
||||
if (strncmp(command, text, len) == 0) {
|
||||
const char *space = strstr(command + len, " ");
|
||||
if (space != NULL) {
|
||||
if ((prev_match_len == 0) || (strncmp (prev_match, command, prev_match_len < space - command ? prev_match_len : space - command) != 0)) {
|
||||
if ((prev_match_len == 0) || (strncmp(prev_match, command, prev_match_len < space - command ? prev_match_len : space - command) != 0)) {
|
||||
linenoiseAddCompletion(lc, str_ndup(command, space - command + 1));
|
||||
prev_match = command;
|
||||
prev_match_len = space - command + 1;
|
||||
|
|
|
@ -176,10 +176,14 @@ const static vocabulory_t vocabulory[] = {
|
|||
{ 0, "hf 15 csetuid" },
|
||||
{ 1, "hf cipurse help" },
|
||||
{ 0, "hf cipurse info" },
|
||||
{ 0, "hf cipurse select" },
|
||||
{ 0, "hf cipurse auth" },
|
||||
{ 0, "hf cipurse read" },
|
||||
{ 0, "hf cipurse write" },
|
||||
{ 0, "hf cipurse aread" },
|
||||
{ 0, "hf cipurse awrite" },
|
||||
{ 0, "hf cipurse formatall" },
|
||||
{ 0, "hf cipurse create" },
|
||||
{ 0, "hf cipurse delete" },
|
||||
{ 0, "hf cipurse default" },
|
||||
{ 1, "hf cipurse test" },
|
||||
|
@ -694,6 +698,7 @@ const static vocabulory_t vocabulory[] = {
|
|||
{ 1, "script list" },
|
||||
{ 1, "script run" },
|
||||
{ 1, "trace help" },
|
||||
{ 1, "trace extract" },
|
||||
{ 1, "trace list" },
|
||||
{ 1, "trace load" },
|
||||
{ 1, "trace save" },
|
||||
|
|
|
@ -4083,7 +4083,7 @@
|
|||
},
|
||||
"hf mf restore": {
|
||||
"command": "hf mf restore",
|
||||
"description": "restore mifare classic binary file to tag. the key file and data file will program the card sector trailers. by default we authenticate to card with key b 0xffffffffffff. `--uid` param is used for filename templates `hf-mf-<uid>-dump.bin` and `hf-mf-<uid>-key.bin. if not specified, it will read the card uid instead. `--ka` param you can indicate that the key file should be used for authentication instead. if so we also try both b/a keys",
|
||||
"description": "restore mifare classic dump file to tag. the key file and dump file will program the card sector trailers. by default we authenticate to card with key b 0xffffffffffff. if access rights in dump file is all zeros, it will be replaced with default values `--uid` param is used for filename templates `hf-mf-<uid>-dump.bin` and `hf-mf-<uid>-key.bin. if not specified, it will read the card uid instead. `--ka` param you can indicate that the key file should be used for authentication instead. if so we also try both b/a keys",
|
||||
"notes": [
|
||||
"hf mf restore",
|
||||
"hf mf restore --1k --uid 04010203",
|
||||
|
@ -4098,7 +4098,7 @@
|
|||
"--2k mifare classic/plus 2k",
|
||||
"--4k mifare classic 4k / s70",
|
||||
"-u, --uid <hex> uid, 6 hex bytes",
|
||||
"-f, --file <fn> data filename",
|
||||
"-f, --file <fn> specify dump filename (bin/eml/json)",
|
||||
"-k, --kfn <fn> key filename",
|
||||
"--ka use specified keyfile to authenticate"
|
||||
],
|
||||
|
@ -4152,24 +4152,24 @@
|
|||
},
|
||||
"hf mf staticnested": {
|
||||
"command": "hf mf staticnested",
|
||||
"description": "execute nested attack against mifare classic card with static nonce for key recovery",
|
||||
"description": "execute nested attack against mifare classic card with static nonce for key recovery. supply a known key from one block to recover all keys",
|
||||
"notes": [
|
||||
"hf mf staticnested --mini --blk 0 -a -k ffffffffffff -> key recovery against mifare mini",
|
||||
"hf mf staticnested --1k --blk 0 -a -k ffffffffffff -> key recovery against mifare classic 1k",
|
||||
"hf mf staticnested --2k --blk 0 -a -k ffffffffffff -> key recovery against mifare 2k",
|
||||
"hf mf staticnested --4k --blk 0 -a -k ffffffffffff -> key recovery against mifare 4k"
|
||||
"hf mf staticnested --mini --blk 0 -a -k ffffffffffff",
|
||||
"hf mf staticnested --1k --blk 0 -a -k ffffffffffff",
|
||||
"hf mf staticnested --2k --blk 0 -a -k ffffffffffff",
|
||||
"hf mf staticnested --4k --blk 0 -a -k ffffffffffff"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help this help",
|
||||
"-k, --key <hex> key specified as 12 hex symbols",
|
||||
"-k, --key <hex> known key (12 hex symbols)",
|
||||
"--mini mifare classic mini / s20",
|
||||
"--1k mifare classic 1k / s50",
|
||||
"--2k mifare classic/plus 2k",
|
||||
"--4k mifare classic 4k / s70",
|
||||
"--blk <dec> input block number",
|
||||
"-a input key specified is a key (default)",
|
||||
"-b input key specified is b key",
|
||||
"-a input key specified is keya (def)",
|
||||
"-b input key specified is keyb",
|
||||
"-e, --emukeys fill simulator keys from found keys",
|
||||
"--dumpkeys dump found keys to file"
|
||||
],
|
||||
|
@ -10345,6 +10345,6 @@
|
|||
"metadata": {
|
||||
"commands_extracted": 603,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2022-02-04T13:37:03"
|
||||
"extracted_on": "2022-02-05T11:30:03"
|
||||
}
|
||||
}
|
|
@ -63,19 +63,19 @@ static int decrypt(uint8_t ciphertext[], int ciphertext_len, uint8_t key[], uint
|
|||
int len;
|
||||
int plaintext_len;
|
||||
|
||||
if(!(ctx = EVP_CIPHER_CTX_new()))
|
||||
if (!(ctx = EVP_CIPHER_CTX_new()))
|
||||
handleErrors();
|
||||
|
||||
if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv))
|
||||
if (1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv))
|
||||
handleErrors();
|
||||
|
||||
EVP_CIPHER_CTX_set_padding(ctx, 0);
|
||||
|
||||
if(1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
|
||||
if (1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
|
||||
handleErrors();
|
||||
plaintext_len = len;
|
||||
|
||||
if(1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
|
||||
if (1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
|
||||
handleErrors();
|
||||
plaintext_len += len;
|
||||
|
||||
|
@ -89,7 +89,7 @@ static int hexstr_to_byte_array(char hexstr[], uint8_t bytes[], size_t byte_len)
|
|||
if (hexstr_len % 16) {
|
||||
return 1;
|
||||
}
|
||||
if (byte_len < hexstr_len/2) {
|
||||
if (byte_len < hexstr_len / 2) {
|
||||
return 2;
|
||||
}
|
||||
char *pos = &hexstr[0];
|
||||
|
@ -100,7 +100,7 @@ static int hexstr_to_byte_array(char hexstr[], uint8_t bytes[], size_t byte_len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
uint8_t iv[16] = {0x00};
|
||||
uint8_t key[16] = {0x00};
|
||||
|
@ -116,10 +116,10 @@ int main (int argc, char* argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(hexstr_to_byte_array(argv[2], tag_challenge, sizeof(tag_challenge)))
|
||||
if (hexstr_to_byte_array(argv[2], tag_challenge, sizeof(tag_challenge)))
|
||||
return 2;
|
||||
|
||||
if(hexstr_to_byte_array(argv[3], lock_challenge, sizeof(lock_challenge)))
|
||||
if (hexstr_to_byte_array(argv[3], lock_challenge, sizeof(lock_challenge)))
|
||||
return 3;
|
||||
|
||||
uint64_t start_time = time(NULL);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __STDC_FORMAT_MACROS
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
#define _POSIX_C_SOURCE 200112L // need localtime_r()
|
||||
#define _POSIX_C_SOURCE 200112L // need localtime_r()
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -213,7 +213,7 @@ static void *brute_thread(void *arguments) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int usage(const char* s) {
|
||||
static int usage(const char *s) {
|
||||
printf(_YELLOW_("syntax:") "\n");
|
||||
printf(" %s <unix timestamp> <16 byte tag challenge> <32 byte reader response challenge>\n", s);
|
||||
printf("\n");
|
||||
|
@ -223,7 +223,7 @@ static int usage(const char* s) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
printf("\n");
|
||||
printf(_CYAN_("Telenot access MIFARE DESFire AES key recovery tool") "\n");
|
||||
|
|
Loading…
Reference in a new issue