CHG: renamed struct sector -> sector_t

CHG: defines on armside
CHG: #define WIN32 ->  _WIN32
CHG: started to enhance "hf mf chkkeys"
REM: removed some duplicates etc in default keys.
This commit is contained in:
iceman1001 2017-03-06 19:11:08 +01:00
commit 57778a4630
12 changed files with 64 additions and 41 deletions

View file

@ -9,6 +9,7 @@
// 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"

View file

@ -29,7 +29,6 @@ extern "C" {
#include "pcf7931.h"
#include "desfire.h"
#include "iso14443b.h"
//#include "iso14443a.h"
#include "emvcard.h"
extern int rsamples; // = 0;

View file

@ -956,9 +956,13 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
//
//-----------------------------------------------------------------------------
void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
uint8_t blockNo = arg0 & 0xff;
uint8_t keyType = (arg0 >> 8) & 0xff;
bool clearTrace = arg1;
#define STD_SEARCH 1
#define EXT_SEARCH 2
uint8_t blockNo = arg0 & 0xFF;
uint8_t keyType = (arg0 >> 8) & 0xFF;
uint8_t searchType = (arg1 >> 8 ) & 0xFF;
bool clearTrace = arg1 & 0xFF;
uint8_t keyCount = arg2;
uint64_t ui64Key = 0;
@ -1026,8 +1030,16 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
continue;
}
isOK = 1;
break;
// found a key.
//
//if ( searchType == EXT_SEARCH) {
//}
//else {
isOK = 1;
break;
//}
}
LED_B_ON();

View file

@ -2,8 +2,7 @@
#define OPTIMIZED_CIPHER_H
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
/**

View file

@ -721,7 +721,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
int CmdHF14AMfNested(const char *Cmd) {
int i, j, res, iterations;
sector *e_sector = NULL;
sector_t *e_sector = NULL;
uint8_t blockNo = 0;
uint8_t keyType = 0;
uint8_t trgBlockNo = 0;
@ -823,7 +823,7 @@ int CmdHF14AMfNested(const char *Cmd) {
time_t start, end;
time(&start);
e_sector = calloc(SectorsCnt, sizeof(sector));
e_sector = calloc(SectorsCnt, sizeof(sector_t));
if (e_sector == NULL) return 1;
//test current key and additional standard keys first
@ -1083,7 +1083,7 @@ int CmdHF14AMfChk(const char *Cmd) {
uint8_t *keyBlock = NULL, *p;
uint8_t stKeyBlock = 20;
sector *e_sector = NULL;
sector_t *e_sector = NULL;
int i, res;
int keycnt = 0;
@ -1230,7 +1230,7 @@ int CmdHF14AMfChk(const char *Cmd) {
}
// initialize storage for found keys
e_sector = calloc(SectorsCnt, sizeof(sector));
e_sector = calloc(SectorsCnt, sizeof(sector_t));
if (e_sector == NULL) {
free(keyBlock);
return 1;
@ -1362,13 +1362,13 @@ int CmdHF14AMfChk(const char *Cmd) {
return 0;
}
sector *k_sector = NULL;
sector_t *k_sector = NULL;
uint8_t k_sectorsCount = 16;
static void emptySectorTable(){
// initialize storage for found keys
if (k_sector == NULL)
k_sector = calloc(k_sectorsCount, sizeof(sector));
k_sector = calloc(k_sectorsCount, sizeof(sector_t));
if (k_sector == NULL)
return;
@ -1720,7 +1720,7 @@ int CmdHF14AMfKeyBrute(const char *Cmd) {
return 0;
}
void printKeyTable( uint8_t sectorscnt, sector *e_sector ){
void printKeyTable( uint8_t sectorscnt, sector_t *e_sector ){
PrintAndLog("|---|----------------|---|----------------|---|");
PrintAndLog("|sec|key A |res|key B |res|");
PrintAndLog("|---|----------------|---|----------------|---|");

View file

@ -16,14 +16,12 @@
#include <string.h>
#include <ctype.h>
#include "proxmark3.h"
#include "iso14443crc.h"
#include "data.h"
#include "ui.h"
#include "cmdparser.h"
#include "common.h"
#include "util.h"
//#include "mifarehost.h"
#include "mifare.h" // nonces_t struct
#include "cmdhfmfhard.h"
#include "nonce2key/nonce2key.h"
@ -63,5 +61,5 @@ int CmdHf14MfDecryptBytes(const char *Cmd);
void showSectorTable(void);
void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose);
void printKeyTable( uint8_t sectorscnt, sector *e_sector );
void printKeyTable( uint8_t sectorscnt, sector_t *e_sector );
#endif

View file

@ -13,7 +13,7 @@
#include <stdint.h>
#ifdef WIN32
#ifdef _WIN32
# define HOST_LITTLE_ENDIAN
#else
# include <sys/types.h>

View file

@ -11,7 +11,7 @@
#ifndef SLEEP_H__
#define SLEEP_H__
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#define sleep(n) Sleep(1000 * n)
#define msleep(n) Sleep(n)

View file

@ -181,27 +181,27 @@ local _keys = {
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',
@ -451,6 +451,9 @@ local _keys = {
'0ffbf65b5a14',
'c5cfe06d9ea3',
'c0dece673829',
--[[
--]]
'a56c2df9a26d',
}
---

View file

@ -192,8 +192,10 @@ out:
}
int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key){
*key = 0;
UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType<<8)), clear_trace, keycnt}};
#define STD_SEARCH 1
#define EXT_SEARCH 2
*key = 0;
UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), ((EXT_SEARCH << 8) | clear_trace), keycnt}};
memcpy(c.d.asBytes, keyBlock, 6 * keycnt);
clearCommandBuffer();
SendCommand(&c);

View file

@ -58,7 +58,7 @@ typedef struct {
typedef struct {
uint64_t Key[2];
int foundKey[2];
} sector;
} sector_t;
extern int compar_int(const void * a, const void * b);
extern char logHexFileName[FILE_PATH_SIZE];

View file

@ -30,6 +30,7 @@ If you want to add more, just put them inside /lualibs/mf_default_keys.lua\n"):f
Arguments:
-h : this help
-p : print keys
]]
local TIMEOUT = 10000 -- 10 seconds
@ -179,12 +180,20 @@ local function dumptofile(results)
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()