Merge pull request #1486 from merlokk/mst

make style
This commit is contained in:
Oleg Moiseenko 2021-08-25 14:48:39 +03:00 committed by GitHub
commit 680fb12250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 3972 additions and 4091 deletions

View file

@ -19,11 +19,11 @@ void hf_field_off(void);
int tearoff_hook(void); int tearoff_hook(void);
#if defined RDV4 || defined ICOPYX #if defined RDV4 || defined ICOPYX
// ADC Vref = 3300mV, and an (10000k+240k):240k voltage divider on the LF input can measure voltages up to 140800 mV // ADC Vref = 3300mV, and an (10000k+240k):240k voltage divider on the LF input can measure voltages up to 140800 mV
#define MAX_ADC_HF_VOLTAGE 140800 #define MAX_ADC_HF_VOLTAGE 140800
#else #else
// ADC Vref = 3300mV, and an (10M+1M):1M voltage divider on the HF input can measure voltages up to 36300 mV // ADC Vref = 3300mV, and an (10M+1M):1M voltage divider on the HF input can measure voltages up to 36300 mV
#define MAX_ADC_HF_VOLTAGE 36300 #define MAX_ADC_HF_VOLTAGE 36300
#endif #endif
// ADC Vref = 3300mV, (240k-10M):240k voltage divider, 140800 mV // ADC Vref = 3300mV, (240k-10M):240k voltage divider, 140800 mV
#define MAX_ADC_LF_VOLTAGE 140800 #define MAX_ADC_LF_VOLTAGE 140800

View file

@ -444,8 +444,7 @@ static bool FpgaConfCurrentMode(int bitstream_version) {
if (bitstream_version == FPGA_BITSTREAM_LF) { if (bitstream_version == FPGA_BITSTREAM_LF) {
LOW(GPIO_FPGA_SWITCH); LOW(GPIO_FPGA_SWITCH);
} } else {
else {
HIGH(GPIO_FPGA_SWITCH); HIGH(GPIO_FPGA_SWITCH);
} }
// update downloaded_bitstream // update downloaded_bitstream

View file

@ -115,41 +115,41 @@ static void UsbPacketReceived(uint8_t *packet) {
#if defined ICOPYX #if defined ICOPYX
if (c->arg[1] == 0xff && c->arg[2] == 0x1fd) { if (c->arg[1] == 0xff && c->arg[2] == 0x1fd) {
#endif #endif
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
uint32_t flash_address = arg0 + (0x100 * j); uint32_t flash_address = arg0 + (0x100 * j);
AT91PS_EFC efc_bank = AT91C_BASE_EFC0; AT91PS_EFC efc_bank = AT91C_BASE_EFC0;
int offset = 0; int offset = 0;
uint32_t page_n = (flash_address - (uint32_t)_flash_start) / AT91C_IFLASH_PAGE_SIZE; uint32_t page_n = (flash_address - (uint32_t)_flash_start) / AT91C_IFLASH_PAGE_SIZE;
if (page_n >= AT91C_IFLASH_NB_OF_PAGES / 2) { if (page_n >= AT91C_IFLASH_NB_OF_PAGES / 2) {
page_n -= AT91C_IFLASH_NB_OF_PAGES / 2; page_n -= AT91C_IFLASH_NB_OF_PAGES / 2;
efc_bank = AT91C_BASE_EFC1; efc_bank = AT91C_BASE_EFC1;
// We need to offset the writes or it will not fill the correct bank write buffer. // We need to offset the writes or it will not fill the correct bank write buffer.
offset = (AT91C_IFLASH_NB_OF_PAGES / 2) * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t); offset = (AT91C_IFLASH_NB_OF_PAGES / 2) * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t);
} }
for (int i = 0 + (64 * j); i < 64 + (64 * j); i++) { for (int i = 0 + (64 * j); i < 64 + (64 * j); i++) {
_flash_start[offset + i] = c->d.asDwords[i]; _flash_start[offset + i] = c->d.asDwords[i];
} }
/* Check that the address that we are supposed to write to is within our allowed region */ /* Check that the address that we are supposed to write to is within our allowed region */
if (((flash_address + AT91C_IFLASH_PAGE_SIZE - 1) >= end_addr) || (flash_address < start_addr)) { if (((flash_address + AT91C_IFLASH_PAGE_SIZE - 1) >= end_addr) || (flash_address < start_addr)) {
/* Disallow write */ /* Disallow write */
ack = false; ack = false;
reply_old(CMD_NACK, 0, 0, 0, 0, 0); reply_old(CMD_NACK, 0, 0, 0, 0, 0);
} else { } else {
efc_bank->EFC_FCR = MC_FLASH_COMMAND_KEY | efc_bank->EFC_FCR = MC_FLASH_COMMAND_KEY |
MC_FLASH_COMMAND_PAGEN(page_n) | MC_FLASH_COMMAND_PAGEN(page_n) |
AT91C_MC_FCMD_START_PROG; AT91C_MC_FCMD_START_PROG;
} }
// Wait until flashing of page finishes // Wait until flashing of page finishes
uint32_t sr; uint32_t sr;
while (!((sr = efc_bank->EFC_FSR) & AT91C_MC_FRDY)); while (!((sr = efc_bank->EFC_FSR) & AT91C_MC_FRDY));
if (sr & (AT91C_MC_LOCKE | AT91C_MC_PROGE)) { if (sr & (AT91C_MC_LOCKE | AT91C_MC_PROGE)) {
ack = false; ack = false;
reply_old(CMD_NACK, sr, 0, 0, 0, 0); reply_old(CMD_NACK, sr, 0, 0, 0, 0);
}
} }
}
#if defined ICOPYX #if defined ICOPYX
} }
#endif #endif

