mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
style
This commit is contained in:
parent
c7cf62fcf1
commit
a3c2d2b815
15 changed files with 58 additions and 47 deletions
|
@ -440,33 +440,32 @@ int json_dumpfd(const json_t *json, int output, size_t flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int json_dump_file(const json_t *json, const char *path, size_t flags) {
|
int json_dump_file(const json_t *json, const char *path, size_t flags) {
|
||||||
int result;
|
|
||||||
|
|
||||||
FILE *output = fopen(path, "w");
|
FILE *f = fopen(path, "w");
|
||||||
if (!output)
|
if (f == NULL) {
|
||||||
return -1;
|
|
||||||
|
|
||||||
result = json_dumpf(json, output, flags);
|
|
||||||
|
|
||||||
if (fclose(output) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags) {
|
|
||||||
int res;
|
|
||||||
hashtable_t parents_set;
|
|
||||||
|
|
||||||
if (!(flags & JSON_ENCODE_ANY)) {
|
|
||||||
if (!json_is_array(json) && !json_is_object(json))
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hashtable_init(&parents_set))
|
int res = json_dumpf(json, f, flags);
|
||||||
|
|
||||||
|
if (fclose(f) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
res = do_dump(json, flags, 0, &parents_set, callback, data);
|
|
||||||
hashtable_close(&parents_set);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags) {
|
||||||
|
if (!(flags & JSON_ENCODE_ANY)) {
|
||||||
|
if (!json_is_array(json) && !json_is_object(json)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hashtable_t parents_set;
|
||||||
|
if (hashtable_init(&parents_set)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int res = do_dump(json, flags, 0, &parents_set, callback, data);
|
||||||
|
hashtable_close(&parents_set);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ int read_iclass_csn(bool loop, bool verbose, bool shallow_mod) {
|
||||||
res = PM3_EMALLOC;
|
res = PM3_EMALLOC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (loop && kbd_enter_pressed() == false);
|
} while (loop && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
DropField();
|
DropField();
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -781,17 +781,20 @@ int legic_print_type(uint32_t tagtype, uint8_t spaces) {
|
||||||
}
|
}
|
||||||
int legic_get_type(legic_card_select_t *card) {
|
int legic_get_type(legic_card_select_t *card) {
|
||||||
|
|
||||||
if (card == NULL)
|
if (card == NULL) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_LEGIC_INFO, NULL, 0);
|
SendCommandNG(CMD_HF_LEGIC_INFO, NULL, 0);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (WaitForResponseTimeout(CMD_HF_LEGIC_INFO, &resp, 1500) == false)
|
if (WaitForResponseTimeout(CMD_HF_LEGIC_INFO, &resp, 1500) == false) {
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
if (resp.status != PM3_SUCCESS)
|
if (resp.status != PM3_SUCCESS) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(card, resp.data.asBytes, sizeof(legic_card_select_t));
|
memcpy(card, resp.data.asBytes, sizeof(legic_card_select_t));
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -1527,7 +1530,7 @@ int readLegicUid(bool loop, bool verbose) {
|
||||||
PrintAndLogEx(SUCCESS, " MSN: " _GREEN_("%s"), sprint_hex(card.uid + 1, sizeof(card.uid) - 1));
|
PrintAndLogEx(SUCCESS, " MSN: " _GREEN_("%s"), sprint_hex(card.uid + 1, sizeof(card.uid) - 1));
|
||||||
legic_print_type(card.cardsize, 0);
|
legic_print_type(card.cardsize, 0);
|
||||||
|
|
||||||
} while (loop && kbd_enter_pressed() == false);
|
} while (loop && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,7 +462,7 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (cm && kbd_enter_pressed() == false);
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,7 +859,7 @@ int CmdLFRead(const char *Cmd) {
|
||||||
int ret = PM3_SUCCESS;
|
int ret = PM3_SUCCESS;
|
||||||
do {
|
do {
|
||||||
ret = lf_read_internal(realtime, verbose, samples);
|
ret = lf_read_internal(realtime, verbose, samples);
|
||||||
} while (cm && kbd_enter_pressed() == false);
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
if (ret == PM3_SUCCESS) {
|
if (ret == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(SUCCESS, "Got " _YELLOW_("%zu") " samples", g_GraphTraceLen);
|
PrintAndLogEx(SUCCESS, "Got " _YELLOW_("%zu") " samples", g_GraphTraceLen);
|
||||||
|
@ -985,7 +985,7 @@ int CmdLFSniff(const char *Cmd) {
|
||||||
int ret = PM3_SUCCESS;
|
int ret = PM3_SUCCESS;
|
||||||
do {
|
do {
|
||||||
ret = lf_sniff(realtime, verbose, samples);
|
ret = lf_sniff(realtime, verbose, samples);
|
||||||
} while (cm && kbd_enter_pressed() == false);
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ static int CmdAWIDReader(const char *Cmd) {
|
||||||
do {
|
do {
|
||||||
lf_read(false, 12000);
|
lf_read(false, 12000);
|
||||||
demodAWID(!cm);
|
demodAWID(!cm);
|
||||||
} while (cm && !kbd_enter_pressed());
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,7 +445,7 @@ static int CmdEM410xReader(const char *Cmd) {
|
||||||
if (break_first && gs_em410xid != 0) {
|
if (break_first && gs_em410xid != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (cm && !kbd_enter_pressed());
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@ static int CmdGuardReader(const char *Cmd) {
|
||||||
do {
|
do {
|
||||||
lf_read(false, 10000);
|
lf_read(false, 10000);
|
||||||
demodGuard(!cm);
|
demodGuard(!cm);
|
||||||
} while (cm && !kbd_enter_pressed());
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ static int CmdHIDReader(const char *Cmd) {
|
||||||
do {
|
do {
|
||||||
lf_read(false, 16000);
|
lf_read(false, 16000);
|
||||||
demodHID(!cm);
|
demodHID(!cm);
|
||||||
} while (cm && !kbd_enter_pressed());
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -912,7 +912,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||||
if (ht2_get_uid(&uid)) {
|
if (ht2_get_uid(&uid)) {
|
||||||
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
||||||
}
|
}
|
||||||
} while (cm && kbd_enter_pressed() == false);
|
} while (cm && (kbd_enter_pressed() == false));
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,10 +575,11 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext_t *ctx, uin
|
||||||
size_t sentdatalen = 0;
|
size_t sentdatalen = 0;
|
||||||
while (cdatalen >= sentdatalen) {
|
while (cdatalen >= sentdatalen) {
|
||||||
|
|
||||||
if ((cdatalen - sentdatalen) > DESFIRE_TX_FRAME_MAX_LEN)
|
if ((cdatalen - sentdatalen) > DESFIRE_TX_FRAME_MAX_LEN) {
|
||||||
len = DESFIRE_TX_FRAME_MAX_LEN;
|
len = DESFIRE_TX_FRAME_MAX_LEN;
|
||||||
else
|
} else {
|
||||||
len = cdatalen - sentdatalen;
|
len = cdatalen - sentdatalen;
|
||||||
|
}
|
||||||
|
|
||||||
size_t sendindx = sentdatalen;
|
size_t sendindx = sentdatalen;
|
||||||
size_t sendlen = len;
|
size_t sendlen = len;
|
||||||
|
@ -657,9 +658,10 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext_t *ctx, uin
|
||||||
}
|
}
|
||||||
pos += buflen;
|
pos += buflen;
|
||||||
|
|
||||||
if (rcode != MFDES_ADDITIONAL_FRAME)
|
if (rcode != MFDES_ADDITIONAL_FRAME) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (resplen) {
|
if (resplen) {
|
||||||
*resplen = (splitbysize) ? i : pos;
|
*resplen = (splitbysize) ? i : pos;
|
||||||
|
@ -969,12 +971,14 @@ int DesfireSelectAIDHexNoFieldOn(DesfireContext_t *ctx, uint32_t aid) {
|
||||||
ctx->secureChannel = DACNone;
|
ctx->secureChannel = DACNone;
|
||||||
int res = DesfireExchangeEx(false, ctx, MFDES_SELECT_APPLICATION, data, 3, &respcode, resp, &resplen, true, 0);
|
int res = DesfireExchangeEx(false, ctx, MFDES_SELECT_APPLICATION, data, 3, &respcode, resp, &resplen, true, 0);
|
||||||
if (res == PM3_SUCCESS) {
|
if (res == PM3_SUCCESS) {
|
||||||
if (resplen != 0)
|
if (resplen != 0) {
|
||||||
return PM3_ECARDEXCHANGE;
|
return PM3_ECARDEXCHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
// select operation fail
|
// select operation fail
|
||||||
if (respcode != MFDES_S_OPERATION_OK)
|
if (respcode != MFDES_S_OPERATION_OK) {
|
||||||
return PM3_EAPDU_FAIL;
|
return PM3_EAPDU_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
DesfireClearSession(ctx);
|
DesfireClearSession(ctx);
|
||||||
ctx->appSelected = (aid != 0x000000);
|
ctx->appSelected = (aid != 0x000000);
|
||||||
|
|
|
@ -17,14 +17,12 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <libgen.h> // basename
|
#include <libgen.h> // basename
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "pm3line.h"
|
#include "pm3line.h"
|
||||||
#include "usart_defs.h"
|
#include "usart_defs.h"
|
||||||
#include "util_posix.h"
|
#include "util_posix.h"
|
||||||
|
@ -43,7 +41,6 @@
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int mainret = PM3_SUCCESS;
|
static int mainret = PM3_SUCCESS;
|
||||||
|
|
||||||
#ifndef LIBPM3
|
#ifndef LIBPM3
|
||||||
|
@ -209,7 +206,6 @@ static void showBanner(void) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, " [ " _YELLOW_("%s!")" :coffee: ]", get_quote());
|
PrintAndLogEx(NORMAL, " [ " _YELLOW_("%s!")" :coffee: ]", get_quote());
|
||||||
// PrintAndLogEx(NORMAL, " [ https://patreon.com/iceman1001/ ]");
|
// PrintAndLogEx(NORMAL, " [ https://patreon.com/iceman1001/ ]");
|
||||||
// PrintAndLogEx(NORMAL, "");
|
|
||||||
// PrintAndLogEx(NORMAL, " Monero");
|
// PrintAndLogEx(NORMAL, " Monero");
|
||||||
// PrintAndLogEx(NORMAL, " 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP");
|
// PrintAndLogEx(NORMAL, " 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
|
@ -75,6 +75,7 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
int calculate_hours_between_dates(const Date_t s, Date_t *e);
|
int calculate_hours_between_dates(const Date_t s, Date_t *e);
|
||||||
|
void add_minutes(Date_t *d, int minutes_to_add);
|
||||||
void add_hours(Date_t *d, int hours_to_add);
|
void add_hours(Date_t *d, int hours_to_add);
|
||||||
void add_days(Date_t *d, int days_to_add);
|
void add_days(Date_t *d, int days_to_add);
|
||||||
uint8_t days_in_month(int year, int month);
|
uint8_t days_in_month(int year, int month);
|
||||||
|
|
|
@ -29,7 +29,7 @@ typedef struct {
|
||||||
enum {
|
enum {
|
||||||
TAG_STATE_RESET = 0x01, // Just powered up, awaiting GetSnr
|
TAG_STATE_RESET = 0x01, // Just powered up, awaiting GetSnr
|
||||||
TAG_STATE_ACTIVATING = 0x02, // In activation phase (password mode), sent UID, awaiting reader password
|
TAG_STATE_ACTIVATING = 0x02, // In activation phase (password mode), sent UID, awaiting reader password
|
||||||
TAG_STATE_ACTIVATED = 0x03, // Activation complete, awaiting read/write commands
|
// TAG_STATE_ACTIVATED = 0x03, // Activation complete, awaiting read/write commands
|
||||||
TAG_STATE_WRITING = 0x04, // In write command, awaiting sector contents to be written
|
TAG_STATE_WRITING = 0x04, // In write command, awaiting sector contents to be written
|
||||||
} state;
|
} state;
|
||||||
uint16_t active_sector;
|
uint16_t active_sector;
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// iCLASS / PICOPASS
|
// iCLASS / PICOPASS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#define PICOPASS_BLOCK_SIZE 8
|
#define PICOPASS_BLOCK_SIZE ( 8 )
|
||||||
|
#define PICOPASS_MAX_BYTES ( 4096 ) // # 32k bits = 4096 bytes
|
||||||
|
|
||||||
// iCLASS reader flags
|
// iCLASS reader flags
|
||||||
#define FLAG_ICLASS_READER_INIT 0x01
|
#define FLAG_ICLASS_READER_INIT 0x01
|
||||||
|
@ -197,5 +198,12 @@ typedef struct {
|
||||||
} header;
|
} header;
|
||||||
} PACKED iclass_card_select_resp_t;
|
} PACKED iclass_card_select_resp_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
picopass_hdr_t hdr;
|
||||||
|
picopass_ns_hdr_t ns_hdr;
|
||||||
|
} header;
|
||||||
|
uint8_t data[PICOPASS_MAX_BYTES];
|
||||||
|
} PACKED iclass_tag_t;
|
||||||
|
|
||||||
#endif // _ICLASS_H_
|
#endif // _ICLASS_H_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue