Merge branch 'master' into experimental_varlen2

* master: (33 commits)
  unified Proxmark3 text
  removed
  more colors
  rearranged banner output and messages
  textual
  revert
  revert
  revert
  style spaces
  fix fake com port
  style
  style
  styles
  not null?
  style
  style
  style
  style
  style
  style
  ...
This commit is contained in:
Philippe Teuwen 2019-04-16 20:58:58 +02:00
commit 8b99df9074
34 changed files with 148 additions and 177 deletions

View file

@ -21,4 +21,4 @@ Make a tarball
tar czvf proxmark3.tgz cov-int tar czvf proxmark3.tgz cov-int
``` ```
Upload it to coverity.com Upload it to scan.coverity.com

View file

@ -292,19 +292,21 @@ test_script:
#proxmark logic tests #proxmark logic tests
ExecTest "proxmark help" "proxmark3 -h" {bash -lc 'cd ~/client;./proxmark3 -h | grep -q Execute && echo Passed || echo Failed'} ExecTest "proxmark help" "proxmark3 -h" {bash -lc 'cd ~/client;./proxmark3 -h | grep -q wait && echo Passed || echo Failed'}
ExecTest "proxmark help hardnested" "proxmark3 -h" {bash -lc 'cd ~/client;./proxmark3 -h | grep -q hardnested && echo Passed || echo Failed'} ExecTest "proxmark help text ISO7816" "proxmark3 -t" {bash -lc 'cd ~/client;./proxmark3 -t 2>&1 | grep -q ISO7816 && echo Passed || echo Failed'}
ExecTest "proxmark help text hardnested" "proxmark3 -t" {bash -lc 'cd ~/client;./proxmark3 -t 2>&1 | grep -q hardnested && echo Passed || echo Failed'}
ExecTest "hf mf offline text" "hf mf" {bash -lc "cd ~/client;./proxmark3 comx -c 'hf mf'"} "at_enc" ExecTest "hf mf offline text" "hf mf" {bash -lc "cd ~/client;./proxmark3 -c 'hf mf'"} "at_enc"
ExecTest "hf mf hardnested" "hf mf hardnested" {bash -lc "cd ~/client;./proxmark3 comx -c 'hf mf hardnested t 1 000000000000'"} "found:" ExecTest "hf mf hardnested" "hf mf hardnested" {bash -lc "cd ~/client;./proxmark3 -c 'hf mf hardnested t 1 000000000000'"} "found:"
#proxmark crypto tests #proxmark crypto tests
ExecTest "emv test" "emv test" {bash -lc "cd ~/client;./proxmark3 comx -c 'emv test'"} "Tests ?OK" ExecTest "emv test" "emv test" {bash -lc "cd ~/client;./proxmark3 -c 'emv test'"} "Test?s? ? OK"
if ($global:TestsPassed) { if ($global:TestsPassed) {

View file

@ -376,6 +376,7 @@ void printUSBSpeed(void) {
uint32_t bytes_transferred = 0; uint32_t bytes_transferred = 0;
LED_B_ON(); LED_B_ON();
while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) { while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) {
cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, 0, USB_CMD_DATA_SIZE, 0, test_data, USB_CMD_DATA_SIZE); cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, 0, USB_CMD_DATA_SIZE, 0, test_data, USB_CMD_DATA_SIZE);
end_time = GetTickCount(); end_time = GetTickCount();

View file

@ -391,6 +391,7 @@ bool WaitForFelicaReply(uint16_t maxbytes) {
// clear RXRDY: // clear RXRDY:
uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR; uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
(void)b;
uint32_t timeout = iso18092_get_timeout(); uint32_t timeout = iso18092_get_timeout();
for (;;) { for (;;) {
@ -481,7 +482,7 @@ void felica_sendraw(UsbCommand *c) {
felica_command_t param = c->arg[0]; felica_command_t param = c->arg[0];
size_t len = c->arg[1] & 0xffff; size_t len = c->arg[1] & 0xffff;
uint8_t *cmd = c->d.asBytes; uint8_t *cmd = c->d.asBytes;
uint32_t arg0 = 0; uint32_t arg0;
felica_card_select_t card; felica_card_select_t card;
@ -519,7 +520,6 @@ void felica_sendraw(UsbCommand *c) {
// Don't append crc on empty bytearray... // Don't append crc on empty bytearray...
if (len > 0) { if (len > 0) {
AddCrc(buf, len); AddCrc(buf, len);
len += 2;
} }
} }

View file

@ -647,10 +647,10 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrAr, uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *txlen) { static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrAr, uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *txlen) {
uint8_t rx_air[HITAG_FRAME_LEN]; uint8_t rx_air[HITAG_FRAME_LEN];
int response_bit[200]; int response_bit[200];
int i, j, z, k; int i, j, z;
unsigned char mask = 1; unsigned char mask = 1;
unsigned char uid[32]; unsigned char uid[32];
uint8_t uid1 = 0x00, uid2 = 0x00, uid3 = 0x00, uid4 = 0x00; uint8_t uid1, uid2, uid3, uid4;
unsigned char crc; unsigned char crc;
uint64_t state; uint64_t state;
uint8_t auth_ks[4]; uint8_t auth_ks[4];
@ -673,7 +673,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
z++; z++;
} }
} }
k = 0; uint16_t k = 0;
for (i = 5; i < z; i += 2) { for (i = 5; i < z; i += 2) {
uid[k] = response_bit[i]; uid[k] = response_bit[i];
k++; k++;
@ -1749,22 +1749,17 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
*/ */
void check_challenges(bool file_given, uint8_t *data) { void check_challenges(bool file_given, uint8_t *data) {
int i, j, z, k; int i, j, z, k;
uint8_t uid_byte[4];
int frame_count = 0, response = 0; int frame_count = 0, response = 0;
uint8_t uid_byte[4];
uint8_t rx[HITAG_FRAME_LEN]; uint8_t rx[HITAG_FRAME_LEN];
uint8_t unlocker[60][8]; uint8_t unlocker[60][8];
int u1 = 0; int u1 = 0;
size_t rxlen = 0; size_t rxlen = 0, txlen = 0;
uint8_t txbuf[HITAG_FRAME_LEN]; uint8_t txbuf[HITAG_FRAME_LEN];
uint8_t *tx = txbuf; uint8_t *tx;
size_t txlen = 0;
int lastbit;
bool bSkip;
int reset_sof;
int tag_sof;
int t_wait = HITAG_T_WAIT_MAX; int t_wait = HITAG_T_WAIT_MAX;
int STATE = 0; int lastbit, reset_sof, tag_sof, STATE = 0;;
bool bStop; bool bSkip, bStop;
int response_bit[200]; int response_bit[200];
unsigned char mask = 1; unsigned char mask = 1;
unsigned char uid[32]; unsigned char uid[32];

View file

@ -521,7 +521,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
// triggered == false -- to wait first for card // triggered == false -- to wait first for card
bool triggered = !(param & 0x03); bool triggered = !(param & 0x03);
uint32_t rsamples = 0; uint32_t rx_samples = 0;
DbpString("Starting to sniff"); DbpString("Starting to sniff");
@ -562,11 +562,11 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
LED_A_OFF(); LED_A_OFF();
// Need two samples to feed Miller and Manchester-Decoder // Need two samples to feed Miller and Manchester-Decoder
if (rsamples & 0x01) { if (rx_samples & 0x01) {
if (!TagIsActive) { // no need to try decoding reader data if the tag is sending if (!TagIsActive) { // no need to try decoding reader data if the tag is sending
uint8_t readerdata = (previous_data & 0xF0) | (*data >> 4); uint8_t readerdata = (previous_data & 0xF0) | (*data >> 4);
if (MillerDecoding(readerdata, (rsamples - 1) * 4)) { if (MillerDecoding(readerdata, (rx_samples - 1) * 4)) {
LED_C_ON(); LED_C_ON();
// check - if there is a short 7bit request from reader // check - if there is a short 7bit request from reader
@ -593,7 +593,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
// no need to try decoding tag data if the reader is sending - and we cannot afford the time // no need to try decoding tag data if the reader is sending - and we cannot afford the time
if (!ReaderIsActive) { if (!ReaderIsActive) {
uint8_t tagdata = (previous_data << 4) | (*data & 0x0F); uint8_t tagdata = (previous_data << 4) | (*data & 0x0F);
if (ManchesterDecoding(tagdata, 0, (rsamples - 1) * 4)) { if (ManchesterDecoding(tagdata, 0, (rx_samples - 1) * 4)) {
LED_B_ON(); LED_B_ON();
if (!LogTrace(receivedResp, if (!LogTrace(receivedResp,
@ -617,7 +617,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
} }
previous_data = *data; previous_data = *data;
rsamples++; rx_samples++;
data++; data++;
if (data == dmaBuf + DMA_BUFFER_SIZE) { if (data == dmaBuf + DMA_BUFFER_SIZE) {
data = dmaBuf; data = dmaBuf;

View file

@ -947,7 +947,6 @@ static RAMFUNC int Handle14443bTagSamplesDemod(int ci, int cq) {
static void GetTagSamplesFor14443bDemod() { static void GetTagSamplesFor14443bDemod() {
bool gotFrame, finished = false; bool gotFrame, finished = false;
// int lastRxCounter = ISO14443B_DMA_BUFFER_SIZE; // int lastRxCounter = ISO14443B_DMA_BUFFER_SIZE;
int ci = 0, cq = 0;
uint32_t time_0 = 0, time_stop = 0; uint32_t time_0 = 0, time_stop = 0;
BigBuf_free(); BigBuf_free();
@ -978,8 +977,8 @@ static void GetTagSamplesFor14443bDemod() {
WDT_HIT(); WDT_HIT();
// LSB is a fpga signal bit. // LSB is a fpga signal bit.
ci = upTo[0]; int ci = upTo[0];
cq = upTo[1]; int cq = upTo[1];
upTo += 2; upTo += 2;
// lastRxCounter -= 2; // lastRxCounter -= 2;

View file

@ -112,7 +112,7 @@ void opt_successor(const uint8_t *k, State *s, bool y, State *successor) {
void opt_suc(const uint8_t *k, State *s, uint8_t *in, uint8_t length, bool add32Zeroes) { void opt_suc(const uint8_t *k, State *s, uint8_t *in, uint8_t length, bool add32Zeroes) {
State x2; State x2;
int i; int i;
uint8_t head = 0; uint8_t head;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
head = 1 & (in[i] >> 7); head = 1 & (in[i] >> 7);
opt_successor(k, s, head, &x2); opt_successor(k, s, head, &x2);
@ -149,8 +149,7 @@ void opt_suc(const uint8_t *k, State *s, uint8_t *in, uint8_t length, bool add32
} }
void opt_output(const uint8_t *k, State *s, uint8_t *buffer) { void opt_output(const uint8_t *k, State *s, uint8_t *buffer) {
uint8_t times = 0; uint8_t bout, times = 0;
uint8_t bout = 0;
State temp = {0, 0, 0, 0}; State temp = {0, 0, 0, 0};
for (; times < 4; times++) { for (; times < 4; times++) {
bout = 0; bout = 0;

View file

@ -2552,7 +2552,7 @@ static int arg_rex_scanfn(struct arg_rex *parent, const char *argval) {
int errorcode = 0; int errorcode = 0;
const TRexChar *error = NULL; const TRexChar *error = NULL;
TRex *rex = NULL; TRex *rex = NULL;
TRexBool is_match = TRex_False; TRexBool is_match;
if (parent->count == parent->hdr.maxcount) { if (parent->count == parent->hdr.maxcount) {
/* maximum number of arguments exceeded */ /* maximum number of arguments exceeded */

View file

@ -222,10 +222,7 @@ static uint16_t calcBSDchecksum4(uint8_t *bytes, uint8_t len, uint32_t mask) {
// measuring LFSR maximum length // measuring LFSR maximum length
static int CmdAnalyseLfsr(const char *Cmd) { static int CmdAnalyseLfsr(const char *Cmd) {
uint16_t start_state = 0; /* Any nonzero start state will work. */ uint16_t lfsr; /* Any nonzero start state will work. */
uint16_t lfsr = start_state;
//uint32_t period = 0;
uint8_t iv = param_get8ex(Cmd, 0, 0, 16); uint8_t iv = param_get8ex(Cmd, 0, 0, 16);
uint8_t find = param_get8ex(Cmd, 1, 0, 16); uint8_t find = param_get8ex(Cmd, 1, 0, 16);
@ -233,11 +230,9 @@ static int CmdAnalyseLfsr(const char *Cmd) {
PrintAndLogEx(NORMAL, " bit# | lfsr | ^0x40 | 0x%02X ^ lfsr \n", find); PrintAndLogEx(NORMAL, " bit# | lfsr | ^0x40 | 0x%02X ^ lfsr \n", find);
for (uint8_t i = 0x01; i < 0x30; i += 1) { for (uint8_t i = 0x01; i < 0x30; i += 1) {
//period = 0;
legic_prng_init(iv); legic_prng_init(iv);
legic_prng_forward(i); legic_prng_forward(i);
lfsr = legic_prng_get_bits(12); lfsr = legic_prng_get_bits(12);
PrintAndLogEx(NORMAL, " %02X | %03X | %03X | %03X \n", i, lfsr, 0x40 ^ lfsr, find ^ lfsr); PrintAndLogEx(NORMAL, " %02X | %03X | %03X | %03X \n", i, lfsr, 0x40 ^ lfsr, find ^ lfsr);
} }
return 0; return 0;

View file

@ -57,8 +57,6 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
SETBMP(); SETBMP();
int args = 0, psets, pass;
int Cnt = 0;
if (width[0] == 0) { //reveng -D if (width[0] == 0) { //reveng -D
*count = mcount(); *count = mcount();
if (!*count) { if (!*count) {
@ -100,6 +98,8 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
if (!ptst(qpoly)) if (!ptst(qpoly))
rflags &= ~R_HAVEQ; rflags &= ~R_HAVEQ;
int pass;
/* if endianness not specified, try /* if endianness not specified, try
* little-endian then big-endian. * little-endian then big-endian.
* NB: crossed-endian algorithms will not be * NB: crossed-endian algorithms will not be
@ -108,7 +108,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
/* scan against preset models */ /* scan against preset models */
if (~uflags & C_NOPCK) { if (~uflags & C_NOPCK) {
pass = 0; pass = 0;
Cnt = 0; int Cnt = 0, psets;
do { do {
psets = mcount(); psets = mcount();
@ -190,6 +190,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
return 0; return 0;
} }
pass = 0; pass = 0;
int args = 0;
do { do {
mptr = candmods = reveng(&model, qpoly, rflags, args, apolys); mptr = candmods = reveng(&model, qpoly, rflags, args, apolys);
if (mptr && plen(mptr->spoly)) { if (mptr && plen(mptr->spoly)) {
@ -233,7 +234,7 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
static model_t model = MZERO; static model_t model = MZERO;
int ibperhx = 8, obperhx = 8; int ibperhx = 8, obperhx = 8;
int rflags = 0; // search flags // int rflags = 0; // search flags
int c; int c;
poly_t apoly, crc; poly_t apoly, crc;
@ -255,17 +256,17 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
PrintAndLogEx(WARNING, "no preset models available"); PrintAndLogEx(WARNING, "no preset models available");
return 0; return 0;
} }
rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX; // rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX;
//set flags //set flags
switch (endian) { switch (endian) {
case 'b': /* b big-endian (RefIn = false, RefOut = false ) */ case 'b': /* b big-endian (RefIn = false, RefOut = false ) */
model.flags &= ~P_REFIN; model.flags &= ~P_REFIN;
rflags |= R_HAVERI; //rflags |= R_HAVERI;
/* fall through: */ /* fall through: */
case 'B': /* B big-endian output (RefOut = false) */ case 'B': /* B big-endian output (RefOut = false) */
model.flags &= ~P_REFOUT; model.flags &= ~P_REFOUT;
rflags |= R_HAVERO; //rflags |= R_HAVERO;
mnovel(&model); mnovel(&model);
/* fall through: */ /* fall through: */
case 'r': /* r right-justified */ case 'r': /* r right-justified */
@ -273,11 +274,11 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
break; break;
case 'l': /* l little-endian input and output */ case 'l': /* l little-endian input and output */
model.flags |= P_REFIN; model.flags |= P_REFIN;
rflags |= R_HAVERI; //rflags |= R_HAVERI;
/* fall through: */ /* fall through: */
case 'L': /* L little-endian output */ case 'L': /* L little-endian output */
model.flags |= P_REFOUT; model.flags |= P_REFOUT;
rflags |= R_HAVERO; //rflags |= R_HAVERO;
mnovel(&model); mnovel(&model);
/* fall through: */ /* fall through: */
case 't': /* t left-justified */ case 't': /* t left-justified */

View file

@ -1527,7 +1527,7 @@ int CmdTuneSamples(const char *Cmd) {
int timeout = 0; int timeout = 0;
PrintAndLogEx(INFO, "\nmeasuring antenna characteristics, please wait..."); PrintAndLogEx(INFO, "\nMeasuring antenna characteristics, please wait...");
UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}}; UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}};
clearCommandBuffer(); clearCommandBuffer();
@ -1538,7 +1538,7 @@ int CmdTuneSamples(const char *Cmd) {
printf("."); printf(".");
fflush(stdout); fflush(stdout);
if (timeout > 7) { if (timeout > 7) {
PrintAndLogEx(WARNING, "\nno response from Proxmark. Aborting..."); PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
return 1; return 1;
} }
} }

View file

@ -531,7 +531,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}}; UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
SendCommand(&ca); SendCommand(&ca);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
PrintAndLogEx(ERR, "Proxmark connection timeout."); PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
return 1; return 1;
} }
@ -553,7 +553,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
memcpy(cr.d.asBytes, rats, 2); memcpy(cr.d.asBytes, rats, 2);
SendCommand(&cr); SendCommand(&cr);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
PrintAndLogEx(ERR, "Proxmark connection timeout."); PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
return 1; return 1;
} }
@ -630,7 +630,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}}; UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
SendCommand(&ca); SendCommand(&ca);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
PrintAndLogEx(ERR, "Proxmark connection timeout."); PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
return 1; return 1;
} }
@ -652,7 +652,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
memcpy(cr.d.asBytes, rats, 2); memcpy(cr.d.asBytes, rats, 2);
SendCommand(&cr); SendCommand(&cr);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
PrintAndLogEx(ERR, "Proxmark connection timeout."); PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
return 1; return 1;
} }

View file

@ -781,7 +781,7 @@ static int CmdHFFido2GetAssertion(const char *cmd) {
char fname[300] = {0}; char fname[300] = {0};
CLIParserInit("hf fido assert", CLIParserInit("hf fido assert",
"Execute a FIDO2 Get Assertion command. Needs json file with parameters. Sample file `fido2.json`. File can be placed in proxmark directory or in `proxmark/fido` directory.", "Execute a FIDO2 Get Assertion command. Needs json file with parameters. Sample file " _YELLOW_("`fido2.json`") ". File can be placed in proxmark directory or in `proxmark/fido` directory.",
"Usage:\n\thf fido assert -> execute command default parameters file `fido2.json`\n" "Usage:\n\thf fido assert -> execute command default parameters file `fido2.json`\n"
"\thf fido assert test.json -l -> execute command with parameters file `text.json` and add to request CredentialId"); "\thf fido assert test.json -l -> execute command with parameters file `text.json` and add to request CredentialId");

View file

@ -1994,7 +1994,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
printf("."); printf(".");
fflush(stdout); fflush(stdout);
if (timeout > 120) { if (timeout > 120) {
PrintAndLogEx(WARNING, "\nNo response from Proxmark. Aborting..."); PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
goto out; goto out;
} }
} }

View file

@ -605,10 +605,8 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
static int CmdHF14AMfRdSc(const char *Cmd) { static int CmdHF14AMfRdSc(const char *Cmd) {
int i; int i;
uint8_t sectorNo = 0; uint8_t isOK, sectorNo = 0, keyType = 0;
uint8_t keyType = 0;
uint8_t key[6] = {0, 0, 0, 0, 0, 0}; uint8_t key[6] = {0, 0, 0, 0, 0, 0};
uint8_t isOK = 0;
uint8_t *data = NULL; uint8_t *data = NULL;
char cmdp = 0x00; char cmdp = 0x00;
@ -799,10 +797,9 @@ static int CmdHF14AMfDump(const char *Cmd) {
fclose(f); fclose(f);
PrintAndLogEx(INFO, "Reading sector access bits..."); PrintAndLogEx(INFO, "Reading sector access bits...");
uint8_t tries = 0; uint8_t tries;
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) { for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) { for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) {
@ -1140,7 +1137,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true); int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true);
switch (isOK) { switch (isOK) {
case -1 : case -1 :
PrintAndLogEx(WARNING, "Error: No response from Proxmark.\n"); PrintAndLogEx(WARNING, "Error: No response from Proxmark3.\n");
break; break;
case -2 : case -2 :
PrintAndLogEx(WARNING, "Button pressed. Aborted.\n"); PrintAndLogEx(WARNING, "Button pressed. Aborted.\n");
@ -1210,7 +1207,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
int16_t isOK = mfnested(blockNo, keyType, key, FirstBlockOfSector(sectorNo), trgKeyType, keyBlock, calibrate); int16_t isOK = mfnested(blockNo, keyType, key, FirstBlockOfSector(sectorNo), trgKeyType, keyBlock, calibrate);
switch (isOK) { switch (isOK) {
case -1 : case -1 :
PrintAndLogEx(WARNING, "error: No response from Proxmark.\n"); PrintAndLogEx(WARNING, "error: No response from Proxmark3.\n");
break; break;
case -2 : case -2 :
PrintAndLogEx(WARNING, "button pressed. Aborted.\n"); PrintAndLogEx(WARNING, "button pressed. Aborted.\n");
@ -1500,7 +1497,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
if (isOK) { if (isOK) {
switch (isOK) { switch (isOK) {
case 1 : case 1 :
PrintAndLogEx(WARNING, "Error: No response from Proxmark.\n"); PrintAndLogEx(WARNING, "Error: No response from Proxmark3.\n");
break; break;
case 2 : case 2 :
PrintAndLogEx(NORMAL, "Button pressed. Aborted.\n"); PrintAndLogEx(NORMAL, "Button pressed. Aborted.\n");
@ -2286,7 +2283,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n"); PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n");
PrintAndLogEx(NORMAL, "Executing mifare sniffing command. \n"); PrintAndLogEx(NORMAL, "Executing mifare sniffing command. \n");
PrintAndLogEx(NORMAL, "Press the key on the proxmark3 device to abort both proxmark3 and client.\n"); PrintAndLogEx(NORMAL, "Press the key on the Proxmark3 device to abort both Proxmark3 and client.\n");
PrintAndLogEx(NORMAL, "Press the key on pc keyboard to abort the client.\n"); PrintAndLogEx(NORMAL, "Press the key on pc keyboard to abort the client.\n");
PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n"); PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n");
@ -3542,7 +3539,7 @@ static command_t CommandTable[] = {
{"chk", CmdHF14AMfChk, 0, "Check keys"}, {"chk", CmdHF14AMfChk, 0, "Check keys"},
{"fchk", CmdHF14AMfChk_fast, 0, "Check keys fast, targets all keys on card"}, {"fchk", CmdHF14AMfChk_fast, 0, "Check keys fast, targets all keys on card"},
{"decrypt", CmdHf14AMfDecryptBytes, 1, "[nt] [ar_enc] [at_enc] [data] - to decrypt sniff or trace"}, {"decrypt", CmdHf14AMfDecryptBytes, 1, "[nt] [ar_enc] [at_enc] [data] - to decrypt sniff or trace"},
{"-----------", CmdHelp, 1, ""}, {"-----------", CmdHelp, 0, ""},
{"dbg", CmdHF14AMfDbg, 0, "Set default debug mode"}, {"dbg", CmdHF14AMfDbg, 0, "Set default debug mode"},
{"rdbl", CmdHF14AMfRdBl, 0, "Read MIFARE classic block"}, {"rdbl", CmdHF14AMfRdBl, 0, "Read MIFARE classic block"},
{"rdsc", CmdHF14AMfRdSc, 0, "Read MIFARE classic sector"}, {"rdsc", CmdHF14AMfRdSc, 0, "Read MIFARE classic sector"},
@ -3552,7 +3549,7 @@ static command_t CommandTable[] = {
{"setmod", CmdHf14AMfSetMod, 0, "Set MIFARE Classic EV1 load modulation strength"}, {"setmod", CmdHf14AMfSetMod, 0, "Set MIFARE Classic EV1 load modulation strength"},
{"auth4", CmdHF14AMfAuth4, 0, "ISO14443-4 AES authentication"}, {"auth4", CmdHF14AMfAuth4, 0, "ISO14443-4 AES authentication"},
// {"sniff", CmdHF14AMfSniff, 0, "Sniff card-reader communication"}, // {"sniff", CmdHF14AMfSniff, 0, "Sniff card-reader communication"},
{"-----------", CmdHelp, 1, ""}, {"-----------", CmdHelp, 0, ""},
{"sim", CmdHF14AMf1kSim, 0, "Simulate MIFARE card"}, {"sim", CmdHF14AMf1kSim, 0, "Simulate MIFARE card"},
{"eclr", CmdHF14AMfEClear, 0, "Clear simulator memory block"}, {"eclr", CmdHF14AMfEClear, 0, "Clear simulator memory block"},
{"eget", CmdHF14AMfEGet, 0, "Get simulator memory block"}, {"eget", CmdHF14AMfEGet, 0, "Get simulator memory block"},
@ -3561,14 +3558,14 @@ static command_t CommandTable[] = {
{"esave", CmdHF14AMfESave, 0, "Save to file emul dump"}, {"esave", CmdHF14AMfESave, 0, "Save to file emul dump"},
{"ecfill", CmdHF14AMfECFill, 0, "Fill simulator memory with help of keys from simulator"}, {"ecfill", CmdHF14AMfECFill, 0, "Fill simulator memory with help of keys from simulator"},
{"ekeyprn", CmdHF14AMfEKeyPrn, 0, "Print keys from simulator memory"}, {"ekeyprn", CmdHF14AMfEKeyPrn, 0, "Print keys from simulator memory"},
{"-----------", CmdHelp, 1, ""}, {"-----------", CmdHelp, 0, ""},
{"csetuid", CmdHF14AMfCSetUID, 0, "Set UID for magic Chinese card"}, {"csetuid", CmdHF14AMfCSetUID, 0, "Set UID for magic Chinese card"},
{"csetblk", CmdHF14AMfCSetBlk, 0, "Write block - Magic Chinese card"}, {"csetblk", CmdHF14AMfCSetBlk, 0, "Write block - Magic Chinese card"},
{"cgetblk", CmdHF14AMfCGetBlk, 0, "Read block - Magic Chinese card"}, {"cgetblk", CmdHF14AMfCGetBlk, 0, "Read block - Magic Chinese card"},
{"cgetsc", CmdHF14AMfCGetSc, 0, "Read sector - Magic Chinese card"}, {"cgetsc", CmdHF14AMfCGetSc, 0, "Read sector - Magic Chinese card"},
{"cload", CmdHF14AMfCLoad, 0, "Load dump into magic Chinese card"}, {"cload", CmdHF14AMfCLoad, 0, "Load dump into magic Chinese card"},
{"csave", CmdHF14AMfCSave, 0, "Save dump from magic Chinese card into file or emulator"}, {"csave", CmdHF14AMfCSave, 0, "Save dump from magic Chinese card into file or emulator"},
{"-----------", CmdHelp, 1, ""}, {"-----------", CmdHelp, 0, ""},
{"mad", CmdHF14AMfMAD, 0, "Checks and prints MAD"}, {"mad", CmdHF14AMfMAD, 0, "Checks and prints MAD"},
{"ndef", CmdHFMFNDEF, 0, "Prints NDEF records from card"}, {"ndef", CmdHFMFNDEF, 0, "Prints NDEF records from card"},

View file

@ -476,10 +476,10 @@ static command_t CommandTable[] = {
{"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"}, {"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
{"setmux", CmdSetMux, 0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"}, {"setmux", CmdSetMux, 0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},
{"tune", CmdTune, 0, "Measure antenna tuning"}, {"tune", CmdTune, 0, "Measure antenna tuning"},
{"version", CmdVersion, 0, "Show version information about the connected Proxmark"}, {"version", CmdVersion, 0, "Show version information about the connected Proxmark3"},
{"status", CmdStatus, 0, "Show runtime status information about the connected Proxmark"}, {"status", CmdStatus, 0, "Show runtime status information about the connected Proxmark3"},
{"ping", CmdPing, 0, "Test if the pm3 is responsive"}, {"ping", CmdPing, 0, "Test if the Proxmark3 is responding"},
{"pingng", CmdPingNG, 0, "Test if the pm3 is responsive"}, {"pingng", CmdPingNG, 0, "Test if the Proxmark3 is responsive, using new frame format (experimental)"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };

View file

@ -506,7 +506,7 @@ static bool DecodeT5555TraceBlock(void) {
// sanity check. Don't use proxmark if it is offline and you didn't specify useGraphbuf // sanity check. Don't use proxmark if it is offline and you didn't specify useGraphbuf
static int SanityOfflineCheck(bool useGraphBuffer) { static int SanityOfflineCheck(bool useGraphBuffer) {
if (!useGraphBuffer && IsOffline()) { if (!useGraphBuffer && IsOffline()) {
PrintAndLogEx(NORMAL, "Your proxmark3 device is offline. Specify [1] to use graphbuffer data instead"); PrintAndLogEx(WARNING, "Your proxmark3 device is offline. Specify [1] to use graphbuffer data instead");
return 0; return 0;
} }
return 1; return 1;
@ -1866,7 +1866,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
printf("."); printf(".");
fflush(stdout); fflush(stdout);
if (timeout > 180) { if (timeout > 180) {
PrintAndLogEx(WARNING, "\nno response from Proxmark. Aborting..."); PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
return 2; return 2;
} }
} }

View file

@ -62,7 +62,7 @@ void SendCommand(UsbCommand *c) {
#endif #endif
if (offline) { if (offline) {
PrintAndLogEx(NORMAL, "Sending bytes to proxmark failed - offline"); PrintAndLogEx(WARNING, "Sending bytes to Proxmark3 failed." _YELLOW_("offline") );
return; return;
} }
@ -258,7 +258,7 @@ bool hookUpPM3() {
ret = false; ret = false;
offline = 1; offline = 1;
} else { } else {
PrintAndLogEx(SUCCESS, "Proxmark reconnected\n"); PrintAndLogEx(SUCCESS, "Proxmark3 reconnected\n");
serial_port_name = ; serial_port_name = ;
ret = true; ret = true;
offline = 0; offline = 0;
@ -325,13 +325,13 @@ __attribute__((force_align_arg_pointer))
if (txBufferNGLen) { // NG packet if (txBufferNGLen) { // NG packet
if (!uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen)) { if (!uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen)) {
//counter_to_offline++; //counter_to_offline++;
PrintAndLogEx(WARNING, "sending bytes to proxmark failed"); PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device" _RED_("failed") );
} }
txBufferNGLen = 0; txBufferNGLen = 0;
} else { } else {
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(UsbCommand))) { if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(UsbCommand))) {
//counter_to_offline++; //counter_to_offline++;
PrintAndLogEx(WARNING, "sending bytes to proxmark failed"); PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device" _RED_("failed") );
} }
} }
txBuffer_pending = false; txBuffer_pending = false;
@ -362,7 +362,7 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), portname); PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), portname);
sp = uart_open(portname, speed); sp = uart_open(portname, speed);
} else { } else {
PrintAndLogEx(SUCCESS, "Waiting for Proxmark to appear on " _YELLOW_("%s"), portname); PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), portname);
fflush(stdout); fflush(stdout);
int openCount = 0; int openCount = 0;
do { do {
@ -399,17 +399,16 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
} }
} }
// check if we can communicate with Pm3
int TestProxmark(void) { int TestProxmark(void) {
// check if we can communicate with Pm3
clearCommandBuffer(); clearCommandBuffer();
UsbCommand resp; UsbCommand resp;
UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}}; UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 5000)) {
PrintAndLogEx(INFO, "Ping successful, communicating with PM3 over %s.", resp.arg[0] == 1 ? "FPC" : "USB"); PrintAndLogEx(INFO, "Communicating with PM3 over %s.", resp.arg[0] == 1 ? "FPC" : "USB");
return 1; return 1;
} else { } else {
PrintAndLogEx(WARNING, _RED_("Ping failed"));
return 0; return 0;
} }
} }
@ -417,7 +416,6 @@ int TestProxmark(void) {
void CloseProxmark(void) { void CloseProxmark(void) {
conn.run = false; conn.run = false;
#ifdef __BIONIC__ #ifdef __BIONIC__
if (USB_communication_thread != 0) { if (USB_communication_thread != 0) {
pthread_join(USB_communication_thread, NULL); pthread_join(USB_communication_thread, NULL);
@ -478,8 +476,8 @@ bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand *response, size_t ms_timeo
if (msclock() - start_time > 3000 && show_warning) { if (msclock() - start_time > 3000 && show_warning) {
// 3 seconds elapsed (but this doesn't mean the timeout was exceeded) // 3 seconds elapsed (but this doesn't mean the timeout was exceeded)
PrintAndLogEx(NORMAL, "Waiting for a response from the proxmark..."); PrintAndLogEx(INFO, "Waiting for a response from the proxmark3...");
PrintAndLogEx(NORMAL, "You can cancel this operation by pressing the pm3 button"); PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
show_warning = false; show_warning = false;
} }
} }
@ -588,7 +586,7 @@ bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbCommand *resp
if (msclock() - start_time > 3000 && show_warning) { if (msclock() - start_time > 3000 && show_warning) {
// 3 seconds elapsed (but this doesn't mean the timeout was exceeded) // 3 seconds elapsed (but this doesn't mean the timeout was exceeded)
PrintAndLogEx(NORMAL, "Waiting for a response from the proxmark..."); PrintAndLogEx(NORMAL, "Waiting for a response from the Proxmark3...");
PrintAndLogEx(NORMAL, "You can cancel this operation by pressing the pm3 button"); PrintAndLogEx(NORMAL, "You can cancel this operation by pressing the pm3 button");
show_warning = false; show_warning = false;
} }

View file

@ -41,9 +41,13 @@
#define TOHEX(v) ((v) < 10 ? (v) + '0' : (v) - 10 + 'a') #define TOHEX(v) ((v) < 10 ? (v) + '0' : (v) - 10 + 'a')
static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_t *read) { static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_t *read) {
if (buf == NULL)
return 0;
size_t left = size; size_t left = size;
char *p = buf; char *p = buf;
while (*p != 0 && *p == ' ') while (*p == ' ')
p++; p++;
while (left > 0) { while (left > 0) {
@ -70,7 +74,7 @@ static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_
return -(p - buf); return -(p - buf);
} }
while (*p != 0 && *p == ' ') while (*p == ' ')
p++; p++;
p--; p--;
@ -79,13 +83,17 @@ static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_
} }
static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) { static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) {
if (buf == NULL)
return 0;
int i; int i;
unsigned char temp[3]; unsigned char temp[3];
char *p = buf; char *p = buf;
*ymv = 0; *ymv = 0;
while (*p != 0 && *p == ' ') while (*p == ' ')
p++; p++;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -101,7 +109,7 @@ static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) {
temp[i] = (c1 * 16 + c2); temp[i] = (c1 * 16 + c2);
} }
while (*p != 0 && *p == ' ') while (*p == ' ')
p++; p++;
p--; p--;
@ -115,8 +123,12 @@ static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) {
} }
static ssize_t emv_pk_read_string(char *buf, char *str, size_t size) { static ssize_t emv_pk_read_string(char *buf, char *str, size_t size) {
if (buf == NULL)
return 0;
char *p = buf; char *p = buf;
while (*p != 0 && *p == ' ') while (*p == ' ')
p++; p++;
while (size > 1) { while (size > 1) {
@ -132,7 +144,7 @@ static ssize_t emv_pk_read_string(char *buf, char *str, size_t size) {
*str = 0; *str = 0;
while (*p != 0 && *p == ' ') while (*p == ' ')
p++; p++;
p--; p--;

View file

@ -280,7 +280,7 @@ static int get_proxmark_state(uint32_t *state) {
*state = resp.arg[0]; *state = resp.arg[0];
break; break;
default: default:
fprintf(stderr, _RED_("Error:") "Couldn't get proxmark state, bad response type: 0x%04" PRIx64 "\n", resp.cmd); fprintf(stderr, _RED_("Error:") "Couldn't get Proxmark3 state, bad response type: 0x%04" PRIx64 "\n", resp.cmd);
return -1; return -1;
break; break;
} }
@ -326,12 +326,12 @@ static int enter_bootloader(char *serial_port_name) {
fprintf(stdout, " " _GREEN_("Found") "\n"); fprintf(stdout, " " _GREEN_("Found") "\n");
return 0; return 0;
} else { } else {
fprintf(stdout, _RED_("Error:") "Proxmark not found.\n"); fprintf(stdout, _RED_("Error:") "Proxmark3 not found.\n");
return -1; return -1;
} }
} }
fprintf(stderr, _RED_("Error:") "Unknown Proxmark mode\n"); fprintf(stderr, _RED_("Error:") "Unknown Proxmark3 mode\n");
return -1; return -1;
} }

View file

@ -40,8 +40,8 @@ static void usage(char *argv0) {
fprintf(stdout, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n"); fprintf(stdout, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n");
fprintf(stdout, "\nExample:\n\n\t %s "SERIAL_PORT_H" armsrc/obj/fullimage.elf\n", argv0); fprintf(stdout, "\nExample:\n\n\t %s "SERIAL_PORT_H" armsrc/obj/fullimage.elf\n", argv0);
#ifdef __linux__ #ifdef __linux__
fprintf(stdout, "\nNote (Linux): if the flasher gets stuck in 'Waiting for Proxmark to reappear on <DEVICE>',\n"); fprintf(stdout, "\nNote (Linux): if the flasher gets stuck in 'Waiting for Proxmark3 to reappear on <DEVICE>',\n");
fprintf(stdout, " you need to blacklist proxmark for modem-manager - see wiki for more details:\n\n"); fprintf(stdout, " you need to blacklist Proxmark3 for modem-manager - see wiki for more details:\n\n");
fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/Gentoo Linux\n\n"); fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/Gentoo Linux\n\n");
fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/Ubuntu Linux\n\n"); fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/Ubuntu Linux\n\n");
fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/OSX\n\n"); fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/OSX\n\n");
@ -82,7 +82,7 @@ int main(int argc, char **argv) {
char *serial_port_name = argv[1]; char *serial_port_name = argv[1];
if (!OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) { if (!OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
fprintf(stderr, "Could not find Proxmark on " _RED_("%s") ".\n\n", serial_port_name); fprintf(stderr, "Could not find Proxmark3 on " _RED_("%s") ".\n\n", serial_port_name);
return -1; return -1;
} else { } else {
fprintf(stderr, _GREEN_("Found") "\n"); fprintf(stderr, _GREEN_("Found") "\n");

View file

@ -42,7 +42,7 @@
#define COMPRESS_MAX_NICE_LENGTH 258 #define COMPRESS_MAX_NICE_LENGTH 258
#define COMPRESS_MAX_CHAIN 8192 #define COMPRESS_MAX_CHAIN 8192
#define HARDNESTED_TABLE_SIZE (sizeof(uint32_t) * ((1L<<19)+1)) #define HARDNESTED_TABLE_SIZE (uint32_t)(sizeof(uint32_t) * ((1L<<19)+1))
static void usage(void) { static void usage(void) {
fprintf(stdout, "Usage: fpga_compress <infile1> <infile2> ... <infile_n> <outfile>\n"); fprintf(stdout, "Usage: fpga_compress <infile1> <infile2> ... <infile_n> <outfile>\n");
@ -95,15 +95,13 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
if (i >= num_infiles * (hardnested_mode ? HARDNESTED_TABLE_SIZE : FPGA_CONFIG_SIZE)) { if (i >= num_infiles * (hardnested_mode ? HARDNESTED_TABLE_SIZE : FPGA_CONFIG_SIZE)) {
if (hardnested_mode) { if (hardnested_mode) {
fprintf(stderr, fprintf(stderr,
#if __WORDSIZE == 64 "Input file too big (> %" PRIu32 " bytes). This is probably not a hardnested bitflip state table.\n"
"Input file too big (> %" PRIu64 " bytes). This is probably not a hardnested bitflip state table.\n"
#else
"Input file too big (> %li bytes). This is probably not a hardnested bitflip state table.\n"
#endif
, HARDNESTED_TABLE_SIZE); , HARDNESTED_TABLE_SIZE);
} else { } else {
fprintf(stderr, "Input files too big (total > %li bytes). These are probably not PM3 FPGA config files.\n", num_infiles * FPGA_CONFIG_SIZE); fprintf(stderr,
"Input files too big (total > %li bytes). These are probably not PM3 FPGA config files.\n"
, num_infiles * FPGA_CONFIG_SIZE);
} }
for (uint16_t j = 0; j < num_infiles; j++) { for (uint16_t j = 0; j < num_infiles; j++) {
fclose(infile[j]); fclose(infile[j]);

View file

@ -281,7 +281,7 @@ static int get_proxmark_state(uint32_t *state) {
*state = resp.arg[0]; *state = resp.arg[0];
break; break;
default: default:
fprintf(stderr, "Error: Couldn't get proxmark state, bad response type: 0x%04x\n", resp.cmd); fprintf(stderr, "Error: Couldn't get Proxmark3 state, bad response type: 0x%04x\n", resp.cmd);
return -1; return -1;
break; break;
} }
@ -319,7 +319,7 @@ static int enter_bootloader(void) {
SendCommand(&c); SendCommand(&c);
fprintf(stderr, "Press and hold down button NOW if your bootloader requires it.\n"); fprintf(stderr, "Press and hold down button NOW if your bootloader requires it.\n");
} }
fprintf(stderr, "Waiting for Proxmark to reappear on USB..."); fprintf(stderr, "Waiting for Proxmark3 to reappear on USB...");
CloseProxmark(); CloseProxmark();
msleep(1000); msleep(1000);
@ -333,7 +333,7 @@ static int enter_bootloader(void) {
return 0; return 0;
} }
fprintf(stderr, "Error: Unknown Proxmark mode\n"); fprintf(stderr, "Error: Unknown Proxmark3 mode\n");
return -1; return -1;
} }

View file

@ -55,7 +55,7 @@ int main(int argc, char **argv) {
usb_init(); usb_init();
fprintf(stderr, "Waiting for Proxmark to appear on USB..."); fprintf(stderr, "Waiting for Proxmark3 to appear on USB...");
while (!OpenProxmark(1)) { while (!OpenProxmark(1)) {
msleep(1000); msleep(1000);
fprintf(stderr, "."); fprintf(stderr, ".");

View file

@ -118,7 +118,7 @@ static uint8_t _select(bool x, bool y, uint8_t r) {
uint8_t retval = 0; uint8_t retval = 0;
retval |= (z0 << 2) & 4; retval |= (z0 << 2) & 4;
retval |= (z1 << 1) & 2; retval |= (z1 << 1) & 2;
retval |= z2 & 1; retval |= (z2) & 1;
// Return value 0 <= retval <= 7 // Return value 0 <= retval <= 7
return retval; return retval;

View file

@ -504,8 +504,8 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
errors += bruteforceItem(*attack, keytable); errors += bruteforceItem(*attack, keytable);
} }
free(attack); free(attack);
t1 = msclock() - t1;
PrintAndLogDevice(SUCCESS, "time: %" PRIu64 " seconds", (msclock() - t1) / 1000); PrintAndLogDevice(SUCCESS, "time: %" PRIu64 " seconds", t1 / 1000);
// Pick out the first 16 bytes of the keytable. // Pick out the first 16 bytes of the keytable.
// The keytable is now in 16-bit ints, where the upper 8 bits // The keytable is now in 16-bit ints, where the upper 8 bits

View file

@ -21,7 +21,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
// message // message
PrintAndLogEx(NORMAL, "--------------------------------------------------------------------------------\n"); PrintAndLogEx(NORMAL, "--------------------------------------------------------------------------------\n");
PrintAndLogEx(NORMAL, "executing Darkside attack. Expected execution time: 25sec on average"); PrintAndLogEx(NORMAL, "executing Darkside attack. Expected execution time: 25sec on average");
PrintAndLogEx(NORMAL, "press pm3-button on the proxmark3 device to abort both proxmark3 and client."); PrintAndLogEx(NORMAL, "press pm3-button on the Proxmark3 device to abort both Proxmark3 and client.");
PrintAndLogEx(NORMAL, "--------------------------------------------------------------------------------\n"); PrintAndLogEx(NORMAL, "--------------------------------------------------------------------------------\n");
while (true) { while (true) {
@ -159,7 +159,7 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
// s70 with 40*2 keys to check, 80*85 = 6800 auth. // s70 with 40*2 keys to check, 80*85 = 6800 auth.
// takes about 97s, still some margin before abort // takes about 97s, still some margin before abort
if (timeout > 180) { if (timeout > 180) {
PrintAndLogEx(WARNING, "\nno response from Proxmark. Aborting..."); PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
return 2; return 2;
} }
} }
@ -919,7 +919,7 @@ int detect_classic_nackbug(bool verbose) {
UsbCommand resp; UsbCommand resp;
if (verbose) if (verbose)
PrintAndLogEx(SUCCESS, "press pm3-button on the proxmark3 device to abort both proxmark3 and client.\n"); PrintAndLogEx(SUCCESS, "press pm3-button on the Proxmark3 device to abort both Proxmark3 and client.\n");
// for nice animation // for nice animation
bool term = !isatty(STDIN_FILENO); bool term = !isatty(STDIN_FILENO);

View file

@ -206,7 +206,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
static void dumpAllHelp(int markdown) { static void dumpAllHelp(int markdown) {
PrintAndLogEx(NORMAL, "\n%sProxmark3 command dump%s\n\n", markdown ? "# " : "", markdown ? "" : "\n======================"); PrintAndLogEx(NORMAL, "\n%sProxmark3 command dump%s\n\n", markdown ? "# " : "", markdown ? "" : "\n======================");
PrintAndLogEx(NORMAL, "Some commands are available only if a Proxmark is actually connected.%s\n", markdown ? " " : ""); PrintAndLogEx(NORMAL, "Some commands are available only if a Proxmark3 is actually connected.%s\n", markdown ? " " : "");
PrintAndLogEx(NORMAL, "Check column \"offline\" for their availability.\n"); PrintAndLogEx(NORMAL, "Check column \"offline\" for their availability.\n");
PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(NORMAL, "\n");
command_t *cmds = getTopLevelCommandTable(); command_t *cmds = getTopLevelCommandTable();
@ -262,7 +262,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
PrintAndLogEx(NORMAL, " %s -m\n", exec_name); PrintAndLogEx(NORMAL, " %s -m\n", exec_name);
PrintAndLogEx(NORMAL, " %s "SERIAL_PORT_H" -f -- flush output everytime\n", exec_name); PrintAndLogEx(NORMAL, " %s "SERIAL_PORT_H" -f -- flush output everytime\n", exec_name);
PrintAndLogEx(NORMAL, " %s "SERIAL_PORT_H" -w -- wait for serial port\n", exec_name); PrintAndLogEx(NORMAL, " %s "SERIAL_PORT_H" -w -- wait for serial port\n", exec_name);
PrintAndLogEx(NORMAL, "\n how to run proxmark3 client\n"); PrintAndLogEx(NORMAL, "\n how to run Proxmark3 client\n");
PrintAndLogEx(NORMAL, " %s "SERIAL_PORT_H" -- runs the pm3 client\n", exec_name); PrintAndLogEx(NORMAL, " %s "SERIAL_PORT_H" -- runs the pm3 client\n", exec_name);
PrintAndLogEx(NORMAL, " %s -- runs the pm3 client in OFFLINE mode\n", exec_name); PrintAndLogEx(NORMAL, " %s -- runs the pm3 client in OFFLINE mode\n", exec_name);
PrintAndLogEx(NORMAL, "\n how to execute different commands from terminal\n"); PrintAndLogEx(NORMAL, "\n how to execute different commands from terminal\n");
@ -420,6 +420,12 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
// ascii art
bool stdinOnPipe = !isatty(STDIN_FILENO);
if (!script_cmds_file && !stdinOnPipe)
showBanner();
// default speed for USB 460800, USART(FPC serial) 115200 baud // default speed for USB 460800, USART(FPC serial) 115200 baud
if (speed == 0) if (speed == 0)
#ifdef WITH_FPC_HOST #ifdef WITH_FPC_HOST
@ -435,7 +441,7 @@ int main(int argc, char *argv[]) {
if (strlen(script_cmd) == 0) { if (strlen(script_cmd) == 0) {
script_cmd = NULL; script_cmd = NULL;
PrintAndLogEx(WARNING, "ERROR: execute command: command not found.\n"); PrintAndLogEx(ERR, _RED_("ERROR:") "execute command: " _YELLOW_("command not found") ".\n");
return 2; return 2;
} else { } else {
if (addLuaExec) { if (addLuaExec) {
@ -450,15 +456,10 @@ int main(int argc, char *argv[]) {
} }
} }
PrintAndLogEx(SUCCESS, "execute command from commandline: %s\n", script_cmd); PrintAndLogEx(SUCCESS, "execute command from commandline: " _YELLOW_("%s") "\n", script_cmd);
} }
} }
// ascii art
bool stdinOnPipe = !isatty(STDIN_FILENO);
if (!script_cmds_file && !stdinOnPipe)
showBanner();
// set global variables // set global variables
set_my_executable_path(); set_my_executable_path();

View file

@ -85,13 +85,12 @@ static struct Crypto1State *
recover(uint32_t *o_head, uint32_t *o_tail, uint32_t oks, recover(uint32_t *o_head, uint32_t *o_tail, uint32_t oks,
uint32_t *e_head, uint32_t *e_tail, uint32_t eks, int rem, uint32_t *e_head, uint32_t *e_tail, uint32_t eks, int rem,
struct Crypto1State *sl, uint32_t in, bucket_array_t bucket) { struct Crypto1State *sl, uint32_t in, bucket_array_t bucket) {
uint32_t *o, *e;
bucket_info_t bucket_info; bucket_info_t bucket_info;
if (rem == -1) { if (rem == -1) {
for (e = e_head; e <= e_tail; ++e) { for (uint32_t *e = e_head; e <= e_tail; ++e) {
*e = *e << 1 ^ (evenparity32(*e & LF_POLY_EVEN)) ^ !!(in & 4); *e = *e << 1 ^ (evenparity32(*e & LF_POLY_EVEN)) ^ (!!(in & 4));
for (o = o_head; o <= o_tail; ++o, ++sl) { for (uint32_t *o = o_head; o <= o_tail; ++o, ++sl) {
sl->even = *o; sl->even = *o;
sl->odd = *e ^ (evenparity32(*o & LF_POLY_ODD)); sl->odd = *e ^ (evenparity32(*o & LF_POLY_ODD));
sl[1].odd = sl[1].even = 0; sl[1].odd = sl[1].even = 0;
@ -301,7 +300,7 @@ uint8_t lfsr_rollback_bit(struct Crypto1State *s, uint32_t in, int fb) {
out ^= LF_POLY_EVEN & (s->even >>= 1); out ^= LF_POLY_EVEN & (s->even >>= 1);
out ^= LF_POLY_ODD & s->odd; out ^= LF_POLY_ODD & s->odd;
out ^= !!in; out ^= !!in;
out ^= (ret = filter(s->odd)) & !!fb; out ^= (ret = filter(s->odd)) & (!!fb);
s->even |= (evenparity32(out)) << 23; s->even |= (evenparity32(out)) << 23;
return ret; return ret;

View file

@ -68,7 +68,7 @@ uint8_t crypto1_bit(struct Crypto1State *s, uint8_t in, int is_encrypted) {
uint32_t feedin, t; uint32_t feedin, t;
uint8_t ret = filter(s->odd); uint8_t ret = filter(s->odd);
feedin = ret & !!is_encrypted; feedin = ret & (!!is_encrypted);
feedin ^= !!in; feedin ^= !!in;
feedin ^= LF_POLY_ODD & s->odd; feedin ^= LF_POLY_ODD & s->odd;
feedin ^= LF_POLY_EVEN & s->even; feedin ^= LF_POLY_EVEN & s->even;

View file

@ -368,12 +368,6 @@ uint8_t lfsr_rollback_bit(struct Crypto1State *s, uint32_t in, int fb) {
* Rollback the shift register in order to get previous states * Rollback the shift register in order to get previous states
*/ */
uint8_t lfsr_rollback_byte(struct Crypto1State *s, uint32_t in, int fb) { uint8_t lfsr_rollback_byte(struct Crypto1State *s, uint32_t in, int fb) {
/*
int i, ret = 0;
for (i = 7; i >= 0; --i)
ret |= lfsr_rollback_bit(s, BIT(in, i), fb) << i;
*/
// unfold loop 20160112
uint8_t ret = 0; uint8_t ret = 0;
ret |= lfsr_rollback_bit(s, BIT(in, 7), fb) << 7; ret |= lfsr_rollback_bit(s, BIT(in, 7), fb) << 7;
ret |= lfsr_rollback_bit(s, BIT(in, 6), fb) << 6; ret |= lfsr_rollback_bit(s, BIT(in, 6), fb) << 6;
@ -389,13 +383,7 @@ uint8_t lfsr_rollback_byte(struct Crypto1State *s, uint32_t in, int fb) {
* Rollback the shift register in order to get previous states * Rollback the shift register in order to get previous states
*/ */
uint32_t lfsr_rollback_word(struct Crypto1State *s, uint32_t in, int fb) { uint32_t lfsr_rollback_word(struct Crypto1State *s, uint32_t in, int fb) {
/*
int i;
uint32_t ret = 0;
for (i = 31; i >= 0; --i)
ret |= lfsr_rollback_bit(s, BEBIT(in, i), fb) << (i ^ 24);
*/
// unfold loop 20160112
uint32_t ret = 0; uint32_t ret = 0;
ret |= lfsr_rollback_bit(s, BEBIT(in, 31), fb) << (31 ^ 24); ret |= lfsr_rollback_bit(s, BEBIT(in, 31), fb) << (31 ^ 24);
ret |= lfsr_rollback_bit(s, BEBIT(in, 30), fb) << (30 ^ 24); ret |= lfsr_rollback_bit(s, BEBIT(in, 30), fb) << (30 ^ 24);
@ -442,7 +430,7 @@ static uint16_t *dist = 0;
int nonce_distance(uint32_t from, uint32_t to) { int nonce_distance(uint32_t from, uint32_t to) {
uint16_t x, i; uint16_t x, i;
if (!dist) { if (!dist) {
dist = malloc(2 << 16); dist = calloc(2 << 16, sizeof(uint8_t));
if (!dist) if (!dist)
return -1; return -1;
for (x = i = 1; i; ++i) { for (x = i = 1; i; ++i) {
@ -470,7 +458,7 @@ static uint32_t fastfwd[2][8] = {
* only correct iff [NR_3] ^ NR_3 does not depend on Nr_3 * only correct iff [NR_3] ^ NR_3 does not depend on Nr_3
*/ */
uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd) { uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd) {
uint32_t *candidates = malloc(4 << 10); uint32_t *candidates = calloc(4 << 10, sizeof(uint8_t));
if (!candidates) return 0; if (!candidates) return 0;
uint32_t c, entry; uint32_t c, entry;
@ -538,7 +526,7 @@ struct Crypto1State *lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8]
odd = lfsr_prefix_ks(ks, 1); odd = lfsr_prefix_ks(ks, 1);
even = lfsr_prefix_ks(ks, 0); even = lfsr_prefix_ks(ks, 0);
s = statelist = malloc((sizeof * statelist) << 20); s = statelist = malloc((sizeof * statelist) << 24); // was << 20. Need more for no_par special attack. Enough???
if (!s || !odd || !even) { if (!s || !odd || !even) {
free(statelist); free(statelist);
statelist = 0; statelist = 0;

View file

@ -62,13 +62,6 @@ uint8_t crypto1_bit(struct Crypto1State *s, uint8_t in, int is_encrypted) {
return ret; return ret;
} }
uint8_t crypto1_byte(struct Crypto1State *s, uint8_t in, int is_encrypted) { uint8_t crypto1_byte(struct Crypto1State *s, uint8_t in, int is_encrypted) {
/*
uint8_t i, ret = 0;
for (i = 0; i < 8; ++i)
ret |= crypto1_bit(s, BIT(in, i), is_encrypted) << i;
*/
// unfold loop 20161012
uint8_t ret = 0; uint8_t ret = 0;
ret |= crypto1_bit(s, BIT(in, 0), is_encrypted) << 0; ret |= crypto1_bit(s, BIT(in, 0), is_encrypted) << 0;
ret |= crypto1_bit(s, BIT(in, 1), is_encrypted) << 1; ret |= crypto1_bit(s, BIT(in, 1), is_encrypted) << 1;
@ -81,13 +74,6 @@ uint8_t crypto1_byte(struct Crypto1State *s, uint8_t in, int is_encrypted) {
return ret; return ret;
} }
uint32_t crypto1_word(struct Crypto1State *s, uint32_t in, int is_encrypted) { uint32_t crypto1_word(struct Crypto1State *s, uint32_t in, int is_encrypted) {
/*
uint32_t i, ret = 0;
for (i = 0; i < 32; ++i)
ret |= crypto1_bit(s, BEBIT(in, i), is_encrypted) << (i ^ 24);
*/
//unfold loop 2016012
uint32_t ret = 0; uint32_t ret = 0;
ret |= crypto1_bit(s, BEBIT(in, 0), is_encrypted) << (0 ^ 24); ret |= crypto1_bit(s, BEBIT(in, 0), is_encrypted) << (0 ^ 24);
ret |= crypto1_bit(s, BEBIT(in, 1), is_encrypted) << (1 ^ 24); ret |= crypto1_bit(s, BEBIT(in, 1), is_encrypted) << (1 ^ 24);