mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
summer restructuring:
* .h include only the strict minimum for their own parsing * this forces all files to include explicitment their needs and not count on far streched dependencies * this helps Makefile to rebuild only the minimum * according to this rule, most standalone .h are now gone * big app.h is gone * remove seldom __cplusplus, if c++ happens, everything will have to be done properly anyway * all unrequired include were removed * split common/ into common/ (client+arm) and common_arm/ (os+bootloader) * bring zlib to common/ * bring stuff not really/not yet used in common back to armsrc/ or client/ * bring liblua into client/ * bring uart into client/ * move some portions of code around (dbprint, protocols,...) * rename unused files into *_disabled.[ch] to make it explicit * rename soft Uarts between 14a, 14b and iclass, so a standalone could use several without clash * remove PrintAndLogDevice * move deprecated-hid-flasher from client to tools * Makefiles * treat deps in armsrc/ as in client/ * client: stop on warning (-Werror), same as for armsrc/ Tested on: * all standalone modes * Linux
This commit is contained in:
parent
b7d412d27b
commit
d19754567d
447 changed files with 2553 additions and 2599 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -39,6 +39,7 @@ client/ui/ui_overlays.h
|
|||
hardnested_stats.txt
|
||||
proxmark3
|
||||
flasher
|
||||
!flasher/
|
||||
lua
|
||||
luac
|
||||
fpga_compress
|
||||
|
|
2
Makefile
2
Makefile
|
@ -31,7 +31,7 @@ endif
|
|||
|
||||
-include Makefile.platform
|
||||
-include .Makefile.options.cache
|
||||
include common/Makefile.hal
|
||||
include common_arm/Makefile.hal
|
||||
|
||||
all clean: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/%
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "BigBuf.h"
|
||||
|
||||
#include "string.h"
|
||||
#include "dbprint.h"
|
||||
|
||||
// BigBuf is the large multi-purpose buffer, typically used to hold A/D samples or traces.
|
||||
// Also used to hold various smaller buffers and the Mifare Emulator Memory.
|
||||
// declare it as uint32_t to achieve alignment to 4 Byte boundary
|
||||
|
|
|
@ -12,10 +12,7 @@
|
|||
#ifndef __BIGBUF_H
|
||||
#define __BIGBUF_H
|
||||
|
||||
#include <stdbool.h> // for bool
|
||||
#include "proxmark3.h"
|
||||
#include "string.h"
|
||||
#include "ticks.h"
|
||||
#include "common.h"
|
||||
|
||||
#define BIGBUF_SIZE 40000
|
||||
#define MAX_FRAME_SIZE 256 // maximum allowed ISO14443 frame
|
||||
|
@ -43,4 +40,5 @@ void set_tracelen(uint32_t value);
|
|||
bool get_tracing(void);
|
||||
bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag);
|
||||
uint8_t emlSet(uint8_t *data, uint32_t offset, uint32_t length);
|
||||
|
||||
#endif /* __BIGBUF_H */
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#ifndef __LCD_H
|
||||
#define __LCD_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "fonts.h"
|
||||
|
||||
// The resolution of the LCD
|
||||
#define LCD_XRES 132
|
||||
#define LCD_YRES 132
|
|
@ -2,16 +2,14 @@
|
|||
# at your option, any later version. See the LICENSE.txt file for the text of
|
||||
# the license.
|
||||
#-----------------------------------------------------------------------------
|
||||
# Makefile for armsrc, see ../common/Makefile.common for common settings
|
||||
# Makefile for armsrc, see ../common_arm/Makefile.common for common settings
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
APP_INCLUDES = apps.h
|
||||
|
||||
# This Makefile might have been called directly, not via the root Makefile, so:
|
||||
ifeq ($(PLTNAME),)
|
||||
-include ../Makefile.platform
|
||||
-include ../.Makefile.options.cache
|
||||
include ../common/Makefile.hal
|
||||
include ../common_arm/Makefile.hal
|
||||
# detect if there were changes in the platform definitions, requiring a clean
|
||||
ifeq ($(PLATFORM_CHANGED), true)
|
||||
$(error platform definitions have been changed, please "make clean" at the root of the project)
|
||||
|
@ -28,9 +26,10 @@ APP_CFLAGS = $(PLATFORM_DEFS) \
|
|||
SRC_LF = lfops.c lfsampling.c pcf7931.c lfdemod.c
|
||||
SRC_ISO15693 = iso15693.c iso15693tools.c
|
||||
SRC_ISO14443a = iso14443a.c mifareutil.c mifarecmd.c epa.c mifaresim.c
|
||||
#UNUSED: mifaresniff.c desfire_crypto.c
|
||||
SRC_ISO14443b = iso14443b.c
|
||||
SRC_FELICA = felica.c
|
||||
SRC_CRAPTO1 = crypto1.c des.c desfire_key.c desfire_crypto.c mifaredesfire.c aes.c platform_util.c
|
||||
SRC_CRAPTO1 = crypto1.c des.c desfire_key.c mifaredesfire.c aes.c platform_util.c
|
||||
SRC_CRC = crc.c crc16.c crc32.c
|
||||
SRC_ICLASS = iclass.c optimized_cipher.c
|
||||
SRC_LEGIC = legicrf.c legicrfsim.c legic_prng.c
|
||||
|
@ -83,7 +82,7 @@ SRC_ZLIB = inflate.c inffast.c inftrees.c adler32.c zutil.c
|
|||
ZLIB_CFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
|
||||
APP_CFLAGS += $(ZLIB_CFLAGS)
|
||||
# zlib includes:
|
||||
APP_CFLAGS += -I../zlib
|
||||
APP_CFLAGS += -I../common/zlib
|
||||
|
||||
# stdint.h provided locally until GCC 4.5 becomes C99 compliant,
|
||||
# stack-protect , no-pie reduces size on Gentoo Hardened 8.2 gcc
|
||||
|
@ -91,7 +90,6 @@ APP_CFLAGS += -I. -fno-stack-protector -fno-pie
|
|||
|
||||
# Compile these in thumb mode (small size)
|
||||
THUMBSRC = start.c \
|
||||
protocols.c \
|
||||
$(SRC_LCD) \
|
||||
$(SRC_ISO15693) \
|
||||
$(SRC_NFCBARCODE) \
|
||||
|
@ -105,6 +103,7 @@ THUMBSRC = start.c \
|
|||
$(SRC_SPIFFS) \
|
||||
appmain.c \
|
||||
printf.c \
|
||||
dbprint.c \
|
||||
commonutil.c \
|
||||
util.c \
|
||||
string.c \
|
||||
|
@ -131,7 +130,7 @@ VERSIONSRC = version.c \
|
|||
fpga_version_info.c
|
||||
|
||||
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
|
||||
include ../common/Makefile.common
|
||||
include ../common_arm/Makefile.common
|
||||
|
||||
COMMON_FLAGS = -Os
|
||||
|
||||
|
@ -220,3 +219,4 @@ help:
|
|||
@echo Possible targets:
|
||||
@echo + all - Build the full image $(OBJDIR)/fullimage.s19
|
||||
@echo + clean - Clean $(OBJDIR)
|
||||
|
||||
|
|
|
@ -19,7 +19,18 @@ you can simply run 'script run read_pwd_mem' or just 'mem dump p l 256'
|
|||
from the client to view the stored quadlets.
|
||||
*/
|
||||
|
||||
#include "hf_bog.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "proxmark3_arm.h"
|
||||
#include "iso14443a.h"
|
||||
#include "protocols.h"
|
||||
#include "util.h"
|
||||
#include "spiffs.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "BigBuf.h"
|
||||
#include "string.h"
|
||||
|
||||
#define DELAY_READER_AIR2ARM_AS_SNIFFER (2 + 3 + 8)
|
||||
#define DELAY_TAG_AIR2ARM_AS_SNIFFER (3 + 14 + 8)
|
||||
|
@ -62,10 +73,10 @@ void RAMFUNC SniffAndStore(uint8_t param) {
|
|||
bool ReaderIsActive = false;
|
||||
|
||||
// Set up the demodulator for tag -> reader responses.
|
||||
DemodInit(receivedResp, receivedRespPar);
|
||||
Demod14aInit(receivedResp, receivedRespPar);
|
||||
|
||||
// Set up the demodulator for the reader -> tag commands
|
||||
UartInit(receivedCmd, receivedCmdPar);
|
||||
Uart14aInit(receivedCmd, receivedCmdPar);
|
||||
|
||||
// Setup and start DMA.
|
||||
if (!FpgaSetupSscDma((uint8_t *)dmaBuf, DMA_BUFFER_SIZE)) {
|
||||
|
@ -74,8 +85,8 @@ void RAMFUNC SniffAndStore(uint8_t param) {
|
|||
return;
|
||||
}
|
||||
|
||||
tUart *uart = GetUart();
|
||||
tDemod *demod = GetDemod();
|
||||
tUart14a *uart = GetUart14a();
|
||||
tDemod14a *demod = GetDemod14a();
|
||||
|
||||
// We won't start recording the frames that we acquire until we trigger;
|
||||
// a good trigger condition to get started is probably when we see a
|
||||
|
@ -153,13 +164,13 @@ void RAMFUNC SniffAndStore(uint8_t param) {
|
|||
break;
|
||||
}
|
||||
/* ready to receive another command. */
|
||||
UartReset();
|
||||
Uart14aReset();
|
||||
/* reset the demod code, which might have been */
|
||||
/* false-triggered by the commands from the reader. */
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
LED_B_OFF();
|
||||
}
|
||||
ReaderIsActive = (uart->state != STATE_UNSYNCD);
|
||||
ReaderIsActive = (uart->state != STATE_14A_UNSYNCD);
|
||||
}
|
||||
|
||||
// no need to try decoding tag data if the reader is sending - and we cannot afford the time
|
||||
|
@ -176,13 +187,13 @@ void RAMFUNC SniffAndStore(uint8_t param) {
|
|||
triggered = true;
|
||||
|
||||
// ready to receive another response.
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
// reset the Miller decoder including its (now outdated) input buffer
|
||||
UartReset();
|
||||
Uart14aReset();
|
||||
// UartInit(receivedCmd, receivedCmdPar);
|
||||
LED_C_OFF();
|
||||
}
|
||||
TagIsActive = (demod->state != DEMOD_UNSYNCD);
|
||||
TagIsActive = (demod->state != DEMOD_14A_UNSYNCD);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// StandAlone Mod
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __HF_BOG_H
|
||||
#define __HF_BOG_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "mifareutil.h"
|
||||
#include "iso14443a.h"
|
||||
#include "protocols.h"
|
||||
#include "util.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include <stdbool.h> // for bool
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "apps.h"
|
||||
#include "printf.h"
|
||||
#include "parity.h"
|
||||
#include "spiffs.h"
|
||||
|
||||
|
||||
#endif /* __HF_BOG_H */
|
|
@ -8,8 +8,27 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// main code for HF Mifare aka ColinRun by Colin Brigato
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include <stdbool.h> // for bool
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "hf_colin.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "commonutil.h"
|
||||
#include "crc16.h"
|
||||
#include "BigBuf.h"
|
||||
#include "frozen.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "mifaresim.h" // mifare1ksim
|
||||
#include "mifareutil.h"
|
||||
#include "iso14443a.h"
|
||||
#include "util.h"
|
||||
#include "vtsend.h"
|
||||
#include "spiffs.h"
|
||||
#include "string.h"
|
||||
|
||||
#define MF1KSZ 1024
|
||||
#define MF1KSZSIZE 64
|
||||
|
|
|
@ -16,22 +16,6 @@
|
|||
#ifndef __HF_COLIN_H
|
||||
#define __HF_COLIN_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "mifaresim.h" // mifare1ksim
|
||||
#include "mifareutil.h"
|
||||
#include "iso14443a.h"
|
||||
#include "protocols.h"
|
||||
#include "util.h"
|
||||
#include "pmflash.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include <stdbool.h> // for bool
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "vtsend.h"
|
||||
#include "apps.h"
|
||||
#include "printf.h"
|
||||
#include "spiffs.h"
|
||||
|
||||
#define _XRED_ "\x1b[31m"
|
||||
#define _XGREEN_ "\x1b[32m"
|
||||
#define _XYELLOW_ "\x1b[33m"
|
||||
|
|
|
@ -33,7 +33,21 @@ on a blank card.
|
|||
## Spanish full description of the project [here](http://bit.ly/2c9nZXR).
|
||||
*/
|
||||
|
||||
#include "hf_mattyrun.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "string.h"
|
||||
#include "commonutil.h"
|
||||
#include "iso14443a.h"
|
||||
#include "mifarecmd.h"
|
||||
#include "crc16.h"
|
||||
#include "BigBuf.h"
|
||||
#include "mifaresim.h" // mifare1ksim
|
||||
#include "mifareutil.h"
|
||||
|
||||
uint8_t uid[10];
|
||||
uint32_t cuid;
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Matías A. Ré Medina 2016
|
||||
// Christian Herrmann, 2018
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// StandAlone Mod
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __HF_MATTYRUN_H
|
||||
#define __HF_MATTYRUN_H
|
||||
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debugstatements, lfops?
|
||||
#include "pm3_cmd.h" // mifare1ksim flags
|
||||
#include "mifaresim.h" // mifare1ksim
|
||||
#include "mifareutil.h"
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
#endif /* __HF_MATTYRUN_H */
|
|
@ -9,8 +9,21 @@
|
|||
// main code for HF standalone mode Mifare /sniff/emulation by Craig Young
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "hf_young.h"
|
||||
#include "common.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include <inttypes.h>
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "string.h"
|
||||
#include "commonutil.h"
|
||||
#include "mifarecmd.h"
|
||||
#include "iso14443a.h"
|
||||
#include "protocols.h"
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
typedef struct {
|
||||
uint8_t uid[10];
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Craig Young 2014
|
||||
// Christian Herrmann, 2017
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// StandAlone Mod
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __HF_YOUNG_H
|
||||
#define __HF_YOUNG_H
|
||||
|
||||
#include <stdbool.h> // for bool
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "iso14443a.h"
|
||||
#include "protocols.h"
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
#endif /* __HF_YOUNG_H */
|
|
@ -24,8 +24,19 @@
|
|||
//-----------------------------------------------------------------------------------
|
||||
// main code for LF aka HID corporate brutefore by Federico Dotta & Maurizio Agazzini
|
||||
//-----------------------------------------------------------------------------------
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "lf_hidbrute.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "lfops.h"
|
||||
|
||||
#define OPTS 3
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF HID corporate 1000 bruteforce - aka Corporatebrute (Federico dotta & Maurizio Agazzini)");
|
||||
}
|
||||
|
|
|
@ -14,10 +14,7 @@
|
|||
#ifndef __LF_HIDBRUTE_H
|
||||
#define __LF_HIDBRUTE_H
|
||||
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debugstatements, lfops?
|
||||
|
||||
#define OPTS 3
|
||||
#include <stdint.h>
|
||||
|
||||
void hid_corporate_1000_calculate_checksum_and_set(uint32_t *high, uint32_t *low, uint32_t cardnum, uint32_t fc);
|
||||
|
||||
|
|
|
@ -7,7 +7,12 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// main code for skeleton aka IceRun by Iceman
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "lf_icerun.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF skeleton mode - aka IceRun (iceman)");
|
||||
|
|
|
@ -9,7 +9,16 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// main code for LF aka Proxbrute by Brad antoniewicz
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "lf_proxbrute.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "lfops.h"
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF HID ProxII bruteforce - aka Proxbrute (Brad Antoniewicz)");
|
||||
|
|
|
@ -8,7 +8,16 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// main code for LF aka SamyRun by Samy Kamkar
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "lf_samyrun.h"
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "lfops.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF HID26 standalone - aka SamyRun (Samy Kamkar)");
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Samy Kamkar 2012
|
||||
// Christian Herrmann, 2017
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// StandAlone Mod
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __LF_SAMYRUN_H
|
||||
#define __LF_SAMYRUN_H
|
||||
|
||||
//#include <stdbool.h> // for bool
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debugstatements, lfops?
|
||||
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
#endif /* __LF_SAMYRUN_H */
|
|
@ -1,5 +1,6 @@
|
|||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debug statements
|
||||
|
||||
#include "dbprint.h"
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" No standalone mode present");
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
#ifndef __STANDALONE_H
|
||||
#define __STANDALONE_H
|
||||
|
||||
#include <stdbool.h> // for bool
|
||||
#include <inttypes.h> // PRIu64
|
||||
|
||||
void RunMod();
|
||||
void ModInfo();
|
||||
|
||||
|
|
165
armsrc/appmain.c
165
armsrc/appmain.c
|
@ -9,26 +9,37 @@
|
|||
// The main application code. This is the first thing called after start.c
|
||||
// executes.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <stdarg.h>
|
||||
#include <inttypes.h>
|
||||
#include "appmain.h"
|
||||
|
||||
#include "usb_cdc.h"
|
||||
#include "proxmark3.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "dbprint.h"
|
||||
#include "pmflash.h"
|
||||
#include "apps.h"
|
||||
#include "fpga.h"
|
||||
#include "util.h"
|
||||
#include "printf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "string.h"
|
||||
#include "legicrf.h"
|
||||
#include "legicrfsim.h"
|
||||
#include "lfsampling.h"
|
||||
#include "BigBuf.h"
|
||||
#include "mifareutil.h"
|
||||
#include "mifaresim.h"
|
||||
#include "hitag.h"
|
||||
#include "iso14443a.h"
|
||||
#include "iso14443b.h"
|
||||
#include "iso15693.h"
|
||||
#include "thinfilm.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "felica.h"
|
||||
#include "hitag2.h"
|
||||
#include "hitagS.h"
|
||||
#include "iclass.h"
|
||||
#include "legicrfsim.h"
|
||||
#include "epa.h"
|
||||
#include "hfsnoop.h"
|
||||
#include "lfops.h"
|
||||
#include "lfsampling.h"
|
||||
#include "mifarecmd.h"
|
||||
#include "mifaredesfire.h"
|
||||
#include "mifaresim.h"
|
||||
#include "pcf7931.h"
|
||||
#include "Standalone/standalone.h"
|
||||
#include "util.h"
|
||||
#include "ticks.h"
|
||||
|
||||
#ifdef WITH_LCD
|
||||
#include "LCD.h"
|
||||
|
@ -61,6 +72,12 @@ struct common_area common_area __attribute__((section(".commonarea")));
|
|||
int button_status = BUTTON_NO_CLICK;
|
||||
bool allow_send_wtx = false;
|
||||
|
||||
inline void send_wtx(uint16_t wtx) {
|
||||
if (allow_send_wtx) {
|
||||
reply_ng(CMD_WTX, PM3_SUCCESS, (uint8_t *)&wtx, sizeof(wtx));
|
||||
}
|
||||
}
|
||||
|
||||
void ToSendReset(void) {
|
||||
ToSendMax = -1;
|
||||
ToSendBit = 8;
|
||||
|
@ -84,128 +101,6 @@ void ToSendStuffBit(int b) {
|
|||
}
|
||||
}
|
||||
|
||||
/* useful when debugging new protocol implementations like FeliCa
|
||||
void PrintToSendBuffer(void) {
|
||||
DbpString("Printing ToSendBuffer:");
|
||||
Dbhexdump(ToSendMax, ToSend, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
void print_result(char *name, uint8_t *buf, size_t len) {
|
||||
|
||||
uint8_t *p = buf;
|
||||
uint16_t tmp = len & 0xFFF0;
|
||||
|
||||
for (; p - buf < tmp; p += 16) {
|
||||
Dbprintf("[%s: %02d/%02d] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||
name,
|
||||
p - buf,
|
||||
len,
|
||||
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]
|
||||
);
|
||||
}
|
||||
if (len % 16 != 0) {
|
||||
char s[46] = {0};
|
||||
char *sp = s;
|
||||
for (; p - buf < len; p++) {
|
||||
sprintf(sp, "%02x ", p[0]);
|
||||
sp += 3;
|
||||
}
|
||||
Dbprintf("[%s: %02d/%02d] %s", name, p - buf, len, s);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Debug print functions, to go out over USB, to the usual PC-side client.
|
||||
//=============================================================================
|
||||
|
||||
inline void send_wtx(uint16_t wtx) {
|
||||
if (allow_send_wtx) {
|
||||
reply_ng(CMD_WTX, PM3_SUCCESS, (uint8_t *)&wtx, sizeof(wtx));
|
||||
}
|
||||
}
|
||||
|
||||
void DbpStringEx(uint32_t flags, char *str) {
|
||||
#if DEBUG
|
||||
struct {
|
||||
uint16_t flag;
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE - sizeof(uint16_t)];
|
||||
} PACKED data;
|
||||
data.flag = flags;
|
||||
uint16_t len = MIN(strlen(str), sizeof(data.buf));
|
||||
memcpy(data.buf, str, len);
|
||||
reply_ng(CMD_DEBUG_PRINT_STRING, PM3_SUCCESS, (uint8_t *)&data, sizeof(data.flag) + len);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DbpString(char *str) {
|
||||
#if DEBUG
|
||||
DbpStringEx(FLAG_LOG, str);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void DbpIntegers(int x1, int x2, int x3) {
|
||||
reply_old(CMD_DEBUG_PRINT_INTEGERS, x1, x2, x3, 0, 0);
|
||||
}
|
||||
#endif
|
||||
void DbprintfEx(uint32_t flags, const char *fmt, ...) {
|
||||
#if DEBUG
|
||||
// should probably limit size here; oh well, let's just use a big buffer
|
||||
char output_string[128] = {0x00};
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
kvsprintf(fmt, output_string, 10, ap);
|
||||
va_end(ap);
|
||||
|
||||
DbpStringEx(flags, output_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Dbprintf(const char *fmt, ...) {
|
||||
#if DEBUG
|
||||
// should probably limit size here; oh well, let's just use a big buffer
|
||||
char output_string[128] = {0x00};
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
kvsprintf(fmt, output_string, 10, ap);
|
||||
va_end(ap);
|
||||
|
||||
DbpString(output_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
// prints HEX & ASCII
|
||||
void Dbhexdump(int len, uint8_t *d, bool bAsci) {
|
||||
#if DEBUG
|
||||
char ascii[9];
|
||||
|
||||
while (len > 0) {
|
||||
|
||||
int l = (len > 8) ? 8 : len;
|
||||
|
||||
memcpy(ascii, d, l);
|
||||
ascii[l] = 0;
|
||||
|
||||
// filter safe ascii
|
||||
for (int i = 0; i < l; i++) {
|
||||
if (ascii[i] < 32 || ascii[i] > 126) {
|
||||
ascii[i] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
if (bAsci)
|
||||
Dbprintf("%-8s %*D", ascii, l, d, " ");
|
||||
else
|
||||
Dbprintf("%*D", l, d, " ");
|
||||
|
||||
len -= 8;
|
||||
d += 8;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Read an ADC channel and block till it completes, then return the result
|
||||
// in ADC units (0 to 1023). Also a routine to average 32 samples and
|
||||
|
|
45
armsrc/appmain.h
Normal file
45
armsrc/appmain.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __APPMAIN_H
|
||||
#define __APPMAIN_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern const uint8_t OddByteParity[256];
|
||||
extern int rsamples; // = 0;
|
||||
extern uint8_t trigger;
|
||||
extern bool allow_send_wtx;
|
||||
|
||||
// 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
|
||||
// ADC Vref = 3300mV, (240k-10M):240k voltage divider, 140800 mV
|
||||
#define MAX_ADC_HF_VOLTAGE_RDV40 140800
|
||||
// ADC Vref = 3300mV, and an (10000k+240k):240k voltage divider on the LF input can measure voltages up to 140800 mV
|
||||
#define MAX_ADC_LF_VOLTAGE 140800
|
||||
|
||||
extern int ToSendMax;
|
||||
extern uint8_t ToSend[];
|
||||
|
||||
void send_wtx(uint16_t wtx);
|
||||
void ReadMem(int addr);
|
||||
void __attribute__((noreturn)) AppMain(void);
|
||||
|
||||
uint16_t AvgAdc(int ch);
|
||||
|
||||
void print_result(char *name, uint8_t *buf, size_t len);
|
||||
//void PrintToSendBuffer(void);
|
||||
void ToSendStuffBit(int b);
|
||||
void ToSendReset(void);
|
||||
void ListenReaderField(uint8_t limit);
|
||||
void StandAloneMode(void);
|
||||
void printStandAloneModes(void);
|
||||
|
||||
#endif
|
254
armsrc/apps.h
254
armsrc/apps.h
|
@ -1,254 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __APPS_H
|
||||
#define __APPS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "common.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "crc32.h"
|
||||
#include "lfdemod.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "hitag2.h"
|
||||
#include "hitagS.h"
|
||||
#include "mifare.h"
|
||||
#include "pcf7931.h"
|
||||
#include "desfire.h"
|
||||
#include "iso14443b.h"
|
||||
#include "Standalone/standalone.h"
|
||||
#include "flashmem.h"
|
||||
|
||||
extern const uint8_t OddByteParity[256];
|
||||
extern int rsamples; // = 0;
|
||||
extern uint8_t trigger;
|
||||
|
||||
// This may be used (sparingly) to declare a function to be copied to
|
||||
// and executed from RAM
|
||||
#define RAMFUNC __attribute((long_call, section(".ramfunc")))
|
||||
|
||||
/// appmain.h
|
||||
void ReadMem(int addr);
|
||||
void __attribute__((noreturn)) AppMain(void);
|
||||
void send_wtx(uint16_t wtx);
|
||||
//void DbpIntegers(int a, int b, int c);
|
||||
void DbpString(char *str);
|
||||
void DbpStringEx(uint32_t flags, char *str);
|
||||
void Dbprintf(const char *fmt, ...);
|
||||
void DbprintfEx(uint32_t flags, const char *fmt, ...);
|
||||
void Dbhexdump(int len, uint8_t *d, bool bAsci);
|
||||
|
||||
// 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
|
||||
// ADC Vref = 3300mV, (240k-10M):240k voltage divider, 140800 mV
|
||||
#define MAX_ADC_HF_VOLTAGE_RDV40 140800
|
||||
// ADC Vref = 3300mV, and an (10000k+240k):240k voltage divider on the LF input can measure voltages up to 140800 mV
|
||||
#define MAX_ADC_LF_VOLTAGE 140800
|
||||
uint16_t AvgAdc(int ch);
|
||||
|
||||
void print_result(char *name, uint8_t *buf, size_t len);
|
||||
//void PrintToSendBuffer(void);
|
||||
void ToSendStuffBit(int b);
|
||||
void ToSendReset(void);
|
||||
void ListenReaderField(uint8_t limit);
|
||||
extern int ToSendMax;
|
||||
extern uint8_t ToSend[];
|
||||
|
||||
void StandAloneMode(void);
|
||||
void printStandAloneModes(void);
|
||||
|
||||
/// lfops.h
|
||||
extern uint8_t decimation;
|
||||
extern uint8_t bits_per_sample ;
|
||||
extern bool averaging;
|
||||
|
||||
void AcquireRawAdcSamples125k(int divisor);
|
||||
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command);
|
||||
void ReadTItag(void);
|
||||
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc);
|
||||
|
||||
void AcquireTiType(void);
|
||||
void AcquireRawBitsTI(void);
|
||||
void SimulateTagLowFrequencyEx(int period, int gap, bool ledcontrol, int numcycles);
|
||||
void SimulateTagLowFrequency(int period, int gap, bool ledcontrol);
|
||||
void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);
|
||||
|
||||
void CmdHIDsimTAGEx(uint32_t hi, uint32_t lo, bool ledcontrol, int numcycles);
|
||||
void CmdHIDsimTAG(uint32_t hi, uint32_t lo, bool ledcontrol);
|
||||
|
||||
void CmdFSKsimTAG(uint8_t fchigh, uint8_t fclow, uint8_t separator, uint8_t clk, uint16_t bitslen, uint8_t *bits, bool ledcontrol);
|
||||
void CmdASKsimTAG(uint8_t encoding, uint8_t invert, uint8_t separator, uint8_t clk, uint16_t size, uint8_t *bits, bool ledcontrol);
|
||||
void CmdPSKsimTag(uint8_t carrier, uint8_t invert, uint8_t clk, uint16_t size, uint8_t *bits, bool ledcontrol);
|
||||
|
||||
void CmdHIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
|
||||
void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol); // Realtime demodulation mode for AWID26
|
||||
void CmdEM410xdemod(int findone, uint32_t *high, uint64_t *low, int ledcontrol);
|
||||
void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
|
||||
void CopyIOtoT55x7(uint32_t hi, uint32_t lo); // Clone an ioProx card to T5557/T5567
|
||||
void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567
|
||||
void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5);
|
||||
void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
|
||||
void CopyIndala64toT55x7(uint32_t hi, uint32_t lo); // Clone Indala 64-bit tag by UID to T55x7
|
||||
void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t uid4, uint32_t uid5, uint32_t uid6, uint32_t uid7); // Clone Indala 224-bit tag by UID to T55x7
|
||||
void T55xxResetRead(uint8_t flags);
|
||||
//id T55xxWriteBlock(uint32_t data, uint8_t blockno, uint32_t pwd, uint8_t flags);
|
||||
void T55xxWriteBlock(uint8_t *data);
|
||||
// void T55xxWriteBlockExt(uint32_t data, uint8_t blockno, uint32_t pwd, uint8_t flags);
|
||||
void T55xxReadBlock(uint8_t page, bool pwd_mode, bool brute_mem, uint8_t block, uint32_t pwd, uint8_t downlink_mode);
|
||||
void T55xxWakeUp(uint32_t pwd, uint8_t flags);
|
||||
void T55xx_ChkPwds(uint8_t flags);
|
||||
|
||||
void TurnReadLFOn(uint32_t delay);
|
||||
|
||||
void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd);
|
||||
void EM4xWriteWord(uint8_t addr, uint32_t data, uint32_t pwd, uint8_t usepwd);
|
||||
|
||||
void Cotag(uint32_t arg0);
|
||||
void setT55xxConfig(uint8_t arg0, t55xx_configurations_t *c);
|
||||
t55xx_configurations_t *getT55xxConfig(void);
|
||||
void printT55xxConfig(void);
|
||||
void loadT55xxConfig(void);
|
||||
|
||||
/// iso14443b.h
|
||||
void SimulateIso14443bTag(uint32_t pupi);
|
||||
void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
|
||||
void ReadSTMemoryIso14443b(uint8_t numofblocks);
|
||||
void RAMFUNC SniffIso14443b(void);
|
||||
void SendRawCommand14443B(uint32_t, uint32_t, uint8_t, uint8_t[]);
|
||||
void SendRawCommand14443B_Ex(PacketCommandNG *c);
|
||||
void ClearFpgaShiftingRegisters(void);
|
||||
|
||||
// iso14443a.h
|
||||
void RAMFUNC SniffIso14443a(uint8_t param);
|
||||
void ReaderIso14443a(PacketCommandNG *c);
|
||||
|
||||
// Also used in iclass.c
|
||||
//bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t len, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag);
|
||||
void GetParity(const uint8_t *pbtCmd, uint16_t len, uint8_t *par);
|
||||
void iso14a_set_trigger(bool enable);
|
||||
// also used in emv
|
||||
//bool prepare_allocated_tag_modulation(tag_response_info_t *response_info);
|
||||
//int GetIso14443aCommandFromReader(uint8_t *received, uint8_t *parity, int *len);
|
||||
|
||||
// epa.h
|
||||
void EPA_PACE_Collect_Nonce(PacketCommandNG *c);
|
||||
void EPA_PACE_Replay(PacketCommandNG *c);
|
||||
|
||||
// mifarecmd.h
|
||||
void MifareReadBlock(uint8_t blockNo, uint8_t keyType, uint8_t *datain);
|
||||
|
||||
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes);
|
||||
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
//void MifareUWriteBlockCompat(uint8_t arg0,uint8_t *datain);
|
||||
void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *datain);
|
||||
void MifareAcquireNonces(uint32_t arg0, uint32_t flags);
|
||||
void MifareChkKeys(uint8_t *datain);
|
||||
void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
|
||||
void MifareEMemClr(void);
|
||||
void MifareEMemSet(uint8_t blockno, uint8_t blockcnt, uint8_t blockwidth, uint8_t *datain);
|
||||
void MifareEMemGet(uint8_t blockno, uint8_t blockcnt);
|
||||
int MifareECardLoad(uint32_t arg0, uint32_t arg1);
|
||||
|
||||
void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); // Work with "magic Chinese" card
|
||||
void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain);
|
||||
void MifareCIdent(); // is "magic chinese" card?
|
||||
|
||||
void MifareSetMod(uint8_t *datain);
|
||||
void MifareUSetPwd(uint8_t arg0, uint8_t *datain);
|
||||
void OnSuccessMagic();
|
||||
void OnErrorMagic(uint8_t reason);
|
||||
|
||||
int32_t dist_nt(uint32_t nt1, uint32_t nt2);
|
||||
void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype);
|
||||
//void RAMFUNC SniffMifare(uint8_t param);
|
||||
|
||||
//desfire
|
||||
void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain);
|
||||
void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain);
|
||||
|
||||
// mifaredesfire.h
|
||||
bool InitDesfireCard();
|
||||
void MifareSendCommand(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareDesfireGetInformation();
|
||||
void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void ReaderMifareDES(uint32_t param, uint32_t param2, uint8_t *datain);
|
||||
int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout);
|
||||
size_t CreateAPDU(uint8_t *datain, size_t len, uint8_t *dataout);
|
||||
void OnSuccess();
|
||||
void OnError(uint8_t reason);
|
||||
|
||||
// desfire_crypto.h
|
||||
void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes, size_t offset, int communication_settings);
|
||||
void *mifare_cryto_postprocess_data(desfiretag_t tag, void *data, size_t *nbytes, int communication_settings);
|
||||
void mifare_cypher_single_block(desfirekey_t key, uint8_t *data, uint8_t *ivect, MifareCryptoDirection direction, MifareCryptoOperation operation, size_t block_size);
|
||||
void mifare_cypher_blocks_chained(desfiretag_t tag, desfirekey_t key, uint8_t *ivect, uint8_t *data, size_t data_size, MifareCryptoDirection direction, MifareCryptoOperation operation);
|
||||
size_t key_block_size(const desfirekey_t key);
|
||||
size_t padded_data_length(const size_t nbytes, const size_t block_size);
|
||||
size_t maced_data_length(const desfirekey_t key, const size_t nbytes);
|
||||
size_t enciphered_data_length(const desfiretag_t tag, const size_t nbytes, int communication_settings);
|
||||
void cmac_generate_subkeys(desfirekey_t key);
|
||||
void cmac(const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t len, uint8_t *cmac);
|
||||
|
||||
// iso15693.h
|
||||
void RecordRawAdcSamplesIso15693(void);
|
||||
void AcquireRawAdcSamplesIso15693(void);
|
||||
void ReaderIso15693(uint32_t parameter); // Simulate an ISO15693 reader - greg
|
||||
void SimTagIso15693(uint32_t parameter, uint8_t *uid); // simulate an ISO15693 tag - greg
|
||||
void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
|
||||
void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint8_t *data); // send arbitrary commands from CLI - atrox
|
||||
void Iso15693InitReader(void);
|
||||
|
||||
// iclass.h
|
||||
void RAMFUNC SniffIClass(void);
|
||||
void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
void ReaderIClass(uint8_t arg0);
|
||||
void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac);
|
||||
void iClass_Authentication(uint8_t *mac);
|
||||
void iClass_Authentication_fast(uint64_t arg0, uint64_t arg1, uint8_t *datain);
|
||||
void iClass_WriteBlock(uint8_t blockno, uint8_t *data);
|
||||
void iClass_ReadBlk(uint8_t blockno);
|
||||
bool iClass_ReadBlock(uint8_t blockno, uint8_t *data, uint8_t len);
|
||||
void iClass_Dump(uint8_t blockno, uint8_t numblks);
|
||||
void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data);
|
||||
void iClass_ReadCheck(uint8_t blockno, uint8_t keytype);
|
||||
|
||||
// cmd.h
|
||||
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
int reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len);
|
||||
int receive_ng(PacketCommandNG *rx);
|
||||
|
||||
// util.h
|
||||
void HfSniff(int, int);
|
||||
|
||||
//felica.c
|
||||
void felica_sendraw(PacketCommandNG *c);
|
||||
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip);
|
||||
void felica_sim_lite(uint64_t uid);
|
||||
void felica_dump_lite_s();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -5,10 +5,7 @@
|
|||
#ifndef __BUZZER_H
|
||||
#define __BUZZER_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
|
||||
#define n_2_7khz 185
|
||||
#define note_1 956
|
||||
|
@ -27,24 +24,3 @@ void Ring_ALL(uint16_t count);
|
|||
void Ring_Little_Star(uint16_t count);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -30,7 +30,10 @@
|
|||
* @brief
|
||||
*/
|
||||
#include "cmd.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "usart.h"
|
||||
#include "crc16.h"
|
||||
#include "string.h"
|
||||
|
||||
// Flags to tell where to add CRC on sent replies
|
||||
bool reply_with_crc_on_usb = false;
|
|
@ -35,14 +35,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "pm3_cmd.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "usart.h"
|
||||
#include "proxmark3.h"
|
||||
|
||||
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
int reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len);
|
||||
int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
int receive_ng(PacketCommandNG *rx);
|
||||
|
||||
// Flags to tell where to add CRC on sent replies
|
||||
extern bool reply_with_crc_on_usb;
|
||||
|
@ -51,33 +43,10 @@ extern bool reply_with_crc_on_fpc;
|
|||
extern bool reply_via_fpc;
|
||||
extern bool reply_via_usb;
|
||||
|
||||
extern void Dbprintf(const char *fmt, ...);
|
||||
#define Dbprintf_usb(...) {\
|
||||
bool tmpfpc = reply_via_fpc;\
|
||||
bool tmpusb = reply_via_usb;\
|
||||
reply_via_fpc = false;\
|
||||
reply_via_usb = true;\
|
||||
Dbprintf(__VA_ARGS__);\
|
||||
reply_via_fpc = tmpfpc;\
|
||||
reply_via_usb = tmpusb;}
|
||||
|
||||
#define Dbprintf_fpc(...) {\
|
||||
bool tmpfpc = reply_via_fpc;\
|
||||
bool tmpusb = reply_via_usb;\
|
||||
reply_via_fpc = true;\
|
||||
reply_via_usb = false;\
|
||||
Dbprintf(__VA_ARGS__);\
|
||||
reply_via_fpc = tmpfpc;\
|
||||
reply_via_usb = tmpusb;}
|
||||
|
||||
#define Dbprintf_all(...) {\
|
||||
bool tmpfpc = reply_via_fpc;\
|
||||
bool tmpusb = reply_via_usb;\
|
||||
reply_via_fpc = true;\
|
||||
reply_via_usb = true;\
|
||||
Dbprintf(__VA_ARGS__);\
|
||||
reply_via_fpc = tmpfpc;\
|
||||
reply_via_usb = tmpusb;}
|
||||
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
int reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len);
|
||||
int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
int receive_ng(PacketCommandNG *rx);
|
||||
|
||||
#endif // _PROXMARK_CMD_H_
|
||||
|
130
armsrc/dbprint.c
Normal file
130
armsrc/dbprint.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Mar 2006
|
||||
// Edits by Gerhard de Koning Gans, Sep 2007 (##)
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// The main application code. This is the first thing called after start.c
|
||||
// executes.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "dbprint.h"
|
||||
|
||||
#include "string.h"
|
||||
#include "cmd.h"
|
||||
#include "printf.h"
|
||||
|
||||
#define DEBUG 1
|
||||
|
||||
//=============================================================================
|
||||
// Debug print functions, to go out over USB, to the usual PC-side client.
|
||||
//=============================================================================
|
||||
|
||||
void DbpStringEx(uint32_t flags, char *str) {
|
||||
#if DEBUG
|
||||
struct {
|
||||
uint16_t flag;
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE - sizeof(uint16_t)];
|
||||
} PACKED data;
|
||||
data.flag = flags;
|
||||
uint16_t len = MIN(strlen(str), sizeof(data.buf));
|
||||
memcpy(data.buf, str, len);
|
||||
reply_ng(CMD_DEBUG_PRINT_STRING, PM3_SUCCESS, (uint8_t *)&data, sizeof(data.flag) + len);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DbpString(char *str) {
|
||||
#if DEBUG
|
||||
DbpStringEx(FLAG_LOG, str);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DbprintfEx(uint32_t flags, const char *fmt, ...) {
|
||||
#if DEBUG
|
||||
// should probably limit size here; oh well, let's just use a big buffer
|
||||
char output_string[128] = {0x00};
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
kvsprintf(fmt, output_string, 10, ap);
|
||||
va_end(ap);
|
||||
|
||||
DbpStringEx(flags, output_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Dbprintf(const char *fmt, ...) {
|
||||
#if DEBUG
|
||||
// should probably limit size here; oh well, let's just use a big buffer
|
||||
char output_string[128] = {0x00};
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
kvsprintf(fmt, output_string, 10, ap);
|
||||
va_end(ap);
|
||||
|
||||
DbpString(output_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
// prints HEX & ASCII
|
||||
void Dbhexdump(int len, uint8_t *d, bool bAsci) {
|
||||
#if DEBUG
|
||||
char ascii[9];
|
||||
|
||||
while (len > 0) {
|
||||
|
||||
int l = (len > 8) ? 8 : len;
|
||||
|
||||
memcpy(ascii, d, l);
|
||||
ascii[l] = 0;
|
||||
|
||||
// filter safe ascii
|
||||
for (int i = 0; i < l; i++) {
|
||||
if (ascii[i] < 32 || ascii[i] > 126) {
|
||||
ascii[i] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
if (bAsci)
|
||||
Dbprintf("%-8s %*D", ascii, l, d, " ");
|
||||
else
|
||||
Dbprintf("%*D", l, d, " ");
|
||||
|
||||
len -= 8;
|
||||
d += 8;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void print_result(char *name, uint8_t *buf, size_t len) {
|
||||
|
||||
uint8_t *p = buf;
|
||||
uint16_t tmp = len & 0xFFF0;
|
||||
|
||||
for (; p - buf < tmp; p += 16) {
|
||||
Dbprintf("[%s: %02d/%02d] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||
name,
|
||||
p - buf,
|
||||
len,
|
||||
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]
|
||||
);
|
||||
}
|
||||
if (len % 16 != 0) {
|
||||
char s[46] = {0};
|
||||
char *sp = s;
|
||||
for (; p - buf < len; p++) {
|
||||
sprintf(sp, "%02x ", p[0]);
|
||||
sp += 3;
|
||||
}
|
||||
Dbprintf("[%s: %02d/%02d] %s", name, p - buf, len, s);
|
||||
}
|
||||
}
|
||||
|
||||
/* useful when debugging new protocol implementations like FeliCa
|
||||
void PrintToSendBuffer(void) {
|
||||
DbpString("Printing ToSendBuffer:");
|
||||
Dbhexdump(ToSendMax, ToSend, 0);
|
||||
}
|
||||
*/
|
53
armsrc/dbprint.h
Normal file
53
armsrc/dbprint.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __DBPRINT_H
|
||||
#define __DBPRINT_H
|
||||
|
||||
#include "common.h"
|
||||
#include "ansi.h"
|
||||
|
||||
#define Dbprintf_usb(...) {\
|
||||
bool tmpfpc = reply_via_fpc;\
|
||||
bool tmpusb = reply_via_usb;\
|
||||
reply_via_fpc = false;\
|
||||
reply_via_usb = true;\
|
||||
Dbprintf(__VA_ARGS__);\
|
||||
reply_via_fpc = tmpfpc;\
|
||||
reply_via_usb = tmpusb;}
|
||||
|
||||
#define Dbprintf_fpc(...) {\
|
||||
bool tmpfpc = reply_via_fpc;\
|
||||
bool tmpusb = reply_via_usb;\
|
||||
reply_via_fpc = true;\
|
||||
reply_via_usb = false;\
|
||||
Dbprintf(__VA_ARGS__);\
|
||||
reply_via_fpc = tmpfpc;\
|
||||
reply_via_usb = tmpusb;}
|
||||
|
||||
#define Dbprintf_all(...) {\
|
||||
bool tmpfpc = reply_via_fpc;\
|
||||
bool tmpusb = reply_via_usb;\
|
||||
reply_via_fpc = true;\
|
||||
reply_via_usb = true;\
|
||||
Dbprintf(__VA_ARGS__);\
|
||||
reply_via_fpc = tmpfpc;\
|
||||
reply_via_usb = tmpusb;}
|
||||
|
||||
|
||||
void DbpString(char *str);
|
||||
void DbpStringEx(uint32_t flags, char *str);
|
||||
void Dbprintf(const char *fmt, ...);
|
||||
void DbprintfEx(uint32_t flags, const char *fmt, ...);
|
||||
void Dbhexdump(int len, uint8_t *d, bool bAsci);
|
||||
void print_result(char *name, uint8_t *buf, size_t len);
|
||||
//void PrintToSendBuffer(void);
|
||||
|
||||
#endif
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include "des.h"
|
||||
#include "string.h"
|
||||
|
||||
const uint8_t sbox[256] = {
|
||||
/* S-box 1 */
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#ifndef __DES_H_
|
||||
#define __DES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "common.h"
|
||||
|
||||
/* the FIPS 46-3 (1999-10-25) name for triple DES is triple data encryption algorithm so TDEA.
|
||||
* Also we only implement the three key mode */
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#ifndef __DESFIRE_H
|
||||
#define __DESFIRE_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "mbedtls/aes.h"
|
||||
#include "common.h"
|
||||
#include "mifare.h"
|
||||
|
||||
#define MAX_CRYPTO_BLOCK_SIZE 16
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef __DESFIRE_CRYPTO_H
|
||||
#define __DESFIRE_CRYPTO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "crc32.h"
|
||||
#include "printf.h"
|
||||
#include "desfire.h"
|
||||
#include "iso14443a.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -25,8 +25,16 @@
|
|||
* Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication
|
||||
* May 2005
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "desfire_crypto.h"
|
||||
|
||||
#include "crc32.h"
|
||||
#include "printf.h"
|
||||
#include "desfire.h"
|
||||
#include "iso14443a.h"
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
static void xor(const uint8_t *ivect, uint8_t *data, const size_t len);
|
||||
static size_t key_macing_length(desfirekey_t key);
|
||||
|
18
armsrc/desfire_crypto_disabled.h
Normal file
18
armsrc/desfire_crypto_disabled.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef __DESFIRE_CRYPTO_H
|
||||
#define __DESFIRE_CRYPTO_H
|
||||
|
||||
#include "common.h"
|
||||
#include "desfire.h"
|
||||
|
||||
void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes, size_t offset, int communication_settings);
|
||||
void *mifare_cryto_postprocess_data(desfiretag_t tag, void *data, size_t *nbytes, int communication_settings);
|
||||
void mifare_cypher_single_block(desfirekey_t key, uint8_t *data, uint8_t *ivect, MifareCryptoDirection direction, MifareCryptoOperation operation, size_t block_size);
|
||||
void mifare_cypher_blocks_chained(desfiretag_t tag, desfirekey_t key, uint8_t *ivect, uint8_t *data, size_t data_size, MifareCryptoDirection direction, MifareCryptoOperation operation);
|
||||
size_t key_block_size(const desfirekey_t key);
|
||||
size_t padded_data_length(const size_t nbytes, const size_t block_size);
|
||||
size_t maced_data_length(const desfirekey_t key, const size_t nbytes);
|
||||
size_t enciphered_data_length(const desfiretag_t tag, const size_t nbytes, int communication_settings);
|
||||
void cmac_generate_subkeys(desfirekey_t key);
|
||||
void cmac(const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t len, uint8_t *cmac);
|
||||
|
||||
#endif
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "desfire_key.h"
|
||||
#include "string.h"
|
||||
|
||||
static inline void update_key_schedules(desfirekey_t key);
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#ifndef __DESFIRE_KEY_INCLUDED
|
||||
#define __DESFIRE_KEY_INCLUDED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "iso14443a.h"
|
||||
#include "common.h"
|
||||
#include "desfire.h"
|
||||
//#include "mifare.h" // iso14a_card_select_t struct
|
||||
void Desfire_des_key_new(const uint8_t value[8], desfirekey_t key);
|
||||
void Desfire_3des_key_new(const uint8_t value[16], desfirekey_t key);
|
||||
void Desfire_des_key_new_with_version(const uint8_t value[8], desfirekey_t key);
|
||||
|
@ -17,4 +14,5 @@ void Desfire_aes_key_new_with_version(const uint8_t value[16], uint8_t version,
|
|||
uint8_t Desfire_key_get_version(desfirekey_t key);
|
||||
void Desfire_key_set_version(desfirekey_t key, uint8_t version);
|
||||
void Desfire_session_key_new(const uint8_t rnda[], const uint8_t rndb[], desfirekey_t authkey, desfirekey_t key);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#ifndef __EMVCARD_H
|
||||
#define __EMVCARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "common.h"
|
||||
|
||||
//structure to hold received/set tag values
|
||||
//variable data inputs have length specifiers
|
10
armsrc/epa.c
10
armsrc/epa.c
|
@ -12,6 +12,16 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "epa.h"
|
||||
|
||||
#include "cmd.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "iso14443a.h"
|
||||
#include "iso14443b.h"
|
||||
#include "string.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "commonutil.h"
|
||||
#include "ticks.h"
|
||||
|
||||
// Protocol and Parameter Selection Request for ISO 14443 type A cards
|
||||
// use regular (1x) speed in both directions
|
||||
// CRC is already included
|
||||
|
|
10
armsrc/epa.h
10
armsrc/epa.h
|
@ -11,9 +11,8 @@
|
|||
#ifndef __EPA_H
|
||||
#define __EPA_H
|
||||
|
||||
#include "cmd.h"
|
||||
#include "iso14443a.h"
|
||||
#include "iso14443b.h"
|
||||
#include "common.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
// this struct is used by EPA_Parse_CardAccess and contains info about the
|
||||
// PACE protocol supported by the chip
|
||||
|
@ -23,8 +22,6 @@ typedef struct {
|
|||
uint8_t parameter_id;
|
||||
} pace_version_info_t;
|
||||
|
||||
// note: EPA_PACE_Collect_Nonce and EPA_PACE_Replay are declared in apps.h
|
||||
|
||||
// general functions
|
||||
void EPA_Finish();
|
||||
size_t EPA_Parse_CardAccess(uint8_t *data,
|
||||
|
@ -37,4 +34,7 @@ int EPA_Setup();
|
|||
int EPA_PACE_MSE_Set_AT(pace_version_info_t pace_version_info, uint8_t password);
|
||||
int EPA_PACE_Get_Nonce(uint8_t requested_length, uint8_t *nonce);
|
||||
|
||||
void EPA_PACE_Collect_Nonce(PacketCommandNG *c);
|
||||
void EPA_PACE_Replay(PacketCommandNG *c);
|
||||
|
||||
#endif /* __EPA_H */
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "felica.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "BigBuf.h"
|
||||
#include "util.h"
|
||||
#include "usb_cdc.h" // for usb_poll_validate_length
|
||||
#include "protocols.h"
|
||||
#include "crc16.h" // crc16 ccitt
|
||||
#include "fpgaloader.h"
|
||||
#include "string.h"
|
||||
#include "commonutil.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
#include "mifare.h"
|
||||
|
||||
// FeliCa timings
|
||||
// minimum time between the start bits of consecutive transfers from reader to tag: 6800 carrier (13.56MHz) cycles
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Samy Kamkar, 2011, 2012
|
||||
// Brad antoniewicz 2011
|
||||
// Christian Herrmann, 2017
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// StandAlone Mod
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __FELICA_H
|
||||
#define __FELICA_H
|
||||
|
||||
#ifndef __LF_PROXBRUTE_H
|
||||
#define __LF_PROXBRUTE_H
|
||||
#include "common.h"
|
||||
#include "cmd.h"
|
||||
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debugstatements, lfops?
|
||||
void felica_sendraw(PacketCommandNG *c);
|
||||
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip);
|
||||
void felica_sim_lite(uint64_t uid);
|
||||
void felica_dump_lite_s();
|
||||
|
||||
#define OPTS 2
|
||||
|
||||
#endif /* __LF_PROXBRUTE_H */
|
||||
#endif
|
|
@ -1,6 +1,11 @@
|
|||
#include "flashmem.h"
|
||||
#include "pmflash.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "string.h"
|
||||
|
||||
/* here: use NCPS2 @ PA10: */
|
||||
#define SPI_CSR_NUM 2
|
||||
#define SPI_PCS(npcs) ((~(1 << (npcs)) & 0xF) << 16)
|
||||
|
|
|
@ -28,9 +28,7 @@
|
|||
#ifndef __FLASHMEM_H
|
||||
#define __FLASHMEM_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "ticks.h"
|
||||
#include "common.h"
|
||||
|
||||
// Used Command
|
||||
#define ID 0x90
|
||||
|
@ -111,7 +109,6 @@
|
|||
#define FASTFLASH (FLASHMEM_SPIBAUDRATE > FLASH_MINFAST)
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
||||
void Dbprintf(const char *fmt, ...);
|
||||
|
||||
void FlashmemSetSpiBaudrate(uint32_t baudrate);
|
||||
bool FlashInit();
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "fpgaloader.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "appmain.h"
|
||||
#include "BigBuf.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "zlib.h"
|
||||
#include "fpga.h"
|
||||
#include "string.h"
|
||||
|
||||
// remember which version of the bitstream we have already downloaded to the FPGA
|
||||
static int downloaded_bitstream = 0;
|
||||
|
@ -153,8 +162,7 @@ void FpgaSetupSsc(void) {
|
|||
//-----------------------------------------------------------------------------
|
||||
// Set up DMA to receive samples from the FPGA. We will use the PDC, with
|
||||
// a single buffer as a circular buffer (so that we just chain back to
|
||||
// ourselves, not to another buffer). The stuff to manipulate those buffers
|
||||
// is in apps.h, because it should be inlined, for speed.
|
||||
// ourselves, not to another buffer).
|
||||
//-----------------------------------------------------------------------------
|
||||
bool FpgaSetupSscDma(uint8_t *buf, int len) {
|
||||
if (buf == NULL) return false;
|
||||
|
|
|
@ -12,32 +12,10 @@
|
|||
#ifndef __FPGALOADER_H
|
||||
#define __FPGALOADER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "apps.h"
|
||||
#include "fpga.h"
|
||||
#include "common.h" // standard definitions
|
||||
#include "proxmark3.h" // common area
|
||||
#include "string.h"
|
||||
#include "BigBuf.h" // bigbuf mem
|
||||
#include "zlib.h" // uncompress
|
||||
#include "common.h"
|
||||
|
||||
|
||||
void FpgaSendCommand(uint16_t cmd, uint16_t v);
|
||||
void FpgaWriteConfWord(uint8_t v);
|
||||
void FpgaDownloadAndGo(int bitstream_version);
|
||||
// void FpgaGatherVersion(int bitstream_version, char *dst, int len);
|
||||
void FpgaSetupSsc(void);
|
||||
void SetupSpi(int mode);
|
||||
bool FpgaSetupSscDma(uint8_t *buf, int len);
|
||||
void Fpga_print_status(void);
|
||||
int FpgaGetCurrent(void);
|
||||
#define FpgaDisableSscDma(void) AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS;
|
||||
#define FpgaEnableSscDma(void) AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTEN;
|
||||
void SetAdcMuxFor(uint32_t whichGpio);
|
||||
|
||||
// extern and generel turn off the antenna method
|
||||
void switch_off(void);
|
||||
|
||||
// definitions for multiple FPGA config files support
|
||||
#define FPGA_BITSTREAM_LF 1
|
||||
|
@ -97,4 +75,18 @@ void switch_off(void);
|
|||
#define FPGA_HF_ISO18092_FLAG_424K (2<<0) // 0010 should enable 414k mode (untested). No autodetect
|
||||
#define FPGA_HF_ISO18092_FLAG_READER (4<<0) // 0100 enables antenna power, to act as a reader instead of tag
|
||||
|
||||
void FpgaSendCommand(uint16_t cmd, uint16_t v);
|
||||
void FpgaWriteConfWord(uint8_t v);
|
||||
void FpgaDownloadAndGo(int bitstream_version);
|
||||
// void FpgaGatherVersion(int bitstream_version, char *dst, int len);
|
||||
void FpgaSetupSsc(void);
|
||||
void SetupSpi(int mode);
|
||||
bool FpgaSetupSscDma(uint8_t *buf, int len);
|
||||
void Fpga_print_status(void);
|
||||
int FpgaGetCurrent(void);
|
||||
void SetAdcMuxFor(uint32_t whichGpio);
|
||||
|
||||
// extern and generel turn off the antenna method
|
||||
void switch_off(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
|
||||
#include "frozen.h"
|
||||
|
||||
//#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "nprintf.h"
|
||||
|
|
|
@ -19,21 +19,9 @@
|
|||
#ifndef CS_FROZEN_FROZEN_H_
|
||||
#define CS_FROZEN_FROZEN_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_WIN32) && _MSC_VER < 1700
|
||||
typedef int bool;
|
||||
enum { false = 0, true = 1 };
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
/* JSON token type */
|
||||
enum json_token_type {
|
||||
JSON_TYPE_INVALID = 0, /* memsetting to 0 should create INVALID value */
|
||||
|
@ -322,8 +310,4 @@ void *json_next_elem(const char *s, int len, void *handle, const char *path,
|
|||
#define JSON_ENABLE_HEX !JSON_MINIMAL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* CS_FROZEN_FROZEN_H_ */
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "usb_cdc.h" // for usb_poll_validate_length
|
||||
|
||||
static void RAMFUNC optimizedSniff(void);
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Iceman, Christian Herrmann, 2019
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// StandAlone Mod
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __HFSNOOP_H
|
||||
#define __HFSNOOP_H
|
||||
|
||||
#ifndef __LF_ICERUN_H
|
||||
#define __LF_ICERUN_H
|
||||
void HfSniff(int, int);
|
||||
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debugstatements, lfops?
|
||||
|
||||
#endif /* __LF_ICERUN_H */
|
||||
#endif
|
|
@ -20,12 +20,14 @@
|
|||
|
||||
#include "hitag2.h"
|
||||
#include "hitag2_crypto.h"
|
||||
#include "hitag.h"
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
|
||||
// Successful crypto auth
|
||||
static bool bCrypto;
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#ifndef _HITAG2_H_
|
||||
#define _HITAG2_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "common.h"
|
||||
#include "hitag.h"
|
||||
|
||||
void SniffHitag(void);
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "hitag2_crypto.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
/* Following is a modified version of cryptolib.com/ciphers/hitag2/ */
|
||||
// Software optimized 48-bit Philips/NXP Mifare Hitag2 PCF7936/46/47/52 stream cipher algorithm by I.C. Wiener 2006-2007.
|
||||
// For educational purposes only.
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
#ifndef __HITAG2_CRYPTO_H
|
||||
#define __HITAG2_CRYPTO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "string.h"
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
|
||||
struct hitag2_tag {
|
||||
uint32_t uid;
|
||||
|
@ -29,8 +24,5 @@ uint32_t _hitag2_byte(uint64_t *x);
|
|||
void hitag2_cipher_reset(struct hitag2_tag *tag, const uint8_t *iv);
|
||||
int hitag2_cipher_authenticate(uint64_t *cs, const uint8_t *authenticator_is);
|
||||
int hitag2_cipher_transcrypt(uint64_t *cs, uint8_t *data, uint16_t bytes, uint16_t bits) ;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,17 @@
|
|||
|
||||
#include "hitagS.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "commonutil.h"
|
||||
#include "hitag2_crypto.h"
|
||||
|
||||
#define CRC_PRESET 0xFF
|
||||
#define CRC_POLYNOM 0x1D
|
||||
|
||||
|
|
|
@ -12,16 +12,9 @@
|
|||
#ifndef _HITAGS_H_
|
||||
#define _HITAGS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "hitag2_crypto.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "hitag.h"
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "BigBuf.h"
|
||||
|
||||
void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data);
|
||||
void ReadHitagS(hitag_function htf, hitag_data *htd);
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "i2c.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "BigBuf.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
#define GPIO_RST AT91C_PIO_PA1
|
||||
#define GPIO_SCL AT91C_PIO_PA5
|
||||
#define GPIO_SDA AT91C_PIO_PA7
|
|
@ -1,10 +1,7 @@
|
|||
#ifndef __I2C_H
|
||||
#define __I2C_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "BigBuf.h"
|
||||
#include "common.h"
|
||||
#include "mifare.h"
|
||||
|
||||
#define I2C_DEVICE_ADDRESS_BOOT 0xB0
|
||||
|
@ -18,7 +15,6 @@
|
|||
#define I2C_DEVICE_CMD_GETVERSION 0x06
|
||||
#define I2C_DEVICE_CMD_SEND_T0 0x07
|
||||
|
||||
|
||||
void I2C_recovery(void);
|
||||
void I2C_init(void);
|
||||
void I2C_Reset(void);
|
||||
|
@ -48,4 +44,5 @@ void SmartCardSetBaud(uint64_t arg0);
|
|||
void SmartCardSetClock(uint64_t arg0);
|
||||
void I2C_print_status(void);
|
||||
int I2C_get_version(uint8_t *maj, uint8_t *min);
|
||||
|
||||
#endif
|
130
armsrc/iclass.c
130
armsrc/iclass.c
|
@ -36,15 +36,24 @@
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "apps.h"
|
||||
#include "iclass.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
// Needed for CRC in emulation mode;
|
||||
// same construction as in ISO 14443;
|
||||
// different initial value (CRC_ICLASS)
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "optimized_cipher.h"
|
||||
#include "usb_cdc.h" // for usb_poll_validate_length
|
||||
|
||||
#include "appmain.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "string.h"
|
||||
#include "util.h"
|
||||
#include "dbprint.h"
|
||||
#include "protocols.h"
|
||||
#include "ticks.h"
|
||||
|
||||
static int timeout = 4096;
|
||||
static int SendIClassAnswer(uint8_t *resp, int respLen, uint16_t delay);
|
||||
|
@ -92,21 +101,21 @@ typedef struct {
|
|||
int bitBuffer;
|
||||
int dropPosition;
|
||||
uint8_t *output;
|
||||
} tUart;
|
||||
} tUartIc;
|
||||
*/
|
||||
typedef struct {
|
||||
enum {
|
||||
DEMOD_UNSYNCD,
|
||||
DEMOD_START_OF_COMMUNICATION,
|
||||
DEMOD_START_OF_COMMUNICATION2,
|
||||
DEMOD_START_OF_COMMUNICATION3,
|
||||
DEMOD_SOF_COMPLETE,
|
||||
DEMOD_MANCHESTER_D,
|
||||
DEMOD_MANCHESTER_E,
|
||||
DEMOD_END_OF_COMMUNICATION,
|
||||
DEMOD_END_OF_COMMUNICATION2,
|
||||
DEMOD_MANCHESTER_F,
|
||||
DEMOD_ERROR_WAIT
|
||||
DEMOD_IC_UNSYNCD,
|
||||
DEMOD_IC_START_OF_COMMUNICATION,
|
||||
DEMOD_IC_START_OF_COMMUNICATION2,
|
||||
DEMOD_IC_START_OF_COMMUNICATION3,
|
||||
DEMOD_IC_SOF_COMPLETE,
|
||||
DEMOD_IC_MANCHESTER_D,
|
||||
DEMOD_IC_MANCHESTER_E,
|
||||
DEMOD_IC_END_OF_COMMUNICATION,
|
||||
DEMOD_IC_END_OF_COMMUNICATION2,
|
||||
DEMOD_IC_MANCHESTER_F,
|
||||
DEMOD_IC_ERROR_WAIT
|
||||
} state;
|
||||
int bitCount;
|
||||
int posCount;
|
||||
|
@ -125,7 +134,7 @@ typedef struct {
|
|||
SUB_BOTH
|
||||
} sub;
|
||||
uint8_t *output;
|
||||
} tDemod;
|
||||
} tDemodIc;
|
||||
|
||||
/*
|
||||
* Abrasive's uart implementation
|
||||
|
@ -138,8 +147,13 @@ typedef struct {
|
|||
bool frame_done;
|
||||
uint8_t *buf;
|
||||
int len;
|
||||
} tUart;
|
||||
static tUart Uart;
|
||||
} tUartIc;
|
||||
static tUartIc Uart;
|
||||
|
||||
static void OnError(uint8_t reason) {
|
||||
reply_old(CMD_ACK, 0, reason, 0, 0, 0);
|
||||
switch_off();
|
||||
}
|
||||
|
||||
static void uart_reset(void) {
|
||||
Uart.frame_done = false;
|
||||
|
@ -499,8 +513,8 @@ static RAMFUNC int OutOfNDecoding(int bit) {
|
|||
//=============================================================================
|
||||
// Manchester
|
||||
//=============================================================================
|
||||
static tDemod Demod;
|
||||
static void DemodReset() {
|
||||
static tDemodIc Demod;
|
||||
static void DemodIcReset() {
|
||||
Demod.bitCount = 0;
|
||||
Demod.posCount = 0;
|
||||
Demod.syncBit = 0;
|
||||
|
@ -512,11 +526,11 @@ static void DemodReset() {
|
|||
Demod.samples = 0;
|
||||
Demod.len = 0;
|
||||
Demod.sub = SUB_NONE;
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
}
|
||||
static void DemodInit(uint8_t *data) {
|
||||
static void DemodIcInit(uint8_t *data) {
|
||||
Demod.output = data;
|
||||
DemodReset();
|
||||
DemodIcReset();
|
||||
}
|
||||
|
||||
// UART debug
|
||||
|
@ -592,7 +606,7 @@ static RAMFUNC int ManchesterDecoding_iclass(uint32_t v) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Demod.state == DEMOD_UNSYNCD) {
|
||||
if (Demod.state == DEMOD_IC_UNSYNCD) {
|
||||
Demod.output[Demod.len] = 0xfa;
|
||||
Demod.syncBit = 0;
|
||||
//Demod.samples = 0;
|
||||
|
@ -620,7 +634,7 @@ static RAMFUNC int ManchesterDecoding_iclass(uint32_t v) {
|
|||
|
||||
if (Demod.syncBit) {
|
||||
Demod.len = 0;
|
||||
Demod.state = DEMOD_START_OF_COMMUNICATION;
|
||||
Demod.state = DEMOD_IC_START_OF_COMMUNICATION;
|
||||
Demod.sub = SUB_FIRST_HALF;
|
||||
Demod.bitCount = 0;
|
||||
Demod.shiftReg = 0;
|
||||
|
@ -644,12 +658,12 @@ static RAMFUNC int ManchesterDecoding_iclass(uint32_t v) {
|
|||
}
|
||||
// SOF must be long burst... otherwise stay unsynced!!!
|
||||
if (!(Demod.buffer & Demod.syncBit) || !(Demod.buffer2 & Demod.syncBit))
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
|
||||
} else {
|
||||
// SOF must be long burst... otherwise stay unsynced!!!
|
||||
if (!(Demod.buffer2 & Demod.syncBit) || !(Demod.buffer3 & Demod.syncBit)) {
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
error = 0x88;
|
||||
uart_debug(error, bit);
|
||||
return false;
|
||||
|
@ -682,74 +696,74 @@ static RAMFUNC int ManchesterDecoding_iclass(uint32_t v) {
|
|||
}
|
||||
|
||||
if (Demod.sub == SUB_NONE) {
|
||||
if (Demod.state == DEMOD_SOF_COMPLETE) {
|
||||
if (Demod.state == DEMOD_IC_SOF_COMPLETE) {
|
||||
Demod.output[Demod.len] = 0x0f;
|
||||
Demod.len++;
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
return true;
|
||||
} else {
|
||||
Demod.state = DEMOD_ERROR_WAIT;
|
||||
Demod.state = DEMOD_IC_ERROR_WAIT;
|
||||
error = 0x33;
|
||||
}
|
||||
}
|
||||
|
||||
switch (Demod.state) {
|
||||
|
||||
case DEMOD_START_OF_COMMUNICATION:
|
||||
case DEMOD_IC_START_OF_COMMUNICATION:
|
||||
if (Demod.sub == SUB_BOTH) {
|
||||
|
||||
Demod.state = DEMOD_START_OF_COMMUNICATION2;
|
||||
Demod.state = DEMOD_IC_START_OF_COMMUNICATION2;
|
||||
Demod.posCount = 1;
|
||||
Demod.sub = SUB_NONE;
|
||||
} else {
|
||||
Demod.output[Demod.len] = 0xab;
|
||||
Demod.state = DEMOD_ERROR_WAIT;
|
||||
Demod.state = DEMOD_IC_ERROR_WAIT;
|
||||
error = 0xd2;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEMOD_START_OF_COMMUNICATION2:
|
||||
case DEMOD_IC_START_OF_COMMUNICATION2:
|
||||
if (Demod.sub == SUB_SECOND_HALF) {
|
||||
Demod.state = DEMOD_START_OF_COMMUNICATION3;
|
||||
Demod.state = DEMOD_IC_START_OF_COMMUNICATION3;
|
||||
} else {
|
||||
Demod.output[Demod.len] = 0xab;
|
||||
Demod.state = DEMOD_ERROR_WAIT;
|
||||
Demod.state = DEMOD_IC_ERROR_WAIT;
|
||||
error = 0xd3;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEMOD_START_OF_COMMUNICATION3:
|
||||
case DEMOD_IC_START_OF_COMMUNICATION3:
|
||||
if (Demod.sub == SUB_SECOND_HALF) {
|
||||
Demod.state = DEMOD_SOF_COMPLETE;
|
||||
Demod.state = DEMOD_IC_SOF_COMPLETE;
|
||||
} else {
|
||||
Demod.output[Demod.len] = 0xab;
|
||||
Demod.state = DEMOD_ERROR_WAIT;
|
||||
Demod.state = DEMOD_IC_ERROR_WAIT;
|
||||
error = 0xd4;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEMOD_SOF_COMPLETE:
|
||||
case DEMOD_MANCHESTER_D:
|
||||
case DEMOD_MANCHESTER_E:
|
||||
case DEMOD_IC_SOF_COMPLETE:
|
||||
case DEMOD_IC_MANCHESTER_D:
|
||||
case DEMOD_IC_MANCHESTER_E:
|
||||
// OPPOSITE FROM ISO14443 - 11110000 = 0 (1 in 14443)
|
||||
// 00001111 = 1 (0 in 14443)
|
||||
if (Demod.sub == SUB_SECOND_HALF) { // SUB_FIRST_HALF
|
||||
Demod.bitCount++;
|
||||
Demod.shiftReg = (Demod.shiftReg >> 1) ^ 0x100;
|
||||
Demod.state = DEMOD_MANCHESTER_D;
|
||||
Demod.state = DEMOD_IC_MANCHESTER_D;
|
||||
} else if (Demod.sub == SUB_FIRST_HALF) { // SUB_SECOND_HALF
|
||||
Demod.bitCount++;
|
||||
Demod.shiftReg >>= 1;
|
||||
Demod.state = DEMOD_MANCHESTER_E;
|
||||
Demod.state = DEMOD_IC_MANCHESTER_E;
|
||||
} else if (Demod.sub == SUB_BOTH) {
|
||||
Demod.state = DEMOD_MANCHESTER_F;
|
||||
Demod.state = DEMOD_IC_MANCHESTER_F;
|
||||
} else {
|
||||
Demod.state = DEMOD_ERROR_WAIT;
|
||||
Demod.state = DEMOD_IC_ERROR_WAIT;
|
||||
error = 0x55;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEMOD_MANCHESTER_F:
|
||||
case DEMOD_IC_MANCHESTER_F:
|
||||
// Tag response does not need to be a complete byte!
|
||||
if (Demod.len > 0 || Demod.bitCount > 0) {
|
||||
if (Demod.bitCount > 1) { // was > 0, do not interpret last closing bit, is part of EOF
|
||||
|
@ -758,22 +772,22 @@ static RAMFUNC int ManchesterDecoding_iclass(uint32_t v) {
|
|||
Demod.len++;
|
||||
}
|
||||
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
return true;
|
||||
} else {
|
||||
Demod.output[Demod.len] = 0xad;
|
||||
Demod.state = DEMOD_ERROR_WAIT;
|
||||
Demod.state = DEMOD_IC_ERROR_WAIT;
|
||||
error = 0x03;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEMOD_ERROR_WAIT:
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
case DEMOD_IC_ERROR_WAIT:
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
break;
|
||||
|
||||
default:
|
||||
Demod.output[Demod.len] = 0xdd;
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.state = DEMOD_IC_UNSYNCD;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -818,10 +832,10 @@ static void iclass_setup_sniff(void) {
|
|||
set_tracing(true);
|
||||
|
||||
// Initialize Demod and Uart structs
|
||||
DemodInit(BigBuf_malloc(ICLASS_BUFFER_SIZE));
|
||||
DemodIcInit(BigBuf_malloc(ICLASS_BUFFER_SIZE));
|
||||
|
||||
uart_init(BigBuf_malloc(ICLASS_BUFFER_SIZE));
|
||||
//UartInit(BigBuf_malloc(ICLASS_BUFFER_SIZE));
|
||||
//UartIcInit(BigBuf_malloc(ICLASS_BUFFER_SIZE));
|
||||
|
||||
if (DBGLEVEL > 1) {
|
||||
// Print debug information about the buffer sizes
|
||||
|
@ -927,7 +941,7 @@ void RAMFUNC SniffIClass(void) {
|
|||
if (Uart.frame_done) {
|
||||
time_stop = GetCountSspClk() - time_0;
|
||||
LogTrace(Uart.buf, Uart.len, time_start, time_stop, NULL, true);
|
||||
DemodReset();
|
||||
DemodIcReset();
|
||||
uart_reset();
|
||||
} else {
|
||||
time_start = GetCountSspClk() - time_0;
|
||||
|
@ -959,12 +973,12 @@ void RAMFUNC SniffIClass(void) {
|
|||
if (ManchesterDecoding_iclass(foo)) {
|
||||
time_stop = GetCountSspClk() - time_0;
|
||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, false);
|
||||
DemodReset();
|
||||
DemodIcReset();
|
||||
uart_reset();
|
||||
} else {
|
||||
time_start = GetCountSspClk() - time_0;
|
||||
}
|
||||
TagIsActive = (Demod.state != DEMOD_UNSYNCD);
|
||||
TagIsActive = (Demod.state != DEMOD_IC_UNSYNCD);
|
||||
}
|
||||
tag_byte = 0;
|
||||
foo = 0;
|
||||
|
@ -1821,7 +1835,7 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
|
|||
bool skip = false;
|
||||
|
||||
// Setup UART/DEMOD to receive
|
||||
DemodInit(receivedResponse);
|
||||
DemodIcInit(receivedResponse);
|
||||
|
||||
if (elapsed) *elapsed = 0;
|
||||
|
||||
|
|
29
armsrc/iclass.h
Normal file
29
armsrc/iclass.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __ICLASS_H
|
||||
#define __ICLASS_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void RAMFUNC SniffIClass(void);
|
||||
void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
void ReaderIClass(uint8_t arg0);
|
||||
void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac);
|
||||
void iClass_Authentication(uint8_t *mac);
|
||||
void iClass_Authentication_fast(uint64_t arg0, uint64_t arg1, uint8_t *datain);
|
||||
void iClass_WriteBlock(uint8_t blockno, uint8_t *data);
|
||||
void iClass_ReadBlk(uint8_t blockno);
|
||||
bool iClass_ReadBlock(uint8_t blockno, uint8_t *data, uint8_t len);
|
||||
void iClass_Dump(uint8_t blockno, uint8_t numblks);
|
||||
void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data);
|
||||
void iClass_ReadCheck(uint8_t blockno, uint8_t keytype);
|
||||
|
||||
#endif
|
|
@ -11,6 +11,21 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "iso14443a.h"
|
||||
|
||||
#include "string.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "appmain.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "parity.h"
|
||||
#include "mifareutil.h"
|
||||
#include "commonutil.h"
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
|
||||
#define MAX_ISO14A_TIMEOUT 524288
|
||||
static uint32_t iso14a_timeout;
|
||||
// if iso14443a not active - transmit/receive dont try to execute
|
||||
|
@ -161,7 +176,7 @@ void GetParity(const uint8_t *pbtCmd, uint16_t len, uint8_t *par) {
|
|||
// Note 1: the bitstream may start at any time. We therefore need to sync.
|
||||
// Note 2: the interpretation of Sequence Y and Z depends on the preceding sequence.
|
||||
//-----------------------------------------------------------------------------
|
||||
static tUart Uart;
|
||||
static tUart14a Uart;
|
||||
|
||||
// Lookup-Table to decide if 4 raw bits are a modulation.
|
||||
// We accept the following:
|
||||
|
@ -176,12 +191,12 @@ const bool Mod_Miller_LUT[] = {
|
|||
#define IsMillerModulationNibble1(b) (Mod_Miller_LUT[(b & 0x000000F0) >> 4])
|
||||
#define IsMillerModulationNibble2(b) (Mod_Miller_LUT[(b & 0x0000000F)])
|
||||
|
||||
tUart *GetUart() {
|
||||
tUart14a *GetUart14a() {
|
||||
return &Uart;
|
||||
}
|
||||
|
||||
void UartReset(void) {
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
void Uart14aReset(void) {
|
||||
Uart.state = STATE_14A_UNSYNCD;
|
||||
Uart.bitCount = 0;
|
||||
Uart.len = 0; // number of decoded data bytes
|
||||
Uart.parityLen = 0; // number of decoded parity bytes
|
||||
|
@ -194,17 +209,17 @@ void UartReset(void) {
|
|||
Uart.syncBit = 9999;
|
||||
}
|
||||
|
||||
void UartInit(uint8_t *data, uint8_t *par) {
|
||||
void Uart14aInit(uint8_t *data, uint8_t *par) {
|
||||
Uart.output = data;
|
||||
Uart.parity = par;
|
||||
UartReset();
|
||||
Uart14aReset();
|
||||
}
|
||||
|
||||
// use parameter non_real_time to provide a timestamp. Set to 0 if the decoder should measure real time
|
||||
RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
|
||||
Uart.fourBits = (Uart.fourBits << 8) | bit;
|
||||
|
||||
if (Uart.state == STATE_UNSYNCD) { // not yet synced
|
||||
if (Uart.state == STATE_14A_UNSYNCD) { // not yet synced
|
||||
Uart.syncBit = 9999; // not set
|
||||
|
||||
// 00x11111 2|3 ticks pause followed by 6|5 ticks unmodulated Sequence Z (a "0" or "start of communication")
|
||||
|
@ -230,20 +245,20 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
|
|||
Uart.startTime = non_real_time ? non_real_time : (GetCountSspClk() & 0xfffffff8);
|
||||
Uart.startTime -= Uart.syncBit;
|
||||
Uart.endTime = Uart.startTime;
|
||||
Uart.state = STATE_START_OF_COMMUNICATION;
|
||||
Uart.state = STATE_14A_START_OF_COMMUNICATION;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (IsMillerModulationNibble1(Uart.fourBits >> Uart.syncBit)) {
|
||||
if (IsMillerModulationNibble2(Uart.fourBits >> Uart.syncBit)) { // Modulation in both halves - error
|
||||
UartReset();
|
||||
Uart14aReset();
|
||||
} else { // Modulation in first half = Sequence Z = logic "0"
|
||||
if (Uart.state == STATE_MILLER_X) { // error - must not follow after X
|
||||
UartReset();
|
||||
if (Uart.state == STATE_14A_MILLER_X) { // error - must not follow after X
|
||||
Uart14aReset();
|
||||
} else {
|
||||
Uart.bitCount++;
|
||||
Uart.shiftReg = (Uart.shiftReg >> 1); // add a 0 to the shiftreg
|
||||
Uart.state = STATE_MILLER_Z;
|
||||
Uart.state = STATE_14A_MILLER_Z;
|
||||
Uart.endTime = Uart.startTime + 8 * (9 * Uart.len + Uart.bitCount + 1) - 6;
|
||||
if (Uart.bitCount >= 9) { // if we decoded a full byte (including parity)
|
||||
Uart.output[Uart.len++] = (Uart.shiftReg & 0xff);
|
||||
|
@ -262,7 +277,7 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
|
|||
if (IsMillerModulationNibble2(Uart.fourBits >> Uart.syncBit)) { // Modulation second half = Sequence X = logic "1"
|
||||
Uart.bitCount++;
|
||||
Uart.shiftReg = (Uart.shiftReg >> 1) | 0x100; // add a 1 to the shiftreg
|
||||
Uart.state = STATE_MILLER_X;
|
||||
Uart.state = STATE_14A_MILLER_X;
|
||||
Uart.endTime = Uart.startTime + 8 * (9 * Uart.len + Uart.bitCount + 1) - 2;
|
||||
if (Uart.bitCount >= 9) { // if we decoded a full byte (including parity)
|
||||
Uart.output[Uart.len++] = (Uart.shiftReg & 0xff);
|
||||
|
@ -276,8 +291,8 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
|
|||
}
|
||||
}
|
||||
} else { // no modulation in both halves - Sequence Y
|
||||
if (Uart.state == STATE_MILLER_Z || Uart.state == STATE_MILLER_Y) { // Y after logic "0" - End of Communication
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
if (Uart.state == STATE_14A_MILLER_Z || Uart.state == STATE_14A_MILLER_Y) { // Y after logic "0" - End of Communication
|
||||
Uart.state = STATE_14A_UNSYNCD;
|
||||
Uart.bitCount--; // last "0" was part of EOC sequence
|
||||
Uart.shiftReg <<= 1; // drop it
|
||||
if (Uart.bitCount > 0) { // if we decoded some bits
|
||||
|
@ -294,15 +309,15 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
|
|||
if (Uart.len) {
|
||||
return true; // we are finished with decoding the raw data sequence
|
||||
} else {
|
||||
UartReset(); // Nothing received - start over
|
||||
Uart14aReset(); // Nothing received - start over
|
||||
}
|
||||
}
|
||||
if (Uart.state == STATE_START_OF_COMMUNICATION) { // error - must not follow directly after SOC
|
||||
UartReset();
|
||||
if (Uart.state == STATE_14A_START_OF_COMMUNICATION) { // error - must not follow directly after SOC
|
||||
Uart14aReset();
|
||||
} else { // a logic "0"
|
||||
Uart.bitCount++;
|
||||
Uart.shiftReg = (Uart.shiftReg >> 1); // add a 0 to the shiftreg
|
||||
Uart.state = STATE_MILLER_Y;
|
||||
Uart.state = STATE_14A_MILLER_Y;
|
||||
if (Uart.bitCount >= 9) { // if we decoded a full byte (including parity)
|
||||
Uart.output[Uart.len++] = (Uart.shiftReg & 0xff);
|
||||
Uart.parityBits <<= 1; // make room for the parity bit
|
||||
|
@ -336,7 +351,7 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
|
|||
// 8 ticks modulated: A collision. Save the collision position and treat as Sequence D
|
||||
// Note 1: the bitstream may start at any time. We therefore need to sync.
|
||||
// Note 2: parameter offset is used to determine the position of the parity bits (required for the anticollision command only)
|
||||
tDemod Demod;
|
||||
tDemod14a Demod;
|
||||
|
||||
// Lookup-Table to decide if 4 raw bits are a modulation.
|
||||
// We accept three or four "1" in any position
|
||||
|
@ -348,11 +363,11 @@ const bool Mod_Manchester_LUT[] = {
|
|||
#define IsManchesterModulationNibble1(b) (Mod_Manchester_LUT[(b & 0x00F0) >> 4])
|
||||
#define IsManchesterModulationNibble2(b) (Mod_Manchester_LUT[(b & 0x000F)])
|
||||
|
||||
tDemod *GetDemod() {
|
||||
tDemod14a *GetDemod14a() {
|
||||
return &Demod;
|
||||
}
|
||||
void DemodReset(void) {
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
void Demod14aReset(void) {
|
||||
Demod.state = DEMOD_14A_UNSYNCD;
|
||||
Demod.len = 0; // number of decoded data bytes
|
||||
Demod.parityLen = 0;
|
||||
Demod.shiftReg = 0; // shiftreg to hold decoded data bits
|
||||
|
@ -367,17 +382,17 @@ void DemodReset(void) {
|
|||
Demod.samples = 0;
|
||||
}
|
||||
|
||||
void DemodInit(uint8_t *data, uint8_t *par) {
|
||||
void Demod14aInit(uint8_t *data, uint8_t *par) {
|
||||
Demod.output = data;
|
||||
Demod.parity = par;
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
}
|
||||
|
||||
// use parameter non_real_time to provide a timestamp. Set to 0 if the decoder should measure real time
|
||||
RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_time) {
|
||||
Demod.twoBits = (Demod.twoBits << 8) | bit;
|
||||
|
||||
if (Demod.state == DEMOD_UNSYNCD) {
|
||||
if (Demod.state == DEMOD_14A_UNSYNCD) {
|
||||
|
||||
if (Demod.highCnt < 2) { // wait for a stable unmodulated signal
|
||||
if (Demod.twoBits == 0x0000) {
|
||||
|
@ -399,7 +414,7 @@ RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_t
|
|||
Demod.startTime = non_real_time ? non_real_time : (GetCountSspClk() & 0xfffffff8);
|
||||
Demod.startTime -= Demod.syncBit;
|
||||
Demod.bitCount = offset; // number of decoded data bits
|
||||
Demod.state = DEMOD_MANCHESTER_DATA;
|
||||
Demod.state = DEMOD_14A_MANCHESTER_DATA;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -455,7 +470,7 @@ RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_t
|
|||
if (Demod.len) {
|
||||
return true; // we are finished with decoding the raw data sequence
|
||||
} else { // nothing received. Start over
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +483,7 @@ RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_t
|
|||
RAMFUNC int ManchesterDecoding_Thinfilm(uint8_t bit) {
|
||||
Demod.twoBits = (Demod.twoBits << 8) | bit;
|
||||
|
||||
if (Demod.state == DEMOD_UNSYNCD) {
|
||||
if (Demod.state == DEMOD_14A_UNSYNCD) {
|
||||
|
||||
if (Demod.highCnt < 2) { // wait for a stable unmodulated signal
|
||||
if (Demod.twoBits == 0x0000) {
|
||||
|
@ -491,7 +506,7 @@ RAMFUNC int ManchesterDecoding_Thinfilm(uint8_t bit) {
|
|||
Demod.startTime -= Demod.syncBit;
|
||||
Demod.bitCount = 1; // number of decoded data bits
|
||||
Demod.shiftReg = 1;
|
||||
Demod.state = DEMOD_MANCHESTER_DATA;
|
||||
Demod.state = DEMOD_14A_MANCHESTER_DATA;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -529,7 +544,7 @@ RAMFUNC int ManchesterDecoding_Thinfilm(uint8_t bit) {
|
|||
if (Demod.len) {
|
||||
return true; // we are finished with decoding the raw data sequence
|
||||
} else { // nothing received. Start over
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,10 +597,10 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
|||
bool ReaderIsActive = false;
|
||||
|
||||
// Set up the demodulator for tag -> reader responses.
|
||||
DemodInit(receivedResp, receivedRespPar);
|
||||
Demod14aInit(receivedResp, receivedRespPar);
|
||||
|
||||
// Set up the demodulator for the reader -> tag commands
|
||||
UartInit(receivedCmd, receivedCmdPar);
|
||||
Uart14aInit(receivedCmd, receivedCmdPar);
|
||||
|
||||
DbpString("Starting to sniff");
|
||||
|
||||
|
@ -659,13 +674,13 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
|||
true)) break;
|
||||
}
|
||||
/* ready to receive another command. */
|
||||
UartReset();
|
||||
Uart14aReset();
|
||||
/* reset the demod code, which might have been */
|
||||
/* false-triggered by the commands from the reader. */
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
LED_B_OFF();
|
||||
}
|
||||
ReaderIsActive = (Uart.state != STATE_UNSYNCD);
|
||||
ReaderIsActive = (Uart.state != STATE_14A_UNSYNCD);
|
||||
}
|
||||
|
||||
// no need to try decoding tag data if the reader is sending - and we cannot afford the time
|
||||
|
@ -684,13 +699,13 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
|||
if ((!triggered) && (param & 0x01)) triggered = true;
|
||||
|
||||
// ready to receive another response.
|
||||
DemodReset();
|
||||
Demod14aReset();
|
||||
// reset the Miller decoder including its (now outdated) input buffer
|
||||
UartReset();
|
||||
//UartInit(receivedCmd, receivedCmdPar);
|
||||
Uart14aReset();
|
||||
//Uart14aInit(receivedCmd, receivedCmdPar);
|
||||
LED_C_OFF();
|
||||
}
|
||||
TagIsActive = (Demod.state != DEMOD_UNSYNCD);
|
||||
TagIsActive = (Demod.state != DEMOD_14A_UNSYNCD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -830,7 +845,7 @@ static bool GetIso14443aCommandFromReader(uint8_t *received, uint8_t *par, int *
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_TAGSIM_LISTEN);
|
||||
|
||||
// Now run a `software UART` on the stream of incoming samples.
|
||||
UartInit(received, par);
|
||||
Uart14aInit(received, par);
|
||||
|
||||
// clear RXRDY:
|
||||
uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
@ -1795,7 +1810,7 @@ int EmGetCmd(uint8_t *received, uint16_t *len, uint8_t *par) {
|
|||
AT91C_BASE_ADC->ADC_CR = AT91C_ADC_START;
|
||||
|
||||
// Now run a 'software UART' on the stream of incoming samples.
|
||||
UartInit(received, par);
|
||||
Uart14aInit(received, par);
|
||||
|
||||
// Clear RXRDY:
|
||||
uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
@ -2024,7 +2039,7 @@ bool GetIso14443aAnswerFromTag_Thinfilm(uint8_t *receivedResponse, uint8_t *rec
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_LISTEN);
|
||||
|
||||
// Now get the answer from the card
|
||||
DemodInit(receivedResponse, NULL);
|
||||
Demod14aInit(receivedResponse, NULL);
|
||||
|
||||
// clear RXRDY:
|
||||
uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
@ -2073,7 +2088,7 @@ static int GetIso14443aAnswerFromTag(uint8_t *receivedResponse, uint8_t *receive
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_LISTEN);
|
||||
|
||||
// Now get the answer from the card
|
||||
DemodInit(receivedResponse, receivedResponsePar);
|
||||
Demod14aInit(receivedResponse, receivedResponsePar);
|
||||
|
||||
// clear RXRDY:
|
||||
uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
@ -2089,7 +2104,7 @@ static int GetIso14443aAnswerFromTag(uint8_t *receivedResponse, uint8_t *receive
|
|||
if (ManchesterDecoding(b, offset, 0)) {
|
||||
NextTransferTime = MAX(NextTransferTime, Demod.endTime - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER) / 16 + FRAME_DELAY_TIME_PICC_TO_PCD);
|
||||
return true;
|
||||
} else if (c++ > timeout && Demod.state == DEMOD_UNSYNCD) {
|
||||
} else if (c++ > timeout && Demod.state == DEMOD_14A_UNSYNCD) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2499,8 +2514,8 @@ void iso14443a_setup(uint8_t fpga_minor_mode) {
|
|||
StartCountSspClk();
|
||||
|
||||
// Prepare the demodulation functions
|
||||
DemodReset();
|
||||
UartReset();
|
||||
Demod14aReset();
|
||||
Uart14aReset();
|
||||
NextTransferTime = 2 * DELAY_ARM2AIR_AS_READER;
|
||||
iso14a_set_timeout(1060); // 106 * 10ms default
|
||||
|
||||
|
|
|
@ -13,21 +13,9 @@
|
|||
#ifndef __ISO14443A_H
|
||||
#define __ISO14443A_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "mifare.h" // struct
|
||||
#include "pm3_cmd.h"
|
||||
#include "cmd.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "crc16.h"
|
||||
#include "mifaresniff.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "parity.h"
|
||||
#include "mifare.h" // structs
|
||||
|
||||
// When the PM acts as tag and is receiving it takes
|
||||
// 2 ticks delay in the RF part (for the first falling edge),
|
||||
|
@ -42,11 +30,11 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
enum {
|
||||
DEMOD_UNSYNCD,
|
||||
// DEMOD_HALF_SYNCD,
|
||||
// DEMOD_MOD_FIRST_HALF,
|
||||
// DEMOD_NOMOD_FIRST_HALF,
|
||||
DEMOD_MANCHESTER_DATA
|
||||
DEMOD_14A_UNSYNCD,
|
||||
// DEMOD_14A_HALF_SYNCD,
|
||||
// DEMOD_14A_MOD_FIRST_HALF,
|
||||
// DEMOD_14A_NOMOD_FIRST_HALF,
|
||||
DEMOD_14A_MANCHESTER_DATA
|
||||
} state;
|
||||
uint16_t twoBits;
|
||||
uint16_t highCnt;
|
||||
|
@ -61,7 +49,7 @@ typedef struct {
|
|||
uint32_t startTime, endTime;
|
||||
uint8_t *output;
|
||||
uint8_t *parity;
|
||||
} tDemod;
|
||||
} tDemod14a;
|
||||
/*
|
||||
typedef enum {
|
||||
MOD_NOMOD = 0,
|
||||
|
@ -73,11 +61,11 @@ typedef enum {
|
|||
|
||||
typedef struct {
|
||||
enum {
|
||||
STATE_UNSYNCD,
|
||||
STATE_START_OF_COMMUNICATION,
|
||||
STATE_MILLER_X,
|
||||
STATE_MILLER_Y,
|
||||
STATE_MILLER_Z,
|
||||
STATE_14A_UNSYNCD,
|
||||
STATE_14A_START_OF_COMMUNICATION,
|
||||
STATE_14A_MILLER_X,
|
||||
STATE_14A_MILLER_Y,
|
||||
STATE_14A_MILLER_Z,
|
||||
// DROP_NONE,
|
||||
// DROP_FIRST_HALF,
|
||||
} state;
|
||||
|
@ -93,7 +81,7 @@ typedef struct {
|
|||
uint32_t startTime, endTime;
|
||||
uint8_t *output;
|
||||
uint8_t *parity;
|
||||
} tUart;
|
||||
} tUart14a;
|
||||
|
||||
#ifndef AddCrc14A
|
||||
# define AddCrc14A(data, len) compute_crc(CRC_14443_A, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
|
@ -109,12 +97,12 @@ typedef struct {
|
|||
|
||||
void GetParity(const uint8_t *pbtCmd, uint16_t len, uint8_t *par);
|
||||
|
||||
tDemod *GetDemod(void);
|
||||
void DemodReset(void);
|
||||
void DemodInit(uint8_t *data, uint8_t *par);
|
||||
tUart *GetUart(void);
|
||||
void UartReset(void);
|
||||
void UartInit(uint8_t *data, uint8_t *par);
|
||||
tDemod14a *GetDemod14a(void);
|
||||
void Demod14aReset(void);
|
||||
void Demod14aInit(uint8_t *data, uint8_t *par);
|
||||
tUart14a *GetUart14a(void);
|
||||
void Uart14aReset(void);
|
||||
void Uart14aInit(uint8_t *data, uint8_t *par);
|
||||
RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time);
|
||||
RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_time);
|
||||
|
||||
|
@ -153,8 +141,4 @@ void DetectNACKbug(void);
|
|||
|
||||
bool GetIso14443aAnswerFromTag_Thinfilm(uint8_t *receivedResponse, uint8_t *received_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ISO14443A_H */
|
||||
|
|
|
@ -10,6 +10,20 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "iso14443b.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "common.h" // access to global variable: DBGLEVEL
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "appmain.h"
|
||||
#include "BigBuf.h"
|
||||
#include "cmd.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "commonutil.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
|
||||
#ifndef FWT_TIMEOUT_14B
|
||||
// defaults to 2000ms
|
||||
# define FWT_TIMEOUT_14B 35312
|
||||
|
@ -52,7 +66,7 @@ static uint32_t iso14b_timeout = FWT_TIMEOUT_14B;
|
|||
|
||||
//=============================================================================
|
||||
// An ISO 14443 Type B tag. We listen for commands from the reader, using
|
||||
// a UART kind of thing that's implemented in software. When we get a
|
||||
// a kind of thing that's implemented in software. When we get a
|
||||
// frame (i.e., a group of bytes between SOF and EOF), we check the CRC.
|
||||
// If it's good, then we can do something appropriate with it, and send
|
||||
// a response.
|
||||
|
@ -60,14 +74,14 @@ static uint32_t iso14b_timeout = FWT_TIMEOUT_14B;
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The software UART that receives commands from the reader, and its state variables.
|
||||
// The software that receives commands from the reader, and its state variables.
|
||||
//-----------------------------------------------------------------------------
|
||||
static struct {
|
||||
enum {
|
||||
STATE_UNSYNCD,
|
||||
STATE_GOT_FALLING_EDGE_OF_SOF,
|
||||
STATE_AWAITING_START_BIT,
|
||||
STATE_RECEIVING_DATA
|
||||
STATE_14B_UNSYNCD,
|
||||
STATE_14B_GOT_FALLING_EDGE_OF_SOF,
|
||||
STATE_14B_AWAITING_START_BIT,
|
||||
STATE_14B_RECEIVING_DATA
|
||||
} state;
|
||||
uint16_t shiftReg;
|
||||
int bitCnt;
|
||||
|
@ -77,8 +91,8 @@ static struct {
|
|||
uint8_t *output;
|
||||
} Uart;
|
||||
|
||||
static void UartReset() {
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
static void Uart14bReset() {
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
Uart.shiftReg = 0;
|
||||
Uart.bitCnt = 0;
|
||||
Uart.byteCnt = 0;
|
||||
|
@ -86,9 +100,9 @@ static void UartReset() {
|
|||
Uart.posCnt = 0;
|
||||
}
|
||||
|
||||
static void UartInit(uint8_t *data) {
|
||||
static void Uart14bInit(uint8_t *data) {
|
||||
Uart.output = data;
|
||||
UartReset();
|
||||
Uart14bReset();
|
||||
// memset(Uart.output, 0x00, MAX_FRAME_SIZE);
|
||||
}
|
||||
|
||||
|
@ -120,7 +134,7 @@ static struct {
|
|||
} Demod;
|
||||
|
||||
// Clear out the state of the "UART" that receives from the tag.
|
||||
static void DemodReset() {
|
||||
static void Demod14bReset() {
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
Demod.bitCount = 0;
|
||||
Demod.posCount = 0;
|
||||
|
@ -133,9 +147,9 @@ static void DemodReset() {
|
|||
Demod.endTime = 0;
|
||||
}
|
||||
|
||||
static void DemodInit(uint8_t *data) {
|
||||
static void Demod14bInit(uint8_t *data) {
|
||||
Demod.output = data;
|
||||
DemodReset();
|
||||
Demod14bReset();
|
||||
// memset(Demod.output, 0x00, MAX_FRAME_SIZE);
|
||||
}
|
||||
|
||||
|
@ -315,16 +329,16 @@ static void CodeIso14443bAsTag(const uint8_t *cmd, int len) {
|
|||
*/
|
||||
static RAMFUNC int Handle14443bReaderUartBit(uint8_t bit) {
|
||||
switch (Uart.state) {
|
||||
case STATE_UNSYNCD:
|
||||
case STATE_14B_UNSYNCD:
|
||||
if (!bit) {
|
||||
// we went low, so this could be the beginning of an SOF
|
||||
Uart.state = STATE_GOT_FALLING_EDGE_OF_SOF;
|
||||
Uart.state = STATE_14B_GOT_FALLING_EDGE_OF_SOF;
|
||||
Uart.posCnt = 0;
|
||||
Uart.bitCnt = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_GOT_FALLING_EDGE_OF_SOF:
|
||||
case STATE_14B_GOT_FALLING_EDGE_OF_SOF:
|
||||
Uart.posCnt++;
|
||||
if (Uart.posCnt == 2) { // sample every 4 1/fs in the middle of a bit
|
||||
if (bit) {
|
||||
|
@ -333,11 +347,11 @@ static RAMFUNC int Handle14443bReaderUartBit(uint8_t bit) {
|
|||
// zeros that it's a valid SOF
|
||||
Uart.posCnt = 0;
|
||||
Uart.byteCnt = 0;
|
||||
Uart.state = STATE_AWAITING_START_BIT;
|
||||
Uart.state = STATE_14B_AWAITING_START_BIT;
|
||||
LED_A_ON(); // Indicate we got a valid SOF
|
||||
} else {
|
||||
// didn't stay down long enough before going high, error
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
}
|
||||
} else {
|
||||
// do nothing, keep waiting
|
||||
|
@ -348,27 +362,27 @@ static RAMFUNC int Handle14443bReaderUartBit(uint8_t bit) {
|
|||
if (Uart.bitCnt > 12) {
|
||||
// Give up if we see too many zeros without a one, too.
|
||||
LED_A_OFF();
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_AWAITING_START_BIT:
|
||||
case STATE_14B_AWAITING_START_BIT:
|
||||
Uart.posCnt++;
|
||||
if (bit) {
|
||||
if (Uart.posCnt > 50 / 2) { // max 57us between characters = 49 1/fs, max 3 etus after low phase of SOF = 24 1/fs
|
||||
// stayed high for too long between characters, error
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
}
|
||||
} else {
|
||||
// falling edge, this starts the data byte
|
||||
Uart.posCnt = 0;
|
||||
Uart.bitCnt = 0;
|
||||
Uart.shiftReg = 0;
|
||||
Uart.state = STATE_RECEIVING_DATA;
|
||||
Uart.state = STATE_14B_RECEIVING_DATA;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_RECEIVING_DATA:
|
||||
case STATE_14B_RECEIVING_DATA:
|
||||
Uart.posCnt++;
|
||||
if (Uart.posCnt == 2) {
|
||||
// time to sample a bit
|
||||
|
@ -391,30 +405,30 @@ static RAMFUNC int Handle14443bReaderUartBit(uint8_t bit) {
|
|||
if (Uart.byteCnt >= Uart.byteCntMax) {
|
||||
// Buffer overflowed, give up
|
||||
LED_A_OFF();
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
} else {
|
||||
// so get the next byte now
|
||||
Uart.posCnt = 0;
|
||||
Uart.state = STATE_AWAITING_START_BIT;
|
||||
Uart.state = STATE_14B_AWAITING_START_BIT;
|
||||
}
|
||||
} else if (Uart.shiftReg == 0x000) {
|
||||
// this is an EOF byte
|
||||
LED_A_OFF(); // Finished receiving
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
if (Uart.byteCnt != 0)
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// this is an error
|
||||
LED_A_OFF();
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LED_A_OFF();
|
||||
Uart.state = STATE_UNSYNCD;
|
||||
Uart.state = STATE_14B_UNSYNCD;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
@ -454,7 +468,7 @@ static int GetIso14443bCommandFromReader(uint8_t *received, uint16_t *len) {
|
|||
}
|
||||
*/
|
||||
// Now run a `software UART' on the stream of incoming samples.
|
||||
UartInit(received);
|
||||
Uart14bInit(received);
|
||||
|
||||
uint8_t mask;
|
||||
while (!BUTTON_PRESS()) {
|
||||
|
@ -949,7 +963,7 @@ static void GetTagSamplesFor14443bDemod() {
|
|||
BigBuf_free();
|
||||
|
||||
// Set up the demodulator for tag -> reader responses.
|
||||
DemodInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
Demod14bInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
|
||||
// The DMA buffer, used to stream samples from the FPGA
|
||||
int8_t *dmaBuf = (int8_t *) BigBuf_malloc(ISO14443B_DMA_BUFFER_SIZE);
|
||||
|
@ -1306,8 +1320,8 @@ void iso14443b_setup() {
|
|||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
||||
// Initialize Demod and Uart structs
|
||||
DemodInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
UartInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
Demod14bInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
Uart14bInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
|
||||
// connect Demodulated Signal to ADC:
|
||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||
|
@ -1411,8 +1425,8 @@ static void iso1444b_setup_sniff(void) {
|
|||
set_tracing(true);
|
||||
|
||||
// Initialize Demod and Uart structs
|
||||
DemodInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
UartInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
Demod14bInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
Uart14bInit(BigBuf_malloc(MAX_FRAME_SIZE));
|
||||
|
||||
if (DBGLEVEL > 1) {
|
||||
// Print debug information about the buffer sizes
|
||||
|
@ -1502,8 +1516,8 @@ void RAMFUNC SniffIso14443b(void) {
|
|||
if (Handle14443bReaderUartBit(ci & 0x01)) {
|
||||
time_stop = GetCountSspClk() - time_0;
|
||||
LogTrace(Uart.output, Uart.byteCnt, time_start, time_stop, NULL, true);
|
||||
UartReset();
|
||||
DemodReset();
|
||||
Uart14bReset();
|
||||
Demod14bReset();
|
||||
} else {
|
||||
time_start = GetCountSspClk() - time_0;
|
||||
}
|
||||
|
@ -1511,12 +1525,12 @@ void RAMFUNC SniffIso14443b(void) {
|
|||
if (Handle14443bReaderUartBit(cq & 0x01)) {
|
||||
time_stop = GetCountSspClk() - time_0;
|
||||
LogTrace(Uart.output, Uart.byteCnt, time_start, time_stop, NULL, true);
|
||||
UartReset();
|
||||
DemodReset();
|
||||
Uart14bReset();
|
||||
Demod14bReset();
|
||||
} else {
|
||||
time_start = GetCountSspClk() - time_0;
|
||||
}
|
||||
ReaderIsActive = (Uart.state > STATE_GOT_FALLING_EDGE_OF_SOF);
|
||||
ReaderIsActive = (Uart.state > STATE_14B_GOT_FALLING_EDGE_OF_SOF);
|
||||
}
|
||||
|
||||
// no need to try decoding tag data if the reader is sending - and we cannot afford the time
|
||||
|
@ -1527,8 +1541,8 @@ void RAMFUNC SniffIso14443b(void) {
|
|||
if (Handle14443bTagSamplesDemod(ci, cq)) {
|
||||
time_stop = GetCountSspClk() - time_0;
|
||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, false);
|
||||
UartReset();
|
||||
DemodReset();
|
||||
Uart14bReset();
|
||||
Demod14bReset();
|
||||
} else {
|
||||
time_start = GetCountSspClk() - time_0;
|
||||
}
|
||||
|
|
|
@ -13,18 +13,10 @@
|
|||
#ifndef __ISO14443B_H
|
||||
#define __ISO14443B_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "common.h"
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "common.h" // access to global variable: DBGLEVEL
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "crc16.h"
|
||||
#include "mifare.h"
|
||||
#include "protocols.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
#ifndef AddCrc14A
|
||||
# define AddCrc14A(data, len) compute_crc(CRC_14443_A, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
|
@ -34,12 +26,18 @@ extern "C" {
|
|||
# define AddCrc14B(data, len) compute_crc(CRC_14443_B, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
#endif
|
||||
|
||||
void SendRawCommand14443B_Ex(PacketCommandNG *c);
|
||||
void iso14443b_setup();
|
||||
uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *response);
|
||||
uint8_t iso14443b_select_card(iso14b_card_select_t *card);
|
||||
uint8_t iso14443b_select_card_srx(iso14b_card_select_t *card);
|
||||
|
||||
void SimulateIso14443bTag(uint32_t pupi);
|
||||
void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
|
||||
void ReadSTMemoryIso14443b(uint8_t numofblocks);
|
||||
void RAMFUNC SniffIso14443b(void);
|
||||
void SendRawCommand14443B(uint32_t, uint32_t, uint8_t, uint8_t[]);
|
||||
void SendRawCommand14443B_Ex(PacketCommandNG *c);
|
||||
|
||||
// testfunctions
|
||||
void WaitForFpgaDelayQueueIsEmpty(uint16_t delay);
|
||||
void ClearFpgaShiftingRegisters(void);
|
||||
|
@ -53,8 +51,4 @@ void ClearFpgaShiftingRegisters(void);
|
|||
#define SIM_ACKNOWLEDGE 5
|
||||
#define SIM_WORK 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ISO14443B_H */
|
||||
|
|
|
@ -58,12 +58,20 @@
|
|||
// *) remove or refactor code under "depricated"
|
||||
// *) document all the functions
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "iso15693.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "util.h"
|
||||
#include "apps.h"
|
||||
#include "string.h"
|
||||
#include "iso15693tools.h"
|
||||
#include "cmd.h"
|
||||
#include "appmain.h"
|
||||
#include "dbprint.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "commonutil.h"
|
||||
#include "ticks.h"
|
||||
#include "BigBuf.h"
|
||||
#include "crc16.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// ISO 15693 Part 2 - Air Interface
|
||||
|
|
26
armsrc/iso15693.h
Normal file
26
armsrc/iso15693.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __ISO15693_H
|
||||
#define __ISO15693_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "pm3_cmd.h" // struct
|
||||
|
||||
void RecordRawAdcSamplesIso15693(void);
|
||||
void AcquireRawAdcSamplesIso15693(void);
|
||||
void ReaderIso15693(uint32_t parameter); // Simulate an ISO15693 reader - greg
|
||||
void SimTagIso15693(uint32_t parameter, uint8_t *uid); // simulate an ISO15693 tag - greg
|
||||
void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
|
||||
void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint8_t *data); // send arbitrary commands from CLI - atrox
|
||||
void Iso15693InitReader(void);
|
||||
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
Linker script for the ARM binary
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
INCLUDE ../common/ldscript.common
|
||||
INCLUDE ../common_arm/ldscript.common
|
||||
|
||||
PHDRS
|
||||
{
|
||||
|
|
|
@ -11,11 +11,20 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "legicrf.h"
|
||||
|
||||
#include "ticks.h" /* timers */
|
||||
#include "crc.h" /* legic crc-4 */
|
||||
#include "legic_prng.h" /* legic PRNG impl */
|
||||
#include "legic.h" /* legic_card_select_t struct */
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "protocols.h"
|
||||
|
||||
static uint8_t *legic_mem; /* card memory, used for read, write */
|
||||
static legic_card_select_t card;/* metadata of currently selected card */
|
||||
static crc_t legic_crc;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef __LEGICRF_H
|
||||
#define __LEGICRF_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "common.h"
|
||||
|
||||
void LegicRfInfo(void);
|
||||
void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv);
|
||||
|
|
|
@ -11,11 +11,17 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "legicrf.h"
|
||||
|
||||
#include "ticks.h" /* timers */
|
||||
#include "crc.h" /* legic crc-4 */
|
||||
#include "legic_prng.h" /* legic PRNG impl */
|
||||
#include "legic.h" /* legic_card_select_t struct */
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
|
||||
static uint8_t *legic_mem; /* card memory, used for sim */
|
||||
static legic_card_select_t card;/* metadata of currently selected card */
|
||||
static crc_t legic_crc;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef __LEGICRFSIM_H
|
||||
#define __LEGICRFSIM_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "common.h"
|
||||
|
||||
void LegicRfSimulate(uint8_t tagtype);
|
||||
|
||||
|
|
|
@ -8,18 +8,23 @@
|
|||
// Also routines for raw mode reading/simulating of LF waveform
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "lfops.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "hitag2.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
#include "crc16.h"
|
||||
#include "string.h"
|
||||
#include "printf.h"
|
||||
#include "lfdemod.h"
|
||||
#include "lfsampling.h"
|
||||
#include "protocols.h"
|
||||
#include "usb_cdc.h" // for usb_poll_validate_length
|
||||
#include "common.h"
|
||||
#include "pmflash.h"
|
||||
#include "flashmem.h" // persistence on flash
|
||||
|
||||
|
@ -154,6 +159,30 @@ t55xx_configurations_t T55xx_Timing = {
|
|||
#define T55XX_DLMODE_1OF4 3 // 1 of 4
|
||||
#define T55XX_LONGLEADINGREFERENCE 4 // Value to tell Write Bit to send long reference
|
||||
|
||||
// ATA55xx shared presets & routines
|
||||
static uint32_t GetT55xxClockBit(uint32_t clock) {
|
||||
switch (clock) {
|
||||
case 128:
|
||||
return T55x7_BITRATE_RF_128;
|
||||
case 100:
|
||||
return T55x7_BITRATE_RF_100;
|
||||
case 64:
|
||||
return T55x7_BITRATE_RF_64;
|
||||
case 50:
|
||||
return T55x7_BITRATE_RF_50;
|
||||
case 40:
|
||||
return T55x7_BITRATE_RF_40;
|
||||
case 32:
|
||||
return T55x7_BITRATE_RF_32;
|
||||
case 16:
|
||||
return T55x7_BITRATE_RF_16;
|
||||
case 8:
|
||||
return T55x7_BITRATE_RF_8;
|
||||
default :
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void printT55xxConfig(void) {
|
||||
|
||||
#define PRN_NA sprintf(s + strlen(s), _RED_("N/A") "| ");
|
||||
|
|
69
armsrc/lfops.h
Normal file
69
armsrc/lfops.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __LFOPS_H
|
||||
#define __LFOPS_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "pm3_cmd.h" // struct
|
||||
|
||||
extern uint8_t decimation;
|
||||
extern uint8_t bits_per_sample ;
|
||||
extern bool averaging;
|
||||
|
||||
void AcquireRawAdcSamples125k(int divisor);
|
||||
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command);
|
||||
void ReadTItag(void);
|
||||
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc);
|
||||
|
||||
void AcquireTiType(void);
|
||||
void AcquireRawBitsTI(void);
|
||||
void SimulateTagLowFrequencyEx(int period, int gap, bool ledcontrol, int numcycles);
|
||||
void SimulateTagLowFrequency(int period, int gap, bool ledcontrol);
|
||||
void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);
|
||||
|
||||
void CmdHIDsimTAGEx(uint32_t hi, uint32_t lo, bool ledcontrol, int numcycles);
|
||||
void CmdHIDsimTAG(uint32_t hi, uint32_t lo, bool ledcontrol);
|
||||
|
||||
void CmdFSKsimTAG(uint8_t fchigh, uint8_t fclow, uint8_t separator, uint8_t clk, uint16_t bitslen, uint8_t *bits, bool ledcontrol);
|
||||
void CmdASKsimTAG(uint8_t encoding, uint8_t invert, uint8_t separator, uint8_t clk, uint16_t size, uint8_t *bits, bool ledcontrol);
|
||||
void CmdPSKsimTag(uint8_t carrier, uint8_t invert, uint8_t clk, uint16_t size, uint8_t *bits, bool ledcontrol);
|
||||
|
||||
void CmdHIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
|
||||
void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol); // Realtime demodulation mode for AWID26
|
||||
void CmdEM410xdemod(int findone, uint32_t *high, uint64_t *low, int ledcontrol);
|
||||
void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
|
||||
void CopyIOtoT55x7(uint32_t hi, uint32_t lo); // Clone an ioProx card to T5557/T5567
|
||||
void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567
|
||||
void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5);
|
||||
void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
|
||||
void CopyIndala64toT55x7(uint32_t hi, uint32_t lo); // Clone Indala 64-bit tag by UID to T55x7
|
||||
void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t uid4, uint32_t uid5, uint32_t uid6, uint32_t uid7); // Clone Indala 224-bit tag by UID to T55x7
|
||||
void T55xxResetRead(uint8_t flags);
|
||||
//id T55xxWriteBlock(uint32_t data, uint8_t blockno, uint32_t pwd, uint8_t flags);
|
||||
void T55xxWriteBlock(uint8_t *data);
|
||||
// void T55xxWriteBlockExt(uint32_t data, uint8_t blockno, uint32_t pwd, uint8_t flags);
|
||||
void T55xxReadBlock(uint8_t page, bool pwd_mode, bool brute_mem, uint8_t block, uint32_t pwd, uint8_t downlink_mode);
|
||||
void T55xxWakeUp(uint32_t pwd, uint8_t flags);
|
||||
void T55xx_ChkPwds(uint8_t flags);
|
||||
|
||||
void TurnReadLFOn(uint32_t delay);
|
||||
|
||||
void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd);
|
||||
void EM4xWriteWord(uint8_t addr, uint32_t data, uint32_t pwd, uint8_t usepwd);
|
||||
|
||||
void Cotag(uint32_t arg0);
|
||||
void setT55xxConfig(uint8_t arg0, t55xx_configurations_t *c);
|
||||
t55xx_configurations_t *getT55xxConfig(void);
|
||||
void printT55xxConfig(void);
|
||||
void loadT55xxConfig(void);
|
||||
|
||||
#endif
|
|
@ -8,6 +8,14 @@
|
|||
|
||||
#include "lfsampling.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "lfdemod.h"
|
||||
|
||||
/*
|
||||
Default LF config is set to:
|
||||
decimation = 1 (we keep 1 out of 1 samples)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
#ifndef __LFSAMPLING_H
|
||||
#define __LFSAMPLING_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "usb_cdc.h" // for usb_poll_validate_length
|
||||
#include "ticks.h" // for StartTicks
|
||||
#include "common.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
typedef struct BitstreamOut BitstreamOut;
|
||||
|
||||
|
@ -82,5 +78,4 @@ sample_config *getSamplingConfig();
|
|||
|
||||
void printConfig();
|
||||
|
||||
|
||||
#endif // __LFSAMPLING_H
|
||||
|
|
|
@ -15,9 +15,23 @@
|
|||
|
||||
#include "mifarecmd.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "pmflash.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "string.h"
|
||||
#include "mifareutil.h"
|
||||
#include "protocols.h"
|
||||
#include "parity.h"
|
||||
#include "BigBuf.h"
|
||||
#include "cmd.h"
|
||||
#include "flashmem.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "iso14443a.h"
|
||||
#include "mifaredesfire.h"
|
||||
#include "util.h"
|
||||
#include "commonutil.h"
|
||||
#include "crc16.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
|
||||
#ifndef HARDNESTED_AUTHENTICATION_TIMEOUT
|
||||
# define HARDNESTED_AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation)
|
||||
|
|
|
@ -1,27 +1,52 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Merlok - June 2011
|
||||
// Gerhard de Koning Gans - May 2008
|
||||
// Hagen Fritsch - June 2010
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to support ISO 14443 type A.
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __MIFARECMD_H
|
||||
#define __MIFARECMD_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "common.h"
|
||||
#include "crc.h"
|
||||
#include "protocols.h"
|
||||
#include "parity.h"
|
||||
|
||||
void MifareReadBlock(uint8_t blockNo, uint8_t keyType, uint8_t *datain);
|
||||
|
||||
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes);
|
||||
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
//void MifareUWriteBlockCompat(uint8_t arg0,uint8_t *datain);
|
||||
void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *datain);
|
||||
void MifareAcquireNonces(uint32_t arg0, uint32_t flags);
|
||||
void MifareChkKeys(uint8_t *datain);
|
||||
void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
|
||||
void MifareEMemClr(void);
|
||||
void MifareEMemSet(uint8_t blockno, uint8_t blockcnt, uint8_t blockwidth, uint8_t *datain);
|
||||
void MifareEMemGet(uint8_t blockno, uint8_t blockcnt);
|
||||
int MifareECardLoad(uint32_t arg0, uint32_t arg1);
|
||||
|
||||
void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); // Work with "magic Chinese" card
|
||||
void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain);
|
||||
void MifareCIdent(); // is "magic chinese" card?
|
||||
|
||||
void MifareSetMod(uint8_t *datain);
|
||||
void MifareUSetPwd(uint8_t arg0, uint8_t *datain);
|
||||
void OnSuccessMagic();
|
||||
void OnErrorMagic(uint8_t reason);
|
||||
|
||||
int32_t dist_nt(uint32_t nt1, uint32_t nt2);
|
||||
void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype);
|
||||
//void RAMFUNC SniffMifare(uint8_t param);
|
||||
|
||||
void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain);
|
||||
void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
#include "mifaredesfire.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "string.h"
|
||||
#include "BigBuf.h"
|
||||
#include "desfire_key.h"
|
||||
#include "mifareutil.h"
|
||||
#include "des.h"
|
||||
#include "cmd.h"
|
||||
#include "dbprint.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crc16.h"
|
||||
#include "mbedtls/aes.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
#define MAX_APPLICATION_COUNT 28
|
||||
#define MAX_FILE_COUNT 16
|
||||
#define MAX_DESFIRE_FRAME_SIZE 60
|
||||
|
|
|
@ -1,13 +1,26 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Jonathan Westhues, Aug 2005
|
||||
// Gerhard de Koning Gans, April 2008, May 2011
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions internal to the app source.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __MIFAREDESFIRE_H
|
||||
#define __MIFAREDESFIRE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "string.h"
|
||||
#include "BigBuf.h"
|
||||
#include "iso14443a.h"
|
||||
#include "desfire_key.h"
|
||||
#include "mifareutil.h"
|
||||
#include "des.h"
|
||||
|
||||
bool InitDesfireCard();
|
||||
void MifareSendCommand(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareDesfireGetInformation();
|
||||
void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void ReaderMifareDES(uint32_t param, uint32_t param2, uint8_t *datain);
|
||||
int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout);
|
||||
size_t CreateAPDU(uint8_t *datain, size_t len, uint8_t *dataout);
|
||||
void OnSuccess();
|
||||
void OnError(uint8_t reason);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,19 +20,24 @@
|
|||
// /!\ Printing Debug message is disrupting emulation,
|
||||
// Only use with caution during debugging
|
||||
|
||||
#include "mifaresim.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "iso14443a.h"
|
||||
#include "mifaresim.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "BigBuf.h"
|
||||
#include "string.h"
|
||||
#include "mifareutil.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "proxmark3.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "protocols.h"
|
||||
#include "apps.h"
|
||||
#include "appmain.h"
|
||||
#include "util.h"
|
||||
#include "commonutil.h"
|
||||
#include "crc16.h"
|
||||
#include "dbprint.h"
|
||||
#include "ticks.h"
|
||||
|
||||
static bool IsTrailerAccessAllowed(uint8_t blockNo, uint8_t keytype, uint8_t action) {
|
||||
uint8_t sector_trailer[16];
|
||||
|
@ -506,7 +511,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
uint8_t rAUTH_NT_keystream[4];
|
||||
uint32_t nonce = 0;
|
||||
|
||||
tUart *uart = GetUart();
|
||||
tUart14a *uart = GetUart14a();
|
||||
|
||||
// free eventually allocated BigBuf memory but keep Emulator Memory
|
||||
BigBuf_free_keep_EM();
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
#ifndef __MIFARESIM_H
|
||||
#define __MIFARESIM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
|
||||
#ifndef CheckCrc14A
|
||||
# define CheckCrc14A(data, len) check_crc(CRC_14443_A, (data), (len))
|
||||
#endif
|
||||
|
||||
void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t atqa, uint8_t sak);
|
||||
|
||||
#define AC_DATA_READ 0
|
||||
#define AC_DATA_WRITE 1
|
||||
#define AC_DATA_INC 2
|
||||
|
@ -36,4 +34,6 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
#define AUTHKEYB 1
|
||||
#define AUTHKEYNONE 0xff
|
||||
|
||||
void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t atqa, uint8_t sak);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,10 +68,10 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
|||
|
||||
|
||||
// Set up the demodulator for tag -> reader responses.
|
||||
DemodInit(receivedResp, receivedRespPar);
|
||||
Demod14aInit(receivedResp, receivedRespPar);
|
||||
|
||||
// Set up the demodulator for the reader -> tag commands
|
||||
UartInit(receivedCmd, receivedCmdPar);
|
||||
Uart14aInit(receivedCmd, receivedCmdPar);
|
||||
|
||||
// Setup and start DMA.
|
||||
// set transfer address and number of bytes. Start transfer.
|
||||
|
@ -80,8 +80,8 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
|||
return;
|
||||
}
|
||||
|
||||
tUart *uart = GetUart();
|
||||
tDemod *demod = GetDemod();
|
||||
tUart14a *uart = GetUart14a();
|
||||
tDemod14a *demod = GetDemod14a();
|
||||
|
||||
MfSniffInit();
|
||||
|
||||
|
@ -149,10 +149,10 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
|||
uint8_t readerbyte = (previous_data & 0xF0) | (*data >> 4);
|
||||
if (MillerDecoding(readerbyte, (sniffCounter - 1) * 4)) {
|
||||
LogTrace(receivedCmd, uart->len, 0, 0, NULL, true);
|
||||
DemodReset();
|
||||
UartReset();
|
||||
Demod14aReset();
|
||||
Uart14aReset();
|
||||
}
|
||||
ReaderIsActive = (uart->state != STATE_UNSYNCD);
|
||||
ReaderIsActive = (uart->state != STATE_14A_UNSYNCD);
|
||||
}
|
||||
|
||||
// no need to try decoding tag data if the reader is sending
|
||||
|
@ -160,10 +160,10 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
|||
uint8_t tagbyte = (previous_data << 4) | (*data & 0x0F);
|
||||
if (ManchesterDecoding(tagbyte, 0, (sniffCounter - 1) * 4)) {
|
||||
LogTrace(receivedResp, demod->len, 0, 0, NULL, false);
|
||||
DemodReset();
|
||||
UartReset();
|
||||
Demod14aReset();
|
||||
Uart14aReset();
|
||||
}
|
||||
TagIsActive = (demod->state != DEMOD_UNSYNCD);
|
||||
TagIsActive = (demod->state != DEMOD_14A_UNSYNCD);
|
||||
}
|
||||
}
|
||||
previous_data = *data;
|
|
@ -11,13 +11,6 @@
|
|||
#ifndef __MIFARESNIFF_H
|
||||
#define __MIFARESNIFF_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SNF_INIT 0
|
|
@ -9,6 +9,17 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "mifareutil.h"
|
||||
|
||||
#include "string.h"
|
||||
#include "BigBuf.h"
|
||||
#include "iso14443a.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "parity.h"
|
||||
#include "commonutil.h"
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "des.h"
|
||||
|
||||
int DBGLEVEL = DBG_ERROR;
|
||||
|
||||
// crypto1 helpers
|
||||
|
|
|
@ -12,14 +12,8 @@
|
|||
#ifndef __MIFAREUTIL_H
|
||||
#define __MIFAREUTIL_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "parity.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443a.h"
|
||||
#include "common.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "des.h"
|
||||
|
||||
// mifare authentication
|
||||
#define CRYPT_NONE 0
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "nprintf.h"
|
||||
|
||||
|
||||
|
|
|
@ -32,14 +32,10 @@
|
|||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/**
|
||||
* Output a character to a custom device like UART, used by the printf() function
|
||||
|
@ -108,10 +104,4 @@ int vprintf_(const char *format, va_list va);
|
|||
*/
|
||||
int fctprintf(void (*out)(char character, void *arg), void *arg, const char *format, ...);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _PRINTF_H_
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#ifndef OPTIMIZED_CIPHER_H
|
||||
#define OPTIMIZED_CIPHER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* Definition 1 (Cipher state). A cipher state of iClass s is an element of F 40/2
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
#include "pcf7931.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "cmd.h"
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "util.h"
|
||||
#include "lfsampling.h"
|
||||
#include "string.h"
|
||||
|
||||
#define T0_PCF 8 //period for the pcf7931 in us
|
||||
#define ALLOC 16
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
#ifndef __PCF7931_H
|
||||
#define __PCF7931_H
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "lfsampling.h"
|
||||
#include "pcf7931.h"
|
||||
#include "string.h"
|
||||
#include "common.h"
|
||||
|
||||
size_t DemodPCF7931(uint8_t **outBlocks);
|
||||
bool IsBlock0PCF7931(uint8_t *block);
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
*/
|
||||
#include "printf.h"
|
||||
|
||||
#include "string.h"
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long long u_quad_t;
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
#ifndef __PRINTF_H
|
||||
#define __PRINTF_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include "string.h"
|
||||
#include "common.h"
|
||||
#include <stdarg.h> // va_list
|
||||
|
||||
int kvsprintf(const char *fmt, void *arg, int radix, va_list ap) __attribute__((format(printf, 1, 0)));
|
||||
int vsprintf(char *dest, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0)));
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#ifndef RADIXSORT_H__
|
||||
#define RADIXSORT_H__
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
|
@ -20,4 +18,5 @@ typedef union {
|
|||
} rscounts_t;
|
||||
|
||||
uint64_t *radixSort(uint64_t *array, uint32_t size);
|
||||
|
||||
#endif // RADIXSORT_H__
|
|
@ -43,6 +43,12 @@
|
|||
RDV40_SPIFFS_SAFE_FOOTER
|
||||
|
||||
#include "spiffs.h"
|
||||
#include "flashmem.h"
|
||||
#include "dbprint.h"
|
||||
#include "printf.h"
|
||||
#include "common.h"
|
||||
#include "string.h"
|
||||
#include "BigBuf.h"
|
||||
|
||||
///// FLASH LEVEL R/W/E operations for feeding SPIFFS Driver/////////////////
|
||||
static s32_t rdv40_spiffs_llread(u32_t addr, u32_t size, u8_t *dst) {
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
|
||||
#ifndef SPIFFS_H_
|
||||
#define SPIFFS_H_
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "spiffs_config.h"
|
||||
|
||||
|
@ -854,8 +853,5 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages);
|
|||
|
||||
#if SPIFFS_CACHE
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SPIFFS_H_ */
|
||||
|
|
|
@ -8,22 +8,7 @@
|
|||
#ifndef SPIFFS_CONFIG_H_
|
||||
#define SPIFFS_CONFIG_H_
|
||||
|
||||
// ----------- 8< ------------
|
||||
// Following includes are for the linux test build of spiffs
|
||||
// These may/should/must be removed/altered/replaced in your target
|
||||
//#include <stdio.h>
|
||||
//#include <stdlib.h>
|
||||
//
|
||||
#include "printf.h"
|
||||
#include "string.h"
|
||||
#include "flashmem.h"
|
||||
|
||||
void Dbprintf(const char *fmt, ...);
|
||||
|
||||
//#include <stddef.h>
|
||||
//#include <unistd.h>
|
||||
// ----------- >8 ------------
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef int s32_t;
|
||||
typedef uint32_t u32_t;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue