// The main application code. This is the first thing called after start.c
// executes.
//-----------------------------------------------------------------------------
+#include <stdarg.h>
#include "usb_cdc.h"
#include "proxmark3.h"
#include "apps.h"
#include "pcf7931.h"
#include "desfire.h"
#include "iso14443b.h"
-//#include "iso14443a.h"
#include "emvcard.h"
extern int rsamples; // = 0;
// \r
//-----------------------------------------------------------------------------\r
void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {\r
- uint8_t blockNo = arg0 & 0xff;\r
- uint8_t keyType = (arg0 >> 8) & 0xff;\r
- bool clearTrace = arg1;\r
+#define STD_SEARCH 1\r
+#define EXT_SEARCH 2\r
+\r
+ uint8_t blockNo = arg0 & 0xFF;\r
+ uint8_t keyType = (arg0 >> 8) & 0xFF;\r
+ uint8_t searchType = (arg1 >> 8 ) & 0xFF;\r
+ bool clearTrace = arg1 & 0xFF;\r
uint8_t keyCount = arg2;\r
uint64_t ui64Key = 0;\r
\r
\r
continue;\r
}\r
- isOK = 1;\r
- break;\r
+ \r
+ // found a key.\r
+ //\r
+ //if ( searchType == EXT_SEARCH) {\r
+ \r
+ //}\r
+ //else {\r
+ isOK = 1;\r
+ break;\r
+ //}\r
}\r
\r
LED_B_ON();\r
#define OPTIMIZED_CIPHER_H
#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
+#include <stddef.h>
#include <stdbool.h>
/**
\r
int CmdHF14AMfNested(const char *Cmd) {\r
int i, j, res, iterations;\r
- sector *e_sector = NULL;\r
+ sector_t *e_sector = NULL;\r
uint8_t blockNo = 0;\r
uint8_t keyType = 0;\r
uint8_t trgBlockNo = 0;\r
time_t start, end;\r
time(&start);\r
\r
- e_sector = calloc(SectorsCnt, sizeof(sector));\r
+ e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
if (e_sector == NULL) return 1;\r
\r
//test current key and additional standard keys first\r
uint8_t *keyBlock = NULL, *p;\r
uint8_t stKeyBlock = 20;\r
\r
- sector *e_sector = NULL;\r
+ sector_t *e_sector = NULL;\r
\r
int i, res;\r
int keycnt = 0;\r
}\r
\r
// initialize storage for found keys\r
- e_sector = calloc(SectorsCnt, sizeof(sector));\r
+ e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
if (e_sector == NULL) {\r
free(keyBlock);\r
return 1;\r
return 0;\r
}\r
\r
-sector *k_sector = NULL;\r
+sector_t *k_sector = NULL;\r
uint8_t k_sectorsCount = 16;\r
static void emptySectorTable(){\r
\r
// initialize storage for found keys\r
if (k_sector == NULL)\r
- k_sector = calloc(k_sectorsCount, sizeof(sector));\r
+ k_sector = calloc(k_sectorsCount, sizeof(sector_t));\r
if (k_sector == NULL) \r
return;\r
\r
return 0; \r
}\r
\r
-void printKeyTable( uint8_t sectorscnt, sector *e_sector ){\r
+void printKeyTable( uint8_t sectorscnt, sector_t *e_sector ){\r
PrintAndLog("|---|----------------|---|----------------|---|");\r
PrintAndLog("|sec|key A |res|key B |res|");\r
PrintAndLog("|---|----------------|---|----------------|---|");\r
#include <string.h>\r
#include <ctype.h>\r
#include "proxmark3.h"\r
-\r
#include "iso14443crc.h"\r
#include "data.h"\r
#include "ui.h"\r
#include "cmdparser.h"\r
#include "common.h"\r
#include "util.h"\r
-//#include "mifarehost.h"\r
#include "mifare.h" // nonces_t struct\r
#include "cmdhfmfhard.h"\r
#include "nonce2key/nonce2key.h"\r
\r
void showSectorTable(void);\r
void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose);\r
-void printKeyTable( uint8_t sectorscnt, sector *e_sector );\r
+void printKeyTable( uint8_t sectorscnt, sector_t *e_sector );\r
#endif\r
#include <stdint.h>
-#ifdef WIN32
+#ifdef _WIN32
# define HOST_LITTLE_ENDIAN
#else
# include <sys/types.h>
#ifndef SLEEP_H__
#define SLEEP_H__
-#ifdef WIN32
+#ifdef _WIN32
#include <windows.h>
#define sleep(n) Sleep(1000 * n)
#define msleep(n) Sleep(n)
hotel system cards,
http://www.proxmark.org/forum/viewtopic.php?id=2430
--]]
- '44ab09010845',
- '85fed980ea5a',
+ '44ab09010845',
+ '85fed980ea5a',
- --[[
- VIGIK1
- --]]
- '314B49474956',
- '564c505f4d41',
+ --[[
+ VIGIK1
+ --]]
+ '314B49474956',
+ '564c505f4d41',
- --[[
- BCARD keyB
- --]]
- 'f4a9ef2afc6d',
+ --[[
+ BCARD keyB
+ --]]
+ 'f4a9ef2afc6d',
- --[[
- --]]
- 'a9f953def0a3',
+ --[[
+ --]]
+ 'a9f953def0a3',
- --[[
- mystery Key A and B for Mifare 1k EV1 (S50) Sector 17!
- --]]
+ --[[
+ mystery Key A and B for Mifare 1k EV1 (S50) Sector 17!
+ --]]
'75ccb59c9bed',
'4b791bea7bcc',
'0ffbf65b5a14',
'c5cfe06d9ea3',
'c0dece673829',
+ --[[
+ --]]
+ 'a56c2df9a26d',
}
---
}\r
\r
int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key){\r
- *key = 0;\r
- UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType<<8)), clear_trace, keycnt}};\r
+#define STD_SEARCH 1\r
+#define EXT_SEARCH 2\r
+ *key = 0; \r
+ UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), ((EXT_SEARCH << 8) | clear_trace), keycnt}};\r
memcpy(c.d.asBytes, keyBlock, 6 * keycnt);\r
clearCommandBuffer();\r
SendCommand(&c);\r
typedef struct {\r
uint64_t Key[2];\r
int foundKey[2];\r
-} sector;\r
+} sector_t;\r
\r
extern int compar_int(const void * a, const void * b);\r
extern char logHexFileName[FILE_PATH_SIZE];\r
Arguments:
-h : this help
+ -p : print keys
]]
local TIMEOUT = 10000 -- 10 seconds
file:close()
end
end
+local function printkeys()
+ for i=0,#keys do
+ print(i,keys[i])
+
+ end
+ print ('Number of keys: '..#keys)
+end
local function main( args)
-- Arguments for the script
- for o, a in getopt.getopt(args, 'h') do
+ for o, a in getopt.getopt(args, 'hp') do
if o == "h" then return help() end
+ if o == "p" then return printkeys() end
end
result, err = reader.read1443a()