Merge branch 'master' into ext_apdu

This commit is contained in:
Oleg Moiseenko 2019-07-15 19:25:48 +03:00 committed by GitHub
commit ddd4601c1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
116 changed files with 1000 additions and 1827 deletions

View file

@ -4,15 +4,33 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
- Added 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)
- 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)

View file

@ -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 \

View file

@ -1,6 +1,7 @@
# 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.
Note that it also supports other Proxmark3 platforms as well!
[![Build status](https://ci.appveyor.com/api/projects/status/ct5blik2wa96bv0x/branch/master?svg=true)](https://ci.appveyor.com/project/iceman1001/proxmark3-ji4wj/branch/master)
[![Latest release](https://img.shields.io/github/release/RfidResearchGroup/proxmark3.svg)](https://github.com/RfidResearchGroup/proxmark3/releases/latest)
@ -15,7 +16,7 @@ This repo is based on iceman fork for Proxmark3. It is dedicated to bringing the
|[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)|||

View file

@ -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

View file

@ -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.
*/

View file

@ -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;
}
@ -424,7 +429,7 @@ failtag:
//-----------------------------------------------------------------------------
// also we could avoid first UID check for every block
// then lets 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 piwied(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;

File diff suppressed because it is too large Load diff

View file

@ -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

View file

@ -1592,38 +1592,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;

View file

@ -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;
}
}

View file

@ -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

View file

@ -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);

View file

@ -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;
}

View file

@ -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.

View file

@ -31,7 +31,12 @@ 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

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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);

View file

@ -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;
}
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}
};

View file

@ -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));

View file

@ -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);

View file

@ -564,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);
@ -634,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;
}
@ -1069,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;
}
@ -1246,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;
}

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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:

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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();
}

View file

@ -177,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;
}
}

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
// }

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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... }"},

View file

@ -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;

View file

@ -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;

View file

@ -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) {

View file

@ -930,3 +930,19 @@ BB3D7B11D224
b210cfa436d2
b8b1cfa646a8
a9f95891f0a4
#
# Keys from APK application "Scan Badge"
4A4C474F524D
444156494442
434143445649
434456495243
A00002000021
EF61A3D48E2A
A23456789123
010000000000
363119000001
A00003000084
675A32413770
395244733978
#
B069D0D03D17

View file

@ -287,7 +287,7 @@ 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);
if (pdol_data_tlv != &data_tlv)
free(pdol_data_tlv);
return PM3_ESOFT;
}
@ -931,7 +931,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 +1001,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 +1047,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 +1131,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.");
}
}

View file

@ -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;
}

View file

@ -511,7 +511,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)
@ -654,14 +654,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 +693,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 +712,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 +745,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 +790,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 +823,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 +839,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 +851,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 +862,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 +882,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 +898,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 +935,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 +966,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 +989,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);

View file

@ -192,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;
}
@ -347,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)
@ -356,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.

View file

@ -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);

View file

@ -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)

View file

@ -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, ",");
}

View file

@ -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

View file

@ -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;
}

View file

@ -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;

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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},

View file

@ -488,7 +488,7 @@ local function readtag(mfkey, aeskey )
for blockNo = 0, numBlocks-1 do
if core.ukbhit() then
if core.kbd_enter_pressed() then
print("[fail] aborted by user")
return nil
end

View file

@ -206,7 +206,7 @@ local function main(args)
if x then core.console(cmd) end
end
if core.ukbhit() then
if core.kbd_enter_pressed() then
print('aborted by user')
break
end

View file

@ -186,7 +186,7 @@ local function main(args)
for cardnum = baseid, endid do
local card = cardHex(cardnum, facility)
print('Press enter to program card '..cardnum..':'..facility..' (hex: '..card..')')
--This would be better with 'press any key', but we'll take what we can get.
--This would be better with 'press Enter', but we'll take what we can get.
io.read()
core.console( ('lf hid clone %s'):format(card) )
end

View file

@ -208,7 +208,7 @@ local function perform_check(numsectors)
for sector = 0, #keys do
-- Check if user aborted
if core.ukbhit() then
if core.kbd_enter_pressed() then
print('Aborted by user')
break
end

View file

@ -70,7 +70,7 @@ end
-- @return if successfull: an table containing card info
-- @return if unsuccessfull : nil, error
local function wait_for_mifare()
while not core.ukbhit() do
while not core.kbd_enter_pressed() do
res, err = lib14a.read()
if res then return res end
-- err means that there was no response from card
@ -161,7 +161,7 @@ local function main(args)
while not _exit do
if print_message then
print('Waiting for card or press any key to stop')
print('Waiting for card or press Enter to stop')
print_message = false
end
res, err = wait_for_mifare()

View file

@ -81,18 +81,19 @@ local function main(args)
if o == 'o' then offset = tonumber(a) end
-- num of bytes to read
if o == 'l' then length = tonumber(a) end
if o == 'l' then
length = tonumber(a)
if length < 0 or length > 256 then
return oops('Error: Length is not valid. Must be less than 256')
end
end
-- keylength
if o == 'k' then keylength = tonumber(a); usedkey = true end
if o == 'm' then keylength =6; usedkey = true; offset = 0x3F000-0x6000; end
if o == 't' then keylength =4; usedkey = true; offset = 0x3F000-0x3000; end
if o == 'i' then keylength =8; usedkey = true; offset = 0x3F000-0x4000; end
end
if length < 0 or length > 256 then
return oops('Error: Length is not valid. Must be less than 256')
if o == 'm' then keylength = 6; usedkey = true; length = 8192; offset = 0x3F000-0x6000; end
if o == 't' then keylength = 4; usedkey = true; length = 4096; offset = 0x3F000-0x3000; end
if o == 'i' then keylength = 8; usedkey = true; length = 4096; offset = 0x3F000-0x4000; end
end
if (offset < 0) or (offset % 4 ~= 0) then
@ -104,8 +105,6 @@ local function main(args)
print('Key length ', keylength)
print( string.rep('--', 20) )
if usedkey then length = 4096 end
data, err = core.GetFromFlashMem(offset, length)
if err then return oops(err) end
@ -116,7 +115,6 @@ local function main(args)
local kl = keylength * 2
for i = 1, keys do
key = string.sub(s, (i - 1) * kl + 1, i * kl )
print(string.format('[%02d] %s',i, key))
end

View file

@ -198,7 +198,7 @@ local function main(args)
io.flush()
if core.ukbhit() then
if core.kbd_enter_pressed() then
print("aborted by user")
break
end

View file

@ -118,7 +118,7 @@ local function main(args)
core.clearCommandBuffer()
if core.ukbhit() then
if core.kbd_enter_pressed() then
print('aborted by user')
break
end

View file

@ -19,14 +19,21 @@ CFILES = $(filter %.c, $(tinycbor_SOURCES))
CMDOBJS = $(CFILES:%.c=%.o)
CLEAN = $(CMDOBJS)
platform = $(shell uname)
CC= gcc
CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function
LIBS= $(SYSLIBS) $(MYLIBS)
DEFAULT_INCLUDES = -I. -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

View file

