mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-10-03 05:36:16 +08:00
commit
7adf47d3d6
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -30,16 +30,17 @@ version.c
|
||||||
*.json
|
*.json
|
||||||
*.old
|
*.old
|
||||||
*.swp
|
*.swp
|
||||||
|
*.json.bak
|
||||||
|
|
||||||
# new build file for add-ons.
|
# new build file for add-ons.
|
||||||
Makefile.platform
|
Makefile.platform
|
||||||
# Cache for detecting platform def changes
|
# Cache for detecting platform def changes
|
||||||
.Makefile.options.cache
|
.Makefile.options.cache
|
||||||
|
|
||||||
!client/hardnested/*.bin
|
!client/resources/hardnested/*.bin
|
||||||
!client/hardnested/tables/*.z
|
!client/resources/hardnested_tables/*.z
|
||||||
client/ui/ui_overlays.h
|
client/src/ui/ui_overlays.h
|
||||||
client/reveng/bmptst
|
client/deps/reveng/bmptst
|
||||||
|
|
||||||
hardnested_stats.txt
|
hardnested_stats.txt
|
||||||
proxmark3
|
proxmark3
|
||||||
|
@ -64,10 +65,14 @@ fpga/*
|
||||||
!fpga/xst_hf.scr
|
!fpga/xst_hf.scr
|
||||||
!fpga/go.bat
|
!fpga/go.bat
|
||||||
!fpga/sim.tcl
|
!fpga/sim.tcl
|
||||||
|
# offcial dumps folder
|
||||||
|
dumps/*
|
||||||
|
|
||||||
#client/*
|
#client/*
|
||||||
# my own traces folder
|
# my own traces folder
|
||||||
client/traces/*
|
client/traces/*
|
||||||
|
# my own dumps folder
|
||||||
|
client/dumps/*
|
||||||
*.ice
|
*.ice
|
||||||
*.new
|
*.new
|
||||||
armsrc/TEMP EMV/*
|
armsrc/TEMP EMV/*
|
||||||
|
|
|
@ -557,7 +557,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
||||||
int res = EmGetCmd(receivedCmd, &receivedCmd_len, receivedCmd_par);
|
int res = EmGetCmd(receivedCmd, &receivedCmd_len, receivedCmd_par);
|
||||||
|
|
||||||
if (res == 2) { //Field is off!
|
if (res == 2) { //Field is off!
|
||||||
FpgaDisableTracing();
|
//FpgaDisableTracing();
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
cardSTATE = MFEMUL_NOFIELD;
|
cardSTATE = MFEMUL_NOFIELD;
|
||||||
if (DBGLEVEL >= DBG_EXTENDED)
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
|
@ -595,14 +595,16 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cardSTATE) {
|
switch (cardSTATE) {
|
||||||
case MFEMUL_NOFIELD:
|
case MFEMUL_NOFIELD: {
|
||||||
if (DBGLEVEL >= DBG_EXTENDED)
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
Dbprintf("MFEMUL_NOFIELD");
|
Dbprintf("MFEMUL_NOFIELD");
|
||||||
break;
|
break;
|
||||||
case MFEMUL_HALTED:
|
}
|
||||||
|
case MFEMUL_HALTED: {
|
||||||
if (DBGLEVEL >= DBG_EXTENDED)
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
Dbprintf("MFEMUL_HALTED");
|
Dbprintf("MFEMUL_HALTED");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MFEMUL_IDLE: {
|
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);
|
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)
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
|
@ -706,8 +708,9 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
||||||
// WORK
|
// WORK
|
||||||
case MFEMUL_WORK: {
|
case MFEMUL_WORK: {
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_EXTENDED)
|
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||||
Dbprintf("[MFEMUL_WORK] Enter in case");
|
Dbprintf("[MFEMUL_WORK] Enter in case");
|
||||||
|
}
|
||||||
|
|
||||||
if (receivedCmd_len == 0) {
|
if (receivedCmd_len == 0) {
|
||||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] NO CMD received");
|
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) {
|
if (encrypted_data) {
|
||||||
// decrypt seqence
|
// decrypt seqence
|
||||||
mf_crypto1_decryptEx(pcs, receivedCmd, receivedCmd_len, receivedCmd_dec);
|
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 {
|
} else {
|
||||||
// Data in clear
|
// Data in clear
|
||||||
memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len);
|
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);
|
EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
|
@ -1251,8 +1255,10 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
||||||
|
|
||||||
} // End While Loop
|
} // End While Loop
|
||||||
|
|
||||||
|
FpgaDisableTracing();
|
||||||
|
|
||||||
// NR AR ATTACK
|
// NR AR ATTACK
|
||||||
|
// mfkey32
|
||||||
if (((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) && (DBGLEVEL >= DBG_INFO)) {
|
if (((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) && (DBGLEVEL >= DBG_INFO)) {
|
||||||
for (uint8_t i = 0; i < ATTACK_KEY_COUNT; i++) {
|
for (uint8_t i = 0; i < ATTACK_KEY_COUNT; i++) {
|
||||||
if (ar_nr_collected[i] == 2) {
|
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++) {
|
for (uint8_t i = ATTACK_KEY_COUNT; i < ATTACK_KEY_COUNT * 2; i++) {
|
||||||
if (ar_nr_collected[i] == 2) {
|
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);
|
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());
|
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
|
if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK
|
||||||
//Send the collected ar_nr in the response
|
//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));
|
reply_mix(CMD_ACK, CMD_HF_MIFARE_SIMULATE, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp));
|
||||||
|
|
|
@ -83,8 +83,9 @@ enum {
|
||||||
EMINCOUNT = 1,
|
EMINCOUNT = 1,
|
||||||
EMAXCOUNT,
|
EMAXCOUNT,
|
||||||
EBADINT,
|
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_,
|
EOVERFLOW_,
|
||||||
#else
|
#else
|
||||||
EOVERFLOW,
|
EOVERFLOW,
|
||||||
|
|
|
@ -33,9 +33,13 @@
|
||||||
#define JSON_INTEGER_IS_LONG_LONG 1
|
#define JSON_INTEGER_IS_LONG_LONG 1
|
||||||
|
|
||||||
/* If locale.h and localeconv() are available, define to 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
|
#define JSON_HAVE_LOCALECONV 1
|
||||||
|
#endif
|
||||||
/* If __atomic builtins are available they will be used to manage
|
/* If __atomic builtins are available they will be used to manage
|
||||||
reference counts of json_t. */
|
reference counts of json_t. */
|
||||||
#define JSON_HAVE_ATOMIC_BUILTINS 1
|
#define JSON_HAVE_ATOMIC_BUILTINS 1
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
|
||||||
|
#ifdef __APPLE__ || defined(__ANDROID__) || defined(ANDROID)
|
||||||
typedef int RetType;
|
typedef int RetType;
|
||||||
typedef int LenType;
|
typedef int LenType;
|
||||||
#elif __GLIBC__
|
#elif __GLIBC__
|
||||||
|
@ -101,7 +102,7 @@ FILE *open_memstream(char **bufptr, size_t *lenptr) {
|
||||||
*bufptr = NULL;
|
*bufptr = NULL;
|
||||||
*lenptr = 0;
|
*lenptr = 0;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__ || defined(__ANDROID__) || defined(ANDROID)
|
||||||
return funopen(b, NULL, write_to_buffer, NULL, close_buffer);
|
return funopen(b, NULL, write_to_buffer, NULL, close_buffer);
|
||||||
#elif __GLIBC__
|
#elif __GLIBC__
|
||||||
static const cookie_io_functions_t vtable = {
|
static const cookie_io_functions_t vtable = {
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include "sys/socket.h"
|
||||||
|
#include "sys/un.h"
|
||||||
|
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
|
|
||||||
|
@ -156,6 +158,51 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
return sp;
|
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);
|
sp->fd = open(pcPortName, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
|
||||||
if (sp->fd == -1) {
|
if (sp->fd == -1) {
|
||||||
uart_close(sp);
|
uart_close(sp);
|
||||||
|
|
|
@ -21,15 +21,21 @@
|
||||||
#include <stdio.h> // for Mingw readline
|
#include <stdio.h> // for Mingw readline
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "proxmark3.h" // PROXLOG
|
#include "proxmark3.h" // PROXLOG
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
#include "pm3_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <direct.h> // _mkdir
|
# include <direct.h> // _mkdir
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "emojis.h"
|
#include "emojis.h"
|
||||||
#include "emojis_alt.h"
|
#include "emojis_alt.h"
|
||||||
|
|
|
@ -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
|
- (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 proxmark3` for stable release
|
||||||
- `brew install --HEAD proxmark3` for latest non-stable from GitHub (use this if previous command fails)
|
- `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
|
For more info, go to https://github.com/RfidResearchGroup/homebrew-proxmark3
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue