diff --git a/.gitignore b/.gitignore index 1b352bcfe..7bbad2e87 100644 --- a/.gitignore +++ b/.gitignore @@ -30,16 +30,17 @@ version.c *.json *.old *.swp +*.json.bak # new build file for add-ons. Makefile.platform # Cache for detecting platform def changes .Makefile.options.cache -!client/hardnested/*.bin -!client/hardnested/tables/*.z -client/ui/ui_overlays.h -client/reveng/bmptst +!client/resources/hardnested/*.bin +!client/resources/hardnested_tables/*.z +client/src/ui/ui_overlays.h +client/deps/reveng/bmptst hardnested_stats.txt proxmark3 @@ -64,10 +65,14 @@ fpga/* !fpga/xst_hf.scr !fpga/go.bat !fpga/sim.tcl +# offcial dumps folder +dumps/* #client/* # my own traces folder client/traces/* +# my own dumps folder +client/dumps/* *.ice *.new armsrc/TEMP EMV/* diff --git a/armsrc/mifaresim.c b/armsrc/mifaresim.c index 8472ba98e..9fb0d9d5d 100644 --- a/armsrc/mifaresim.c +++ b/armsrc/mifaresim.c @@ -557,7 +557,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 int res = EmGetCmd(receivedCmd, &receivedCmd_len, receivedCmd_par); if (res == 2) { //Field is off! - FpgaDisableTracing(); + //FpgaDisableTracing(); LEDsoff(); cardSTATE = MFEMUL_NOFIELD; if (DBGLEVEL >= DBG_EXTENDED) @@ -595,14 +595,16 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 } switch (cardSTATE) { - case MFEMUL_NOFIELD: + case MFEMUL_NOFIELD: { if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("MFEMUL_NOFIELD"); break; - case MFEMUL_HALTED: + } + case MFEMUL_HALTED: { if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("MFEMUL_HALTED"); break; + } case MFEMUL_IDLE: { LogTrace(uart->output, uart->len, uart->startTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->endTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->parity, true); if (DBGLEVEL >= DBG_EXTENDED) @@ -706,8 +708,9 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 // WORK case MFEMUL_WORK: { - if (DBGLEVEL >= DBG_EXTENDED) + if (DBGLEVEL >= DBG_EXTENDED) { Dbprintf("[MFEMUL_WORK] Enter in case"); + } if (receivedCmd_len == 0) { if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] NO CMD received"); @@ -718,13 +721,14 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 if (encrypted_data) { // decrypt seqence mf_crypto1_decryptEx(pcs, receivedCmd, receivedCmd_len, receivedCmd_dec); - if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] Decrypt seqence"); + if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] Decrypt sequence"); } else { // Data in clear memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len); } - if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) { // all commands must have a valid CRC + // all commands must have a valid CRC + if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) { EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA); FpgaDisableTracing(); @@ -1251,8 +1255,10 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 } // End While Loop + FpgaDisableTracing(); // NR AR ATTACK + // mfkey32 if (((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) && (DBGLEVEL >= DBG_INFO)) { for (uint8_t i = 0; i < ATTACK_KEY_COUNT; i++) { if (ar_nr_collected[i] == 2) { @@ -1268,7 +1274,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 } } } - + + // mfkey32 v2 for (uint8_t i = ATTACK_KEY_COUNT; i < ATTACK_KEY_COUNT * 2; i++) { if (ar_nr_collected[i] == 2) { Dbprintf("Collected two pairs of AR/NR which can be used to extract %s from reader for sector %d:", (i < ATTACK_KEY_COUNT / 2) ? "keyA" : "keyB", ar_nr_resp[i].sector); @@ -1288,7 +1295,6 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", get_tracing(), BigBuf_get_traceLen()); } - if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK //Send the collected ar_nr in the response reply_mix(CMD_ACK, CMD_HF_MIFARE_SIMULATE, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp)); diff --git a/client/deps/cliparser/argtable3.c b/client/deps/cliparser/argtable3.c index 3acbce48e..f66c22d6d 100644 --- a/client/deps/cliparser/argtable3.c +++ b/client/deps/cliparser/argtable3.c @@ -83,8 +83,9 @@ enum { EMINCOUNT = 1, EMAXCOUNT, EBADINT, - // The same name define EOVERFLOW in errno.h on windows platform -#ifdef __STDC_WANT_SECURE_LIB__ + +// The same name define EOVERFLOW in errno.h on windows platform or android +#if defined(__STDC_WANT_SECURE_LIB__) || defined(__ANDROID__) || defined(ANDROID) EOVERFLOW_, #else EOVERFLOW, diff --git a/client/deps/jansson/jansson_config.h b/client/deps/jansson/jansson_config.h index b34baa551..92f6ffb25 100644 --- a/client/deps/jansson/jansson_config.h +++ b/client/deps/jansson/jansson_config.h @@ -33,9 +33,13 @@ #define JSON_INTEGER_IS_LONG_LONG 1 /* If locale.h and localeconv() are available, define to 1, - otherwise to 0. */ + otherwise to 0. tips: android don't support localeconv() +*/ +#if defined(__ANDROID__) || defined(ANDROID) +#define JSON_HAVE_LOCALECONV 0 +#else #define JSON_HAVE_LOCALECONV 1 - +#endif /* If __atomic builtins are available they will be used to manage reference counts of json_t. */ #define JSON_HAVE_ATOMIC_BUILTINS 1 diff --git a/client/deps/tinycbor/open_memstream.c b/client/deps/tinycbor/open_memstream.c index 199832461..098bf90fe 100644 --- a/client/deps/tinycbor/open_memstream.c +++ b/client/deps/tinycbor/open_memstream.c @@ -35,7 +35,8 @@ #if defined(__unix__) || defined(__APPLE__) # include #endif -#ifdef __APPLE__ + +#ifdef __APPLE__ || defined(__ANDROID__) || defined(ANDROID) typedef int RetType; typedef int LenType; #elif __GLIBC__ @@ -101,7 +102,7 @@ FILE *open_memstream(char **bufptr, size_t *lenptr) { *bufptr = NULL; *lenptr = 0; -#ifdef __APPLE__ +#ifdef __APPLE__ || defined(__ANDROID__) || defined(ANDROID) return funopen(b, NULL, write_to_buffer, NULL, close_buffer); #elif __GLIBC__ static const cookie_io_functions_t vtable = { diff --git a/client/src/uart/uart_posix.c b/client/src/uart/uart_posix.c index 0077924cf..0e05f8389 100644 --- a/client/src/uart/uart_posix.c +++ b/client/src/uart/uart_posix.c @@ -48,6 +48,8 @@ #include #include #include +#include "sys/socket.h" +#include "sys/un.h" #include "comms.h" @@ -156,6 +158,51 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { return sp; } + // The socket for abstract namespace implement. + // Is local socket buffer, not a TCP or any net connection! + // so, you can't connect with address like: 127.0.0.1, or any IP + // see http://man7.org/linux/man-pages/man7/unix.7.html + if (memcmp(pcPortName, "socket:", 7) == 0) { + if (strlen(pcPortName) <= 7) { + free(sp); + return INVALID_SERIAL_PORT; + } + + // we must use max timeout! + timeout.tv_usec = UART_TCP_CLIENT_RX_TIMEOUT_MS * 1000; + + size_t servernameLen = (strlen(pcPortName) - 7) + 1; + char serverNameBuf[servernameLen]; + memset(serverNameBuf, '\0', servernameLen); + for (int i = 7, j = 0; j < servernameLen; ++i, ++j) { + serverNameBuf[j] = pcPortName[i]; + } + serverNameBuf[servernameLen - 1] = '\0'; + + int localsocket, len; + struct sockaddr_un remote; + + remote.sun_path[0] = '\0'; // abstract namespace + strcpy(remote.sun_path + 1, serverNameBuf); + remote.sun_family = AF_LOCAL; + int nameLen = strlen(serverNameBuf); + len = 1 + nameLen + offsetof(struct sockaddr_un, sun_path); + + if ((localsocket = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1) { + free(sp); + return INVALID_SERIAL_PORT; + } + + if (connect(localsocket, (struct sockaddr *) &remote, len) == -1) { + free(sp); + return INVALID_SERIAL_PORT; + } + + sp->fd = localsocket; + + return sp; + } + sp->fd = open(pcPortName, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK); if (sp->fd == -1) { uart_close(sp); diff --git a/client/src/ui.c b/client/src/ui.c index bb3039b05..bd8ed0dce 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -21,15 +21,21 @@ #include // for Mingw readline #include #include + +#ifndef ANDROID #include +#endif + #include #include "util.h" #include "proxmark3.h" // PROXLOG #include "fileutils.h" #include "pm3_cmd.h" + #ifdef _WIN32 # include // _mkdir #endif + #include #include "emojis.h" #include "emojis_alt.h" diff --git a/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md b/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md index 367452454..6e21f852b 100644 --- a/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md @@ -13,7 +13,8 @@ For further questions about Mac & Homebrew, contact @Chrisfu (https://github.c - (Optional) `export HOMEBREW_PROXMARK3_PLATFORM=xxxxxx` to specify [platform](https://github.com/RfidResearchGroup/proxmark3/blob/master/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md#platform), default value is `PM3RDV4` if none - `brew install proxmark3` for stable release - `brew install --HEAD proxmark3` for latest non-stable from GitHub (use this if previous command fails) - - `brew install --with-blueshark proxmark3` for blueshark support + - `brew install --with-blueshark proxmark3` for blueshark support, stable release + - `brew install --HEAD --with-blueshark proxmark3` for blueshark support, latest non-stable from GitHub (use this if previous command fails) For more info, go to https://github.com/RfidResearchGroup/homebrew-proxmark3