View file

@ -164,7 +164,7 @@ uint8_t iclass_CRC_check(bool isResponse, uint8_t *d, uint8_t n) {
int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
if ((gs_ntag_i2c_state == 1) && (cmdsize == 6) && (memcmp(cmd+1, "\x00\x00\x00", 3) == 0)) { if ((gs_ntag_i2c_state == 1) && (cmdsize == 6) && (memcmp(cmd + 1, "\x00\x00\x00", 3) == 0)) {
snprintf(exp, size, "SECTOR(%d)", cmd[0]); snprintf(exp, size, "SECTOR(%d)", cmd[0]);
gs_ntag_i2c_state = 0; gs_ntag_i2c_state = 0;
return 1; return 1;
@ -244,14 +244,13 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
if (cmdsize == 4) if (cmdsize == 4)
// cmd0 == 0xC2 and cmd1 == 0xFF // cmd0 == 0xC2 and cmd1 == 0xFF
// high probability its SELECT SECTOR COMMAND: // high probability its SELECT SECTOR COMMAND:
if (cmd[1] == 0xFF) { if (cmd[1] == 0xFF) {
snprintf(exp, size, "SELECT SECTOR"); snprintf(exp, size, "SELECT SECTOR");
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 0; return 0;
break; break;
case MIFARE_CMD_TRANSFER: case MIFARE_CMD_TRANSFER:
@ -344,12 +343,12 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
snprintf(exp, size, "?"); snprintf(exp, size, "?");
break; break;
} }
case NTAG_I2C_FASTWRITE: case NTAG_I2C_FASTWRITE:
if (cmdsize == 69) if (cmdsize == 69)
snprintf(exp, size, "FAST WRITE (%d - %d)", cmd[1], cmd[2]); snprintf(exp, size, "FAST WRITE (%d - %d)", cmd[1], cmd[2]);
else else
snprintf(exp, size, "?"); snprintf(exp, size, "?");
break; break;
default: default:
return 0; return 0;

View file

@ -683,7 +683,7 @@ static int CmdHF14ADesInfo(const char *Cmd) {
PrintAndLogEx(SUCCESS, " Card doesn't support 'free mem' cmd"); PrintAndLogEx(SUCCESS, " Card doesn't support 'free mem' cmd");
} }
} }
if (cardtype == DESFIRE_LIGHT) { if (cardtype == DESFIRE_LIGHT) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("Desfire Light info")); PrintAndLogEx(INFO, "--- " _CYAN_("Desfire Light info"));

View file

