mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-19 11:33:51 +08:00
Merge pull request #1 from RfidResearchGroup/master
Sync Master to fork
This commit is contained in:
commit
9a1c0ff8a8
154 changed files with 2197 additions and 2234 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -3,6 +3,11 @@
|
|||
|
||||
.history
|
||||
.bash_history
|
||||
.bash_profile
|
||||
.bash_logout
|
||||
.bashrc
|
||||
.inputrc
|
||||
.profile
|
||||
*.log
|
||||
*.eml
|
||||
*.o
|
||||
|
|
29
CHANGELOG.md
29
CHANGELOG.md
|
@ -3,8 +3,35 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Add 'hw standalone' to jump to standalone mode from command line or script (@doegox)
|
||||
- Add to 'hf 14a apdu' print apdu and compose apdu (@merlokk)
|
||||
- Change: buggy 'mem read' removed, 'mem save' renamed 'mem dump', can now display too (@doegox)
|
||||
- Fix: timeout for mem wipe was too short, thanks @cjbrigato (@doegox)
|
||||
- Fix 'hf mf sim' - Mifare Classic simulation more flexible anti-collision check (@McEloff)
|
||||
- Change: 'hf mf sim' - Mifare Classic simulation not respond NACK on invalid authentication request (@McEloff)
|
||||
- Change: 'read_pwd_mem.lua' now handles Mifare Classic dictionaries large than 4096 bytes (@iceman)
|
||||
- Change: Don't clear trace log during 'hf mf chk', to save whole process history (@McEloff)
|
||||
- Add 'msleep' command, for pauses in scripts (@doegox)
|
||||
- Add support for WSL in proxmark.sh (@doegox)
|
||||
- Add documentation for usage of Proxmark3 under WSL (@doegox)
|
||||
- Change: replace aes.c with mbedtls version (@slurdge)
|
||||
- Change: replace ukbhit by kbd_enter_pressed, not requiring tcgetattr (@xianglin1998/@doegox)
|
||||
- Add config for RaspberryPi in JTAG tools (@doegox)
|
||||
- Add config for FTDI C232HM-DDHSL-0 in JTAG tools (@doegox)
|
||||
- Fix compilation under MacOSX with binutils (@matrix)
|
||||
- Add dynamic report of the chipID for flashing purposes (@slurdge)
|
||||
- Fix Clang warnings (@matrix)
|
||||
- Fix EMVGPO bug (@matrix)
|
||||
- Add hitag2 write password auth (@ViRb3)
|
||||
- Add check if bootloader segment is within bounds (@slurdge)
|
||||
- Add 'hf 15 csetuid' - set UID on ISO-15693 Magic tags (@t0m4-null)
|
||||
- Change: Print help if unknown arg for hitag reader/writer (@ViRb3)
|
||||
- Fix clock deadlock in hitag sniff (@ViRb3)
|
||||
- Add compiler info in client & ARM sections (@slurdge)
|
||||
- Add support for automatic COM detection on Windows (@slurdge)
|
||||
- Add support for compilation on RaspberryPiZero (armv6) (@doegox)
|
||||
- Change: updates to README (@iceman)
|
||||
- Change: hf mf/mfu dbg => hw dbg (@doegox)
|
||||
- Change: 'hf mf/mfu dbg' => 'hw dbg' (@doegox)
|
||||
- Change: replace usb_poll_validate_length() by data_available() that supports USART too (@doegox)
|
||||
- Make sure standalone modes can be launched when connected on USB without client (@doegox)
|
||||
- Change: cleaner makefile execution, use 'make V=1' if you want to see full lines (@doegox)
|
||||
|
|
4
Makefile
4
Makefile
|
@ -145,12 +145,12 @@ style:
|
|||
# Make sure astyle is installed
|
||||
@which astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 )
|
||||
# Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile
|
||||
find . \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" \) \
|
||||
find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" \) \
|
||||
-exec perl -pi -e 's/[ \t]+$$//' {} \; \
|
||||
-exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \
|
||||
-exec sh -c "echo >> {}" \;
|
||||
# Apply astyle on *.c, *.h, *.cpp
|
||||
find . \( -name "*.[ch]" -or -name "*.cpp" \) -exec astyle --formatted --mode=c --suffix=none \
|
||||
find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) \) -exec astyle --formatted --mode=c --suffix=none \
|
||||
--indent=spaces=4 --indent-switches \
|
||||
--keep-one-line-blocks --max-instatement-indent=60 \
|
||||
--style=google --pad-oper --unpad-paren --pad-header \
|
||||
|
|
32
README.md
32
README.md
|
@ -1,14 +1,11 @@
|
|||
# Proxmark3 RDV4.0 Dedicated Github
|
||||
|
||||
This repo is based on iceman fork for proxmark3. It is dedicated to bringing the most out of the new features for proxmark3 RDV4.0 new hardware and design.
|
||||
This repo is based on iceman fork for Proxmark3. It is dedicated to bringing the most out of the new features for Proxmark3 RDV4.0 new hardware and design.
|
||||
Note that it also supports other Proxmark3 platforms as well!
|
||||
|
||||
[](https://ci.appveyor.com/project/iceman1001/proxmark3-ji4wj/branch/master)
|
||||
[](https://github.com/RfidResearchGroup/proxmark3/releases/latest)
|
||||
|
||||
<a href="http://www.youtube.com/watch?feature=player_embedded&v=uyJ-y0kSWfc
|
||||
" target="_blank"><img src="https://github.com/5w0rdfish/proxmark3/blob/master/prox.png"
|
||||
alt="Yuotube" width="100%" height="auto" border="10" /></a>
|
||||
|
||||
---
|
||||
|
||||
# PROXMARK INSTALLATION AND OVERVIEW
|
||||
|
@ -19,9 +16,11 @@ alt="Yuotube" width="100%" height="auto" border="10" /></a>
|
|||
|[Development](#development) | [Important notes on ModemManager for Linux users](/doc/md/Installation_Instructions/ModemManager-Must-Be-Discarded.md) | [Validating proxmark client functionality](/doc/md/Use_of_Proxmark/1_Validation.md) |
|
||||
|[Why didn't you base it on official PM3 Master?](#why-didnt-you-base-it-on-official-pm3-master)| [Homebrew (Mac OS X) & Upgrading HomeBrew Tap Formula](/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md) | [First Use and Verification](/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md)|
|
||||
|[PM3 GUI](#pm3-gui)|[Setup and build for Windows](/doc/md/Installation_Instructions/Windows-Installation-Instructions.md)|[Commands & Features](/doc/md/Use_of_Proxmark/3_Commands-and-Features.md)|
|
||||
|[Issues](#issues)|[Blue shark manual](/doc/bt_manual_v10.md) ||
|
||||
|[Issues](#issues)|[Blue shark manual](/doc/bt_manual_v10.md) |[Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)|
|
||||
|[Notes on UART](/doc/uart_notes.md)|||
|
||||
|[Notes on Frame format](/doc/new_frame_format.md)|||
|
||||
|[Notes on Termux / Android](/doc/termux_notes.md)|||
|
||||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode) ||
|
||||
|[Donations](#Donations)|||
|
||||
|
||||
## What has changed?
|
||||
|
@ -45,17 +44,20 @@ This fork now compiles just fine on
|
|||
|
||||
If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first.
|
||||
|
||||
Internal notes on [Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md).
|
||||
- Internal notes on [Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md).
|
||||
- Internal notes on UART
|
||||
- Internal notes on Frame format
|
||||
- Internal notes on standalone mode
|
||||
|
||||
---
|
||||
|
||||
## Why didn't you base it on official PM3 Master?
|
||||
|
||||
The separation from official pm3 repo gives us a lot of freedom to create a firmware/client that suits the RDV40 features. We don't want to mess up the official pm3 repo with RDV40 specific code.
|
||||
## Why didn't you base it on official Proxmark3 Master?
|
||||
|
||||
## PM3 GUI
|
||||
The separation from official Proxmark3 repo gives us a lot of freedom to create a firmware/client that suits the RDV40 features. We don't want to mess up the official Proxmark3 repo with RDV40 specific code.
|
||||
|
||||
## Proxmark3 GUI
|
||||
The official PM3-GUI from Gaucho will not work.
|
||||
The new universal GUI will work. [Proxmark3 Universal GUI](https://github.com/burma69/PM3UniversalGUI)
|
||||
The new universal GUI will work. [Proxmark3 Universal GUI](https://github.com/burma69/PM3UniversalGUI) Almost, change needed in order to show helptext when client isn't connected to a device.
|
||||
|
||||
## Issues
|
||||
|
||||
|
@ -69,4 +71,8 @@ It's needed to have a good USB cable to connect Proxmark3 to USB. If you have st
|
|||
- updated Feb 2019 [@5w0rdfish](https://mobile.twitter.com/5w0rdFish)
|
||||
|
||||
# Donations
|
||||
Nothing says thank you as much as a donation, https://www.patreon.com/iceman1001
|
||||
Nothing says thank you as much as a donation. So if you feel the love, do feel free to become a iceman patron. For some tiers it comes with rewards.
|
||||
|
||||
https://www.patreon.com/iceman1001
|
||||
|
||||
All support is welcome!
|
||||
|
|
|
@ -30,7 +30,7 @@ SRC_ISO15693 = iso15693.c iso15693tools.c
|
|||
SRC_ISO14443a = iso14443a.c mifareutil.c mifarecmd.c epa.c mifaresim.c
|
||||
SRC_ISO14443b = iso14443b.c
|
||||
SRC_FELICA = felica.c
|
||||
SRC_CRAPTO1 = crypto1.c des.c aes.c desfire_key.c desfire_crypto.c mifaredesfire.c
|
||||
SRC_CRAPTO1 = crypto1.c des.c desfire_key.c desfire_crypto.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
|
||||
|
@ -68,41 +68,7 @@ else
|
|||
endif
|
||||
|
||||
# Generic standalone Mode injection of source code
|
||||
|
||||
|
||||
SRC_STANDALONE = placeholder.c
|
||||
# WITH_STANDALONE_LF_ICERUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_icerun.c
|
||||
endif
|
||||
# WITH_STANDALONE_LF_SAMYRUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_SAMYRUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_samyrun.c
|
||||
endif
|
||||
# WITH_STANDALONE_LF_PROXBRUTE
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_PROXBRUTE,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_proxbrute.c
|
||||
endif
|
||||
# WITH_STANDALONE_LF_HIDBRUTE
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_HIDBRUTE,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_hidbrute.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_YOUNG
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_YOUNG,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = hf_young.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_MATTYRUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_MATTYRUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = hf_mattyrun.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_COLIN
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_COLIN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = vtsend.c hf_colin.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_BOG
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_BOG,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = hf_bog.c
|
||||
endif
|
||||
include Standalone/Makefile.inc
|
||||
|
||||
#the FPGA bitstream files. Note: order matters!
|
||||
FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit
|
||||
|
|
46
armsrc/Standalone/Makefile.hal
Normal file
46
armsrc/Standalone/Makefile.hal
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Default standalone if no standalone specified
|
||||
DEFAULT_STANDALONE=LF_SAMYRUN
|
||||
HELP_EXAMPLE_STANDALONE=HF_COLIN
|
||||
# (you can set explicitly STANDALONE= to disable standalone modes)
|
||||
STANDALONE?=$(DEFAULT_STANDALONE)
|
||||
|
||||
define KNOWN_STANDALONE_DEFINITIONS
|
||||
+==========================================================+
|
||||
| STANDALONE | DESCRIPTION |
|
||||
+==========================================================+
|
||||
| | No standalone mode |
|
||||
+----------------------------------------------------------+
|
||||
| LF_SAMYRUN (def)| HID26 read/clone/sim |
|
||||
| | - Samy Kamkar |
|
||||
+----------------------------------------------------------+
|
||||
| LF_ICERUN | standalone mode skeleton |
|
||||
| | - iceman |
|
||||
+----------------------------------------------------------+
|
||||
| LF_PROXBRUTE | HID ProxII bruteforce |
|
||||
| | - Brad Antoniewicz |
|
||||
+----------------------------------------------------------+
|
||||
| LF_HIDBRUTE | HID corporate 1000 bruteforce |
|
||||
| | - Federico dotta & Maurizio Agazzini |
|
||||
+----------------------------------------------------------+
|
||||
| HF_YOUNG | Mifare sniff/simulation |
|
||||
| | - Craig Young |
|
||||
+----------------------------------------------------------+
|
||||
| HF_MATTYRUN | Mifare sniff/clone |
|
||||
| | - Matías A. Ré Medina |
|
||||
+----------------------------------------------------------+
|
||||
| HF_COLIN | Mifare ultra fast sniff/sim/clone |
|
||||
| | - Colin Brigato |
|
||||
+----------------------------------------------------------+
|
||||
| HF_BOG | 14a sniff with ULC/ULEV1/NTAG auth |
|
||||
| | storing in flashmem - Bogito |
|
||||
+----------------------------------------------------------+
|
||||
|
||||
endef
|
||||
|
||||
STANDALONE_MODES := LF_SAMYRUN LF_ICERUN LF_PROXBRUTE LF_HIDBRUTE
|
||||
STANDALONE_MODES += HF_YOUNG HF_MATTYRUN HF_COLIN HF_BOG
|
||||
ifneq ($(filter $(STANDALONE),$(STANDALONE_MODES)),)
|
||||
STANDALONE_PLATFORM_DEFS += -DWITH_STANDALONE_$(STANDALONE)
|
||||
else ifneq ($(STANDALONE),)
|
||||
$(error Invalid STANDALONE: $(STANDALONE). $(KNOWN_DEFINITIONS))
|
||||
endif
|
36
armsrc/Standalone/Makefile.inc
Normal file
36
armsrc/Standalone/Makefile.inc
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Generic standalone Mode injection of source code
|
||||
|
||||
SRC_STANDALONE = placeholder.c
|
||||
# WITH_STANDALONE_LF_ICERUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_icerun.c
|
||||
endif
|
||||
# WITH_STANDALONE_LF_SAMYRUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_SAMYRUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_samyrun.c
|
||||
endif
|
||||
# WITH_STANDALONE_LF_PROXBRUTE
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_PROXBRUTE,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_proxbrute.c
|
||||
endif
|
||||
# WITH_STANDALONE_LF_HIDBRUTE
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_HIDBRUTE,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_hidbrute.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_YOUNG
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_YOUNG,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = hf_young.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_MATTYRUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_MATTYRUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = hf_mattyrun.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_COLIN
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_COLIN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = vtsend.c hf_colin.c
|
||||
endif
|
||||
# WITH_STANDALONE_HF_BOG
|
||||
ifneq (,$(findstring WITH_STANDALONE_HF_BOG,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = hf_bog.c
|
||||
endif
|
||||
|
|
@ -15,7 +15,7 @@ The retrieved sniffing session can be acquired by connecting the device
|
|||
to a client that supports the reconnect capability and issue 'hf 14a list'.
|
||||
|
||||
In order to view the grabbed authentication attempts in the flash mem,
|
||||
you can simply run 'script run read_pwd_mem' or just 'mem read l 256'
|
||||
you can simply run 'script run read_pwd_mem' or just 'mem dump p l 256'
|
||||
from the client to view the stored quadlets.
|
||||
*/
|
||||
|
||||
|
@ -282,7 +282,7 @@ void RAMFUNC SniffAndStore(uint8_t param) {
|
|||
}
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" HF 14a sniff standalone with ULC/ULEV1/NTAG auth storing in flashmem - aka BogitoRun (Bogito)");
|
||||
DbpString(" HF 14a sniff standalone with ULC/ULEV1/NTAG auth storing in flashmem - aka BogitoRun (Bogito)");
|
||||
}
|
||||
|
||||
void RunMod() {
|
||||
|
|
|
@ -101,6 +101,8 @@ void ReadLastTagFromFlash() {
|
|||
size_t size = len;
|
||||
uint8_t *mem = BigBuf_malloc(size);
|
||||
|
||||
FlashmemSetSpiBaudrate(24000000);
|
||||
|
||||
if (!FlashInit()) {
|
||||
return;
|
||||
}
|
||||
|
@ -148,6 +150,9 @@ void WriteTagToFlash(uint8_t index, size_t size) {
|
|||
|
||||
emlGetMem(data, 0, (size * 64) / 1024);
|
||||
|
||||
|
||||
FlashmemSetSpiBaudrate(48000000);
|
||||
|
||||
if (!FlashInit()) {
|
||||
return;
|
||||
}
|
||||
|
@ -197,7 +202,7 @@ void WriteTagToFlash(uint8_t index, size_t size) {
|
|||
}
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" HF Mifare ultra fast sniff/sim/clone - aka VIGIKPWN (Colin Brigato)");
|
||||
DbpString(" HF Mifare ultra fast sniff/sim/clone - aka VIGIKPWN (Colin Brigato)");
|
||||
}
|
||||
|
||||
void RunMod() {
|
||||
|
@ -424,7 +429,7 @@ failtag:
|
|||
//-----------------------------------------------------------------------------
|
||||
// also we could avoid first UID check for every block
|
||||
|
||||
// then let’s expose this “optimal case” of “well known vigik schemes” :
|
||||
// then let's expose this “optimal case” of “well known vigik schemes” :
|
||||
for (uint8_t type = 0; type < 2 && !err && !trapped; type++) {
|
||||
for (int sec = 0; sec < sectorsCnt && !err && !trapped; ++sec) {
|
||||
key = cjat91_saMifareChkKeys(sec * 4, type, NULL, size, &keyBlock[0], &key64);
|
||||
|
@ -783,10 +788,18 @@ readysim:
|
|||
case 7:
|
||||
flags = FLAG_7B_UID_IN_DATA;
|
||||
break;
|
||||
default:
|
||||
case 4:
|
||||
flags = FLAG_4B_UID_IN_DATA;
|
||||
break;
|
||||
default:
|
||||
flags = FLAG_UID_IN_EMUL;
|
||||
break;
|
||||
}
|
||||
|
||||
// Use UID, SAK, ATQA from EMUL, if uid not defined
|
||||
//if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
|
||||
flags |= FLAG_UID_IN_EMUL;
|
||||
//}
|
||||
Mifare1ksim(flags | FLAG_MF_1K, 0, cjuid);
|
||||
LED_C_OFF();
|
||||
SpinOff(50);
|
||||
|
@ -902,7 +915,7 @@ int e_MifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
|
|||
return (isOK) ? PM3_SUCCESS : PM3_EUNDEF;
|
||||
}
|
||||
|
||||
/* the chk function is a piwi’ed(tm) check that will try all keys for
|
||||
/* the chk function is a piwi'ed(tm) check that will try all keys for
|
||||
a particular sector. also no tracing no dbg */
|
||||
int cjat91_saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, uint8_t keyCount, uint8_t *datain, uint64_t *key) {
|
||||
DBGLEVEL = DBG_NONE;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#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>
|
||||
|
|
|
@ -193,7 +193,7 @@ static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, ui
|
|||
}
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" HF Mifare sniff/clone - aka MattyRun (Matías A. Ré Medina)");
|
||||
DbpString(" HF Mifare sniff/clone - aka MattyRun (Matías A. Ré Medina)");
|
||||
}
|
||||
|
||||
void RunMod() {
|
||||
|
@ -223,6 +223,7 @@ void RunMod() {
|
|||
*/
|
||||
bool printKeys = false; // Prints keys
|
||||
bool transferToEml = true; // Transfer keys to emulator memory
|
||||
bool ecfill = true; // Fill emulator memory with cards content.
|
||||
bool simulation = true; // Simulates an exact copy of the target tag
|
||||
bool fillFromEmulator = false; // Dump emulator memory.
|
||||
|
||||
|
|
|
@ -8,18 +8,20 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// main code for HF standalone mode Mifare /sniff/emulation by Craig Young
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "hf_young.h"
|
||||
#include "common.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t uid[10];
|
||||
uint8_t uidlen;
|
||||
uint8_t atqa[2];
|
||||
uint8_t sak;
|
||||
} __attribute__((__packed__)) card_clone_t;
|
||||
} PACKED card_clone_t;
|
||||
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" HF Mifare sniff/simulation - (Craig Young)");
|
||||
DbpString(" HF Mifare sniff/simulation - (Craig Young)");
|
||||
}
|
||||
|
||||
void RunMod() {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "lf_hidbrute.h"
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF HID corporate 1000 bruteforce - aka Corporatebrute (Federico dotta & Maurizio Agazzini)");
|
||||
DbpString(" LF HID corporate 1000 bruteforce - aka Corporatebrute (Federico dotta & Maurizio Agazzini)");
|
||||
}
|
||||
|
||||
// samy's sniff and repeat routine for LF
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
#include "lf_icerun.h"
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF skeleton mode - aka IceRun (iceman)");
|
||||
DbpString(" LF skeleton mode - aka IceRun (iceman)");
|
||||
}
|
||||
|
||||
// samy's sniff and repeat routine for LF
|
||||
void RunMod() {
|
||||
StandAloneMode();
|
||||
Dbprintf("[=] LF skeleton code a.k.a IceRun started");
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "lf_proxbrute.h"
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF HID ProxII bruteforce - aka Proxbrute (Brad Antoniewicz)");
|
||||
DbpString(" LF HID ProxII bruteforce - aka Proxbrute (Brad Antoniewicz)");
|
||||
}
|
||||
|
||||
// samy's sniff and repeat routine for LF
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "lf_samyrun.h"
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF HID26 standalone - aka SamyRun (Samy Kamkar)");
|
||||
DbpString(" LF HID26 standalone - aka SamyRun (Samy Kamkar)");
|
||||
}
|
||||
|
||||
// samy's sniff and repeat routine for LF
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "apps.h" // debug statements
|
||||
|
||||
void ModInfo(void) {
|
||||
DbpString(" No standalone mode present");
|
||||
DbpString(" No standalone mode present");
|
||||
}
|
||||
|
||||
void RunMod() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# StandAlone Modes
|
||||
# Standalone Modes
|
||||
|
||||
This contains functionality for different StandAlone modes. The fullimage will be built given the correct compiler flags used. Build targets for these files are contained in `armsrc/Makefile` and `common/Makefile.hal`
|
||||
This contains functionality for different StandAlone modes. The fullimage will be built given the correct compiler flags used. Build targets for these files are contained in `Makefile.inc` and `Makefile.hal`
|
||||
|
||||
If you want to implement a new standalone mode, you need to implement the methods provided in `standalone.h`.
|
||||
Have a look at the skeleton standalone mode called IceRun, in the files `lf_icerun.c lf_icerun.h`.
|
||||
|
@ -19,7 +19,7 @@ The RunMod function, which is your "main" function when running. You need to ch
|
|||
|
||||
````
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF good description of your mode - aka FooRun (your name)");
|
||||
DbpString(" LF good description of your mode - aka FooRun (your name)");
|
||||
}
|
||||
|
||||
void RunMod(void) {
|
||||
|
@ -40,8 +40,6 @@ void RunMod(void) {
|
|||
}
|
||||
````
|
||||
|
||||
Each standalone mode needs to have its own compiler flag to be added in `armsrc/Makefile`.
|
||||
|
||||
## Naming your standalone mode
|
||||
|
||||
We suggest that you follow these guidelines:
|
||||
|
@ -58,9 +56,9 @@ This leads to your next step, your DEFINE name needed in Makefile.
|
|||
`WITH_STANDALONE_LF_FOO`
|
||||
|
||||
|
||||
## Update COMMON/MAKEFILE.HAL
|
||||
## Update MAKEFILE.HAL
|
||||
|
||||
Add your mode to the `common/Makefile.hal` help and modes list:
|
||||
Add your mode to the `Makefile.hal` help and modes list:
|
||||
```
|
||||
+==========================================================+
|
||||
| STANDALONE | DESCRIPTION |
|
||||
|
@ -74,13 +72,13 @@ STANDALONE_MODES := LF_SAMYRUN LF_ICERUN LF_PROXBRUTE LF_HIDBRUTE LF_FOO
|
|||
STANDALONE_MODES += HF_YOUNG HF_MATTYRUN HF_COLIN HF_BOG
|
||||
```
|
||||
|
||||
## Update ARMSRC/MAKEFILE
|
||||
Add your source code files like the following sample in the `armsrc/Makefile`
|
||||
## Update MAKEFILE.INC
|
||||
Add your source code files like the following sample in the `Makefile.inc`
|
||||
|
||||
```
|
||||
# WITH_STANDALONE_LF_ICERUN
|
||||
ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS)))
|
||||
SRC_STANDALONE = lf_icerun.c
|
||||
SRC_STANDALONE = lf_icerun.c
|
||||
endif
|
||||
|
||||
# WITH_STANDALONE_LF_FOO
|
||||
|
@ -95,15 +93,44 @@ This will enable an easy way to detect on client side which standalone mode has
|
|||
|
||||
````
|
||||
void ModInfo(void) {
|
||||
DbpString(" LF good description of your mode - aka FooRun (your name)");
|
||||
DbpString(" LF good description of your mode - aka FooRun (your name)");
|
||||
}
|
||||
````
|
||||
|
||||
## Compiling your standalone mode
|
||||
Once all this is done, you and others can now easily compile different standalone modes by just selecting one of the standalone modes in `common/Makefile.hal`, e.g.:
|
||||
Once all this is done, you and others can now easily compile different standalone modes by just selecting one of the standalone modes (list in `Makefile.hal` or ) , e.g.:
|
||||
|
||||
- rename Makefile.platform.sample -> Makefile.platform
|
||||
- edit the "STANDALONE" row inside Makefile.platform. You need to uncomment it and add your standalone mode name
|
||||
|
||||
Makefile.platform.sample
|
||||
```
|
||||
PLATFORM_DEFS += -DWITH_STANDALONE_LF_FOO
|
||||
# If you want to use it, copy this file as Makefile.platform and adjust it to your needs
|
||||
PLATFORM=PM3RDV4
|
||||
#PLATFORM_EXTRAS=BTADDON
|
||||
#STANDALONE=LF_SAMYRUN
|
||||
```
|
||||
becomes
|
||||
|
||||
Makefile.platform
|
||||
```
|
||||
# If you want to use it, copy this file as Makefile.platform and adjust it to your needs
|
||||
PLATFORM=PM3RDV4
|
||||
#PLATFORM_EXTRAS=BTADDON
|
||||
STANDALONE=LF_FOO
|
||||
```
|
||||
|
||||
Remember only one can be selected at a time for now.
|
||||
|
||||
The final steps is to
|
||||
- force recompilation of all code. ```make clean```
|
||||
- compile ```make -j8```
|
||||
- flash your device
|
||||
- connect to your device
|
||||
- press button long time to trigger ledshow and enter your new standalone mode
|
||||
- if connected with usb / fpc , you can also see debug statements from your device in standalone mode. Useful for debugging :)
|
||||
|
||||
When compiling you will see a header showing what configurations your project compiled with.
|
||||
Make sure it says your standalone mode name.
|
||||
|
||||
Happy hacking!
|
||||
|
|
1170
armsrc/aes.c
1170
armsrc/aes.c
File diff suppressed because it is too large
Load diff
34
armsrc/aes.h
34
armsrc/aes.h
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* AES Cryptographic Algorithm Header File. Include this header file in
|
||||
* your source which uses these given APIs. (This source is kept under
|
||||
* public domain)
|
||||
*/
|
||||
#ifndef __AES_H
|
||||
#define __AES_H
|
||||
|
||||
// AES context structure
|
||||
typedef struct {
|
||||
unsigned int Ek[60];
|
||||
unsigned int Dk[60];
|
||||
unsigned int Iv[4];
|
||||
unsigned char Nr;
|
||||
unsigned char Mode;
|
||||
} AesCtx;
|
||||
|
||||
// key length in bytes
|
||||
#define KEY128 16
|
||||
#define KEY192 24
|
||||
#define KEY256 32
|
||||
// block size in bytes
|
||||
#define BLOCKSZ 16
|
||||
// mode
|
||||
#define EBC 0
|
||||
#define CBC 1
|
||||
|
||||
// AES API function prototype
|
||||
|
||||
int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode);
|
||||
int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen);
|
||||
int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);
|
||||
|
||||
#endif
|
|
@ -13,6 +13,7 @@
|
|||
#include <inttypes.h>
|
||||
#include "usb_cdc.h"
|
||||
#include "proxmark3.h"
|
||||
#include "pmflash.h"
|
||||
#include "apps.h"
|
||||
#include "fpga.h"
|
||||
#include "util.h"
|
||||
|
@ -339,19 +340,25 @@ void SendVersion(void) {
|
|||
if (bootrom_version < &_flash_start || bootrom_version >= &_flash_end) {
|
||||
strcat(VersionString, "bootrom version information appears invalid\n");
|
||||
} else {
|
||||
FormatVersionInformation(temp, sizeof(temp), " bootrom: ", bootrom_version);
|
||||
FormatVersionInformation(temp, sizeof(temp), " bootrom: ", bootrom_version);
|
||||
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
}
|
||||
|
||||
FormatVersionInformation(temp, sizeof(temp), " os: ", &version_information);
|
||||
FormatVersionInformation(temp, sizeof(temp), " os: ", &version_information);
|
||||
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
|
||||
strncat(VersionString, "\n [ FPGA ]\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
#if defined(__clang__)
|
||||
strncat(VersionString, " compiled with Clang/LLVM "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
strncat(VersionString, " compiled with GCC "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
#endif
|
||||
|
||||
strncat(VersionString, "\n [ FPGA ]\n ", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
|
||||
for (int i = 0; i < fpga_bitstream_num; i++) {
|
||||
strncat(VersionString, fpga_version_information[i], sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
if (i < fpga_bitstream_num - 1) {
|
||||
strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
strncat(VersionString, "\n ", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
}
|
||||
}
|
||||
// Send Chip ID and used flash memory
|
||||
|
@ -368,10 +375,10 @@ void SendVersion(void) {
|
|||
struct p payload;
|
||||
payload.id = *(AT91C_DBGU_CIDR);
|
||||
payload.section_size = text_and_rodata_section_size + compressed_data_section_size;
|
||||
payload.versionstr_len = strlen(VersionString);
|
||||
memcpy(payload.versionstr, VersionString, strlen(VersionString));
|
||||
payload.versionstr_len = strlen(VersionString) + 1;
|
||||
memcpy(payload.versionstr, VersionString, payload.versionstr_len);
|
||||
|
||||
reply_ng(CMD_VERSION, PM3_SUCCESS, (uint8_t *)&payload, 12 + strlen(VersionString));
|
||||
reply_ng(CMD_VERSION, PM3_SUCCESS, (uint8_t *)&payload, 12 + payload.versionstr_len);
|
||||
}
|
||||
|
||||
// measure the Connection Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time.
|
||||
|
@ -1586,38 +1593,6 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
FlashmemSetSpiBaudrate(packet->oldarg[0]);
|
||||
break;
|
||||
}
|
||||
case CMD_FLASHMEM_READ: {
|
||||
LED_B_ON();
|
||||
uint32_t startidx = packet->oldarg[0];
|
||||
uint16_t len = packet->oldarg[1];
|
||||
|
||||
Dbprintf("FlashMem read | %d - %d | ", startidx, len);
|
||||
|
||||
size_t size = MIN(PM3_CMD_DATA_SIZE, len);
|
||||
|
||||
if (!FlashInit()) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t *mem = BigBuf_malloc(size);
|
||||
|
||||
for (size_t i = 0; i < len; i += size) {
|
||||
len = MIN((len - i), size);
|
||||
|
||||
Dbprintf("FlashMem reading | %d | %d | %d |", startidx + i, i, len);
|
||||
uint16_t isok = Flash_ReadDataCont(startidx + i, mem, len);
|
||||
if (isok == len) {
|
||||
print_result("Chunk: ", mem, len);
|
||||
} else {
|
||||
Dbprintf("FlashMem reading failed | %d | %d", len, isok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
BigBuf_free();
|
||||
FlashStop();
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
case CMD_FLASHMEM_WRITE: {
|
||||
LED_B_ON();
|
||||
uint8_t isok = 0;
|
||||
|
@ -1783,6 +1758,10 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
SendStatus();
|
||||
break;
|
||||
}
|
||||
case CMD_STANDALONE: {
|
||||
RunMod();
|
||||
break;
|
||||
}
|
||||
case CMD_CAPABILITIES: {
|
||||
SendCapabilities();
|
||||
break;
|
||||
|
|
|
@ -571,15 +571,19 @@ void mifare_cypher_single_block(desfirekey_t key, uint8_t *data, uint8_t *ivect,
|
|||
case T_AES:
|
||||
switch (operation) {
|
||||
case MCO_ENCYPHER: {
|
||||
AesCtx ctx;
|
||||
AesCtxIni(&ctx, ivect, key->data, KEY128, CBC);
|
||||
AesEncrypt(&ctx, data, edata, sizeof(edata));
|
||||
mbedtls_aes_context ctx;
|
||||
mbedtls_aes_init(&ctx);
|
||||
mbedtls_aes_setkey_enc(&ctx, key->data, 128);
|
||||
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, sizeof(edata), ivect, data, edata);
|
||||
mbedtls_aes_free(&ctx);
|
||||
break;
|
||||
}
|
||||
case MCO_DECYPHER: {
|
||||
AesCtx ctx;
|
||||
AesCtxIni(&ctx, ivect, key->data, KEY128, CBC);
|
||||
AesDecrypt(&ctx, edata, data, sizeof(edata));
|
||||
mbedtls_aes_context ctx;
|
||||
mbedtls_aes_init(&ctx);
|
||||
mbedtls_aes_setkey_dec(&ctx, key->data, 128);
|
||||
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, sizeof(edata), ivect, edata, data);
|
||||
mbedtls_aes_free(&ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "flashmem.h"
|
||||
#include "pmflash.h"
|
||||
|
||||
/* here: use NCPS2 @ PA10: */
|
||||
#define SPI_CSR_NUM 2
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#define RESUME 0x7A
|
||||
|
||||
// Flash busy timeout: 20ms is the strict minimum when writing 256kb
|
||||
#define BUSY_TIMEOUT 50000L
|
||||
#define BUSY_TIMEOUT 200000L
|
||||
|
||||
#define WINBOND_MANID 0xEF
|
||||
#define WINBOND_DEVID 0x11
|
||||
|
|
142
armsrc/hitag2.c
142
armsrc/hitag2.c
|
@ -331,64 +331,6 @@ size_t blocknr;
|
|||
// Hitag2 operations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static bool hitag2_password(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *txlen) {
|
||||
// Reset the transmission frame length
|
||||
*txlen = 0;
|
||||
|
||||
// Try to find out which command was send by selecting on length (in bits)
|
||||
switch (rxlen) {
|
||||
// No answer, try to resurrect
|
||||
case 0: {
|
||||
// Stop if there is no answer (after sending password)
|
||||
if (bPwd) {
|
||||
DbpString("Password failed!");
|
||||
return false;
|
||||
}
|
||||
*txlen = 5;
|
||||
memcpy(tx, "\xC0", nbytes(*txlen));
|
||||
}
|
||||
break;
|
||||
|
||||
// Received UID, tag password
|
||||
case 32: {
|
||||
if (!bPwd) {
|
||||
*txlen = 32;
|
||||
memcpy(tx, password, 4);
|
||||
bPwd = true;
|
||||
memcpy(tag.sectors[blocknr], rx, 4);
|
||||
blocknr++;
|
||||
} else {
|
||||
|
||||
if (blocknr == 1) {
|
||||
//store password in block1, the TAG answers with Block3, but we need the password in memory
|
||||
memcpy(tag.sectors[blocknr], tx, 4);
|
||||
} else {
|
||||
memcpy(tag.sectors[blocknr], rx, 4);
|
||||
}
|
||||
|
||||
blocknr++;
|
||||
if (blocknr > 7) {
|
||||
DbpString("Read succesful!");
|
||||
bSuccessful = true;
|
||||
return false;
|
||||
}
|
||||
*txlen = 10;
|
||||
tx[0] = 0xC0 | (blocknr << 3) | ((blocknr ^ 7) >> 2);
|
||||
tx[1] = ((blocknr ^ 7) << 6);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Unexpected response
|
||||
default: {
|
||||
Dbprintf("Uknown frame length: %d", rxlen);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool hitag2_write_page(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *txlen) {
|
||||
switch (writestate) {
|
||||
case WRITE_STATE_START:
|
||||
|
@ -431,6 +373,71 @@ static bool hitag2_write_page(uint8_t *rx, const size_t rxlen, uint8_t *tx, size
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool hitag2_password(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *txlen, bool write) {
|
||||
// Reset the transmission frame length
|
||||
*txlen = 0;
|
||||
|
||||
if (bPwd && write) {
|
||||
if (!hitag2_write_page(rx, rxlen, tx, txlen)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Try to find out which command was send by selecting on length (in bits)
|
||||
switch (rxlen) {
|
||||
// No answer, try to resurrect
|
||||
case 0: {
|
||||
// Stop if there is no answer (after sending password)
|
||||
if (bPwd) {
|
||||
DbpString("Password failed!");
|
||||
return false;
|
||||
}
|
||||
*txlen = 5;
|
||||
memcpy(tx, "\xC0", nbytes(*txlen));
|
||||
}
|
||||
break;
|
||||
|
||||
// Received UID, tag password
|
||||
case 32: {
|
||||
if (!bPwd) {
|
||||
*txlen = 32;
|
||||
memcpy(tx, password, 4);
|
||||
bPwd = true;
|
||||
memcpy(tag.sectors[blocknr], rx, 4);
|
||||
blocknr++;
|
||||
} else {
|
||||
|
||||
if (blocknr == 1) {
|
||||
//store password in block1, the TAG answers with Block3, but we need the password in memory
|
||||
memcpy(tag.sectors[blocknr], tx, 4);
|
||||
} else {
|
||||
memcpy(tag.sectors[blocknr], rx, 4);
|
||||
}
|
||||
|
||||
blocknr++;
|
||||
if (blocknr > 7) {
|
||||
DbpString("Read succesful!");
|
||||
bSuccessful = true;
|
||||
return false;
|
||||
}
|
||||
*txlen = 10;
|
||||
tx[0] = 0xC0 | (blocknr << 3) | ((blocknr ^ 7) >> 2);
|
||||
tx[1] = ((blocknr ^ 7) << 6);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Unexpected response
|
||||
default: {
|
||||
Dbprintf("Uknown frame length: %d", rxlen);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool hitag2_crypto(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *txlen, bool write) {
|
||||
// Reset the transmission frame length
|
||||
*txlen = 0;
|
||||
|
@ -739,7 +746,7 @@ void SniffHitag(void) {
|
|||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
|
||||
// synchronized startup procedure
|
||||
while (AT91C_BASE_TC0->TC_CV > 0) {}; // wait until TC0 returned to zero
|
||||
while (AT91C_BASE_TC1->TC_CV > 0) {}; // wait until TC1 returned to zero
|
||||
|
||||
// Reset the received frame, frame count and timing info
|
||||
memset(rx, 0x00, sizeof(rx));
|
||||
|
@ -887,7 +894,6 @@ void SniffHitag(void) {
|
|||
set_tracing(false);
|
||||
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
|
||||
|
||||
// release allocated memory from BigBuff.
|
||||
BigBuf_free();
|
||||
|
@ -1218,7 +1224,7 @@ void ReaderHitag(hitag_function htf, hitag_data *htd) {
|
|||
tx = txbuf;
|
||||
switch (htf) {
|
||||
case RHT2F_PASSWORD: {
|
||||
bStop = !hitag2_password(rx, rxlen, tx, &txlen);
|
||||
bStop = !hitag2_password(rx, rxlen, tx, &txlen, false);
|
||||
break;
|
||||
}
|
||||
case RHT2F_AUTHENTICATE: {
|
||||
|
@ -1392,6 +1398,16 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
|||
writestate = WRITE_STATE_START;
|
||||
}
|
||||
break;
|
||||
case WHT2F_PASSWORD: {
|
||||
DbpString("Authenticating using password:");
|
||||
memcpy(password, htd->pwd.password, 4);
|
||||
memcpy(writedata, htd->crypto.data, 4);
|
||||
Dbhexdump(4, password, false);
|
||||
blocknr = page;
|
||||
bPwd = false;
|
||||
writestate = WRITE_STATE_START;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
Dbprintf("Error, unknown function: %d", htf);
|
||||
StartTicks();
|
||||
|
@ -1481,6 +1497,10 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
|||
bStop = !hitag2_crypto(rx, rxlen, tx, &txlen, true);
|
||||
}
|
||||
break;
|
||||
case WHT2F_PASSWORD: {
|
||||
bStop = !hitag2_password(rx, rxlen, tx, &txlen, true);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
Dbprintf("Error, unknown function: %d", htf);
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "protocols.h"
|
||||
#include "usb_cdc.h" // for usb_poll_validate_length
|
||||
#include "common.h"
|
||||
#include "pmflash.h"
|
||||
#include "flashmem.h" // persistence on mem
|
||||
|
||||
//#define START_GAP 31*8 // was 250 // SPEC: 1*8 to 50*8 - typ 15*8 (15fc)
|
||||
|
|
|
@ -136,11 +136,11 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
|
|||
uint32_t sample_total_numbers = 0;
|
||||
uint32_t sample_total_saved = 0;
|
||||
uint32_t cancel_counter = 0;
|
||||
|
||||
|
||||
uint16_t checker = 0;
|
||||
|
||||
|
||||
while (true) {
|
||||
if ( checker == 1000 ) {
|
||||
if (checker == 1000) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
break;
|
||||
else
|
||||
|
@ -148,7 +148,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
|
|||
} else {
|
||||
++checker;
|
||||
}
|
||||
|
||||
|
||||
WDT_HIT();
|
||||
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
||||
|
@ -293,11 +293,11 @@ void doT55x7Acquisition(size_t sample_size) {
|
|||
bool startFound = false;
|
||||
bool highFound = false;
|
||||
bool lowFound = false;
|
||||
|
||||
|
||||
uint16_t checker = 0;
|
||||
|
||||
while ( skipCnt < 1000 && (i < bufsize)) {
|
||||
if ( checker == 1000 ) {
|
||||
|
||||
while (skipCnt < 1000 && (i < bufsize)) {
|
||||
if (checker == 1000) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
break;
|
||||
else
|
||||
|
@ -371,9 +371,9 @@ void doCotagAcquisition(size_t sample_size) {
|
|||
uint16_t noise_counter = 0;
|
||||
|
||||
uint16_t checker = 0;
|
||||
|
||||
|
||||
while ((i < bufsize) && (noise_counter < (COTAG_T1 << 1))) {
|
||||
if ( checker == 1000 ) {
|
||||
if (checker == 1000) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
break;
|
||||
else
|
||||
|
@ -431,9 +431,9 @@ uint32_t doCotagAcquisitionManchester() {
|
|||
uint8_t curr = 0, prev = 0;
|
||||
uint16_t noise_counter = 0;
|
||||
uint16_t checker = 0;
|
||||
|
||||
|
||||
while ((sample_counter < bufsize) && (noise_counter < (COTAG_T1 << 1))) {
|
||||
if ( checker == 1000 ) {
|
||||
if (checker == 1000) {
|
||||
if (BUTTON_PRESS() || data_available())
|
||||
break;
|
||||
else
|
||||
|
|
|
@ -14,8 +14,11 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "mifarecmd.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "pmflash.h"
|
||||
|
||||
#ifndef HARDNESTED_AUTHENTICATION_TIMEOUT
|
||||
# define HARDNESTED_AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation)
|
||||
#endif
|
||||
|
|
|
@ -433,15 +433,9 @@ void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
desfirekey_t key = &defaultkey;
|
||||
Desfire_aes_key_new(keybytes, key);
|
||||
|
||||
AesCtx ctx;
|
||||
mbedtls_aes_context ctx;
|
||||
uint8_t IV[16] = {0x00};
|
||||
if (AesCtxIni(&ctx, IV, key->data, KEY128, CBC) < 0) {
|
||||
if (DBGLEVEL >= 4) {
|
||||
DbpString("AES context failed to init");
|
||||
}
|
||||
OnError(7);
|
||||
return;
|
||||
}
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
cmd[0] = AUTHENTICATE_AES;
|
||||
cmd[1] = 0x00; //keynumber
|
||||
|
@ -457,13 +451,27 @@ void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
memcpy(encRndB, resp + 3, 16);
|
||||
|
||||
// dekryptera tagnonce.
|
||||
AesDecrypt(&ctx, encRndB, decRndB, 16);
|
||||
if (mbedtls_aes_setkey_dec(&ctx, key->data, 128) != 0) {
|
||||
if (DBGLEVEL >= 4) {
|
||||
DbpString("mbedtls_aes_setkey_dec failed");
|
||||
}
|
||||
OnError(7);
|
||||
return;
|
||||
}
|
||||
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, 16, IV, encRndB, decRndB);
|
||||
rol(decRndB, 16);
|
||||
uint8_t nonce[16] = {0x00};
|
||||
memcpy(both, nonce, 16);
|
||||
memcpy(both + 16, decRndB, 16);
|
||||
uint8_t encBoth[32] = {0x00};
|
||||
AesEncrypt(&ctx, both, encBoth, 32);
|
||||
if (mbedtls_aes_setkey_enc(&ctx, key->data, 128) != 0) {
|
||||
if (DBGLEVEL >= 4) {
|
||||
DbpString("mbedtls_aes_setkey_enc failed");
|
||||
}
|
||||
OnError(7);
|
||||
return;
|
||||
}
|
||||
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, 32, IV, both, encBoth);
|
||||
|
||||
cmd[0] = ADDITIONAL_FRAME;
|
||||
memcpy(cmd + 1, encBoth, 32);
|
||||
|
|
|
@ -606,8 +606,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
|
|||
if (receivedCmd_len == 9 && receivedCmd[1] == 0x70) {
|
||||
if (memcmp(&receivedCmd[2], responses[uid_index].response, 4) == 0) {
|
||||
bool cl_finished = (uid_len == 4 && uid_index == UIDBCC1) ||
|
||||
(uid_len == 7 && uid_index == UIDBCC2) ||
|
||||
(uid_len == 10 && uid_index == UIDBCC3);
|
||||
(uid_len == 7 && uid_index == UIDBCC2) ||
|
||||
(uid_len == 10 && uid_index == UIDBCC3);
|
||||
EmSendPrecompiledCmd(&responses[cl_finished ? SAK : SAKuid]);
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("SELECT CLx %02x%02x%02x%02x received", receivedCmd[2], receivedCmd[3], receivedCmd[4], receivedCmd[5]);
|
||||
if (cl_finished) {
|
||||
|
@ -625,7 +625,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
|
|||
}
|
||||
|
||||
// Incoming anti-collision frame
|
||||
if (receivedCmd_len >= 2 && receivedCmd_len <= 6 && receivedCmd[1] == 0x50) {
|
||||
// receivedCmd[1] indicates number of byte and bit collision, supports only for bit collision is zero
|
||||
if (receivedCmd_len >= 3 && receivedCmd_len <= 6 && (receivedCmd[1] & 0x0f) == 0) {
|
||||
// we can process only full-byte frame anti-collision procedure
|
||||
if (memcmp(&receivedCmd[2], responses[uid_index].response, receivedCmd_len - 2) == 0) {
|
||||
// response missing part of UID via relative array index
|
||||
|
@ -1036,8 +1037,9 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
|
|||
);
|
||||
}
|
||||
cardAUTHKEY = AUTHKEYNONE; // not authenticated
|
||||
EmSend4bit(mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA));
|
||||
cardSTATE_TO_IDLE();
|
||||
// Really tags not respond NACK on invalid authentication
|
||||
LogTrace(uart->output, uart->len, uart->startTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->endTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->parity, true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,8 +122,10 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
|||
switch (c->cmd) {
|
||||
case CMD_DEVICE_INFO: {
|
||||
dont_ack = 1;
|
||||
arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM |
|
||||
DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH;
|
||||
arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT |
|
||||
DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM |
|
||||
DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH |
|
||||
DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO;
|
||||
if (common_area.flags.osimage_present)
|
||||
arg0 |= DEVICE_INFO_FLAG_OSIMAGE_PRESENT;
|
||||
|
||||
|
@ -131,6 +133,13 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
|||
}
|
||||
break;
|
||||
|
||||
case CMD_CHIP_INFO: {
|
||||
dont_ack = 1;
|
||||
arg0 = *(AT91C_DBGU_CIDR);
|
||||
reply_old(CMD_CHIP_INFO, arg0, 0, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_SETUP_WRITE: {
|
||||
/* The temporary write buffer of the embedded flash controller is mapped to the
|
||||
* whole memory region, only the last 8 bits are decoded.
|
||||
|
|
|
@ -31,7 +31,19 @@ platform = $(shell uname)
|
|||
VPATH = ../common ../zlib ../uart
|
||||
OBJDIR = obj
|
||||
|
||||
LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm
|
||||
LDLIBS =
|
||||
ifneq ($(platform),Darwin)
|
||||
LDLIBS += -L/opt/local/lib
|
||||
endif
|
||||
LDLIBS += -L/usr/local/lib -lreadline -lpthread -lm
|
||||
|
||||
# RPi Zero gcc requires -latomic
|
||||
# but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
|
||||
# doesn't recognize option --as-needed
|
||||
ifneq ($(platform),Darwin)
|
||||
LDLIBS += -Wl,--as-needed -latomic -Wl,--no-as-needed
|
||||
endif
|
||||
|
||||
LUALIB = ../liblua/liblua.a
|
||||
JANSSONLIBPATH = ./jansson
|
||||
JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
|
||||
|
|
|
@ -623,8 +623,7 @@ static int CmdAnalyseA(const char *Cmd) {
|
|||
for (uint8_t k=0; k<4; k = (k+1) % 4 ) {
|
||||
PrintAndLogEx(NORMAL, "\e[s%c\e[u", star[k]);
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar(); (void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
|
|||
//set model
|
||||
c = mbynam(&model, inModel);
|
||||
if (!c) {
|
||||
PrintAndLogEx(WARNING, "error: preset model '%s' not found. Use reveng -D to list presets. [%d]", inModel, c);
|
||||
PrintAndLogEx(ERR, "error: preset model '%s' not found. Use reveng -D to list presets. [%d]", inModel, c);
|
||||
return 0;
|
||||
}
|
||||
if (c < 0) {
|
||||
|
|
|
@ -602,7 +602,7 @@ static int Cmdmandecoderaw(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (high > 7 || low < 0) {
|
||||
PrintAndLogEx(WARNING, "Error: please raw demod the wave first then manchester raw decode");
|
||||
PrintAndLogEx(ERR, "Error: please raw demod the wave first then manchester raw decode");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ static int Cmdmandecoderaw(const char *Cmd) {
|
|||
uint8_t alignPos = 0;
|
||||
errCnt = manrawdecode(bits, &size, invert, &alignPos);
|
||||
if (errCnt >= maxErr) {
|
||||
PrintAndLogEx(WARNING, "Too many errors: %u", errCnt);
|
||||
PrintAndLogEx(ERR, "Too many errors: %u", errCnt);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -658,11 +658,11 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) {
|
|||
|
||||
errCnt = BiphaseRawDecode(bits, &size, &offset, invert);
|
||||
if (errCnt < 0) {
|
||||
PrintAndLogEx(WARNING, "Error during decode:%d", errCnt);
|
||||
PrintAndLogEx(ERR, "Error during decode:%d", errCnt);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (errCnt > maxErr) {
|
||||
PrintAndLogEx(WARNING, "Too many errors attempting to decode: %d", errCnt);
|
||||
PrintAndLogEx(ERR, "Too many errors attempting to decode: %d", errCnt);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ int CmdPSK1rawDemod(const char *Cmd) {
|
|||
int ans = PSKDemod(Cmd, true);
|
||||
//output
|
||||
if (ans != PM3_SUCCESS) {
|
||||
if (g_debugMode) PrintAndLogEx(WARNING, "Error demoding: %d", ans);
|
||||
if (g_debugMode) PrintAndLogEx(ERR, "Error demoding: %d", ans);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "PSK1 demoded bitstream:");
|
||||
|
@ -1307,7 +1307,7 @@ static int CmdPSK2rawDemod(const char *Cmd) {
|
|||
|
||||
int ans = PSKDemod(Cmd, true);
|
||||
if (ans != PM3_SUCCESS) {
|
||||
if (g_debugMode) PrintAndLogEx(WARNING, "Error demoding: %d", ans);
|
||||
if (g_debugMode) PrintAndLogEx(ERR, "Error demoding: %d", ans);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
|
|
|
@ -37,17 +37,6 @@ static int usage_flashmem_spibaud(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_flashmem_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Read flash memory on device");
|
||||
PrintAndLogEx(NORMAL, "Usage: mem read o <offset> l <len>");
|
||||
PrintAndLogEx(NORMAL, " o <offset> : offset in memory");
|
||||
PrintAndLogEx(NORMAL, " l <len> : length");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " mem read o 0 l 32"); // read 32 bytes starting at offset 0
|
||||
PrintAndLogEx(NORMAL, " mem read o 1024 l 10"); // read 10 bytes starting at offset 1024
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_flashmem_load(void) {
|
||||
PrintAndLogEx(NORMAL, "Loads binary file into flash memory on device");
|
||||
PrintAndLogEx(NORMAL, "Usage: mem load [o <offset>] f <file name> [m|t|i]");
|
||||
|
@ -67,17 +56,19 @@ static int usage_flashmem_load(void) {
|
|||
PrintAndLogEx(NORMAL, " mem load f default_iclass_keys i");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_flashmem_save(void) {
|
||||
PrintAndLogEx(NORMAL, "Saves flash memory on device into the file");
|
||||
PrintAndLogEx(NORMAL, " Usage: mem save [o <offset>] [l <length>] f <file name>");
|
||||
static int usage_flashmem_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "Dumps flash memory on device into a file or in console");
|
||||
PrintAndLogEx(NORMAL, " Usage: mem dump [o <offset>] [l <length>] [f <file name>] [p]");
|
||||
PrintAndLogEx(NORMAL, " o <offset> : offset in memory");
|
||||
PrintAndLogEx(NORMAL, " l <length> : length");
|
||||
PrintAndLogEx(NORMAL, " f <filename> : file name");
|
||||
PrintAndLogEx(NORMAL, " p : print dump in console");
|
||||
PrintAndLogEx(NORMAL, " You must specify at lease option f or option p, both if you wish");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " mem save f myfile"); // download whole flashmem to file myfile
|
||||
PrintAndLogEx(NORMAL, " mem save f myfile l 4096"); // download 4096 bytes from default offset 0 to file myfile
|
||||
PrintAndLogEx(NORMAL, " mem save f myfile o 1024 l 4096"); // downlowd 4096 bytes from offset 1024 to file myfile
|
||||
PrintAndLogEx(NORMAL, " mem dump f myfile"); // download whole flashmem to file myfile
|
||||
PrintAndLogEx(NORMAL, " mem dump p o 262015 l 128"); // display 128 bytes from offset 262015 (RSA sig)
|
||||
PrintAndLogEx(NORMAL, " mem dump p f myfile o 241664 l 58"); // download and display 58 bytes from offset 241664 to file myfile
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_flashmem_wipe(void) {
|
||||
|
@ -105,46 +96,6 @@ static int usage_flashmem_info(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdFlashMemRead(const char *Cmd) {
|
||||
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
uint32_t start_index = 0, len = 0;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'o':
|
||||
start_index = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'l':
|
||||
len = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'h':
|
||||
return usage_flashmem_read();
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Validations
|
||||
if (errors || cmdp == 0) {
|
||||
usage_flashmem_read();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (start_index + len > FLASH_MEM_MAX_SIZE) {
|
||||
PrintAndLogDevice(WARNING, "error, start_index + length is larger than available memory");
|
||||
return PM3_EOVFLOW;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_FLASHMEM_READ, start_index, len, 0, NULL, 0);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdFlashmemSpiBaudrate(const char *Cmd) {
|
||||
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
|
@ -258,7 +209,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (datalen > FLASH_MEM_MAX_SIZE) {
|
||||
PrintAndLogDevice(WARNING, "error, filesize is larger than available memory");
|
||||
PrintAndLogDevice(ERR, "error, filesize is larger than available memory");
|
||||
free(data);
|
||||
return PM3_EOVFLOW;
|
||||
}
|
||||
|
@ -311,17 +262,18 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Wrote "_GREEN_("%u")"bytes to offset "_GREEN_("%u"), datalen, start_index);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int CmdFlashMemSave(const char *Cmd) {
|
||||
static int CmdFlashMemDump(const char *Cmd) {
|
||||
|
||||
char filename[FILE_PATH_SIZE] = {0};
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
bool print = false;
|
||||
uint32_t start_index = 0, len = FLASH_MEM_MAX_SIZE;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_flashmem_save();
|
||||
return usage_flashmem_dump();
|
||||
case 'l':
|
||||
len = param_get32ex(Cmd, cmdp + 1, FLASH_MEM_MAX_SIZE, 10);
|
||||
cmdp += 2;
|
||||
|
@ -330,6 +282,10 @@ static int CmdFlashMemSave(const char *Cmd) {
|
|||
start_index = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'p':
|
||||
print = true;
|
||||
cmdp += 1;
|
||||
break;
|
||||
case 'f':
|
||||
//File handling
|
||||
if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) {
|
||||
|
@ -348,13 +304,13 @@ static int CmdFlashMemSave(const char *Cmd) {
|
|||
|
||||
//Validations
|
||||
if (errors || cmdp == 0) {
|
||||
usage_flashmem_save();
|
||||
usage_flashmem_dump();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint8_t *dump = calloc(len, sizeof(uint8_t));
|
||||
if (!dump) {
|
||||
PrintAndLogDevice(WARNING, "error, cannot allocate memory ");
|
||||
PrintAndLogDevice(ERR, "error, cannot allocate memory ");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
@ -365,8 +321,15 @@ static int CmdFlashMemSave(const char *Cmd) {
|
|||
return PM3_EFLASH;
|
||||
}
|
||||
|
||||
saveFile(filename, ".bin", dump, len);
|
||||
saveFileEML(filename, dump, len, 16);
|
||||
if (print) {
|
||||
print_hex_break(dump, len, 32);
|
||||
}
|
||||
|
||||
if (filename[0] != '\0') {
|
||||
saveFile(filename, ".bin", dump, len);
|
||||
saveFileEML(filename, dump, len, 16);
|
||||
}
|
||||
|
||||
free(dump);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -612,10 +575,9 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"spibaud", CmdFlashmemSpiBaudrate, IfPm3Flash, "Set Flash memory Spi baudrate [rdv40]"},
|
||||
{"read", CmdFlashMemRead, IfPm3Flash, "Read Flash memory [rdv40]"},
|
||||
{"info", CmdFlashMemInfo, IfPm3Flash, "Flash memory information [rdv40]"},
|
||||
{"load", CmdFlashMemLoad, IfPm3Flash, "Load data into flash memory [rdv40]"},
|
||||
{"save", CmdFlashMemSave, IfPm3Flash, "Save data from flash memory [rdv40]"},
|
||||
{"dump", CmdFlashMemDump, IfPm3Flash, "Dump data from flash memory [rdv40]"},
|
||||
{"wipe", CmdFlashMemWipe, IfPm3Flash, "Wipe data from flash memory [rdv40]"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "pmflash.h"
|
||||
#include "common.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "util_posix.h" // msclock
|
||||
#include "loclass/fileutils.h" //saveFile
|
||||
|
|
|
@ -40,7 +40,7 @@ static int usage_hf_sniff() {
|
|||
static int usage_hf_tune() {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf tune [<iter>]");
|
||||
PrintAndLogEx(NORMAL, "Continuously measure HF antenna tuning.");
|
||||
PrintAndLogEx(NORMAL, "Press button or keyboard to interrupt.");
|
||||
PrintAndLogEx(NORMAL, "Press button or Enter to interrupt.");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " <iter> - number of iterations (default: infinite)");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
@ -98,7 +98,7 @@ int CmdHFTune(const char *Cmd) {
|
|||
int iter = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
PacketResponseNG resp;
|
||||
PrintAndLogEx(SUCCESS, "Measuring HF antenna, click button or press a key to exit");
|
||||
PrintAndLogEx(SUCCESS, "Measuring HF antenna, click button or press Enter to exit");
|
||||
clearCommandBuffer();
|
||||
uint8_t mode[] = {1};
|
||||
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));
|
||||
|
@ -109,9 +109,7 @@ int CmdHFTune(const char *Cmd) {
|
|||
mode[0] = 2;
|
||||
// loop forever (till button pressed) if iter = 0 (default)
|
||||
for (uint8_t i = 0; iter == 0 || i < iter; i++) {
|
||||
if (ukbhit()) { // abort by keyboard press
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) { // abort by keyboard press
|
||||
break;
|
||||
}
|
||||
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));
|
||||
|
|
|
@ -375,9 +375,7 @@ static int CmdHF14ACUIDs(const char *Cmd) {
|
|||
// repeat n times
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\n[!] aborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
@ -489,7 +487,7 @@ int CmdHF14ASim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
||||
|
||||
while (!ukbhit()) {
|
||||
while (!kbd_enter_pressed()) {
|
||||
if (WaitForResponseTimeout(CMD_SIMULATE_MIFARE_CARD, &resp, 1500) == 0) continue;
|
||||
if (resp.status != PM3_SUCCESS) break;
|
||||
|
||||
|
@ -800,7 +798,7 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
|
|||
vActivateField = false;
|
||||
if (*dataoutlen) {
|
||||
if (clen != datainlen)
|
||||
PrintAndLogEx(WARNING, "APDU: I-block/R-block sequence error. Data len=%d, Sent=%d, Last packet len=%d", datainlen, clen, *dataoutlen);
|
||||
PrintAndLogEx(ERR, "APDU: I-block/R-block sequence error. Data len=%d, Sent=%d, Last packet len=%d", datainlen, clen, *dataoutlen);
|
||||
break;
|
||||
}
|
||||
} while (clen < datainlen);
|
||||
|
@ -836,20 +834,33 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
|
|||
static int CmdHF14AAPDU(const char *Cmd) {
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
int datalen = 0;
|
||||
uint8_t header[PM3_CMD_DATA_SIZE];
|
||||
int headerlen = 0;
|
||||
bool activateField = false;
|
||||
bool leaveSignalON = false;
|
||||
bool decodeTLV = false;
|
||||
bool decodeAPDU = false;
|
||||
bool makeAPDU = false;
|
||||
bool extendedAPDU = false;
|
||||
int le = 0;
|
||||
|
||||
CLIParserInit("hf 14a apdu",
|
||||
"Sends an ISO 7816-4 APDU via ISO 14443-4 block transmission protocol (T=CL)",
|
||||
"Sample:\n\thf 14a apdu -st 00A404000E325041592E5359532E444446303100\n");
|
||||
"Sends an ISO 7816-4 APDU via ISO 14443-4 block transmission protocol (T=CL). works with all apdu types from ISO 7816-4:2013",
|
||||
"Sample:\n\thf 14a apdu -st 00A404000E325041592E5359532E444446303100\n"
|
||||
"\thf 14a apdu -sd 00A404000E325041592E5359532E444446303100 - decode apdu\n"
|
||||
"\thf 14a apdu -sm 00A40400 325041592E5359532E4444463031 -l 256 - encode standard apdu\n"
|
||||
"\thf 14a apdu -sm 00A40400 325041592E5359532E4444463031 -el 65536 - encode extended apdu\n");
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("sS", "select", "activate field and select card"),
|
||||
arg_lit0("kK", "keep", "leave the signal field ON after receive response"),
|
||||
arg_lit0("tT", "tlv", "executes TLV decoder if it possible"),
|
||||
arg_strx1(NULL, NULL, "<APDU (hex)>", NULL),
|
||||
arg_lit0("sS", "select", "activate field and select card"),
|
||||
arg_lit0("kK", "keep", "leave the signal field ON after receive response"),
|
||||
arg_lit0("tT", "tlv", "executes TLV decoder if it possible"),
|
||||
arg_lit0("dD", "decapdu", "decode apdu request if it possible"),
|
||||
arg_str0("mM", "make", "<head (CLA INS P1 P2) hex>", "make apdu with head from this field and data from data field. Must be 4 bytes length: <CLA INS P1 P2>"),
|
||||
arg_lit0("eE", "extended", "make extended length apdu if `m` parameter included"),
|
||||
arg_int0("lL", "le", "<Le (int)>", "Le apdu parameter if `m` parameter included"),
|
||||
arg_strx1(NULL, NULL, "<APDU (hex) | data (hex)>", "data if `m` parameter included"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(Cmd, argtable, false);
|
||||
|
@ -857,12 +868,66 @@ static int CmdHF14AAPDU(const char *Cmd) {
|
|||
activateField = arg_get_lit(1);
|
||||
leaveSignalON = arg_get_lit(2);
|
||||
decodeTLV = arg_get_lit(3);
|
||||
// len = data + PCB(1b) + CRC(2b)
|
||||
CLIGetHexBLessWithReturn(4, data, &datalen, 1 + 2);
|
||||
decodeAPDU = arg_get_lit(4);
|
||||
|
||||
CLIGetHexWithReturn(5, header, &headerlen);
|
||||
makeAPDU = headerlen > 0;
|
||||
if (makeAPDU && headerlen != 4) {
|
||||
PrintAndLogEx(ERR, "header length must be 4 bytes instead of %d", headerlen);
|
||||
return 1;
|
||||
}
|
||||
extendedAPDU = arg_get_lit(6);
|
||||
le = arg_get_int_def(7, 0);
|
||||
|
||||
if (makeAPDU) {
|
||||
uint8_t apdudata[PM3_CMD_DATA_SIZE] = {0};
|
||||
int apdudatalen = 0;
|
||||
|
||||
CLIGetHexBLessWithReturn(8, apdudata, &apdudatalen, 1 + 2);
|
||||
|
||||
APDUStruct apdu;
|
||||
apdu.cla = header[0];
|
||||
apdu.ins = header[1];
|
||||
apdu.p1 = header[2];
|
||||
apdu.p2 = header[3];
|
||||
|
||||
apdu.lc = apdudatalen;
|
||||
apdu.data = apdudata;
|
||||
|
||||
apdu.extended_apdu = extendedAPDU;
|
||||
apdu.le = le;
|
||||
|
||||
if (APDUEncode(&apdu, data, &datalen)) {
|
||||
PrintAndLogEx(ERR, "can't make apdu with provided parameters.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (extendedAPDU) {
|
||||
PrintAndLogEx(ERR, "make mode not set but here `e` option.");
|
||||
return 3;
|
||||
}
|
||||
if (le > 0) {
|
||||
PrintAndLogEx(ERR, "make mode not set but here `l` option.");
|
||||
return 3;
|
||||
}
|
||||
|
||||
// len = data + PCB(1b) + CRC(2b)
|
||||
CLIGetHexBLessWithReturn(8, data, &datalen, 1 + 2);
|
||||
}
|
||||
|
||||
CLIParserFree();
|
||||
PrintAndLogEx(NORMAL, ">>>>[%s%s%s] %s", activateField ? "sel " : "", leaveSignalON ? "keep " : "", decodeTLV ? "TLV" : "", sprint_hex(data, datalen));
|
||||
|
||||
if (decodeAPDU) {
|
||||
APDUStruct apdu;
|
||||
|
||||
if (APDUDecode(data, datalen, &apdu) == 0)
|
||||
APDUPrint(apdu);
|
||||
else
|
||||
PrintAndLogEx(WARNING, "can't decode APDU.");
|
||||
}
|
||||
|
||||
int res = ExchangeAPDU14a(data, datalen, activateField, leaveSignalON, data, PM3_CMD_DATA_SIZE, &datalen);
|
||||
|
||||
if (res)
|
||||
|
|
117
client/cmdhf15.c
117
client/cmdhf15.c
|
@ -407,6 +407,17 @@ static int usage_15_readmulti(void) {
|
|||
"\tcount#: number of pages");
|
||||
return 0;
|
||||
}
|
||||
static int usage_15_csetuid(void) {
|
||||
PrintAndLogEx(NORMAL, "Set UID for magic Chinese card (only works with such cards)\n"
|
||||
"\n"
|
||||
"Usage: hf 15 csetuid <uid>\n"
|
||||
"Options:\n"
|
||||
"\tuid : <8B hex> full UID eg E011223344556677\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
"\thf 15 csetuid E011223344556677");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses common HF 15 CMD parameters and prepares some data structures
|
||||
|
@ -553,7 +564,7 @@ static int CmdHF15Demod(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (mask != 0x01) {
|
||||
PrintAndLogEx(WARNING, "Error, uneven octet! (discard extra bits!)");
|
||||
PrintAndLogEx(WARNING, "Warning, uneven octet! (discard extra bits!)");
|
||||
PrintAndLogEx(NORMAL, " mask = %02x", mask);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "%d octets", k);
|
||||
|
@ -623,7 +634,7 @@ static int CmdHF15Info(const char *Cmd) {
|
|||
recv = resp.data.asBytes;
|
||||
|
||||
if (recv[0] & ISO15_RES_ERROR) {
|
||||
PrintAndLogEx(WARNING, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
PrintAndLogEx(ERR, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1069,7 @@ static int CmdHF15Read(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (recv[0] & ISO15_RES_ERROR) {
|
||||
PrintAndLogEx(WARNING, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
PrintAndLogEx(ERR, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -1235,7 +1246,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
|||
fclose(f);
|
||||
return 0;
|
||||
} else if (bytes_read != blocksize) {
|
||||
PrintAndLogEx(WARNING, "File reading error (%s), %u bytes read instead of %u bytes.", filename, bytes_read, blocksize);
|
||||
PrintAndLogEx(ERR, "File reading error (%s), %u bytes read instead of %u bytes.", filename, bytes_read, blocksize);
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
|
@ -1269,6 +1280,103 @@ static int CmdHF15Restore(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commandline handling: HF15 CMD CSETUID
|
||||
* Set UID for magic Chinese card
|
||||
*/
|
||||
static int CmdHF15CSetUID(const char *Cmd) {
|
||||
uint8_t uid[8] = {0x00};
|
||||
uint8_t oldUid[8], newUid[8] = {0x00};
|
||||
PacketResponseNG resp;
|
||||
int reply = 1, fast = 0;
|
||||
uint8_t data[4][9] = {{0x00}};
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 1 || cmdp == 'h') return usage_15_csetuid();
|
||||
|
||||
if (param_gethex(Cmd, 0, uid, 16)) {
|
||||
PrintAndLogEx(WARNING, "UID must include 16 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (uid[0] != 0xe0) {
|
||||
PrintAndLogEx(WARNING, "UID must begin with the byte " _YELLOW_("E0"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "new UID | %s", sprint_hex(uid, sizeof(uid)));
|
||||
PrintAndLogEx(NORMAL, "Using backdoor Magic tag function");
|
||||
|
||||
if (!getUID(oldUid)) {
|
||||
PrintAndLogEx(FAILED, "Can't get old UID.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// Command 1 : 02213E00000000
|
||||
data[0][0] = 0x02;
|
||||
data[0][1] = 0x21;
|
||||
data[0][2] = 0x3e;
|
||||
data[0][3] = 0x00;
|
||||
data[0][4] = 0x00;
|
||||
data[0][5] = 0x00;
|
||||
data[0][6] = 0x00;
|
||||
|
||||
// Command 2 : 02213F69960000
|
||||
data[1][0] = 0x02;
|
||||
data[1][1] = 0x21;
|
||||
data[1][2] = 0x3f;
|
||||
data[1][3] = 0x69;
|
||||
data[1][4] = 0x96;
|
||||
data[1][5] = 0x00;
|
||||
data[1][6] = 0x00;
|
||||
|
||||
// Command 3 : 022138u8u7u6u5 (where uX = uid byte X)
|
||||
data[2][0] = 0x02;
|
||||
data[2][1] = 0x21;
|
||||
data[2][2] = 0x38;
|
||||
data[2][3] = uid[7];
|
||||
data[2][4] = uid[6];
|
||||
data[2][5] = uid[5];
|
||||
data[2][6] = uid[4];
|
||||
|
||||
// Command 4 : 022139u4u3u2u1 (where uX = uid byte X)
|
||||
data[3][0] = 0x02;
|
||||
data[3][1] = 0x21;
|
||||
data[3][2] = 0x39;
|
||||
data[3][3] = uid[3];
|
||||
data[3][4] = uid[2];
|
||||
data[3][5] = uid[1];
|
||||
data[3][6] = uid[0];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
AddCrc15(data[i], 7);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_ISO_15693_COMMAND, sizeof(data[i]), fast, reply, data[i], sizeof(data[i]));
|
||||
|
||||
if (reply) {
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
uint8_t len = resp.oldarg[0];
|
||||
PrintAndLogEx(NORMAL, "received %i octets", len);
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!getUID(newUid)) {
|
||||
PrintAndLogEx(FAILED, "Can't get new UID.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "old UID : %02X %02X %02X %02X %02X %02X %02X %02X", oldUid[7], oldUid[6], oldUid[5], oldUid[4], oldUid[3], oldUid[2], oldUid[1], oldUid[0]);
|
||||
PrintAndLogEx(SUCCESS, "new UID : %02X %02X %02X %02X %02X %02X %02X %02X", newUid[7], newUid[6], newUid[5], newUid[4], newUid[3], newUid[2], newUid[1], newUid[0]);
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHF15Help, AlwaysAvailable, "This help"},
|
||||
{"demod", CmdHF15Demod, AlwaysAvailable, "Demodulate ISO15693 from tag"},
|
||||
|
@ -1285,6 +1393,7 @@ static command_t CommandTable[] = {
|
|||
{"read", CmdHF15Read, IfPm3Iso15693, "Read a block"},
|
||||
{"write", CmdHF15Write, IfPm3Iso15693, "Write a block"},
|
||||
{"readmulti", CmdHF15Readmulti, IfPm3Iso15693, "Reads multiple Blocks"},
|
||||
{"csetuid", CmdHF15CSetUID, IfPm3Iso15693, "Set UID for magic Chinese card"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ static int CmdHFFelicaSim(const char *Cmd) {
|
|||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "Press pm3-button to abort simulation");
|
||||
|
||||
while (!ukbhit()) {
|
||||
while (!kbd_enter_pressed()) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
}
|
||||
return 0;
|
||||
|
@ -357,9 +357,7 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
|||
timeout++;
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\n[!] aborted via keyboard!\n");
|
||||
DropField();
|
||||
return 1;
|
||||
|
|
|
@ -176,7 +176,7 @@ static int usage_hf_iclass_managekeys(void) {
|
|||
return 0;
|
||||
}
|
||||
static int usage_hf_iclass_reader(void) {
|
||||
PrintAndLogEx(NORMAL, "Act as a Iclass reader. Look for iClass tags until a key or the pm3 button is pressed\n");
|
||||
PrintAndLogEx(NORMAL, "Act as a Iclass reader. Look for iClass tags until Enter or the pm3 button is pressed\n");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf iclass reader [h] [1]\n");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h This help text");
|
||||
|
@ -376,16 +376,14 @@ static int CmdHFiClassSim(const char *Cmd) {
|
|||
|
||||
case 2: {
|
||||
PrintAndLogEx(INFO, "Starting iCLASS sim 2 attack (elite mode)");
|
||||
PrintAndLogEx(INFO, "press keyboard to cancel");
|
||||
PrintAndLogEx(INFO, "press Enter to cancel");
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_SIMULATE_TAG_ICLASS, simType, NUM_CSNS, 0, csns, 8 * NUM_CSNS);
|
||||
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
tries++;
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -427,16 +425,14 @@ static int CmdHFiClassSim(const char *Cmd) {
|
|||
case 4: {
|
||||
// reader in key roll mode, when it has two keys it alternates when trying to verify.
|
||||
PrintAndLogEx(INFO, "Starting iCLASS sim 4 attack (elite mode, reader in key roll mode)");
|
||||
PrintAndLogEx(INFO, "press keyboard to cancel");
|
||||
PrintAndLogEx(INFO, "press Enter to cancel");
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_SIMULATE_TAG_ICLASS, simType, NUM_CSNS, 0, csns, 8 * NUM_CSNS);
|
||||
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
tries++;
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -554,14 +550,14 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
|||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogDevice(WARNING, "error, when getting filesize");
|
||||
PrintAndLogDevice(ERR, "error, when getting filesize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t *dump = calloc(fsize, sizeof(uint8_t));
|
||||
if (!dump) {
|
||||
PrintAndLogDevice(WARNING, "error, cannot allocate memory ");
|
||||
PrintAndLogDevice(ERR, "error, cannot allocate memory ");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -573,7 +569,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
|||
//Validate
|
||||
|
||||
if (bytes_read < fsize) {
|
||||
PrintAndLogDevice(WARNING, "error, could only read %d bytes (should be %d)", bytes_read, fsize);
|
||||
PrintAndLogDevice(ERR, "error, could only read %d bytes (should be %d)", bytes_read, fsize);
|
||||
free(dump);
|
||||
return 1;
|
||||
}
|
||||
|
@ -654,7 +650,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
|||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogEx(WARNING, "error, when getting filesize");
|
||||
PrintAndLogEx(ERR, "error, when getting filesize");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
|
@ -669,7 +665,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
|||
size_t bytes_read = fread(decrypted, 1, fsize, f);
|
||||
fclose(f);
|
||||
if (bytes_read == 0) {
|
||||
PrintAndLogEx(WARNING, "file reading error");
|
||||
PrintAndLogEx(ERR, "file reading error");
|
||||
free(decrypted);
|
||||
return 3;
|
||||
}
|
||||
|
@ -969,9 +965,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
while (true) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\n[!] aborted via keyboard!\n");
|
||||
DropField();
|
||||
return 0;
|
||||
|
@ -1287,7 +1281,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
|||
fseek(f, startblock * 8, SEEK_SET);
|
||||
size_t bytes_read = fread(tag_data, sizeof(iclass_block_t), endblock - startblock + 1, f);
|
||||
if (bytes_read == 0) {
|
||||
PrintAndLogEx(WARNING, "file reading error.");
|
||||
PrintAndLogEx(ERR, "file reading error.");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
|
@ -1454,7 +1448,7 @@ static int CmdHFiClass_loclass(const char *Cmd) {
|
|||
errors += testMAC();
|
||||
errors += doKeyTests(0);
|
||||
errors += testElite();
|
||||
if (errors) PrintAndLogDevice(WARNING, "There were errors!!!");
|
||||
if (errors) PrintAndLogDevice(ERR, "There were errors!!!");
|
||||
return errors;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
@ -1524,7 +1518,7 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
|
|||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogEx(WARNING, "Error, when getting filesize");
|
||||
PrintAndLogEx(ERR, "Error, when getting filesize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1682,7 +1676,7 @@ static int loadKeys(char *filename) {
|
|||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogEx(WARNING, "Error, when getting filesize");
|
||||
PrintAndLogEx(ERR, "Error, when getting filesize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1945,9 +1939,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
uint64_t t2 = msclock();
|
||||
uint8_t timeout = 0;
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\n[!] Aborted via keyboard!\n");
|
||||
goto out;
|
||||
}
|
||||
|
@ -2446,7 +2438,7 @@ int readIclass(bool loop, bool verbose) {
|
|||
|
||||
// loop in client not device - else on windows have a communication error
|
||||
PacketResponseNG resp;
|
||||
while (!ukbhit()) {
|
||||
while (!kbd_enter_pressed()) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_READER_ICLASS, flags, 0, 0, NULL, 0);
|
||||
|
|
|
@ -1037,7 +1037,7 @@ static int CmdLegicRestore(const char *Cmd) {
|
|||
fclose(f);
|
||||
|
||||
if (bytes_read == 0) {
|
||||
PrintAndLogEx(WARNING, "File reading error");
|
||||
PrintAndLogEx(ERR, "File reading error");
|
||||
free(data);
|
||||
return 2;
|
||||
}
|
||||
|
@ -1139,7 +1139,7 @@ static int CmdLegicELoad(const char *Cmd) {
|
|||
// load file
|
||||
size_t bytes_read = fread(data, 1, numofbytes, f);
|
||||
if (bytes_read == 0) {
|
||||
PrintAndLogEx(WARNING, "File reading error");
|
||||
PrintAndLogEx(ERR, "File reading error");
|
||||
free(data);
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
|
|
@ -765,7 +765,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
bytes_read = fread(keyA[sectorNo], 1, 6, f);
|
||||
if (bytes_read != 6) {
|
||||
PrintAndLogEx(WARNING, "File reading error.");
|
||||
PrintAndLogEx(ERR, "File reading error.");
|
||||
fclose(f);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
bytes_read = fread(keyB[sectorNo], 1, 6, f);
|
||||
if (bytes_read != 6) {
|
||||
PrintAndLogEx(WARNING, "File reading error.");
|
||||
PrintAndLogEx(ERR, "File reading error.");
|
||||
fclose(f);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
|||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
bytes_read = fread(keyA[sectorNo], 1, 6, fkeys);
|
||||
if (bytes_read != 6) {
|
||||
PrintAndLogEx(WARNING, "File reading error " _YELLOW_("%s"), keyFilename);
|
||||
PrintAndLogEx(ERR, "File reading error " _YELLOW_("%s"), keyFilename);
|
||||
fclose(fkeys);
|
||||
return 2;
|
||||
}
|
||||
|
@ -993,7 +993,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
|||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
bytes_read = fread(keyB[sectorNo], 1, 6, fkeys);
|
||||
if (bytes_read != 6) {
|
||||
PrintAndLogEx(WARNING, "File reading error " _YELLOW_("%s"), keyFilename);
|
||||
PrintAndLogEx(ERR, "File reading error " _YELLOW_("%s"), keyFilename);
|
||||
fclose(fkeys);
|
||||
return 2;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
|||
memcpy(data, key, 6);
|
||||
bytes_read = fread(bldata, 1, 16, fdump);
|
||||
if (bytes_read != 16) {
|
||||
PrintAndLogEx(WARNING, "File reading error " _YELLOW_("%s"), dataFilename);
|
||||
PrintAndLogEx(ERR, "File reading error " _YELLOW_("%s"), dataFilename);
|
||||
fclose(fdump);
|
||||
fdump = NULL;
|
||||
return 2;
|
||||
|
@ -1129,7 +1129,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true);
|
||||
switch (isOK) {
|
||||
case -1 :
|
||||
PrintAndLogEx(WARNING, "Error: No response from Proxmark3.\n");
|
||||
PrintAndLogEx(ERR, "Error: No response from Proxmark3.\n");
|
||||
break;
|
||||
case -2 :
|
||||
PrintAndLogEx(WARNING, "Button pressed. Aborted.\n");
|
||||
|
@ -1162,7 +1162,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
}
|
||||
return PM3_SUCCESS;
|
||||
default :
|
||||
PrintAndLogEx(WARNING, "Unknown Error.\n");
|
||||
PrintAndLogEx(ERR, "Unknown Error.\n");
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
} else { // ------------------------------------ multiple sectors working
|
||||
|
@ -1199,7 +1199,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
int16_t isOK = mfnested(blockNo, keyType, key, FirstBlockOfSector(sectorNo), trgKeyType, keyBlock, calibrate);
|
||||
switch (isOK) {
|
||||
case -1 :
|
||||
PrintAndLogEx(WARNING, "error: No response from Proxmark3.\n");
|
||||
PrintAndLogEx(ERR, "error: No response from Proxmark3.\n");
|
||||
break;
|
||||
case -2 :
|
||||
PrintAndLogEx(WARNING, "button pressed. Aborted.\n");
|
||||
|
@ -1221,7 +1221,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
continue;
|
||||
|
||||
default :
|
||||
PrintAndLogEx(WARNING, "unknown Error.\n");
|
||||
PrintAndLogEx(ERR, "unknown Error.\n");
|
||||
}
|
||||
free(e_sector);
|
||||
return PM3_ESOFT;
|
||||
|
@ -1502,7 +1502,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
|||
if (isOK) {
|
||||
switch (isOK) {
|
||||
case 1 :
|
||||
PrintAndLogEx(WARNING, "Error: No response from Proxmark3.\n");
|
||||
PrintAndLogEx(ERR, "Error: No response from Proxmark3.\n");
|
||||
break;
|
||||
case 2 :
|
||||
PrintAndLogEx(NORMAL, "Button pressed. Aborted.\n");
|
||||
|
@ -1692,9 +1692,7 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
|
|||
// main keychunk loop
|
||||
for (i = 0; i < keycnt; i += chunksize) {
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
|
||||
goto out;
|
||||
}
|
||||
|
@ -1961,6 +1959,8 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
|||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
|
||||
// clear trace log by first check keys call only
|
||||
bool clearLog = true;
|
||||
// check keys.
|
||||
for (trgKeyType = (keyType == 2) ? 0 : keyType; trgKeyType < 2; (keyType == 2) ? (++trgKeyType) : (trgKeyType = 2)) {
|
||||
|
||||
|
@ -1974,20 +1974,20 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
|||
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(INFO, "\naborted via keyboard!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
uint16_t size = keycnt - c > max_keys ? max_keys : keycnt - c;
|
||||
|
||||
if (mfCheckKeys(b, trgKeyType, true, size, &keyBlock[6 * c], &key64) == PM3_SUCCESS) {
|
||||
if (mfCheckKeys(b, trgKeyType, clearLog, size, &keyBlock[6 * c], &key64) == PM3_SUCCESS) {
|
||||
e_sector[i].Key[trgKeyType] = key64;
|
||||
e_sector[i].foundKey[trgKeyType] = true;
|
||||
clearLog = false;
|
||||
break;
|
||||
}
|
||||
clearLog = false;
|
||||
}
|
||||
b < 127 ? (b += 4) : (b += 16);
|
||||
}
|
||||
|
@ -2281,7 +2281,7 @@ static int CmdHF14AMfSim(const char *Cmd) {
|
|||
if (flags & FLAG_INTERACTIVE) {
|
||||
PrintAndLogEx(INFO, "Press pm3-button or send another cmd to abort simulation");
|
||||
|
||||
while (!ukbhit()) {
|
||||
while (!kbd_enter_pressed()) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
if (!(flags & FLAG_NR_AR_ATTACK)) break;
|
||||
if ((resp.oldarg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
|
||||
|
@ -2328,8 +2328,8 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n");
|
||||
PrintAndLogEx(NORMAL, "Executing mifare sniffing command. \n");
|
||||
PrintAndLogEx(NORMAL, "Press the key on the Proxmark3 device to abort both Proxmark3 and client.\n");
|
||||
PrintAndLogEx(NORMAL, "Press the key on pc keyboard to abort the client.\n");
|
||||
PrintAndLogEx(NORMAL, "Press the button on the Proxmark3 device to abort both Proxmark3 and client.\n");
|
||||
PrintAndLogEx(NORMAL, "Press Enter to abort the client.\n");
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n");
|
||||
|
||||
clearCommandBuffer();
|
||||
|
@ -2341,9 +2341,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
|||
while (true) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(INFO, "\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
@ -2830,7 +2828,7 @@ static int CmdHF14AMfCSetUID(const char *Cmd) {
|
|||
|
||||
res = mfCSetUID(uid, (atqaPresent) ? atqa : NULL, (atqaPresent) ? sak : NULL, oldUid, wipeCard);
|
||||
if (res) {
|
||||
PrintAndLogEx(WARNING, "Can't set UID. error=%d", res);
|
||||
PrintAndLogEx(ERR, "Can't set UID. error=%d", res);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -2860,7 +2858,7 @@ static int CmdHF14AMfCSetBlk(const char *Cmd) {
|
|||
|
||||
res = mfCSetBlock(blockNo, block, NULL, params);
|
||||
if (res) {
|
||||
PrintAndLogEx(WARNING, "Can't write block. error=%d", res);
|
||||
PrintAndLogEx(ERR, "Can't write block. error=%d", res);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
@ -2935,7 +2933,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
|
||||
// 64 or 256blocks.
|
||||
if (datalen != 1024 && datalen != 4096) {
|
||||
PrintAndLogEx(WARNING, "File content error. ");
|
||||
PrintAndLogEx(ERR, "File content error. ");
|
||||
free(data);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
@ -2974,7 +2972,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
|
||||
// 64 or 256blocks.
|
||||
if (blockNum != 16 * 4 && blockNum != 32 * 4 + 8 * 16) {
|
||||
PrintAndLogEx(WARNING, "File content error. There must be 64 blocks");
|
||||
PrintAndLogEx(ERR, "File content error. There must be 64 blocks");
|
||||
free(data);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
@ -2996,7 +2994,7 @@ static int CmdHF14AMfCGetBlk(const char *Cmd) {
|
|||
|
||||
int res = mfCGetBlock(blockNo, data, MAGIC_SINGLE);
|
||||
if (res) {
|
||||
PrintAndLogEx(WARNING, "Can't read block. error=%d", res);
|
||||
PrintAndLogEx(ERR, "Can't read block. error=%d", res);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -3047,7 +3045,7 @@ static int CmdHF14AMfCGetSc(const char *Cmd) {
|
|||
|
||||
int res = mfCGetBlock(start + i, data, flags);
|
||||
if (res) {
|
||||
PrintAndLogEx(WARNING, "Can't read block. %d error=%d", start + i, res);
|
||||
PrintAndLogEx(ERR, "Can't read block. %d error=%d", start + i, res);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "%3d | %s", start + i, sprint_hex(data, 16));
|
||||
|
@ -3242,7 +3240,7 @@ static int CmdHf14AMfNack(const char *Cmd) {
|
|||
bool verbose = (ctmp == 'v');
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Started testing card for NACK bug. Press key to abort");
|
||||
PrintAndLogEx(INFO, "Started testing card for NACK bug. Press Enter to abort");
|
||||
|
||||
detect_classic_nackbug(verbose);
|
||||
return PM3_SUCCESS;
|
||||
|
@ -3307,9 +3305,7 @@ static int CmdHF14AMfice(const char *Cmd) {
|
|||
uint64_t t1 = msclock();
|
||||
|
||||
do {
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(INFO, "\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ static void init_bitflip_bitarrays(void) {
|
|||
fseek(statesfile, 0, SEEK_END);
|
||||
int fsize = ftell(statesfile);
|
||||
if (fsize == -1) {
|
||||
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
|
||||
PrintAndLogEx(ERR, "File read error with %s. Aborting...\n", state_file_name);
|
||||
fclose(statesfile);
|
||||
exit(5);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ static void init_bitflip_bitarrays(void) {
|
|||
uint8_t input_buffer[filesize];
|
||||
size_t bytesread = fread(input_buffer, 1, filesize, statesfile);
|
||||
if (bytesread != filesize) {
|
||||
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
|
||||
PrintAndLogEx(ERR, "File read error with %s. Aborting...\n", state_file_name);
|
||||
fclose(statesfile);
|
||||
//inflateEnd(&compressed_stream);
|
||||
exit(5);
|
||||
|
@ -279,7 +279,7 @@ static void init_bitflip_bitarrays(void) {
|
|||
if ((float)count / (1 << 24) < IGNORE_BITFLIP_THRESHOLD) {
|
||||
uint32_t *bitset = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
if (bitset == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in init_bitflip_statelists(). Aborting...\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in init_bitflip_statelists(). Aborting...\n");
|
||||
inflateEnd(&compressed_stream);
|
||||
exit(4);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ static void init_part_sum_bitarrays(void) {
|
|||
for (uint16_t part_sum_a0 = 0; part_sum_a0 < NUM_PART_SUMS; part_sum_a0++) {
|
||||
part_sum_a0_bitarrays[odd_even][part_sum_a0] = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
if (part_sum_a0_bitarrays[odd_even][part_sum_a0] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in init_part_suma0_statelists(). Aborting...\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in init_part_suma0_statelists(). Aborting...\n");
|
||||
exit(4);
|
||||
}
|
||||
clear_bitarray24(part_sum_a0_bitarrays[odd_even][part_sum_a0]);
|
||||
|
@ -410,7 +410,7 @@ static void init_part_sum_bitarrays(void) {
|
|||
for (uint16_t part_sum_a8 = 0; part_sum_a8 < NUM_PART_SUMS; part_sum_a8++) {
|
||||
part_sum_a8_bitarrays[odd_even][part_sum_a8] = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
if (part_sum_a8_bitarrays[odd_even][part_sum_a8] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in init_part_suma8_statelists(). Aborting...\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in init_part_suma8_statelists(). Aborting...\n");
|
||||
exit(4);
|
||||
}
|
||||
clear_bitarray24(part_sum_a8_bitarrays[odd_even][part_sum_a8]);
|
||||
|
@ -449,7 +449,7 @@ static void init_sum_bitarrays(void) {
|
|||
for (odd_even_t odd_even = EVEN_STATE; odd_even <= ODD_STATE; odd_even++) {
|
||||
sum_a0_bitarrays[odd_even][sum_a0] = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
if (sum_a0_bitarrays[odd_even][sum_a0] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in init_sum_bitarrays(). Aborting...\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in init_sum_bitarrays(). Aborting...\n");
|
||||
exit(4);
|
||||
}
|
||||
clear_bitarray24(sum_a0_bitarrays[odd_even][sum_a0]);
|
||||
|
@ -564,14 +564,14 @@ static void init_nonce_memory(void) {
|
|||
}
|
||||
nonces[i].states_bitarray[EVEN_STATE] = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
if (nonces[i].states_bitarray[EVEN_STATE] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in init_nonce_memory(). Aborting...\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in init_nonce_memory(). Aborting...\n");
|
||||
exit(4);
|
||||
}
|
||||
set_bitarray24(nonces[i].states_bitarray[EVEN_STATE]);
|
||||
nonces[i].num_states_bitarray[EVEN_STATE] = 1 << 24;
|
||||
nonces[i].states_bitarray[ODD_STATE] = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
if (nonces[i].states_bitarray[ODD_STATE] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in init_nonce_memory(). Aborting...\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in init_nonce_memory(). Aborting...\n");
|
||||
exit(4);
|
||||
}
|
||||
set_bitarray24(nonces[i].states_bitarray[ODD_STATE]);
|
||||
|
@ -1048,7 +1048,7 @@ static int read_nonce_file(char *filename) {
|
|||
hardnested_print_progress(0, progress_text, (float)(1LL << 47), 0);
|
||||
size_t bytes_read = fread(read_buf, 1, 6, fnonces);
|
||||
if (bytes_read != 6) {
|
||||
PrintAndLogEx(WARNING, "File reading error.");
|
||||
PrintAndLogEx(ERR, "File reading error.");
|
||||
fclose(fnonces);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1711,12 +1711,12 @@ static void add_matching_states(statelist_t *candidates, uint8_t part_sum_a0, ui
|
|||
const uint32_t worstcase_size = 1 << 20;
|
||||
candidates->states[odd_even] = (uint32_t *)malloc(sizeof(uint32_t) * worstcase_size);
|
||||
if (candidates->states[odd_even] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in add_matching_states() - statelist.\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in add_matching_states() - statelist.\n");
|
||||
exit(4);
|
||||
}
|
||||
uint32_t *candidates_bitarray = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * worstcase_size);
|
||||
if (candidates_bitarray == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in add_matching_states() - bitarray.\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in add_matching_states() - bitarray.\n");
|
||||
free(candidates->states[odd_even]);
|
||||
exit(4);
|
||||
}
|
||||
|
@ -1772,7 +1772,7 @@ static void add_bitflip_candidates(uint8_t byte) {
|
|||
uint32_t worstcase_size = nonces[byte].num_states_bitarray[odd_even] + 1;
|
||||
candidates1->states[odd_even] = (uint32_t *)malloc(sizeof(uint32_t) * worstcase_size);
|
||||
if (candidates1->states[odd_even] == NULL) {
|
||||
PrintAndLogEx(WARNING, "Out of memory error in add_bitflip_candidates().\n");
|
||||
PrintAndLogEx(ERR, "Out of memory error in add_bitflip_candidates().\n");
|
||||
exit(4);
|
||||
}
|
||||
|
||||
|
|
|
@ -1232,7 +1232,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
|||
status = ul_read(0, data, sizeof(data));
|
||||
if (status == -1) {
|
||||
DropField();
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to READ");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to READ");
|
||||
return status;
|
||||
} else if (status == 16) {
|
||||
ul_print_default(data);
|
||||
|
@ -1248,7 +1248,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
|||
uint8_t ulc_conf[16] = {0x00};
|
||||
status = ul_read(0x28, ulc_conf, sizeof(ulc_conf));
|
||||
if (status == -1) {
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to READ UL-C");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to READ UL-C");
|
||||
DropField();
|
||||
return status;
|
||||
}
|
||||
|
@ -1263,7 +1263,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
|||
status = ul_read(0x2C, ulc_deskey, sizeof(ulc_deskey));
|
||||
if (status == -1) {
|
||||
DropField();
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to READ magic");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to READ magic");
|
||||
return status;
|
||||
}
|
||||
if (status == 16) ulc_print_3deskey(ulc_deskey);
|
||||
|
@ -1306,7 +1306,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
|||
uint8_t ulev1_signature[32] = {0x00};
|
||||
status = ulev1_readSignature(ulev1_signature, sizeof(ulev1_signature));
|
||||
if (status == -1) {
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to READ SIGNATURE");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to READ SIGNATURE");
|
||||
DropField();
|
||||
return status;
|
||||
}
|
||||
|
@ -1322,7 +1322,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
|||
uint8_t version[10] = {0x00};
|
||||
status = ulev1_getVersion(version, sizeof(version));
|
||||
if (status == -1) {
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to GETVERSION");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to GETVERSION");
|
||||
DropField();
|
||||
return status;
|
||||
} else if (status == 10) {
|
||||
|
@ -1346,7 +1346,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
|
|||
if (startconfigblock) { // if we know where the config block is...
|
||||
status = ul_read(startconfigblock, ulev1_conf, sizeof(ulev1_conf));
|
||||
if (status == -1) {
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to READ EV1");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to READ EV1");
|
||||
DropField();
|
||||
return status;
|
||||
} else if (status == 16) {
|
||||
|
@ -2134,7 +2134,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogEx(WARNING, "Error, when getting filesize");
|
||||
PrintAndLogEx(ERR, "Error, when getting filesize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -2150,7 +2150,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
size_t bytes_read = fread(dump, 1, fsize, f);
|
||||
fclose(f);
|
||||
if (bytes_read < MFU_DUMP_PREFIX_LENGTH) {
|
||||
PrintAndLogEx(WARNING, "Error, dump file is too small");
|
||||
PrintAndLogEx(ERR, "Error, dump file is too small");
|
||||
free(dump);
|
||||
return 1;
|
||||
}
|
||||
|
@ -2167,7 +2167,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
uint8_t pages = (bytes_read - MFU_DUMP_PREFIX_LENGTH) / 4;
|
||||
|
||||
if (pages - 1 != mem->pages) {
|
||||
PrintAndLogEx(WARNING, "Error, invalid dump, wrong page count");
|
||||
PrintAndLogEx(ERR, "Error, invalid dump, wrong page count");
|
||||
free(dump);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
|
|||
static int topaz_read_dynamic_data(void) {
|
||||
// first read the remaining block of segment 0
|
||||
if (topaz_read_block(topaz_tag.uid, 0x0f, &topaz_tag.dynamic_memory[0]) == -1) {
|
||||
PrintAndLogEx(WARNING, "Error while reading dynamic memory block %02x. Aborting...", 0x0f);
|
||||
PrintAndLogEx(ERR, "Error while reading dynamic memory block %02x. Aborting...", 0x0f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ static int topaz_read_dynamic_data(void) {
|
|||
uint8_t max_segment = topaz_tag.size / 128 - 1;
|
||||
for (uint8_t segment = 1; segment <= max_segment; segment++) {
|
||||
if (topaz_read_segment(topaz_tag.uid, segment, &topaz_tag.dynamic_memory[(segment - 1) * 128 + 8]) == -1) {
|
||||
PrintAndLogEx(WARNING, "Error while reading dynamic memory block %02x. Aborting...", 0x0f);
|
||||
PrintAndLogEx(ERR, "Error while reading dynamic memory block %02x. Aborting...", 0x0f);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
|||
status = topaz_select(atqa, rid_response);
|
||||
|
||||
if (status == -1) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "Error: couldn't receive ATQA");
|
||||
if (verbose) PrintAndLogEx(ERR, "Error: couldn't receive ATQA");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (status == -2) {
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to RID");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to RID");
|
||||
topaz_switch_off_field();
|
||||
return -1;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
|||
status = topaz_rall(uid_echo, rall_response);
|
||||
|
||||
if (status == -1) {
|
||||
PrintAndLogEx(WARNING, "Error: tag didn't answer to RALL");
|
||||
PrintAndLogEx(ERR, "Error: tag didn't answer to RALL");
|
||||
topaz_switch_off_field();
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -479,6 +479,13 @@ static int CmdSetMux(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdStandalone(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_STANDALONE, NULL, 0);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdTune(const char *Cmd) {
|
||||
return CmdTuneSamples(Cmd);
|
||||
}
|
||||
|
@ -591,6 +598,7 @@ static command_t CommandTable[] = {
|
|||
{"reset", CmdReset, IfPm3Present, "Reset the Proxmark3"},
|
||||
{"setlfdivisor", CmdSetDivisor, IfPm3Present, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
|
||||
{"setmux", CmdSetMux, IfPm3Present, "Set the ADC mux to a specific value"},
|
||||
{"standalone", CmdStandalone, IfPm3Present, "Jump to the standalone mode"},
|
||||
{"status", CmdStatus, IfPm3Present, "Show runtime status information about the connected Proxmark3"},
|
||||
{"tune", CmdTune, IfPm3Present, "Measure antenna tuning"},
|
||||
{"version", CmdVersion, IfPm3Present, "Show version information about the connected Proxmark3"},
|
||||
|
@ -621,6 +629,11 @@ void pm3_version(bool verbose) {
|
|||
PrintAndLogEx(NORMAL, "\n" _BLUE_(" [ Proxmark3 RFID instrument ]") "\n");
|
||||
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
|
||||
PrintAndLogEx(NORMAL, " client: RRG/Iceman"); // TODO version info?
|
||||
#if defined(__clang__)
|
||||
PrintAndLogEx(NORMAL, " compiled with Clang/LLVM "__VERSION__);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
PrintAndLogEx(NORMAL, " compiled with GCC "__VERSION__);
|
||||
#endif
|
||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK RDV4 ]");
|
||||
PrintAndLogEx(NORMAL, " external flash: %s", IfPm3Flash() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
PrintAndLogEx(NORMAL, " smartcard reader: %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
|
|
|
@ -573,7 +573,7 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
dataLen = hextobinarray((char *)data, hexData);
|
||||
|
||||
if (dataLen == 0) errors = true;
|
||||
if (errors) PrintAndLogEx(WARNING, "Error getting hex data");
|
||||
if (errors) PrintAndLogEx(ERR, "Error getting hex data");
|
||||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
|
@ -685,7 +685,7 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
dataLen = hextobinarray((char *)data, hexData);
|
||||
|
||||
if (dataLen == 0) errors = true;
|
||||
if (errors) PrintAndLogEx(WARNING, "Error getting hex data, datalen: %d", dataLen);
|
||||
if (errors) PrintAndLogEx(ERR, "Error getting hex data, datalen: %d", dataLen);
|
||||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
|
@ -788,7 +788,7 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
dataLen = hextobinarray((char *)data, hexData);
|
||||
|
||||
if (dataLen == 0) errors = true;
|
||||
if (errors) PrintAndLogEx(WARNING, "Error getting hex data");
|
||||
if (errors) PrintAndLogEx(ERR, "Error getting hex data");
|
||||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
|
@ -957,7 +957,7 @@ static bool CheckChipType(bool getDeviceData) {
|
|||
retval = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
//check for t55xx chip...
|
||||
if (tryDetectP1(true)) {
|
||||
PrintAndLogEx(SUCCESS, "\nChipset detection : " _GREEN_("T55xx") "found");
|
||||
|
@ -1084,8 +1084,8 @@ int CmdLFfind(const char *Cmd) {
|
|||
}
|
||||
out:
|
||||
// identify chipset
|
||||
if ( CheckChipType(isOnline) == false ) {
|
||||
PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed") );
|
||||
if (CheckChipType(isOnline) == false) {
|
||||
PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed"));
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ static int sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, uin
|
|||
PrintAndLogEx(INFO, "Trying FC: %u; CN: %u", fc, cn);
|
||||
|
||||
if (getAWIDBits(fmtlen, fc, cn, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ static int CmdAWIDSim(const char *Cmd) {
|
|||
verify_values(&fmtlen, &fc, &cn);
|
||||
|
||||
if (getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ static int CmdAWIDClone(const char *Cmd) {
|
|||
verify_values(&fmtlen, &fc, &cn);
|
||||
|
||||
if (getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ static int CmdAWIDClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ static int CmdAWIDBrute(const char *Cmd) {
|
|||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Bruteforceing AWID %d Reader", fmtlen);
|
||||
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or press key");
|
||||
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or press Enter");
|
||||
|
||||
uint16_t up = cn;
|
||||
uint16_t down = cn;
|
||||
|
@ -503,9 +503,7 @@ static int CmdAWIDBrute(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "Device offline\n");
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(INFO, "aborted via keyboard!");
|
||||
return sendPing();
|
||||
}
|
||||
|
|
|
@ -482,12 +482,12 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
|
||||
int filelen = param_getstr(Cmd, 0, filename, FILE_PATH_SIZE);
|
||||
if (filelen == 0) {
|
||||
PrintAndLogEx(WARNING, "Error: Please specify a filename");
|
||||
PrintAndLogEx(ERR, "Error: Please specify a filename");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if ((f = fopen(filename, "r")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Error: Could not open UIDs file ["_YELLOW_("%s")"]", filename);
|
||||
PrintAndLogEx(ERR, "Error: Could not open UIDs file ["_YELLOW_("%s")"]", filename);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
|
@ -544,9 +544,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
char testuid[11];
|
||||
testuid[10] = 0;
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\nAborted via keyboard!\n");
|
||||
free(uidBlock);
|
||||
return PM3_EOPABORTED;
|
||||
|
@ -580,9 +578,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
static int CmdEM410xWatch(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
do {
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
@ -617,21 +613,21 @@ static int CmdEM410xWrite(const char *Cmd) {
|
|||
|
||||
// Check ID
|
||||
if (id == 0xFFFFFFFFFFFFFFFF) {
|
||||
PrintAndLogEx(WARNING, "Error! ID is required.\n");
|
||||
PrintAndLogEx(ERR, "Error! ID is required.\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (id >= 0x10000000000) {
|
||||
PrintAndLogEx(WARNING, "Error! Given EM410x ID is longer than 40 bits.\n");
|
||||
PrintAndLogEx(ERR, "Error! Given EM410x ID is longer than 40 bits.\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// Check Card
|
||||
if (card == 0xFF) {
|
||||
PrintAndLogEx(WARNING, "Error! Card type required.\n");
|
||||
PrintAndLogEx(ERR, "Error! Card type required.\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (card < 0) {
|
||||
PrintAndLogEx(WARNING, "Error! Bad card type selected.\n");
|
||||
PrintAndLogEx(ERR, "Error! Bad card type selected.\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
@ -641,7 +637,7 @@ static int CmdEM410xWrite(const char *Cmd) {
|
|||
|
||||
// Allowed clock rates: 16, 32, 40 and 64
|
||||
if ((clock1 != 16) && (clock1 != 32) && (clock1 != 64) && (clock1 != 40)) {
|
||||
PrintAndLogEx(WARNING, "Error! Clock rate" _YELLOW_("%d")" not valid. Supported clock rates are 16, 32, 40 and 64.\n", clock1);
|
||||
PrintAndLogEx(ERR, "Error! Clock rate" _YELLOW_("%d")" not valid. Supported clock rates are 16, 32, 40 and 64.\n", clock1);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
@ -841,7 +837,7 @@ int EM4x50Read(const char *Cmd, bool verbose) {
|
|||
}
|
||||
}
|
||||
if (!clk) {
|
||||
if (verbose || g_debugMode) PrintAndLogEx(WARNING, "Error: EM4x50 - didn't find a clock");
|
||||
if (verbose || g_debugMode) PrintAndLogEx(ERR, "Error: EM4x50 - didn't find a clock");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
} else tol = clk / 8;
|
||||
|
@ -1266,7 +1262,7 @@ static int CmdEM4x05Write(const char *Cmd) {
|
|||
SendCommandNG(CMD_EM4X_WRITE_WORD, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_EM4X_WRITE_WORD, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
|
@ -1377,10 +1373,10 @@ static void printEM4x05config(uint32_t wordData) {
|
|||
PrintAndLogEx(NORMAL, " PSK CF: %u | %s", PSKcf, cf);
|
||||
PrintAndLogEx(NORMAL, " Delay: %u | %s", delay, cdelay);
|
||||
PrintAndLogEx(NORMAL, " LastWordR: %02u | Address of last word for default read - meaning %u blocks are output", LWR, numblks);
|
||||
PrintAndLogEx(NORMAL, " ReadLogin: %u | Read login is %s", readLogin, readLogin ? _YELLOW_("required") : _GREEN_("not required") );
|
||||
PrintAndLogEx(NORMAL, " ReadHKL: %u | Read housekeeping words login is %s", readHKL, readHKL ? _YELLOW_("required") : _GREEN_("not required") );
|
||||
PrintAndLogEx(NORMAL, "WriteLogin: %u | Write login is %s", writeLogin, writeLogin ? _YELLOW_("required") : _GREEN_("not required") );
|
||||
PrintAndLogEx(NORMAL, " WriteHKL: %u | Write housekeeping words login is %s", writeHKL, writeHKL ? _YELLOW_("required") : _GREEN_("not Required") );
|
||||
PrintAndLogEx(NORMAL, " ReadLogin: %u | Read login is %s", readLogin, readLogin ? _YELLOW_("required") : _GREEN_("not required"));
|
||||
PrintAndLogEx(NORMAL, " ReadHKL: %u | Read housekeeping words login is %s", readHKL, readHKL ? _YELLOW_("required") : _GREEN_("not required"));
|
||||
PrintAndLogEx(NORMAL, "WriteLogin: %u | Write login is %s", writeLogin, writeLogin ? _YELLOW_("required") : _GREEN_("not required"));
|
||||
PrintAndLogEx(NORMAL, " WriteHKL: %u | Write housekeeping words login is %s", writeHKL, writeHKL ? _YELLOW_("required") : _GREEN_("not Required"));
|
||||
PrintAndLogEx(NORMAL, " R.A.W.: %u | Read after write is %s", raw, raw ? "on" : "off");
|
||||
PrintAndLogEx(NORMAL, " Disable: %u | Disable command is %s", disable, disable ? "accepted" : "not accepted");
|
||||
PrintAndLogEx(NORMAL, " R.T.F.: %u | Reader talk first is %s", rtf, rtf ? _YELLOW_("enabled") : "disabled");
|
||||
|
@ -1400,7 +1396,7 @@ static void printEM4x05info(uint32_t block0, uint32_t serial) {
|
|||
snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4305");
|
||||
break;
|
||||
case 8:
|
||||
snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4205");
|
||||
snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4205");
|
||||
break;
|
||||
case 4:
|
||||
snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "Unknown");
|
||||
|
|
|
@ -264,7 +264,7 @@ static int CmdFdxClone(const char *Cmd) {
|
|||
|
||||
// getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits)
|
||||
if (getFDXBits(animalid, countryid, 1, 0, 0, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ static int CmdFdxClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ static int CmdGuardClone(const char *Cmd) {
|
|||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (getGuardBits(fmtlen, facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ static int CmdGuardClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ static int CmdGuardSim(const char *Cmd) {
|
|||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (getGuardBits(fmtlen, facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
|
|
@ -580,9 +580,7 @@ static int CmdHIDBrute(const char *Cmd) {
|
|||
return PM3_ENODATA;
|
||||
}
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(INFO, "aborted via keyboard!");
|
||||
return sendPing();
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ static int usage_hitag_writer(void) {
|
|||
PrintAndLogEx(NORMAL, " Hitag1 (1*)");
|
||||
PrintAndLogEx(NORMAL, " Hitag2 (2*)");
|
||||
PrintAndLogEx(NORMAL, " 24 <key> (set to 0 if no authentication is needed) <page> <byte0...byte3> write page on a Hitag2 tag");
|
||||
PrintAndLogEx(NORMAL, " 27 <password> <page> <byte0...byte3> write page on a Hitag2 tag");
|
||||
return 0;
|
||||
}
|
||||
static int usage_hitag_checkchallenges(void) {
|
||||
|
@ -176,7 +177,7 @@ static int CmdLFHitagList(const char *Cmd) {
|
|||
if (strlen(filename) > 0) {
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
|
||||
PrintAndLogEx(ERR, "Error: Could not open file [%s]", filename);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
}
|
||||
|
@ -551,6 +552,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
|||
case WHTSF_CHALLENGE:
|
||||
case WHTSF_KEY:
|
||||
case WHT2F_CRYPTO:
|
||||
default:
|
||||
return usage_hitag_reader();
|
||||
}
|
||||
|
||||
|
@ -658,6 +660,12 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
|||
num_to_bytes(param_get32ex(Cmd, 3, 0, 16), 4, htd.crypto.data);
|
||||
break;
|
||||
}
|
||||
case WHT2F_PASSWORD: {
|
||||
num_to_bytes(param_get64ex(Cmd, 1, 0, 16), 4, htd.pwd.password);
|
||||
arg2 = param_get32ex(Cmd, 2, 0, 10);
|
||||
num_to_bytes(param_get32ex(Cmd, 3, 0, 16), 4, htd.crypto.data);
|
||||
break;
|
||||
}
|
||||
case RHTSF_CHALLENGE:
|
||||
case RHTSF_KEY:
|
||||
case RHT2F_PASSWORD:
|
||||
|
@ -665,6 +673,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
|||
case RHT2F_CRYPTO:
|
||||
case RHT2F_TEST_AUTH_ATTEMPTS:
|
||||
case RHT2F_UID_ONLY:
|
||||
default:
|
||||
return usage_hitag_writer();
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ static int CmdIOProxSim(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
|
||||
|
||||
if (getIOProxBits(version, fc, cn, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
// IOProx uses: fcHigh: 10, fcLow: 8, clk: 64, invert: 1
|
||||
|
@ -249,7 +249,7 @@ static int CmdIOProxClone(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (getIOProxBits(version, fc, cn, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ static int CmdJablotronClone(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (getJablotronBits(fullcode, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ static int CmdJablotronClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ static int CmdKeriClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ static int CmdLFNedapClone(const char *Cmd) {
|
|||
cardnumber = (cn & 0x00FFFFFF);
|
||||
|
||||
if ( getNedapBits(cardnumber, bits) == PM3_SUCCESS ) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ static int CmdLFNedapClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ static int CmdLFNedapSim(const char *Cmd) {
|
|||
memset(bs, 0x00, sizeof(bs));
|
||||
|
||||
if (getNedapBits(cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ static int CmdNoralsyClone(const char *Cmd) {
|
|||
blocks[0] = T5555_MODULATION_MANCHESTER | T5555_SET_BITRATE(32) | T5555_ST_TERMINATOR | 3 << T5555_MAXBLOCK_SHIFT;
|
||||
|
||||
if (getnoralsyBits(id, year, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ static int CmdNoralsyClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ static int CmdNoralsySim(const char *Cmd) {
|
|||
year = param_get32ex(Cmd, 1, 2000, 10);
|
||||
|
||||
if (getnoralsyBits(id, year, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ static int CmdParadoxSim(const char *Cmd) {
|
|||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
// if ( GetParadoxBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
// PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
// PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ static int CmdPrescoClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ static int CmdPyramidClone(const char *Cmd) {
|
|||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (getPyramidBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ static int CmdPyramidClone(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ static int CmdPyramidSim(const char *Cmd) {
|
|||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (getPyramidBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
PrintAndLogEx(ERR, "Error with tag bitstream generation.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
|
|
@ -1103,7 +1103,7 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
|
|||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not ACK write operation. (May be due to old firmware)");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not ACK write operation. (May be due to old firmware)");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
@ -1829,13 +1829,13 @@ static int CmdT55xxWipe(const char *Cmd) {
|
|||
else
|
||||
snprintf(ptrData, sizeof(writeData), "b 0 d 000880E0 p 0");
|
||||
|
||||
if (CmdT55xxWriteBlock(ptrData) != PM3_SUCCESS) PrintAndLogEx(WARNING, "Error writing blk 0");
|
||||
if (CmdT55xxWriteBlock(ptrData) != PM3_SUCCESS) PrintAndLogEx(WARNING, "Warning: error writing blk 0");
|
||||
|
||||
for (uint8_t blk = 1; blk < 8; blk++) {
|
||||
|
||||
snprintf(ptrData, sizeof(writeData), "b %d d 0", blk);
|
||||
|
||||
if (CmdT55xxWriteBlock(ptrData) != PM3_SUCCESS) PrintAndLogEx(WARNING, "Error writing blk %d", blk);
|
||||
if (CmdT55xxWriteBlock(ptrData) != PM3_SUCCESS) PrintAndLogEx(WARNING, "Warning: error writing blk %d", blk);
|
||||
|
||||
memset(writeData, 0x00, sizeof(writeData));
|
||||
}
|
||||
|
@ -1843,9 +1843,7 @@ static int CmdT55xxWipe(const char *Cmd) {
|
|||
}
|
||||
|
||||
static bool IsCancelled(void) {
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
|
||||
return true;
|
||||
}
|
||||
|
@ -1921,7 +1919,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
|||
// TODO, a way of reallocating memory if file was larger
|
||||
keyBlock = calloc(4 * 200, sizeof(uint8_t));
|
||||
if (keyBlock == NULL) {
|
||||
PrintAndLogDevice(WARNING, "error, cannot allocate memory ");
|
||||
PrintAndLogDevice(ERR, "error, cannot allocate memory ");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -2155,7 +2153,7 @@ bool tryDetectP1(bool getData) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// try ask clock detect. it could be another type even if successful.
|
||||
clk = GetAskClock("", false);
|
||||
if (clk > 0) {
|
||||
|
@ -2164,14 +2162,14 @@ bool tryDetectP1(bool getData) {
|
|||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
st = true;
|
||||
if ((ASKDemod_ext("0 1 1", false, false, 1, &st) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if ((ASKbiphaseDemod("0 0 0 2", false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
|
@ -2184,7 +2182,7 @@ bool tryDetectP1(bool getData) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// try NRZ clock detect. it could be another type even if successful.
|
||||
clk = GetNrzClock("", false); //has the most false positives :(
|
||||
if (clk > 0) {
|
||||
|
|
|
@ -233,7 +233,7 @@ static int CmdTIDemod(const char *Cmd) {
|
|||
|
||||
// only 15 bits compare, last bit of ident is not valid
|
||||
if ((shift3 ^ shift0) & 0x7FFF) {
|
||||
PrintAndLogEx(WARNING, "Error: Ident mismatch!");
|
||||
PrintAndLogEx(WARNING, "Warning: Ident mismatch!");
|
||||
}
|
||||
// WARNING the order of the bytes in which we calc crc below needs checking
|
||||
// i'm 99% sure the crc algorithm is correct, but it may need to eat the
|
||||
|
@ -257,7 +257,7 @@ static int CmdTIDemod(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Tag data = %08X%08X [Crc %04X %s]", shift1, shift0, crc, crcStr);
|
||||
|
||||
if (crc != (shift2 & 0xFFFF))
|
||||
PrintAndLogEx(WARNING, "Error: CRC mismatch, calculated %04X, got %04X", crc, shift2 & 0xFFFF);
|
||||
PrintAndLogEx(WARNING, "Warning: CRC mismatch, calculated %04X, got %04X", crc, shift2 & 0xFFFF);
|
||||
|
||||
retval = PM3_SUCCESS;
|
||||
goto out;
|
||||
|
|
|
@ -91,7 +91,7 @@ static int CmdVikingClone(const char *Cmd) {
|
|||
SendCommandMIX(CMD_VIKING_CLONE_TAG, rawID >> 32, rawID & 0xFFFFFFFF, Q5, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -186,7 +186,7 @@ static int CmdVisa2kClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,32 @@ static int CmdRem(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_msleep(void) {
|
||||
PrintAndLogEx(NORMAL, "Sleep for given amount of milliseconds");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: msleep <ms>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h This help");
|
||||
PrintAndLogEx(NORMAL, " <ms> time in milliseconds");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " msleep 100");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdMsleep(const char *Cmd) {
|
||||
uint32_t ms = 0;
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) < 1 || ctmp == 'h') return usage_msleep();
|
||||
if (param_getchar(Cmd, 0) != 0x00) {
|
||||
ms = param_get32ex(Cmd, 0, 0, 10);
|
||||
if (ms == 0)
|
||||
return usage_msleep();
|
||||
}
|
||||
msleep(ms);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdQuit(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return PM3_EFATAL;
|
||||
|
@ -50,8 +76,9 @@ static command_t CommandTable[] = {
|
|||
{"hw", CmdHW, AlwaysAvailable, "{ Hardware commands... }"},
|
||||
{"lf", CmdLF, AlwaysAvailable, "{ Low Frequency commands... }"},
|
||||
{"mem", CmdFlashMem, IfPm3Flash, "{ Flash Memory manipulation... }"},
|
||||
{"rem", CmdRem, AlwaysAvailable, "{ Add text to row in log file }"},
|
||||
{"reveng", CmdRev, AlwaysAvailable, "{ Crc calculations from the RevEng software... }"},
|
||||
{"msleep", CmdMsleep, AlwaysAvailable, "Add a pause in milliseconds"},
|
||||
{"rem", CmdRem, AlwaysAvailable, "Add text to row in log file"},
|
||||
{"reveng", CmdRev, AlwaysAvailable, "{ Crc calculations from the RevEng software }"},
|
||||
{"sc", CmdSmartcard, IfPm3Smartcard, "{ Smart card ISO7816 commands... }"},
|
||||
{"script", CmdScript, AlwaysAvailable, "{ Scripting commands }"},
|
||||
{"trace", CmdTrace, AlwaysAvailable, "{ Trace manipulation... }"},
|
||||
|
|
|
@ -284,7 +284,7 @@ static int PrintATR(uint8_t *atr, size_t atrlen) {
|
|||
vxor ^= atr[i];
|
||||
|
||||
if (vxor)
|
||||
PrintAndLogEx(WARNING, "Check sum error. Must be 0 got 0x%02X", vxor);
|
||||
PrintAndLogEx(WARNING, "Invalid check sum. Must be 0 got 0x%02X", vxor);
|
||||
else
|
||||
PrintAndLogEx(INFO, "Check sum OK.");
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ static int PrintATR(uint8_t *atr, size_t atrlen) {
|
|||
uint8_t calen = 2 + T1len + TD1len + TDilen + K;
|
||||
|
||||
if (atrlen != calen && atrlen != calen + 1) // may be CRC
|
||||
PrintAndLogEx(ERR, "ATR length error. len: %d, T1len: %d, TD1len: %d, TDilen: %d, K: %d", atrlen, T1len, TD1len, TDilen, K);
|
||||
PrintAndLogEx(WARNING, "Invalid ATR length. len: %d, T1len: %d, TD1len: %d, TDilen: %d, K: %d", atrlen, T1len, TD1len, TDilen, K);
|
||||
|
||||
if (K > 0)
|
||||
PrintAndLogEx(INFO, "\nHistorical bytes | len 0x%02d | format %02x", K, atr[2 + T1len + TD1len + TDilen]);
|
||||
|
@ -568,14 +568,14 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
|||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogEx(WARNING, "error, when getting filesize");
|
||||
PrintAndLogEx(ERR, "error, when getting filesize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t *dump = calloc(fsize, sizeof(uint8_t));
|
||||
if (!dump) {
|
||||
PrintAndLogEx(WARNING, "error, cannot allocate memory ");
|
||||
PrintAndLogEx(ERR, "error, cannot allocate memory ");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -914,9 +914,7 @@ static int smart_brute_sfi(bool decodeTLV) {
|
|||
|
||||
for (uint16_t rec = 1; rec <= 255; rec++) {
|
||||
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
|
||||
free(buf);
|
||||
return 1;
|
||||
|
|
|
@ -312,11 +312,9 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, _RED_("WARNING: process only if strictly needed!"));
|
||||
PrintAndLogEx(WARNING, "This requires BT turned ON and NOT connected!");
|
||||
PrintAndLogEx(WARNING, "Is the add-on blue light blinking? (Say 'n' if you want to abort) [y/n]");
|
||||
while (!ukbhit()) {
|
||||
msleep(200);
|
||||
}
|
||||
|
||||
if (tolower(getchar()) != 'y') {
|
||||
char input[3];
|
||||
if ((fgets(input, sizeof(input), stdin) == NULL) || (strncmp(input, "y\n", sizeof(input)) != 0)) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(FAILED, "Aborting.");
|
||||
return PM3_EOPABORTED;
|
||||
|
@ -448,11 +446,10 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
}
|
||||
|
||||
if ((baudrate != USART_BAUD_RATE) || (parity != USART_PARITY)) {
|
||||
PrintAndLogEx(WARNING, "Add-on uart settings changed, please turn BT add-on OFF and ON again, then press any key.");
|
||||
while (!ukbhit()) {
|
||||
PrintAndLogEx(WARNING, "Add-on uart settings changed, please turn BT add-on OFF and ON again, then press Enter.");
|
||||
while (!kbd_enter_pressed()) {
|
||||
msleep(200);
|
||||
}
|
||||
getchar();
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "Trying to connect add-on with the new settings.");
|
||||
found = usart_bt_testcomm(USART_BAUD_RATE, USART_PARITY) == PM3_SUCCESS;
|
||||
|
|
|
@ -136,7 +136,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
|||
txBufferNG.pre.ng = ng;
|
||||
txBufferNG.pre.length = len;
|
||||
txBufferNG.pre.cmd = cmd;
|
||||
if ( len > 0 && data )
|
||||
if (len > 0 && data)
|
||||
memcpy(&txBufferNG.data, data, len);
|
||||
|
||||
if ((conn.send_via_fpc_usart && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc_usart) && conn.send_with_crc_on_usb)) {
|
||||
|
@ -359,7 +359,7 @@ __attribute__((force_align_arg_pointer))
|
|||
|
||||
res = uart_receive(sp, (uint8_t *)&rx_raw.data, length, &rxlen);
|
||||
if ((res != PM3_SUCCESS) || (rxlen != length)) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame error variable part too short? %d/%d", rxlen, length);
|
||||
PrintAndLogEx(WARNING, "Received packet frame with variable part too short? %d/%d", rxlen, length);
|
||||
error = true;
|
||||
} else {
|
||||
|
||||
|
@ -392,7 +392,7 @@ __attribute__((force_align_arg_pointer))
|
|||
if (!error) { // Get the postamble
|
||||
res = uart_receive(sp, (uint8_t *)&rx_raw.foopost, sizeof(PacketResponseNGPostamble), &rxlen);
|
||||
if ((res != PM3_SUCCESS) || (rxlen != sizeof(PacketResponseNGPostamble))) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame error fetching postamble");
|
||||
PrintAndLogEx(WARNING, "Received packet frame without postamble");
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ __attribute__((force_align_arg_pointer))
|
|||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&rx_raw, sizeof(PacketResponseNGPreamble) + length, &first, &second);
|
||||
if ((first << 8) + second != rx.crc) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame CRC error %02X%02X <> %04X", first, second, rx.crc);
|
||||
PrintAndLogEx(WARNING, "Received packet frame with invalid CRC %02X%02X <> %04X", first, second, rx.crc);
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ __attribute__((force_align_arg_pointer))
|
|||
|
||||
res = uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(PacketResponseNGPreamble), sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble), &rxlen);
|
||||
if ((res != PM3_SUCCESS) || (rxlen != sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble))) {
|
||||
PrintAndLogEx(WARNING, "Received packet OLD frame payload error too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble));
|
||||
PrintAndLogEx(WARNING, "Received packet OLD frame with payload too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble));
|
||||
error = true;
|
||||
}
|
||||
if (!error) {
|
||||
|
|
|
@ -97,9 +97,15 @@ f1d83f964314,--RKFRejskortDanmarkKeyB
|
|||
fc00018778f7,--VästtrafikenKeyA, RKFÖstgötaTrafikenKeyA
|
||||
44ab09010845,-- hotel system
|
||||
85fed980ea5a,-- hotel system
|
||||
314B49474956,--VIGIK1KeyA
|
||||
564c505f4d41,--VIGIK1KeyB
|
||||
ba5b895da162,--VIGIK1KeyB
|
||||
314B49474956 --VIGIK1 A
|
||||
564c505f4d41 --VIGIK1 B
|
||||
ba5b895da162 --VIGIK1 B
|
||||
# Vigik mystery Keys Mifare 1k EV1 (S50)
|
||||
5c8ff9990da2, 16 A
|
||||
75ccb59c9bed, 17 A
|
||||
d01afeeb890a, 16 B
|
||||
4b791bea7bcc, 17 B
|
||||
#
|
||||
4143414F5250,
|
||||
a9b43414F585,--Tehran Railway
|
||||
1FB235AC1388,--Tehran Railway
|
||||
|
@ -109,8 +115,6 @@ f4a9ef2afc6d,--BCARD KeyB
|
|||
#
|
||||
#
|
||||
a9f953def0a3,--
|
||||
75ccb59c9bed,-- mystery KeyA Mifare 1k EV1 (S50) Sector 17!
|
||||
4b791bea7bcc,-- mystery KeyB Mifare 1k EV1 (S50) Sector 17!
|
||||
#
|
||||
# Here be BIP keys...
|
||||
3A42F33AF429,
|
||||
|
@ -770,14 +774,18 @@ A2B2C9D187FB,
|
|||
A2F63A485632,
|
||||
98631ED2B229,
|
||||
19F1FFE02563,
|
||||
#OMNITEC.ES HOTEL TIMECARD / MAINTENANCECARD
|
||||
563A22C01FC8, -- Argentina
|
||||
43CA22C13091, -- Argentina
|
||||
25094DF2C1BD, -- Argentina
|
||||
#
|
||||
# OMNITEC.ES HOTEL TIMECARD / MAINTENANCECARD
|
||||
AFBECD120454,
|
||||
#OMNITEC.ES HOTEL EMERGENCYCARD
|
||||
#
|
||||
# OMNITEC.ES HOTEL EMERGENCYCARD
|
||||
842146108088,
|
||||
# MORE KEYS:
|
||||
8A19D40CF2B5,
|
||||
AE8587108640,
|
||||
#TAPCARD PUBLIC TRANSPORT LA
|
||||
#
|
||||
# TAPCARD PUBLIC TRANSPORT LA
|
||||
#
|
||||
EA1B88DF0A76,
|
||||
D1991E71E2C5,
|
||||
05F89678CFCF,
|
||||
|
@ -810,10 +818,10 @@ B81846F06EDF,
|
|||
C6A76CB2F3B5,
|
||||
E3AD9E9BA5D4,
|
||||
6C9EC046C1A4,
|
||||
#ROC HIGHSCHOOL ACCESSCARD
|
||||
A0A1A2A3A4A5,
|
||||
#
|
||||
# ROC HIGHSCHOOL ACCESSCARD
|
||||
#
|
||||
B021669B44BB,
|
||||
A0A1A2A3A4A5,
|
||||
B18CDCDE52B7,
|
||||
A22647F422AE,
|
||||
B268F7C9CA63,
|
||||
|
@ -840,10 +848,12 @@ BCF5A6B5E13F,
|
|||
AD5645062534,
|
||||
BDF837787A71,
|
||||
AE43F36C1A9A,
|
||||
BE7C4F6C7A9A,
|
||||
BE7C4F6C7A9A,
|
||||
5EC7938F140A,
|
||||
82D58AA49CCB,
|
||||
#MELONCARD
|
||||
#
|
||||
# MELONCARD
|
||||
#
|
||||
323334353637,
|
||||
#
|
||||
#
|
||||
|
@ -861,7 +871,9 @@ A7FB4824ACBF,
|
|||
00F0BD116D70,
|
||||
4CFF128FA3EF,
|
||||
10F3BEBC01DF,
|
||||
#Transportes Insular La Palma
|
||||
#
|
||||
# Transportes Insular La Palma
|
||||
#
|
||||
0172066b2f03,
|
||||
0000085f0000,
|
||||
1a80b93f7107,
|
||||
|
@ -894,3 +906,43 @@ b1a862985913,
|
|||
3b0172066b2f,
|
||||
3f1a87298691,
|
||||
f3f0172066b2,
|
||||
#
|
||||
# Tehran ezpay
|
||||
#
|
||||
38A88AEC1C43
|
||||
CBD2568BC7C6
|
||||
7BCB4774EC8F
|
||||
22ECE9316461
|
||||
AE4B497A2527
|
||||
EEC0626B01A1
|
||||
2C71E22A32FE
|
||||
91142568B22F
|
||||
7D56759A974A
|
||||
D3B1C7EA5C53
|
||||
41C82D231497
|
||||
0B8B21C692C2
|
||||
604Ac8D87C7E
|
||||
8E7B29460F12
|
||||
BB3D7B11D224
|
||||
#
|
||||
# Chaco
|
||||
#
|
||||
b210cfa436d2
|
||||
b8b1cfa646a8
|
||||
a9f95891f0a4
|
||||
#
|
||||
# Keys from APK application "Scan Badge"
|
||||
4A4C474F524D
|
||||
444156494442
|
||||
434143445649
|
||||
434456495243
|
||||
A00002000021
|
||||
EF61A3D48E2A
|
||||
A23456789123
|
||||
010000000000
|
||||
363119000001
|
||||
A00003000084
|
||||
675A32413770
|
||||
395244733978
|
||||
#
|
||||
B069D0D03D17
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef __ELF_H__
|
||||
#define __ELF_H__
|
||||
|
||||
#include "proxmark3.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t p_type;
|
||||
uint32_t p_offset;
|
||||
|
@ -18,7 +20,7 @@ typedef struct {
|
|||
uint32_t p_memsz;
|
||||
uint32_t p_flags;
|
||||
uint32_t p_align;
|
||||
} __attribute__((__packed__)) Elf32_Phdr;
|
||||
} PACKED Elf32_Phdr;
|
||||
|
||||
#define EI_NIDENT 16
|
||||
|
||||
|
@ -37,7 +39,7 @@ typedef struct {
|
|||
uint16_t e_shentsize;
|
||||
uint16_t e_shnum;
|
||||
uint16_t e_shtrndx;
|
||||
} __attribute__((__packed__)) Elf32_Ehdr;
|
||||
} PACKED Elf32_Ehdr;
|
||||
|
||||
#define PT_NULL 0
|
||||
#define PT_LOAD 1
|
||||
|
|
|
@ -14,4 +14,16 @@
|
|||
|
||||
#define PROXPROMPT "proxmark3> "
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef DWORD uint32_t;
|
||||
typedef BYTE uint8_t;
|
||||
#define PACKED
|
||||
// stuff
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#define PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#define SLEEP_H__
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#define msleep(n) Sleep(n)
|
||||
#include <windows.h>
|
||||
#define msleep(n) Sleep(n)
|
||||
#else
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
static void nsleep(uint64_t n) {
|
||||
struct timespec timeout;
|
||||
timeout.tv_sec = n / 1000000000;
|
||||
timeout.tv_nsec = n % 1000000000;
|
||||
while (nanosleep(&timeout, &timeout) && errno == EINTR);
|
||||
}
|
||||
#define msleep(n) nsleep(1000000 * (uint64_t)n)
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
static void nsleep(uint64_t n) {
|
||||
struct timespec timeout;
|
||||
timeout.tv_sec = n / 1000000000;
|
||||
timeout.tv_nsec = n % 1000000000;
|
||||
while (nanosleep(&timeout, &timeout) && errno == EINTR);
|
||||
}
|
||||
#define msleep(n) nsleep(1000000 * (uint64_t)n)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,16 +12,8 @@
|
|||
|
||||
#ifndef __USB_CMD_H
|
||||
#define __USB_CMD_H
|
||||
#ifdef _MSC_VER
|
||||
typedef DWORD uint32_t;
|
||||
typedef BYTE uint8_t;
|
||||
#define PACKED
|
||||
// stuff
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#define PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#include "proxmark3.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t cmd;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef __ELF_H__
|
||||
#define __ELF_H__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t p_type;
|
||||
uint32_t p_offset;
|
||||
|
@ -18,7 +20,7 @@ typedef struct {
|
|||
uint32_t p_memsz;
|
||||
uint32_t p_flags;
|
||||
uint32_t p_align;
|
||||
} __attribute__((__packed__)) Elf32_Phdr;
|
||||
} PACKED Elf32_Phdr;
|
||||
|
||||
#define EI_NIDENT 16
|
||||
|
||||
|
@ -37,7 +39,7 @@ typedef struct {
|
|||
uint16_t e_shentsize;
|
||||
uint16_t e_shnum;
|
||||
uint16_t e_shtrndx;
|
||||
} __attribute__((__packed__)) Elf32_Ehdr;
|
||||
} PACKED Elf32_Ehdr;
|
||||
|
||||
#define PT_NULL 0
|
||||
#define PT_LOAD 1
|
||||
|
|
|
@ -314,3 +314,190 @@ const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2) {
|
|||
else
|
||||
return APDUCodeTable[0].Description; //empty string
|
||||
}
|
||||
|
||||
int APDUDecode(uint8_t *data, int len, APDUStruct *apdu) {
|
||||
ExtAPDUHeader *hapdu = (ExtAPDUHeader *)data;
|
||||
|
||||
apdu->cla = hapdu->cla;
|
||||
apdu->ins = hapdu->ins;
|
||||
apdu->p1 = hapdu->p1;
|
||||
apdu->p2 = hapdu->p2;
|
||||
|
||||
apdu->lc = 0;
|
||||
apdu->data = NULL;
|
||||
apdu->le = 0;
|
||||
apdu->extended_apdu = false;
|
||||
apdu->case_type = 0x00;
|
||||
|
||||
uint8_t b0 = hapdu->lc[0];
|
||||
|
||||
// case 1
|
||||
if (len == 4) {
|
||||
apdu->case_type = 0x01;
|
||||
}
|
||||
|
||||
// case 2S (Le)
|
||||
if (len == 5) {
|
||||
apdu->case_type = 0x02;
|
||||
apdu->le = b0;
|
||||
if (!apdu->le)
|
||||
apdu->le = 0x100;
|
||||
}
|
||||
|
||||
// case 3S (Lc + data)
|
||||
if (len == 5U + b0 && b0 != 0) {
|
||||
apdu->case_type = 0x03;
|
||||
apdu->lc = b0;
|
||||
}
|
||||
|
||||
// case 4S (Lc + data + Le)
|
||||
if (len == 5U + b0 + 1U && b0 != 0) {
|
||||
apdu->case_type = 0x04;
|
||||
apdu->lc = b0;
|
||||
apdu->le = data[len - 1];
|
||||
if (!apdu->le)
|
||||
apdu->le = 0x100;
|
||||
}
|
||||
|
||||
// extended length apdu
|
||||
if (len >= 7 && b0 == 0) {
|
||||
uint16_t extlen = (hapdu->lc[1] << 8) + hapdu->lc[2];
|
||||
|
||||
// case 2E (Le) - extended
|
||||
if (len == 7) {
|
||||
apdu->case_type = 0x12;
|
||||
apdu->extended_apdu = true;
|
||||
apdu->le = extlen;
|
||||
if (!apdu->le)
|
||||
apdu->le = 0x10000;
|
||||
}
|
||||
|
||||
// case 3E (Lc + data) - extended
|
||||
if (len == 7U + extlen) {
|
||||
apdu->case_type = 0x13;
|
||||
apdu->extended_apdu = true;
|
||||
apdu->lc = extlen;
|
||||
}
|
||||
|
||||
// case 4E (Lc + data + Le) - extended 2-byte Le
|
||||
if (len == 7U + extlen + 2U) {
|
||||
apdu->case_type = 0x14;
|
||||
apdu->extended_apdu = true;
|
||||
apdu->lc = extlen;
|
||||
apdu->le = (data[len - 2] << 8) + data[len - 1];
|
||||
if (!apdu->le)
|
||||
apdu->le = 0x10000;
|
||||
}
|
||||
|
||||
// case 4E (Lc + data + Le) - extended 3-byte Le
|
||||
if (len == 7U + extlen + 3U && data[len - 3] == 0) {
|
||||
apdu->case_type = 0x24;
|
||||
apdu->extended_apdu = true;
|
||||
apdu->lc = extlen;
|
||||
apdu->le = (data[len - 2] << 8) + data[len - 1];
|
||||
if (!apdu->le)
|
||||
apdu->le = 0x10000;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apdu->case_type)
|
||||
return 1;
|
||||
|
||||
if (apdu->lc) {
|
||||
if (apdu->extended_apdu) {
|
||||
apdu->data = data + 7;
|
||||
} else {
|
||||
apdu->data = data + 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APDUEncode(APDUStruct *apdu, uint8_t *data, int *len) {
|
||||
if (len)
|
||||
*len = 0;
|
||||
|
||||
if (apdu->le > 0x10000 || apdu->lc > 0xffff)
|
||||
return 1;
|
||||
|
||||
size_t dptr = 0;
|
||||
data[dptr++] = apdu->cla;
|
||||
data[dptr++] = apdu->ins;
|
||||
data[dptr++] = apdu->p1;
|
||||
data[dptr++] = apdu->p2;
|
||||
|
||||
if (apdu->lc) {
|
||||
if (apdu->extended_apdu || apdu->lc > 0xff || apdu->le > 0x100) {
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = (apdu->lc >> 8) & 0xff;
|
||||
data[dptr++] = (apdu->lc) & 0xff;
|
||||
memmove(&data[dptr], apdu->data, apdu->lc);
|
||||
dptr += apdu->lc;
|
||||
apdu->extended_apdu = true;
|
||||
} else {
|
||||
data[dptr++] = apdu->lc;
|
||||
memmove(&data[dptr], apdu->data, apdu->lc);
|
||||
dptr += apdu->lc;
|
||||
}
|
||||
}
|
||||
|
||||
if (apdu->le) {
|
||||
if (apdu->extended_apdu) {
|
||||
if (apdu->le != 0x10000) {
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = (apdu->le >> 8) & 0xff;
|
||||
data[dptr++] = (apdu->le) & 0xff;
|
||||
} else {
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = 0x00;
|
||||
}
|
||||
} else {
|
||||
if (apdu->le != 0x100)
|
||||
data[dptr++] = apdu->le;
|
||||
else
|
||||
data[dptr++] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
if (len)
|
||||
*len = dptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APDUEncodeS(sAPDU *sapdu, bool extended, uint16_t le, uint8_t *data, int *len) {
|
||||
if (extended && le > 0x100)
|
||||
return 10;
|
||||
|
||||
APDUStruct apdu;
|
||||
|
||||
apdu.cla = sapdu->CLA;
|
||||
apdu.ins = sapdu->INS;
|
||||
apdu.p1 = sapdu->P1;
|
||||
apdu.p2 = sapdu->P2;
|
||||
|
||||
apdu.lc = sapdu->Lc;
|
||||
if (sapdu->Lc)
|
||||
apdu.data = sapdu->data;
|
||||
else
|
||||
apdu.data = NULL;
|
||||
apdu.le = le;
|
||||
|
||||
apdu.extended_apdu = extended;
|
||||
apdu.case_type = 0x00;
|
||||
|
||||
return APDUEncode(&apdu, data, len);
|
||||
}
|
||||
|
||||
void APDUPrint(APDUStruct apdu) {
|
||||
APDUPrintEx(apdu, 0);
|
||||
}
|
||||
|
||||
void APDUPrintEx(APDUStruct apdu, size_t maxdatalen) {
|
||||
PrintAndLogEx(INFO, "APDU: %scase=0x%02x cla=0x%02x ins=0x%02x p1=0x%02x p2=0x%02x Lc=0x%02x(%d) Le=0x%02x(%d)",
|
||||
apdu.extended_apdu ? "[e]" : "", apdu.case_type, apdu.cla, apdu.ins, apdu.p1, apdu.p2, apdu.lc, apdu.lc, apdu.le, apdu.le);
|
||||
if (maxdatalen > 0)
|
||||
PrintAndLogEx(INFO, "data: %s%s", sprint_hex(apdu.data, MIN(apdu.lc, maxdatalen)), apdu.lc > maxdatalen ? "..." : "");
|
||||
}
|
||||
|
|
|
@ -14,8 +14,11 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#define APDUCODE_TYPE_NONE 0
|
||||
#define APDUCODE_TYPE_INFO 1
|
||||
#define APDUCODE_TYPE_WARNING 2
|
||||
|
@ -31,4 +34,39 @@ typedef struct {
|
|||
const APDUCode *GetAPDUCode(uint8_t sw1, uint8_t sw2);
|
||||
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
|
||||
|
||||
typedef struct {
|
||||
uint8_t CLA;
|
||||
uint8_t INS;
|
||||
uint8_t P1;
|
||||
uint8_t P2;
|
||||
uint8_t Lc;
|
||||
uint8_t *data;
|
||||
} PACKED sAPDU;
|
||||
|
||||
typedef struct {
|
||||
uint8_t cla;
|
||||
uint8_t ins;
|
||||
uint8_t p1;
|
||||
uint8_t p2;
|
||||
uint8_t lc[3];
|
||||
} PACKED ExtAPDUHeader;
|
||||
|
||||
typedef struct {
|
||||
uint8_t cla;
|
||||
uint8_t ins;
|
||||
uint8_t p1;
|
||||
uint8_t p2;
|
||||
uint16_t lc;
|
||||
uint8_t *data;
|
||||
uint32_t le;
|
||||
bool extended_apdu;
|
||||
uint8_t case_type;
|
||||
} PACKED APDUStruct;
|
||||
|
||||
extern int APDUDecode(uint8_t *data, int len, APDUStruct *apdu);
|
||||
extern int APDUEncode(APDUStruct *apdu, uint8_t *data, int *len);
|
||||
extern int APDUEncodeS(sAPDU *apdu, bool extended, uint16_t le, uint8_t *data, int *len);
|
||||
extern void APDUPrint(APDUStruct apdu);
|
||||
extern void APDUPrintEx(APDUStruct apdu, size_t maxdatalen);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -287,8 +287,8 @@ static int CmdEMVGPO(const char *Cmd) {
|
|||
PrintAndLogEx(ERR, "Can't create PDOL data.");
|
||||
tlvdb_free(tmp_ext);
|
||||
tlvdb_free(tlvRoot);
|
||||
if (pdol_data_tlv != &data_tlv);
|
||||
free(pdol_data_tlv);
|
||||
if (pdol_data_tlv != &data_tlv)
|
||||
free(pdol_data_tlv);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
||||
|
@ -830,6 +830,12 @@ static int CmdEMVExec(const char *Cmd) {
|
|||
SetAPDULogging(showAPDU);
|
||||
res = EMVSearchPSE(channel, activateField, true, psenum, decodeTLV, tlvSelect);
|
||||
|
||||
// check PPSE instead of PSE and vice versa
|
||||
if (res) {
|
||||
PrintAndLogEx(NORMAL, "Check PPSE instead of PSE and vice versa...");
|
||||
res = EMVSearchPSE(channel, false, true, psenum == 1 ? 2 : 1, decodeTLV, tlvSelect);
|
||||
}
|
||||
|
||||
// check PPSE and select application id
|
||||
if (!res) {
|
||||
TLVPrintAIDlistFromSelectTLV(tlvSelect);
|
||||
|
@ -931,7 +937,7 @@ static int CmdEMVExec(const char *Cmd) {
|
|||
|
||||
while (AFL && AFL->len) {
|
||||
if (AFL->len % 4) {
|
||||
PrintAndLogEx(WARNING, "Error: Wrong AFL length: %d", AFL->len);
|
||||
PrintAndLogEx(WARNING, "Warning: Wrong AFL length: %d", AFL->len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1007,7 @@ static int CmdEMVExec(const char *Cmd) {
|
|||
AIP = AIPtlv->value[0] + AIPtlv->value[1] * 0x100;
|
||||
PrintAndLogEx(NORMAL, "* * AIP=%04x", AIP);
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Can't found AIP.");
|
||||
PrintAndLogEx(ERR, "Can't find AIP.");
|
||||
}
|
||||
|
||||
// SDA
|
||||
|
@ -1047,11 +1053,11 @@ static int CmdEMVExec(const char *Cmd) {
|
|||
TLVPrintFromTLVLev(cvr, 1);
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "WARNING: IAD not found.");
|
||||
PrintAndLogEx(WARNING, "WARNING: IAD not found.");
|
||||
}
|
||||
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error AC: Application Transaction Counter (ATC) not found.");
|
||||
PrintAndLogEx(WARNING, "Warning AC: Application Transaction Counter (ATC) not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1131,14 +1137,14 @@ static int CmdEMVExec(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "Transaction approved ONLINE.");
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Error: CID transaction code error %2x", CID->value[0] & EMVAC_AC_MASK);
|
||||
PrintAndLogEx(WARNING, "Warning: CID transaction code error %2x", CID->value[0] & EMVAC_AC_MASK);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error: Wrong CID length %d", CID->len);
|
||||
PrintAndLogEx(WARNING, "Warning: Wrong CID length %d", CID->len);
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error: CID(9F27) not found.");
|
||||
PrintAndLogEx(WARNING, "Warning: CID(9F27) not found.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "emv_pk.h"
|
||||
#include "crypto.h"
|
||||
#include "proxmark3.h"
|
||||
|
||||
#include "util.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -398,7 +398,7 @@ static struct emv_pk *emv_pk_get_ca_pk_from_file(const char *fname,
|
|||
|
||||
FILE *f = fopen(fname, "r");
|
||||
if (!f) {
|
||||
perror("fopen");
|
||||
PrintAndLogEx(ERR, "Error: can't open file %s.", fname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -277,24 +277,25 @@ static int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool Lea
|
|||
}
|
||||
|
||||
// COMPUTE APDU
|
||||
memcpy(data, &apdu, 5);
|
||||
if (apdu.data)
|
||||
memcpy(&data[5], apdu.data, apdu.Lc);
|
||||
int datalen = 0;
|
||||
if (APDUEncodeS(&apdu, false, IncludeLe ? 0x100 : 0x00, data, &datalen)) {
|
||||
PrintAndLogEx(ERR, "APDU encoding error.");
|
||||
return 201;
|
||||
}
|
||||
|
||||
if (APDULogging)
|
||||
PrintAndLogEx(SUCCESS, ">>>> %s", sprint_hex(data, (IncludeLe ? 6 : 5) + apdu.Lc));
|
||||
PrintAndLogEx(SUCCESS, ">>>> %s", sprint_hex(data, datalen));
|
||||
|
||||
switch (channel) {
|
||||
case ECC_CONTACTLESS:
|
||||
// 6 byes + data = INS + CLA + P1 + P2 + Lc + <data = Nc> + Le(?IncludeLe)
|
||||
res = ExchangeAPDU14a(data, (IncludeLe ? 6 : 5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||
res = ExchangeAPDU14a(data, datalen, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
break;
|
||||
case ECC_CONTACT:
|
||||
if (IfPm3Smartcard())
|
||||
res = ExchangeAPDUSC(data, (IncludeLe ? 6 : 5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||
res = ExchangeAPDUSC(data, datalen, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||
else
|
||||
res = 1;
|
||||
if (res) {
|
||||
|
@ -336,7 +337,7 @@ static int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool Lea
|
|||
}
|
||||
|
||||
int EMVExchange(EMVCommandChannel channel, bool LeaveFieldON, sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
||||
return EMVExchangeEx(channel, false, LeaveFieldON, apdu, (channel == ECC_CONTACTLESS), Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
return EMVExchangeEx(channel, false, LeaveFieldON, apdu, false, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
}
|
||||
|
||||
int EMVSelect(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t *AID, size_t AIDLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
||||
|
@ -511,7 +512,7 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
|||
PrintAndLogEx(WARNING, "%s ERROR: Can't get TLV from response.", PSE_or_PPSE);
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "%s ERROR: Can't select PPSE AID. Error: %d", PSE_or_PPSE, res);
|
||||
PrintAndLogEx(ERR, "%s ERROR: Can't select PPSE AID. Error: %d", PSE_or_PPSE, res);
|
||||
}
|
||||
|
||||
if (!LeaveFieldON)
|
||||
|
@ -531,14 +532,17 @@ int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON,
|
|||
int retrycnt = 0;
|
||||
for (int i = 0; i < AIDlistLen; i ++) {
|
||||
param_gethex_to_eol(AIDlist[i].aid, 0, aidbuf, sizeof(aidbuf), &aidlen);
|
||||
res = EMVSelect(channel, (i == 0) ? ActivateField : false, (i == AIDlistLen - 1) ? LeaveFieldON : true, aidbuf, aidlen, data, sizeof(data), &datalen, &sw, tlv);
|
||||
res = EMVSelect(channel, (i == 0) ? ActivateField : false, true, aidbuf, aidlen, data, sizeof(data), &datalen, &sw, tlv);
|
||||
// retry if error and not returned sw error
|
||||
if (res && res != 5) {
|
||||
if (++retrycnt < 3) {
|
||||
i--;
|
||||
} else {
|
||||
// (1) - card select error, proxmark error OR (200) - result length = 0
|
||||
if (res == 1 || res == 200) {
|
||||
// (1) - card select error, (4) reply timeout, (200) - result length = 0
|
||||
if (res == 1 || res == 4 ||res == 200) {
|
||||
if (!LeaveFieldON)
|
||||
DropFieldEx(channel);
|
||||
|
||||
PrintAndLogEx(WARNING, "Exit...");
|
||||
return 1;
|
||||
}
|
||||
|
@ -562,6 +566,9 @@ int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON,
|
|||
}
|
||||
}
|
||||
|
||||
if (!LeaveFieldON)
|
||||
DropFieldEx(channel);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -609,9 +616,9 @@ int EMVGPO(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *PDOL, size_t P
|
|||
}
|
||||
|
||||
int EMVReadRecord(EMVCommandChannel channel, bool LeaveFieldON, uint8_t SFI, uint8_t SFIrec, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
||||
int res = EMVExchange(channel, LeaveFieldON, (sAPDU) {0x00, 0xb2, SFIrec, (SFI << 3) | 0x04, 0, NULL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
if (*sw == 0x6700) {
|
||||
PrintAndLogEx(INFO, ">>> trying to reissue command withouth Le...");
|
||||
int res = EMVExchangeEx(channel, false, LeaveFieldON, (sAPDU) {0x00, 0xb2, SFIrec, (SFI << 3) | 0x04, 0, NULL}, true, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
if (*sw == 0x6700 || *sw == 0x6f00) {
|
||||
PrintAndLogEx(INFO, ">>> trying to reissue command without Le...");
|
||||
res = EMVExchangeEx(channel, false, LeaveFieldON, (sAPDU) {0x00, 0xb2, SFIrec, (SFI << 3) | 0x04, 0, NULL}, false, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
}
|
||||
return res;
|
||||
|
@ -622,9 +629,9 @@ int EMVAC(EMVCommandChannel channel, bool LeaveFieldON, uint8_t RefControl, uint
|
|||
}
|
||||
|
||||
int EMVGenerateChallenge(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
||||
int res = EMVExchange(channel, LeaveFieldON, (sAPDU) {0x00, 0x84, 0x00, 0x00, 0x00, NULL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
if (*sw == 0x6700) {
|
||||
PrintAndLogEx(INFO, ">>> trying to reissue command withouth Le...");
|
||||
int res = EMVExchangeEx(channel, false, LeaveFieldON, (sAPDU) {0x00, 0x84, 0x00, 0x00, 0x00, NULL}, true, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
if (*sw == 0x6700 || *sw == 0x6f00) {
|
||||
PrintAndLogEx(INFO, ">>> trying to reissue command without Le...");
|
||||
res = EMVExchangeEx(channel, false, LeaveFieldON, (sAPDU) {0x00, 0x84, 0x00, 0x00, 0x00, NULL}, false, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||
}
|
||||
return res;
|
||||
|
@ -654,14 +661,14 @@ int trSDA(struct tlvdb *tlv) {
|
|||
|
||||
struct emv_pk *pk = get_ca_pk(tlv);
|
||||
if (!pk) {
|
||||
PrintAndLogEx(WARNING, "Error: Key not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Key not found. Exit.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
struct emv_pk *issuer_pk = emv_pki_recover_issuer_cert(pk, tlv);
|
||||
if (!issuer_pk) {
|
||||
emv_pk_free(pk);
|
||||
PrintAndLogEx(WARNING, "Error: Issuer certificate not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Issuer certificate not found. Exit.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -693,7 +700,7 @@ int trSDA(struct tlvdb *tlv) {
|
|||
} else {
|
||||
emv_pk_free(issuer_pk);
|
||||
emv_pk_free(pk);
|
||||
PrintAndLogEx(WARNING, "SSAD verify error");
|
||||
PrintAndLogEx(ERR, "SSAD verify error");
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -712,21 +719,21 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
|
||||
struct emv_pk *pk = get_ca_pk(tlv);
|
||||
if (!pk) {
|
||||
PrintAndLogEx(WARNING, "Error: Key not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Key not found. Exit.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
const struct tlv *sda_tlv = tlvdb_get(tlv, 0x21, NULL);
|
||||
/* if (!sda_tlv || sda_tlv->len < 1) { it may be 0!!!!
|
||||
emv_pk_free(pk);
|
||||
PrintAndLogEx(WARNING, "Error: Can't find input list for Offline Data Authentication. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Can't find input list for Offline Data Authentication. Exit.");
|
||||
return 3;
|
||||
}
|
||||
*/
|
||||
struct emv_pk *issuer_pk = emv_pki_recover_issuer_cert(pk, tlv);
|
||||
if (!issuer_pk) {
|
||||
emv_pk_free(pk);
|
||||
PrintAndLogEx(WARNING, "Error: Issuer certificate not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Issuer certificate not found. Exit.");
|
||||
return 2;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Issuer PK recovered. RID %02hhx:%02hhx:%02hhx:%02hhx:%02hhx IDX %02hhx CSN %02hhx:%02hhx:%02hhx\n",
|
||||
|
@ -745,7 +752,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
if (!icc_pk) {
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
PrintAndLogEx(WARNING, "Error: ICC certificate not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: ICC certificate not found. Exit.");
|
||||
return 2;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "ICC PK recovered. RID %02hhx:%02hhx:%02hhx:%02hhx:%02hhx IDX %02hhx CSN %02hhx:%02hhx:%02hhx\n",
|
||||
|
@ -790,7 +797,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
|
||||
const struct tlvdb *atc_db = emv_pki_recover_atc_ex(icc_pk, tlv, true);
|
||||
if (!atc_db) {
|
||||
PrintAndLogEx(WARNING, "Error: Can't recover IDN (ICC Dynamic Number)");
|
||||
PrintAndLogEx(ERR, "Error: Can't recover IDN (ICC Dynamic Number)");
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
emv_pk_free(icc_pk);
|
||||
|
@ -823,7 +830,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
PrintAndLogEx(NORMAL, "SDAD verified OK. (Data Authentication Code: %02hhx:%02hhx)\n", dac_tlv->value[0], dac_tlv->value[1]);
|
||||
tlvdb_add(tlv, dac_db);
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error: SSAD verify error");
|
||||
PrintAndLogEx(ERR, "Error: SSAD verify error");
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
emv_pk_free(icc_pk);
|
||||
|
@ -839,7 +846,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
|
||||
struct tlv *ddol_data_tlv = dol_process(ddol_tlv, tlv, 0);
|
||||
if (!ddol_data_tlv) {
|
||||
PrintAndLogEx(WARNING, "Error: Can't create DDOL TLV");
|
||||
PrintAndLogEx(ERR, "Error: Can't create DDOL TLV");
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
emv_pk_free(icc_pk);
|
||||
|
@ -851,7 +858,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
PrintAndLogEx(NORMAL, "\n* Internal Authenticate");
|
||||
int res = EMVInternalAuthenticate(channel, true, (uint8_t *)ddol_data_tlv->value, ddol_data_tlv->len, buf, sizeof(buf), &len, &sw, NULL);
|
||||
if (res) {
|
||||
PrintAndLogEx(WARNING, "Internal Authenticate error(%d): %4x. Exit...", res, sw);
|
||||
PrintAndLogEx(ERR, "Internal Authenticate error(%d): %4x. Exit...", res, sw);
|
||||
free(ddol_data_tlv);
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
|
@ -862,7 +869,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
struct tlvdb *dda_db = NULL;
|
||||
if (buf[0] == 0x80) {
|
||||
if (len < 3) {
|
||||
PrintAndLogEx(WARNING, "Error: Internal Authenticate format1 parsing error. length=%d", len);
|
||||
PrintAndLogEx(WARNING, "Warning: Internal Authenticate format1 parsing error. length=%d", len);
|
||||
} else {
|
||||
// parse response 0x80
|
||||
struct tlvdb *t80 = tlvdb_parse_multi(buf, len);
|
||||
|
@ -882,7 +889,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
} else {
|
||||
dda_db = tlvdb_parse_multi(buf, len);
|
||||
if (!dda_db) {
|
||||
PrintAndLogEx(WARNING, "Error: Can't parse Internal Authenticate result as TLV");
|
||||
PrintAndLogEx(ERR, "Error: Can't parse Internal Authenticate result as TLV");
|
||||
free(ddol_data_tlv);
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
|
@ -898,7 +905,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
|||
struct tlvdb *idn_db = emv_pki_recover_idn_ex(icc_pk, dda_db, ddol_data_tlv, true);
|
||||
free(ddol_data_tlv);
|
||||
if (!idn_db) {
|
||||
PrintAndLogEx(WARNING, "Error: Can't recover IDN (ICC Dynamic Number)");
|
||||
PrintAndLogEx(ERR, "Error: Can't recover IDN (ICC Dynamic Number)");
|
||||
tlvdb_free(dda_db);
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
|
@ -935,20 +942,20 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
|
|||
|
||||
struct emv_pk *pk = get_ca_pk(tlv);
|
||||
if (!pk) {
|
||||
PrintAndLogEx(WARNING, "Error: Key not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Key not found. Exit.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
const struct tlv *sda_tlv = tlvdb_get(tlv, 0x21, NULL);
|
||||
if (!sda_tlv || sda_tlv->len < 1) {
|
||||
PrintAndLogEx(WARNING, "Error: Can't find input list for Offline Data Authentication. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Can't find input list for Offline Data Authentication. Exit.");
|
||||
emv_pk_free(pk);
|
||||
return 3;
|
||||
}
|
||||
|
||||
struct emv_pk *issuer_pk = emv_pki_recover_issuer_cert(pk, tlv);
|
||||
if (!issuer_pk) {
|
||||
PrintAndLogEx(WARNING, "Error: Issuer certificate not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: Issuer certificate not found. Exit.");
|
||||
emv_pk_free(pk);
|
||||
return 2;
|
||||
}
|
||||
|
@ -966,7 +973,7 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
|
|||
|
||||
struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv);
|
||||
if (!icc_pk) {
|
||||
PrintAndLogEx(WARNING, "Error: ICC certificate not found. Exit.");
|
||||
PrintAndLogEx(ERR, "Error: ICC certificate not found. Exit.");
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
return 2;
|
||||
|
@ -989,7 +996,7 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
|
|||
PrintAndLogEx(NORMAL, "SSAD verified OK. (%02hhx:%02hhx)", dac_tlv->value[0], dac_tlv->value[1]);
|
||||
tlvdb_add(tlv, dac_db);
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Error: SSAD verify error");
|
||||
PrintAndLogEx(ERR, "Error: SSAD verify error");
|
||||
emv_pk_free(pk);
|
||||
emv_pk_free(issuer_pk);
|
||||
emv_pk_free(icc_pk);
|
||||
|
|
|
@ -45,15 +45,6 @@ enum TransactionType {
|
|||
};
|
||||
extern const char *TransactionTypeStr[];
|
||||
|
||||
typedef struct {
|
||||
uint8_t CLA;
|
||||
uint8_t INS;
|
||||
uint8_t P1;
|
||||
uint8_t P2;
|
||||
uint8_t Lc;
|
||||
uint8_t *data;
|
||||
} sAPDU;
|
||||
|
||||
enum CardPSVendor {
|
||||
CV_NA,
|
||||
CV_VISA,
|
||||
|
|
|
@ -173,6 +173,10 @@ static int check_segs(flash_file_t *ctx, int can_write_bl) {
|
|||
PrintAndLogEx(ERR, "Attempted to write bootloader but bootloader writes are not enabled");
|
||||
return -1;
|
||||
}
|
||||
if (can_write_bl && seg->start < BOOTLOADER_END && (seg->start + seg->length > BOOTLOADER_END)) {
|
||||
PrintAndLogEx(ERR, "Error: Segment is outside of bootloader bounds");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -188,7 +192,6 @@ int flash_load(flash_file_t *ctx, const char *name, int can_write_bl) {
|
|||
fd = fopen(name, "rb");
|
||||
if (!fd) {
|
||||
PrintAndLogEx(ERR, _RED_("Could not open file") "%s >>> ", name);
|
||||
perror(NULL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -343,7 +346,7 @@ static int wait_for_ack(PacketResponseNG *ack) {
|
|||
}
|
||||
|
||||
// Go into flashing mode
|
||||
int flash_start_flashing(int enable_bl_writes, char *serial_port_name) {
|
||||
int flash_start_flashing(int enable_bl_writes, char *serial_port_name, uint32_t *chipinfo) {
|
||||
uint32_t state;
|
||||
|
||||
if (enter_bootloader(serial_port_name) < 0)
|
||||
|
@ -352,6 +355,13 @@ int flash_start_flashing(int enable_bl_writes, char *serial_port_name) {
|
|||
if (get_proxmark_state(&state) < 0)
|
||||
return -1;
|
||||
|
||||
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO) {
|
||||
SendCommandBL(CMD_CHIP_INFO, 0, 0, 0, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_CHIP_INFO, &resp);
|
||||
*chipinfo = resp.oldarg[0];
|
||||
}
|
||||
|
||||
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
|
||||
// This command is stupid. Why the heck does it care which area we're
|
||||
// flashing, as long as it's not the bootloader area? The mind boggles.
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
} flash_file_t;
|
||||
|
||||
int flash_load(flash_file_t *ctx, const char *name, int can_write_bl);
|
||||
int flash_start_flashing(int enable_bl_writes, char *serial_port_name);
|
||||
int flash_start_flashing(int enable_bl_writes, char *serial_port_name, uint32_t *chipid);
|
||||
int flash_write(flash_file_t *ctx);
|
||||
void flash_free(flash_file_t *ctx);
|
||||
int flash_stop_flashing(void);
|
||||
|
|
|
@ -35,6 +35,42 @@ static void usage(char *argv0) {
|
|||
#endif
|
||||
}
|
||||
|
||||
int chipid_to_mem_avail(uint32_t iChipID) {
|
||||
int mem_avail = 0;
|
||||
switch ((iChipID & 0xF00) >> 8) {
|
||||
case 0:
|
||||
mem_avail = 0;
|
||||
break;
|
||||
case 1:
|
||||
mem_avail = 8;
|
||||
break;
|
||||
case 2:
|
||||
mem_avail = 16;
|
||||
break;
|
||||
case 3:
|
||||
mem_avail = 32;
|
||||
break;
|
||||
case 5:
|
||||
mem_avail = 64;
|
||||
break;
|
||||
case 7:
|
||||
mem_avail = 128;
|
||||
break;
|
||||
case 9:
|
||||
mem_avail = 256;
|
||||
break;
|
||||
case 10:
|
||||
mem_avail = 512;
|
||||
break;
|
||||
case 12:
|
||||
mem_avail = 1024;
|
||||
break;
|
||||
case 14:
|
||||
mem_avail = 2048;
|
||||
}
|
||||
return mem_avail;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int can_write_bl = 0;
|
||||
int num_files = 0;
|
||||
|
@ -84,12 +120,21 @@ int main(int argc, char **argv) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
res = flash_start_flashing(can_write_bl, serial_port_name);
|
||||
uint32_t chipid = 0;
|
||||
res = flash_start_flashing(can_write_bl, serial_port_name, &chipid);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
|
||||
int mem_avail = chipid_to_mem_avail(chipid);
|
||||
if (mem_avail != 0) {
|
||||
PrintAndLogEx(NORMAL, "Available memory on this board: %uK bytes\n", mem_avail);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "Available memory on this board: "_RED_("UNKNOWN")"\n");
|
||||
PrintAndLogEx(ERR, _RED_("Note: Your bootloader does not understand the new CHIP_INFO command"));
|
||||
PrintAndLogEx(ERR, _RED_("It is recommended that you update your bootloader") "\n");
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "\n" _BLUE_("Flashing..."));
|
||||
|
||||
// TODO check if enough space on Pm3 mem to write the given files
|
||||
for (int i = 0; i < num_files; i++) {
|
||||
res = flash_write(&files[i]);
|
||||
if (res < 0)
|
||||
|
|
|
@ -375,7 +375,7 @@ static void print_version_info_preamble(FILE *outfile, int num_infiles) {
|
|||
fprintf(outfile, "\n");
|
||||
fprintf(outfile, "\n");
|
||||
fprintf(outfile, "const int fpga_bitstream_num = %d;\n", num_infiles);
|
||||
fprintf(outfile, "const char* const fpga_version_information[%d] = {\n", num_infiles);
|
||||
fprintf(outfile, "const char *const fpga_version_information[%d] = {\n", num_infiles);
|
||||
}
|
||||
|
||||
static int generate_fpga_version_info(FILE *infile[], char *infile_names[], int num_infiles, FILE *outfile) {
|
||||
|
@ -386,7 +386,7 @@ static int generate_fpga_version_info(FILE *infile[], char *infile_names[], int
|
|||
|
||||
for (int i = 0; i < num_infiles; i++) {
|
||||
FpgaGatherVersion(infile[i], infile_names[i], version_string, sizeof(version_string));
|
||||
fprintf(outfile, "\t\" %s\"", version_string);
|
||||
fprintf(outfile, " \" %s\"", version_string);
|
||||
if (i != num_infiles - 1) {
|
||||
fprintf(outfile, ",");
|
||||
}
|
||||
|
|
|
@ -36,15 +36,23 @@ CFILES = $(filter %.c, $(libjansson_la_SOURCES))
|
|||
CMDOBJS = $(CFILES:%.c=%.o)
|
||||
CLEAN = $(CMDOBJS)
|
||||
|
||||
platform = $(shell uname)
|
||||
|
||||
CC= gcc
|
||||
CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function -Wno-format-truncation
|
||||
CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function
|
||||
|
||||
LDFLAGS= $(SYSLDFLAGS) $(libjansson_la_LDFLAGS)
|
||||
LIBS= $(SYSLIBS) $(MYLIBS)
|
||||
DEFAULT_INCLUDES = -I.
|
||||
DEFS = -DHAVE_STDINT_H
|
||||
|
||||
ifeq ($(platform),Darwin)
|
||||
AR= /usr/bin/ar rcs
|
||||
RANLIB= /usr/bin/ranlib
|
||||
else
|
||||
AR= ar rcs
|
||||
RANLIB= ranlib
|
||||
endif
|
||||
RM= rm -f
|
||||
TST= echo
|
||||
|
||||
|
|
|
@ -111,7 +111,11 @@ static void error_set(json_error_t *error, const lex_t *lex,
|
|||
|
||||
if (saved_text && saved_text[0]) {
|
||||
if (lex->saved_text.length <= 20) {
|
||||
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near '%s'", msg_text, saved_text);
|
||||
int ret = snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near '%s'", msg_text, saved_text);
|
||||
if (ret < 0) {
|
||||
jsonp_error_set(error, line, col, pos, code, "%s", "internal snprint error");
|
||||
return;
|
||||
}
|
||||
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||
result = msg_with_context;
|
||||
}
|
||||
|
@ -124,7 +128,11 @@ static void error_set(json_error_t *error, const lex_t *lex,
|
|||
/* No context for UTF-8 decoding errors */
|
||||
result = msg_text;
|
||||
} else {
|
||||
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near end of file", msg_text);
|
||||
int ret = snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near end of file", msg_text);
|
||||
if (ret < 0) {
|
||||
jsonp_error_set(error, line, col, pos, code, "%s", "internal snprint error");
|
||||
return;
|
||||
}
|
||||
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||
result = msg_with_context;
|
||||
}
|
||||
|
|
|
@ -517,7 +517,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
|
|||
first16bytes[i] = keytable[i] & 0xFF;
|
||||
|
||||
if (!(keytable[i] & CRACKED))
|
||||
PrintAndLogDevice(WARNING, "error, we are missing byte %d, custom key calculation will fail...", i);
|
||||
PrintAndLogDevice(WARNING, "Warning: we are missing byte %d, custom key calculation will fail...", i);
|
||||
}
|
||||
errors += calculateMasterKey(first16bytes, NULL);
|
||||
return errors;
|
||||
|
@ -541,7 +541,7 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) {
|
|||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize <= 0) {
|
||||
PrintAndLogDevice(WARNING, "Error, when getting filesize");
|
||||
PrintAndLogDevice(ERR, "Error, when getting filesize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) {
|
|||
fclose(f);
|
||||
|
||||
if (bytes_read < fsize) {
|
||||
PrintAndLogDevice(WARNING, "Error, could only read %d bytes (should be %d)", bytes_read, fsize);
|
||||
PrintAndLogDevice(WARNING, "Warning: could only read %d bytes (should be %d)", bytes_read, fsize);
|
||||
}
|
||||
|
||||
uint8_t res = bruteforceDump(dump, fsize, keytable);
|
||||
|
@ -612,7 +612,7 @@ static int _testBruteforce() {
|
|||
} else if (fileExists("client/loclass/iclass_dump.bin")) {
|
||||
errors |= bruteforceFile("client/loclass/iclass_dump.bin", keytable);
|
||||
} else {
|
||||
PrintAndLogDevice(WARNING, "Error: The file iclass_dump.bin was not found!");
|
||||
PrintAndLogDevice(ERR, "Error: The file iclass_dump.bin was not found!");
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
|
@ -627,14 +627,14 @@ static int _test_iclass_key_permutation() {
|
|||
permutekey_rev(testcase_output, testcase_output_rev);
|
||||
|
||||
if (memcmp(testcase_output, testcase_output_correct, 8) != 0) {
|
||||
PrintAndLogDevice(WARNING, "Error with iclass key permute!");
|
||||
PrintAndLogDevice(ERR, "Error with iclass key permute!");
|
||||
printarr("testcase_output", testcase_output, 8);
|
||||
printarr("testcase_output_correct", testcase_output_correct, 8);
|
||||
return 1;
|
||||
|
||||
}
|
||||
if (memcmp(testcase, testcase_output_rev, 8) != 0) {
|
||||
PrintAndLogDevice(WARNING, "Error with reverse iclass key permute");
|
||||
PrintAndLogDevice(ERR, "Error with reverse iclass key permute");
|
||||
printarr("testcase", testcase, 8);
|
||||
printarr("testcase_output_rev", testcase_output_rev, 8);
|
||||
return 1;
|
||||
|
@ -651,7 +651,7 @@ static int _testHash1() {
|
|||
hash1(csn, k);
|
||||
|
||||
if (memcmp(k, expected, 8) != 0) {
|
||||
PrintAndLogDevice(WARNING, "Error with hash1!");
|
||||
PrintAndLogDevice(ERR, "Error with hash1!");
|
||||
printarr("calculated", k, 8);
|
||||
printarr("expected", expected, 8);
|
||||
return 1;
|
||||
|
|
|
@ -14,7 +14,7 @@ function Emulator:set_mem (data, clear_first)
|
|||
-- Clear out the emulator memory first
|
||||
local memclrCmd = Command:newMIX{cmd = cmds.CMD_MIFARE_EML_MEMCLR}
|
||||
|
||||
local _, err = memclrCmd.sendMIX()
|
||||
local _, err = memclrCmd:sendMIX()
|
||||
if err then
|
||||
print('Failed to clear emulator memory:', err)
|
||||
return false
|
||||
|
@ -36,7 +36,7 @@ function Emulator:set_mem (data, clear_first)
|
|||
arg2 = self.BLOCK_COUNT}
|
||||
|
||||
-- Send command and wait for response
|
||||
local _, err = memsetCmd.sendMIX()
|
||||
local _, err = memsetCmd:sendMIX()
|
||||
if err then
|
||||
print('Failed setting memory', err)
|
||||
return false
|
||||
|
@ -62,7 +62,7 @@ function Emulator:get_mem (size)
|
|||
arg2 = MAX_BLOCKS,
|
||||
arg3 = 0}
|
||||
|
||||
local response, err = getmemCmd.sendMIX()
|
||||
local response, err = getmemCmd:sendMIX()
|
||||
if err then
|
||||
print('Failed getting memory:', err)
|
||||
return false
|
||||
|
|
|
@ -15,10 +15,10 @@ local reader15693 = require('read15')
|
|||
-- @return if successfull: an table containing card info
|
||||
-- @return if unsuccessfull : nil, error
|
||||
local function waitForTag()
|
||||
print("Waiting for card... press any key to quit")
|
||||
print("Waiting for card... press Enter to quit")
|
||||
local readers = {reader14443A, reader14443B, reader15693}
|
||||
local i = 0;
|
||||
while not core.ukbhit() do
|
||||
while not core.kbd_enter_pressed() do
|
||||
i = (i % 3) +1
|
||||
r = readers[i]
|
||||
print("Reading with ",i)
|
||||
|
|
|
@ -60,7 +60,7 @@ local function parse14443a(data)
|
|||
uint8_t sak;
|
||||
uint8_t ats_len;
|
||||
uint8_t ats[256];
|
||||
} __attribute__((__packed__)) iso14a_card_select_t;
|
||||
} PACKED iso14a_card_select_t;
|
||||
--]]
|
||||
|
||||
local count, uid, uidlen, atqa, sak, ats_len, ats = bin.unpack('H10CH2CCH', data)
|
||||
|
@ -121,8 +121,8 @@ end
|
|||
-- @return if successfull: an table containing card info
|
||||
-- @return if unsuccessfull : nil, error
|
||||
local function waitFor14443a()
|
||||
print('Waiting for card... press any key to quit')
|
||||
while not core.ukbhit() do
|
||||
print('Waiting for card... press Enter to quit')
|
||||
while not core.kbd_enter_pressed() do
|
||||
res, err = read14443a()
|
||||
if res then return res end
|
||||
-- err means that there was no response from card
|
||||
|
|
|
@ -39,7 +39,7 @@ local function parse1443b(data)
|
|||
uint8_t atqb[7];
|
||||
uint8_t chipid;
|
||||
uint8_t cid;
|
||||
} __attribute__((__packed__)) iso14b_card_select_t;
|
||||
} PACKED iso14b_card_select_t;
|
||||
|
||||
--]]
|
||||
|
||||
|
@ -99,8 +99,8 @@ end
|
|||
-- @return if successfull: an table containing card info
|
||||
-- @return if unsuccessfull : nil, error
|
||||
local function waitFor14443b()
|
||||
print('Waiting for card... press any key to quit')
|
||||
while not core.ukbhit() do
|
||||
print('Waiting for card... press Enter to quit')
|
||||
while not core.kbd_enter_pressed() do
|
||||
res, err = read14443b(false)
|
||||
if res then return res end
|
||||
-- err means that there was no response from card
|
||||
|
@ -112,7 +112,7 @@ end
|
|||
-- turns on the HF field.
|
||||
local function connect14443b()
|
||||
local c = Command:newMIX{cmd = cmds.CMD_ISO_14443B_COMMAND, arg1 = ISO14B_COMMAND.ISO14B_CONNECT}
|
||||
return c.sendMIX(true)
|
||||
return c:sendMIX(true)
|
||||
end
|
||||
---
|
||||
-- Sends an instruction to do nothing, only disconnect
|
||||
|
@ -120,7 +120,7 @@ local function disconnect14443b()
|
|||
local c = Command:newMIX{cmd = cmds.CMD_ISO_14443B_COMMAND, arg1 = ISO14B_COMMAND.ISO14B_DISCONNECT}
|
||||
-- We can ignore the response here, no ACK is returned for this command
|
||||
-- Check /armsrc/iso14443b.c, ReaderIso14443b() for details
|
||||
return c.sendMIX(true)
|
||||
return c:sendMIX(true)
|
||||
end
|
||||
|
||||
local library = {
|
||||
|
|
|
@ -133,8 +133,8 @@ end
|
|||
-- @return if successfull: an table containing card info
|
||||
-- @return if unsuccessfull : nil, error
|
||||
local function waitFor15693()
|
||||
print('Waiting for card... press any key to quit')
|
||||
while not core.ukbhit() do
|
||||
print('Waiting for card... press Enter to quit')
|
||||
while not core.kbd_enter_pressed() do
|
||||
res, err = read15693()
|
||||
if res then return res end
|
||||
-- err means that there was no response from card
|
||||
|
@ -147,7 +147,7 @@ local function disconnect15693()
|
|||
local c = Command:newMIX{cmd = cmds.CMD_ISO_15693_COMMAND}
|
||||
-- We can ignore the response here, no ACK is returned for this command
|
||||
-- Check /armsrc/iso14443a.c, ReaderIso14443a() for details
|
||||
return c.sendMIX(true)
|
||||
return c:sendMIX(true)
|
||||
end
|
||||
|
||||
local library = {
|
||||
|
|
|
@ -28,9 +28,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
|||
SendCommandMIX(CMD_READER_MIFARE, arg0, blockno, key_type, NULL, 0);
|
||||
|
||||
//flush queue
|
||||
while (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
while (kbd_enter_pressed()) {
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
||||
|
@ -38,9 +36,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
|||
while (true) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
||||
|
@ -918,7 +914,7 @@ int detect_classic_prng(void) {
|
|||
|
||||
// if select tag failed.
|
||||
if (resp.oldarg[0] == 0) {
|
||||
PrintAndLogEx(WARNING, "error: selecting tag failed, can't detect prng\n");
|
||||
PrintAndLogEx(ERR, "error: selecting tag failed, can't detect prng\n");
|
||||
return PM3_ERFTRANS;
|
||||
}
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &respA, 2500)) {
|
||||
|
@ -928,7 +924,7 @@ int detect_classic_prng(void) {
|
|||
|
||||
// check respA
|
||||
if (respA.oldarg[0] != 4) {
|
||||
PrintAndLogEx(WARNING, "PRNG data error: Wrong length: %d", respA.oldarg[0]);
|
||||
PrintAndLogEx(ERR, "PRNG data error: Wrong length: %d", respA.oldarg[0]);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -955,9 +951,7 @@ int detect_classic_nackbug(bool verbose) {
|
|||
while (true) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
if (kbd_enter_pressed()) {
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
||||
|
@ -1002,7 +996,7 @@ int detect_classic_nackbug(bool verbose) {
|
|||
PrintAndLogEx(SUCCESS, "No NACK bug detected");
|
||||
return PM3_SUCCESS;
|
||||
default :
|
||||
PrintAndLogEx(WARNING, "errorcode from device [%i]", ok);
|
||||
PrintAndLogEx(ERR, "errorcode from device [%i]", ok);
|
||||
return PM3_EUNDEF;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -97,8 +97,8 @@ class WorkerThread : public QThread {
|
|||
~WorkerThread();
|
||||
void run();
|
||||
private:
|
||||
char *script_cmds_file = NULL;
|
||||
char *script_cmd = NULL;
|
||||
char *script_cmds_file;
|
||||
char *script_cmd;
|
||||
};
|
||||
|
||||
class ProxGuiQT : public QObject {
|
||||
|
|
|
@ -388,7 +388,7 @@ int main(int argc, char *argv[]) {
|
|||
show_help(false, exec_name);
|
||||
return 1;
|
||||
}
|
||||
uint32_t tmpspeed = strtoul(argv[i + 1], NULL, 10);
|
||||
uint64_t tmpspeed = strtoul(argv[i + 1], NULL, 10);
|
||||
if ((tmpspeed == ULONG_MAX) || (tmpspeed == 0)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") "invalid baudrate: -b " _YELLOW_("%s") "\n", argv[i + 1]);
|
||||
return 1;
|
||||
|
|
|
@ -411,8 +411,8 @@ static int l_foobar(lua_State *L) {
|
|||
* @param L
|
||||
* @return boolean, true if kbhit, false otherwise.
|
||||
*/
|
||||
static int l_ukbhit(lua_State *L) {
|
||||
lua_pushboolean(L, ukbhit() ? true : false);
|
||||
static int l_kbd_enter_pressed(lua_State *L) {
|
||||
lua_pushboolean(L, kbd_enter_pressed() ? true : false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ int set_pm3_libraries(lua_State *L) {
|
|||
{"WaitForResponseTimeout", l_WaitForResponseTimeout},
|
||||
{"mfDarkside", l_mfDarkside},
|
||||
{"foobar", l_foobar},
|
||||
{"ukbhit", l_ukbhit},
|
||||
{"kbd_enter_pressed", l_kbd_enter_pressed},
|
||||
{"clearCommandBuffer", l_clearCommandBuffer},
|
||||
{"console", l_CmdConsole},
|
||||
{"iso15693_crc", l_iso15693_crc},
|
||||
|
|
|
@ -21,7 +21,7 @@ local function nfc_read_amiibo ()
|
|||
arg2 = 135
|
||||
}
|
||||
|
||||
local result, err = command.sendMIX()
|
||||
local result, err = command:sendMIX()
|
||||
if result then
|
||||
-- Do Mifare Ultralight read
|
||||
local count, cmd, arg0, data_len, offset = bin.unpack('LLLL', result)
|
||||
|
@ -95,7 +95,7 @@ local function emulate_amiibo (amiibo_data)
|
|||
arg2 = uid_first,
|
||||
arg3 = uid_second
|
||||
}
|
||||
local _, err = simCmd.sendMIX()
|
||||
local _, err = simCmd:sendMIX()
|
||||
if err then
|
||||
print('Failed to start simulator', err)
|
||||
return
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue