Skip to content

Commit

Permalink
CHG: renamed struct sector -> sector_t
Browse files Browse the repository at this point in the history
CHG: defines on armside
CHG: #define WIN32 ->  _WIN32
CHG: started to enhance "hf mf chkkeys"
REM: removed some duplicates etc in default keys.
  • Loading branch information
iceman1001 committed Mar 6, 2017
1 parent 318bae2 commit 57778a4
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 41 deletions.
1 change: 1 addition & 0 deletions armsrc/appmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion armsrc/apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 17 additions & 5 deletions armsrc/mifarecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions armsrc/optimized_cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#define OPTIMIZED_CIPHER_H

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>

/**
Expand Down
14 changes: 7 additions & 7 deletions client/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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("|---|----------------|---|----------------|---|");
Expand Down
4 changes: 1 addition & 3 deletions client/cmdhfmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion client/hid-flasher/proxendian.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <stdint.h>

#ifdef WIN32
#ifdef _WIN32
# define HOST_LITTLE_ENDIAN
#else
# include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion client/hid-flasher/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 20 additions & 17 deletions client/lualibs/mf_default_keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -451,6 +451,9 @@ local _keys = {
'0ffbf65b5a14',
'c5cfe06d9ea3',
'c0dece673829',
--[[
--]]
'a56c2df9a26d',
}

---
Expand Down
6 changes: 4 additions & 2 deletions client/mifarehost.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo
}

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);
Expand Down
2 changes: 1 addition & 1 deletion client/mifarehost.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
11 changes: 10 additions & 1 deletion client/scripts/mfkeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 57778a4

Please sign in to comment.