@ -26,38 +26,45 @@ uint8_t g_debugMode = 0;
#define MAX_BIN_BREAK_LENGTH (3072+384+1)
#ifndef _WIN32
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdarg.h>
#include <fcntl.h>
int ukbhit(void) {
int cnt = 0;
int error;
static struct termios Otty, Ntty;
if (tcgetattr(STDIN_FILENO, &Otty) == -1) return -1;
Ntty = Otty;
Ntty.c_iflag = 0x0000; // input mode
Ntty.c_oflag = 0x0000; // output mode
Ntty.c_lflag &= ~ICANON; // control mode = raw
Ntty.c_cc[VMIN] = 1; // return if at least 1 character is in the queue
Ntty.c_cc[VTIME] = 0; // no timeout. Wait forever
if (0 == (error = tcsetattr(STDIN_FILENO, TCSANOW, &Ntty))) { // set new attributes
error += ioctl(STDIN_FILENO, FIONREAD, &cnt); // get number of characters available
error += tcsetattr(STDIN_FILENO, TCSANOW, &Otty); // reset attributes
int kbd_enter_pressed(void) {
int flags;
if ((flags = fcntl(STDIN_FILENO, F_GETFL, 0)) < 0) {
PrintAndLogEx(ERR, "fcntl failed in kbd_enter_pressed");
return -1;
}
return (error == 0 ? cnt : -1);
//non-blocking
flags |= O_NONBLOCK;
if (fcntl(STDIN_FILENO, F_SETFL, flags) < 0) {
PrintAndLogEx(ERR, "fcntl failed in kbd_enter_pressed");
return -1;
}
int c;
int ret = 0;
do { //get all available chars
c = getchar();
ret |= c == '\n';
} while (c != EOF);
//blocking
flags &= ~O_NONBLOCK;
if (fcntl(STDIN_FILENO, F_SETFL, flags) < 0) {
PrintAndLogEx(ERR, "fcntl failed in kbd_enter_pressed");
return -1;
}
return ret;
}
#else
#include <conio.h>
int ukbhit(void) {
return kbhit();
int kbd_enter_pressed(void) {
int ret = 0;
while (kbhit()) {
ret |= getch() == '\r';
}
return ret;
}
#endif

View file

@ -135,7 +135,7 @@
uint8_t g_debugMode;
int ukbhit(void);
int kbd_enter_pressed(void);
void AddLogLine(const char *fn, const char *data, const char *c);
void AddLogHex(const char *fn, const char *extData, const uint8_t *data, const size_t len);
void AddLogUint64(const char *fn, const char *data, const uint64_t value);

View file

@ -43,15 +43,13 @@ TARFLAGS = -C .. -rvf
# amount of shell command line parsing going on. echo "" on
# Windows yields literal "", on Linux yields an empty line
ifeq ($(shell echo ""),)
# This is probably a proper system, so we can use uname
UNAME := $(shell uname)
DELETE=rm -rf
MOVE=mv
COPY=cp
PATHSEP=/
FLASH_TOOL=client/flasher
DETECTED_OS=$(UNAME)
# This is probably a proper system, so we can use uname
DETECTED_OS=$(platform)
else
# Assume that we are running on Windows.
@ -65,7 +63,7 @@ DETECTED_OS=Windows
endif
# Also search prerequisites in the common directory (for usb.c), the fpga directory (for fpga.bit), and the zlib directory
VPATH = . ../common ../common/crapto1 ../common/polarssl ../fpga ../zlib ../armsrc/Standalone ../uart
VPATH = . ../common ../common/crapto1 ../common/mbedtls ../fpga ../zlib ../armsrc/Standalone ../uart
INCLUDES = ../include/proxmark3.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h $(APP_INCLUDES)

View file

@ -3,7 +3,7 @@
#include <string.h>
#include <stdarg.h>
#include "aes.h"
#include "mbedtls/aes.h"
#include "mifare.h"
#define MAX_CRYPTO_BLOCK_SIZE 16
@ -71,10 +71,6 @@ enum DESFIRE_CRYPTOALGO {
struct desfire_key {
enum DESFIRE_CRYPTOALGO type;
uint8_t data[24];
// DES_key_schedule ks1;
// DES_key_schedule ks2;
// DES_key_schedule ks3;
AesCtx aes_ks;
uint8_t cmac_sk1[24];
uint8_t cmac_sk2[24];
uint8_t aes_version;

View file

@ -59,6 +59,8 @@ CFILES = $(filter %.c, $(mbedtls_SOURCES))
CMDOBJS = $(CFILES:%.c=%.o)
CLEAN = $(CMDOBJS)
platform = $(shell uname)
CC= gcc
CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function
LDFLAGS= $(SYSLDFLAGS) $(mbedtls_LDFLAGS)
@ -66,8 +68,13 @@ LIBS= $(SYSLIBS) $(MYLIBS)
DEFAULT_INCLUDES = -I. -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

View file

@ -60,9 +60,9 @@
* mbedtls_platform_zeroize() to use a suitable implementation for their
* platform and needs.
*/
static void *(* const volatile memset_func)(void *, int, size_t) = memset;
//static void *(* const volatile memset_func)(void *, int, size_t) = memset;
void mbedtls_platform_zeroize(void *buf, size_t len) {
memset_func(buf, 0, len);
memset(buf, 0, len);
}
#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */

View file

@ -1,60 +1,169 @@
# Building on Windows
You will need to use the Gator96100 Proxspace package to assist in your windows installation.
This can be downloaded from https://github.com/Gator96100/ProxSpace/
# Installing on Windows
There are two ways to install, build and use Proxmark3 on Windows:
* Using Gator96100 **ProxSpace**, a package to assist in your Windows installation of MinGW
* Using native **WSL**, if you're running a Windows 10 version recent enough (FCU 1709 or later)
---
# Video Installation guide
# Installing on Windows with ProxSpace
## Video Installation guide
[![Windows Installation tutorial](https://github.com/5w0rdfish/Proxmark3-RDV4-ParrotOS/blob/master/screenshot-www.youtube.com-2019.03.17-20-44-33.png)](https://youtu.be/zzF0NCMJnYU "Windows Installation Tutorial")
## Manual Installation
## Driver Installation
### Driver Installation
Install required drivers for your Windows installation. You may need admin privileges to do this.
Step by step guides are online such as [RiscCorps](https://store.ryscc.com/blogs/news/how-to-install-a-proxmark3-driver-on-windows-10).
Install required drivers for your windows installation. You will may need admin privileges to do this.
(This is covered in the video) Step by step guides are online such as [RiscCorps](https://store.ryscc.com/blogs/news/how-to-install-a-proxmark3-driver-on-windows-10)
## Download / clone ProxSpace repo
### Install Github
Download the Gator96100 ProxSpace package from https://github.com/Gator96100/ProxSpace/
Install Github for Windows https://desktop.github.com/
If you prefer, you can clone it, provided that you installed Github for Windows https://desktop.github.com/.
### Download / clone Proxspace repo
Download the required proxspace repo. https://github.com/Gator96100/ProxSpace/
Extract 'ProxSpace' to a location on drive without spaces.
Extract 'ProxSpace' to a location path without spaces.
For example D:\OneDrive\Documents\GitHub is ok whereas C:\My Documents\My Projects\proxspace is not.
### Clone the RRG/Iceman repository
If you're running Windows in a Virtualbox guest, make sure not to install ProxSpace on a vbox shared drive. (It's ok later to move the `/pm3` subfolder to a shared drive and edit the `*.bat`)
```sh
git clone https://github.com/RfidResearchGroup/proxmark3.git
```
### Copy files to Proxspace
Copy all the contents from the `proxmark3` folder into the proxspace `pm3` folder
### Run the .bat
## Launch ProxSpace
Run `runme.bat` or `runme64.bat` depending on your Windows architecture.
Please note you will need to use `/` as you are using BASH.
You'll get a Bash prompt and your home directory should become the ProxSpace `pm3` sub-directory.
### Compile and use the project
Please note you will need to use `/` in paths as you are using Bash.
## Clone the RRG/Iceman repository
```sh
cd
git clone https://github.com/RfidResearchGroup/proxmark3.git
cd proxmark3
```
If you're a contributing developer, you probably want to be able to use `make style`. If so, you've to install astyle:
```sh
pacman -S mingw-w64-x86_64-astyle
```
## Compile and use the project
Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md).
The only differences are that executables end with `.exe` (e.g. `client/flasher.exe`) and that the Proxmark3 port is one of your `comX` ports where "X" is the com port number assigned to proxmark3 under Windows.
To use the compiled client and flasher, the only differences are that executables end with `.exe` (e.g. `client/flasher.exe`) and that the Proxmark3 port is one of your `comX` ports where "X" is the com port number assigned to proxmark3 under Windows.
So flashing will resemble
To flash: In principle, the helper script `flash-all.sh` should auto-detect your COM port, so you can just try:
```sh
./flash-all.sh
```
If COM port detection failed, you'll have to call the flasher manually and specify the correct port:
```sh
client/flasher.exe comX -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf
```
And running the client will resemble
Similarly, to run the client, you may try:
```sh
cd client
./proxmark3.exe comX
./proxmark3.sh
```
Or, by specifying the COM port manually:
```sh
client/proxmark3.exe comX
```
# Installing on Windows with WSL
It requires to run a Windows 10 version 1709 or above. Previous versions didn't have support for COM ports.
Install WSL with e.g. the standard Ubuntu.
For WSL configuration, see [Manage and configure Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/wsl-config).
## X Server Installation
If you want to run the graphical components of the Proxmark3 client, you need to install a X Server such as [VcXsrv](https://sourceforge.net/projects/vcxsrv/) or [Xming](https://sourceforge.net/projects/xming/) and launch it, e.g. by executing XLaunch.
## Dependencies
Enter WSL prompt (`wsl`) and from there, follow the [Linux Installation Instructions](/doc/md/Installation_Instructions/Linux-Installation-Instructions.md) for Ubuntu, summarized here below:
```sh
sudo apt-get update
sudo apt-get install p7zip git ca-certificates build-essential libreadline5 libreadline-dev libusb-0.1-4 \
libusb-dev perl pkg-config wget libncurses5-dev gcc-arm-none-eabi libstdc++-arm-none-eabi-newlib \
libqt4-dev
```
If you don't need the graphical components of the Proxmark3 client, you can skip the installation of `libqt4-dev`.
## Clone the RRG/Iceman repository
```sh
git clone https://github.com/RfidResearchGroup/proxmark3.git
```
## Compile and use the project
Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md).
To use the compiled client and flasher, the only difference is that the Proxmark3 port is translated from your `comX` port where "X" is the com port number assigned to proxmark3 under Windows, to a `/dev/ttySX`.
Depending on the Windows version, you might need to give permission to the current user to access `/dev/ttySX`: (change X to your port number)
```sh
ls -al /dev/ttySX
groups|grep dialout
```
If group ownership is `dialout` and your user is member of `dialout` group, all is fine. Else you'll have to provide access to `/dev/ttySX`: (Unfortunately the access rights of the port won't survive and will have to be fixed again next time.)
```sh
sudo chmod 666 /dev/ttySX
```
If you installed a X Server and compiled the Proxmark3 with QT4 support, you've to export the `DISPLAY` environment variable:
```sh
export DISPLAY=:0
```
and add it to your Bash profile for the next times:
```sh
echo "export DISPLAY=:0" >> ~/.bashrc
```
To flash: In principle, the helper script `flash-all.sh` should auto-detect your COMX==/dev/ttySX port, so you can just try:
```sh
./flash-all.sh
```
If port detection failed, you'll have to call the flasher manually and specify the correct port:
```sh
client/flasher /dev/ttySX -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf
```
Similarly, to run the client, you may try:
```sh
./proxmark3.sh
```
Or, by specifying the COM port manually:
```sh
client/proxmark3 /dev/ttySX
```
Note that it may take a quite long time for a freshly plugged Proxmark3 to be visible on a WSL /dev/ttySX port.

View file

@ -1,5 +1,16 @@
# Compilation instructions
## Tuning compilation parameters
The client and the Proxmark3 firmware should always be in sync.
Nevertheless, the firmware can be tuned depending on the Proxmark3 platform and options.
Indeed, the RRG/Iceman fork can be used on other Proxmark3 hardware platforms as well.
Via some definitions, you can adjust the firmware for a given platform, but also to add features like the support of the Blue Shark add-on or to select which standalone mode to embed.
To learn how to adjust the firmware, please read [Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md).
## Get the latest commits
```sh
@ -15,48 +26,23 @@ make clean && make all
## Flash the BOOTROM & FULLIMAGE
In most cases, you can run the script `flash-all.sh` which try to auto-detect the port to use, on several OS.
For the other cases, specify the port by yourself. For example, for a Proxmark3 connected via USB under Linux:
```sh
client/flasher /dev/ttyACM0 -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf
```
## Run the client
```sh
cd client
./proxmark3 /dev/ttyACM0
```
In most cases, you can run the script `proxmark3.sh` which try to auto-detect the port to use, on several OS.
## Compiling for other boards
For the other cases, specify the port by yourself. For example, for a Proxmark3 connected via USB under Linux:
Available boards
| BOARD | PLATFORM |
|:---------------:|:---------------------------------------|
| `PM3RDV4` (def) | Proxmark3 rdv4 with AT91SAM7S512 |
| `PM3EVO` | Proxmark3 EVO with AT91SAM7S512 |
| `PM3EASY` | Proxmark3 rdv3 Easy with AT91SAM7S256 |
| `PM3RDV2` | Proxmark3 rdv2 with AT91SAM7S512 |
| `PM3OLD256` | Proxmark3 V1 with AT91SAM7S256 |
| `PM3OLD512` | Proxmark3 V1 with AT91SAM7S512 |
Create a file named `Makefile.platform` in the root directory of the repository:
Here, for example, for a Proxmark3 connected via USB under Linux:
```sh
# PLATFORM=${BOARD}
# Following example is to compile sources for Proxmark3 rdv3 Easy
PLATFORM=PM3EASY
```
From this point:
```sh
# Clean and compile
make clean && make all
# Flash the BOOTROM & FULLIMAGE
client/flasher /dev/ttyACM0 -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf
# Run the client
cd client
./proxmark3 /dev/ttyACM0
```

View file

@ -0,0 +1,82 @@
# Advanced compilation parameters
The client and the Proxmark3 firmware should always be in sync.
Nevertheless, the firmware can be tuned depending on the Proxmark3 platform and options.
Indeed, the RRG/Iceman fork can be used on other Proxmark3 hardware platforms as well.
Via some definitions, you can adjust the firmware for a given platform, but also to add features like the support of the Blue Shark add-on or to select which standalone mode to embed.
## Client
The client doesn't depend on the capabilities of the Proxmark3 it's connected to.
So you can use the same client for different Proxmark3 platforms, given that everything is running the same version.
## Firmware
By default, the firmware is of course tuned for the Proxmark3 Rdv4.0 device, which has built-in support for 256kb onboard flash SPI memory, Sim module (smart card support), FPC connector.
These features make it very different from all other devices, there is non other like this one.
**Recommendation**: if you don't have a RDV4, we strongly recommend your device to have at least a 512kb arm chip, since this repo is on the very edge of 256kb limit.
A firmware built for the RDV4 can still run on the other platforms as it will auto-detect during boot that external SPI and Sim are not present, still it will boot faster if it's tuned to the platform.
If you need to tune things and save the configuration, create a file `Makefile.platform` in the root directory of the repository, see `Makefile.platform.sample`.
For an up-to-date exhaustive list of options, you can run `make PLATFORM=`.
## PLATFORM
Here are the supported values you can assign to `PLATFORM` in `Makefile.platform`:
| PLATFORM | DESCRIPTION |
|-----------------|----------------------------------------|
| PM3RDV4 (def) | Proxmark3 rdv4 with AT91SAM7S512 |
| PM3EVO | Proxmark3 EVO with AT91SAM7S512 |
| PM3EASY | Proxmark3 rdv3 Easy with AT91SAM7S256 |
| PM3RDV2 | Proxmark3 rdv2 with AT91SAM7S512 |
| PM3OLD256 | Proxmark3 V1 with AT91SAM7S256 |
| PM3OLD512 | Proxmark3 V1 with AT91SAM7S512 |
By default `PLATFORM=PM3RDV4`.
Known issues:
* 256kb Arm chip devices: The compiled firmware image from this repo may/will be too large for your device.
* PM3 Evo: it has a different led/button pin assignment. It tends to be messed up.
## PLATFORM_EXTRAS
Here are the supported values you can assign to `PLATFORM_EXTRAS` in `Makefile.platform`:
| PLATFORM_EXTRAS | DESCRIPTION |
|-----------------|----------------------------------------|
| BTADDON | Proxmark3 rdv4 BT add-on |
By default `PLATFORM_EXTRAS=`.
If you have installed a Blue Shark add-on on your RDV4, define `PLATFORM_EXTRAS=BTADDON` in your `Makefile.platform`.
## STANDALONE
The RRG/Iceman fork gives you to easily choose which standalone mode to embed in the firmware.
Here are the supported values you can assign to `STANDALONE` in `Makefile.platform`:
| 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
By default `STANDALONE=LF_SAMYRUN`.
## Next step
See [Compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md)

View file

@ -373,9 +373,9 @@ It was needed to tune pm3 RX usart `maxtry` :
time client/proxmark3 -p /dev/ttyUSB0 -b 115200 -c "lf read"
6.28s
time client/proxmark3 -p /dev/ttyACM0 -c "mem save f foo_usb"
time client/proxmark3 -p /dev/ttyACM0 -c "mem dump f foo_usb"
1.48s
time client/proxmark3 -p /dev/ttyUSB0 -b 115200 -c "mem save f foo_fpc"
time client/proxmark3 -p /dev/ttyUSB0 -b 115200 -c "mem dump f foo_fpc"
25.34s

View file

@ -1,4 +1,5 @@
#!/bin/bash
cd $(dirname "$0")
PM3PATH=$(dirname "$0")
cd "$PM3PATH" || exit 1
. proxmark3.sh

View file

@ -1,4 +1,5 @@
#!/bin/bash
cd $(dirname "$0")
PM3PATH=$(dirname "$0")
cd "$PM3PATH" || exit 1
. proxmark3.sh

View file

@ -1,4 +1,5 @@
#!/bin/bash
cd $(dirname "$0")
PM3PATH=$(dirname "$0")
cd "$PM3PATH" || exit 1
. proxmark3.sh

View file

@ -216,6 +216,7 @@ typedef struct {
#define CMD_FINISH_WRITE 0x0003
#define CMD_HARDWARE_RESET 0x0004
#define CMD_START_FLASH 0x0005
#define CMD_CHIP_INFO 0x0006
#define CMD_NACK 0x00fe
#define CMD_ACK 0x00ff
@ -237,7 +238,6 @@ typedef struct {
#define CMD_SET_DBGMODE 0x0114
// RDV40, Flash memory operations
#define CMD_FLASHMEM_READ 0x0120
#define CMD_FLASHMEM_WRITE 0x0121
#define CMD_FLASHMEM_WIPE 0x0122
#define CMD_FLASHMEM_DOWNLOAD 0x0123
@ -541,6 +541,9 @@ typedef struct {
/* Set if this device understands the extend start flash command */
#define DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH (1<<4)
/* Set if this device understands the chip info command */
#define DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO (1<<5)
/* CMD_START_FLASH may have three arguments: start of area to flash,
end of area to flash, optional magic.
The bootrom will not allow to overwrite itself unless this magic

View file

@ -12,13 +12,20 @@ endif
# Your platform. See PLATS for possible values.
PLAT= none
platform= $(shell uname)
CC= gcc
CFLAGS= -O3 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS)
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
LIBS= -lm $(SYSLIBS) $(MYLIBS)
ifeq ($(platform),Darwin)
AR= /usr/bin/ar rc
RANLIB= /usr/bin/ranlib
else
AR= ar rc
RANLIB= ranlib
endif
RM= rm -f
SYSCFLAGS=

View file

@ -3,29 +3,31 @@
FULLIMAGE="armsrc/obj/fullimage.elf"
BOOTIMAGE="bootrom/obj/bootrom.elf"
cd $(dirname "$0")
PM3PATH=$(dirname "$0")
cd "$PM3PATH" || exit 1
function wait4proxmark_Linux {
echo >&2 "Waiting for Proxmark to appear..."
while [ ! -c /dev/ttyACM? -a ! -c /dev/pm3-? ]; do
while true; do
PM3=$(find /dev/pm3-* /dev/ttyACM* 2>/dev/null | head -1)
if [[ $PM3 != "" ]]; then
break
fi
sleep .1
done
local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1`
echo >&2 -e "Found proxmark on ${PM3}\n"
echo $PM3
echo "$PM3"
}
function wait4proxmark_macOS {
echo >&2 "Waiting for Proxmark to appear..."
while true; do
PM3=$(ls /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1)
PM3=$(find /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1)
if [[ $PM3 != "" ]]; then
#echo >&2 -e "Found proxmark on $(ls /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1)\n"
break
fi
sleep .1
done
echo $PM3
echo "$PM3"
}
function wait4proxmark_Windows {
@ -38,30 +40,48 @@ function wait4proxmark_Windows {
fi
sleep .1
done
echo $PM3
echo "$PM3"
}
function wait4proxmark_WSL {
echo >&2 "Waiting for Proxmark to appear..."
while true; do
device=$(wmic.exe path Win32_SerialPort where "PNPDeviceID like '%VID_9AC4&PID_4B8F%'" get DeviceID,PNPDeviceID 2>/dev/null | awk 'NR==2')
if [[ $device != "" ]]; then
PM3=${device/ */}
PM3="/dev/ttyS${PM3#COM}"
break
fi
sleep .1
done
if [ -e "$PM3" ] && [ ! -w "$PM3" ]; then
echo "We need to give current user read/write access to $PM3"
sudo chmod 666 "$PM3"
fi
echo "$PM3"
}
SCRIPT=$(basename -- "$0")
if [ "$SCRIPT" = "proxmark3.sh" ]; then
CMD=client/proxmark3
CMD() { client/proxmark3 "$@"; }
elif [ "$SCRIPT" = "flash-all.sh" ]; then
CMD=client/flasher
ARG1="-b $BOOTIMAGE"
ARG2="$FULLIMAGE"
CMD() { client/flasher "$1" -b "$BOOTIMAGE" "$FULLIMAGE"; }
elif [ "$SCRIPT" = "flash-fullimage.sh" ]; then
CMD=client/flasher
ARG2="$FULLIMAGE"
CMD() { client/flasher "$1" "$FULLIMAGE"; }
elif [ "$SCRIPT" = "flash-bootrom.sh" ]; then
CMD=client/flasher
ARG1="-b $BOOTIMAGE"
CMD() { client/flasher "$1" -b "$BOOTIMAGE"; }
else
echo "Script ran under unknown name, abort: $SCRIPT"
exit 1
fi
HOSTOS=$(uname | awk '{print toupper($0)}')
if [ "$HOSTOS" = "LINUX" ]; then
if uname -a|grep -q Microsoft; then
PORT=$(wait4proxmark_WSL)
else
PORT=$(wait4proxmark_Linux)
fi
elif [ "$HOSTOS" = "DARWIN" ]; then
PORT=$(wait4proxmark_macOS)
elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then
@ -75,6 +95,5 @@ if [ "$PORT" = "" ]; then
exit 1
fi
#echo Running "$CMD" "$PORT" $ARG1 $ARG2 "$@"
"$CMD" "$PORT" $ARG1 $ARG2 "$@"
CMD "$PORT" "$@"
exit $?

View file

@ -0,0 +1,3 @@
# Ports
telnet_port 4444
gdb_port 3333

View file

@ -1,7 +1,3 @@
# Ports
telnet_port 4444
gdb_port 3333
# Commands specific to the Olimex ARM-USB-OCD Dongle
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG"

View file

@ -1,7 +1,3 @@
# Ports
telnet_port 4444
gdb_port 3333
# Commands specific to the Bus Blaster
interface ftdi
ftdi_device_desc "Dual RS232-HS"

View file

@ -1,7 +1,3 @@
# Ports
telnet_port 4444
gdb_port 3333
# Commands specific to the BusPirate
interface buspirate
buspirate_port /dev/ttyUSB0

Some files were not shown because too many files have changed in this diff Show more