@ -189,7 +189,7 @@ static int testBitStream(void) {
uint8_t output [] = {0, 0, 0, 0, 0, 0, 0, 0}; uint8_t output [] = {0, 0, 0, 0, 0, 0, 0, 0};
BitstreamIn_t in = { input, sizeof(input) * 8, 0}; BitstreamIn_t in = { input, sizeof(input) * 8, 0};
BitstreamOut_t out = { output, 0, 0} BitstreamOut_t out = { output, 0, 0}
; ;
while (bitsLeft(&in) > 0) { while (bitsLeft(&in) > 0) {
pushBit(&out, headBit(&in)); pushBit(&out, headBit(&in));
//printf("Bits left: %d\n", bitsLeft(&in)); //printf("Bits left: %d\n", bitsLeft(&in));

View file

@ -1590,7 +1590,7 @@ bool DesfireCheckAuthCmd(DesfireISOSelectWay way, uint32_t appID, uint8_t keyNum
uint8_t datalen = (authcmd == MFDES_AUTHENTICATE_EV2F) ? 3 : 1; uint8_t datalen = (authcmd == MFDES_AUTHENTICATE_EV2F) ? 3 : 1;
res = DesfireExchangeEx(false, &dctx, authcmd, data, datalen, &respcode, recv_data, &recv_len, false, 0); res = DesfireExchangeEx(false, &dctx, authcmd, data, datalen, &respcode, recv_data, &recv_len, false, 0);
DropField(); DropField();
if (checklrp) if (checklrp)
return (res == PM3_SUCCESS && respcode == 0xaf && recv_len == 17 && recv_data[0] == 0x01); return (res == PM3_SUCCESS && respcode == 0xaf && recv_len == 17 && recv_data[0] == 0x01);
else else

View file

@ -638,7 +638,7 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
break; break;
} }
char *begin = calloc(ndef->TypeLen + 1,sizeof(char)); char *begin = calloc(ndef->TypeLen + 1, sizeof(char));
memcpy(begin, ndef->Type, ndef->TypeLen); memcpy(begin, ndef->Type, ndef->TypeLen);
str_lower(begin); str_lower(begin);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -378,9 +378,9 @@ char *sprint_bytebits_bin(const uint8_t *data, const size_t len) {
} }
char *sprint_bin(const uint8_t *data, const size_t len) { char *sprint_bin(const uint8_t *data, const size_t len) {
size_t binlen = (len*8 > MAX_BIN_BREAK_LENGTH) ? MAX_BIN_BREAK_LENGTH : len*8; size_t binlen = (len * 8 > MAX_BIN_BREAK_LENGTH) ? MAX_BIN_BREAK_LENGTH : len * 8;
static uint8_t buf[MAX_BIN_BREAK_LENGTH]; static uint8_t buf[MAX_BIN_BREAK_LENGTH];
bytes_to_bytebits(data, binlen/8, buf); bytes_to_bytebits(data, binlen / 8, buf);
return sprint_bytebits_bin_break(buf, binlen, 0); return sprint_bytebits_bin_break(buf, binlen, 0);
} }

View file

@ -13,9 +13,9 @@
#define FPGA_BITSTREAM_FIXED_HEADER_SIZE sizeof(bitparse_fixed_header) #define FPGA_BITSTREAM_FIXED_HEADER_SIZE sizeof(bitparse_fixed_header)
#define FPGA_INTERLEAVE_SIZE 288 #define FPGA_INTERLEAVE_SIZE 288
#if defined XC3 #if defined XC3
#define FPGA_CONFIG_SIZE 72864L // our current fpga_[lh]f.bit files are 72742 bytes. Rounded up to next multiple of FPGA_INTERLEAVE_SIZE #define FPGA_CONFIG_SIZE 72864L // our current fpga_[lh]f.bit files are 72742 bytes. Rounded up to next multiple of FPGA_INTERLEAVE_SIZE
#else #else
#define FPGA_CONFIG_SIZE 42336L // our current fpga_[lh]f.bit files are 42175 bytes. Rounded up to next multiple of FPGA_INTERLEAVE_SIZE #define FPGA_CONFIG_SIZE 42336L // our current fpga_[lh]f.bit files are 42175 bytes. Rounded up to next multiple of FPGA_INTERLEAVE_SIZE
#endif #endif
#define FPGA_RING_BUFFER_BYTES (1024 * 39) #define FPGA_RING_BUFFER_BYTES (1024 * 39)
#define FPGA_TRACE_SIZE 3072 #define FPGA_TRACE_SIZE 3072

View file

@ -973,7 +973,7 @@
}, },
"help": { "help": {
"command": "help", "command": "help",
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210821.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save", "description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210825.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
"notes": [ "notes": [
"auto" "auto"
], ],
@ -3726,9 +3726,10 @@
"--tb target b key", "--tb target b key",
"--emu fill simulator keys from found keys", "--emu fill simulator keys from found keys",
"--dump dump found keys to file", "--dump dump found keys to file",
"--single single sector (defaults to all)" "--single single sector (defaults to all)",
"--mem use dictionary from flashmemory"
], ],
"usage": "hf mf nested [-hab] [-k <hex>] [--mini] [--1k] [--2k] [--4k] [--blk <dec>] [--tblk <dec>] [--ta] [--tb] [--emu] [--dump] [--single]" "usage": "hf mf nested [-hab] [-k <hex>] [--mini] [--1k] [--2k] [--4k] [--blk <dec>] [--tblk <dec>] [--ta] [--tb] [--emu] [--dump] [--single] [--mem]"
}, },
"hf mf personalize": { "hf mf personalize": {
"command": "hf mf personalize", "command": "hf mf personalize",
@ -4438,7 +4439,8 @@
"hf mfdes detect -> detect key 0 from picc level", "hf mfdes detect -> detect key 0 from picc level",
"hf mfdes detect -s d40 -> detect key 0 from picc level via secure channel d40", "hf mfdes detect -s d40 -> detect key 0 from picc level via secure channel d40",
"hf mfdes detect --dict mfdes_default_keys -> detect key 0 from picc level with help of the standard dictionary", "hf mfdes detect --dict mfdes_default_keys -> detect key 0 from picc level with help of the standard dictionary",
"hf mfdes detect --aid 123456 -n 2 --save -> detect key 2 from app 123456 and if succeed - save params to defaults (`default` command)" "hf mfdes detect --aid 123456 -n 2 --save -> detect key 2 from app 123456 and if succeed - save params to defaults (`default` command)",
"hf mfdes detect --appisoid df01 --save -> detect key 0 and save to defaults with card in the lrp mode"
], ],
"offline": false, "offline": false,
"options": [ "options": [
@ -4454,10 +4456,11 @@
"-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",
"--aid <app id hex> application id (3 hex bytes, big endian)", "--aid <app id hex> application id (3 hex bytes, big endian)",
"--appisoid <isoid hex> application iso id (iso df id) (2 hex bytes, big endian).",
"--dict <file> file with keys dictionary", "--dict <file> file with keys dictionary",
"--save save found key and parameters to defaults" "--save save found key and parameters to defaults"
], ],
"usage": "hf mfdes detect [-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>] [--aid <app id hex>] [--dict <file>] [--save]" "usage": "hf mfdes detect [-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>] [--aid <app id hex>] [--appisoid <isoid hex>] [--dict <file>] [--save]"
}, },
"hf mfdes dump": { "hf mfdes dump": {
"command": "hf mfdes dump", "command": "hf mfdes dump",
@ -5468,8 +5471,8 @@
"command": "hf mfu sim", "command": "hf mfu sim",
"description": "simulate mifare ultralight family type based upon iso/iec 14443 type a tag with 4,7 or 10 byte uid from emulator memory. see `hf mfu eload` first. see `hf 14a sim -h` to see available types. you want 2 or 7 usually.", "description": "simulate mifare ultralight family type based upon iso/iec 14443 type a tag with 4,7 or 10 byte uid from emulator memory. see `hf mfu eload` first. see `hf 14a sim -h` to see available types. you want 2 or 7 usually.",
"notes": [ "notes": [
"hf mfu sim -t 2 --uid 1122344556677 -> mifare ultralight", "hf mfu sim -t 2 --uid 11223344556677 -> mifare ultralight",
"hf mfu sim -t 7 --uid 1122344556677 -n 5 -> amiibo (ntag 215), pack 0x8080" "hf mfu sim -t 7 --uid 11223344556677 -n 5 -> amiibo (ntag 215), pack 0x8080"
], ],
"offline": false, "offline": false,
"options": [ "options": [
@ -7239,7 +7242,7 @@
}, },
"lf hitag info": { "lf hitag info": {
"command": "lf hitag info", "command": "lf hitag info",
"description": "sniff traffic between hitag reader and tag.", "description": "hitag2 tag information",
"notes": [ "notes": [
"lf hitag info" "lf hitag info"
], ],
@ -9997,6 +10000,6 @@
"metadata": { "metadata": {
"commands_extracted": 589, "commands_extracted": 589,
"extracted_by": "PM3Help2JSON v1.00", "extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2021-08-21T16:13:04" "extracted_on": "2021-08-25T11:37:52"
} }
} }

View file

@ -838,7 +838,7 @@ Check column "offline" for their availability.
|`lf hitag help `|Y |`This help` |`lf hitag help `|Y |`This help`
|`lf hitag eload `|N |`Load Hitag dump file into emulator memory` |`lf hitag eload `|N |`Load Hitag dump file into emulator memory`
|`lf hitag list `|Y |`List Hitag trace history` |`lf hitag list `|Y |`List Hitag trace history`
|`lf hitag info `|N |`Tag information` |`lf hitag info `|N |`Hitag2 tag information`
|`lf hitag reader `|N |`Act like a Hitag reader` |`lf hitag reader `|N |`Act like a Hitag reader`
|`lf hitag sim `|N |`Simulate Hitag transponder` |`lf hitag sim `|N |`Simulate Hitag transponder`
|`lf hitag sniff `|N |`Eavesdrop Hitag communication` |`lf hitag sniff `|N |`Eavesdrop Hitag communication`

View file

@ -46,4 +46,4 @@
//options for ISO18092 / Felica //options for ISO18092 / Felica
`define FPGA_HF_ISO18092_FLAG_NOMOD 1 // 0001 disable modulation module `define FPGA_HF_ISO18092_FLAG_NOMOD 1 // 0001 disable modulation module
`define FPGA_HF_ISO18092_FLAG_424K 2 // 0010 should enable 414k mode (untested). No autodetect `define FPGA_HF_ISO18092_FLAG_424K 2 // 0010 should enable 414k mode (untested). No autodetect
`define FPGA_HF_ISO18092_FLAG_READER 4 // 0100 enables antenna power, to act as a reader instead of tag `define FPGA_HF_ISO18092_FLAG_READER 4 // 0100 enables antenna power, to act as a reader instead of tag

View file

@ -44,9 +44,9 @@
#define GPIO_USB_PU AT91C_PIO_PA24 #define GPIO_USB_PU AT91C_PIO_PA24
#define GPIO_RELAY AT91C_PIO_PA25 #define GPIO_RELAY AT91C_PIO_PA25
#if defined XC3 #if defined XC3
#define GPIO_FPGA_SWITCH AT91C_PIO_PA26 #define GPIO_FPGA_SWITCH AT91C_PIO_PA26
#else #else
#define GPIO_FPGA_ON AT91C_PIO_PA26 #define GPIO_FPGA_ON AT91C_PIO_PA26
#endif #endif
#define GPIO_FPGA_DONE AT91C_PIO_PA27 #define GPIO_FPGA_DONE AT91C_PIO_PA27
#define GPIO_FPGA_NPROGRAM AT91C_PIO_PA28 #define GPIO_FPGA_NPROGRAM AT91C_PIO_PA28

View file

@ -193,7 +193,7 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
#define MIFARE_ULNANO_LOCKSIG 0xAC #define MIFARE_ULNANO_LOCKSIG 0xAC
// NTAG i2k 2K uses sector 0, and sector 1 to have access to // NTAG i2k 2K uses sector 0, and sector 1 to have access to
// block 0x00-0xFF. // block 0x00-0xFF.
#define NTAG_I2C_SELECT_SECTOR 0xC2 #define NTAG_I2C_SELECT_SECTOR 0xC2
#define NTAG_I2C_FASTWRITE 0xA6 #define NTAG_I2C_FASTWRITE 0xA6

View file

@ -29,9 +29,9 @@
#define ADC_CHAN_LF 4 #define ADC_CHAN_LF 4
#if defined RDV4 || defined ICOPYX #if defined RDV4 || defined ICOPYX
#define ADC_CHAN_HF 7 #define ADC_CHAN_HF 7
#else #else
#define ADC_CHAN_HF 5 #define ADC_CHAN_HF 5
#endif #endif
#define ADC_MODE_PRESCALE(x) ((x) << 8) #define ADC_MODE_PRESCALE(x) ((x) << 8)
#define ADC_MODE_STARTUP_TIME(x) ((x) << 16) #define ADC_MODE_STARTUP_TIME(x) ((x) << 16)