mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
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:
parent
318bae20de
commit
57778a4630
12 changed files with 64 additions and 41 deletions
|
@ -9,6 +9,7 @@
|
||||||
// The main application code. This is the first thing called after start.c
|
// The main application code. This is the first thing called after start.c
|
||||||
// executes.
|
// executes.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#include <stdarg.h>
|
||||||
#include "usb_cdc.h"
|
#include "usb_cdc.h"
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
|
|
|
@ -29,7 +29,6 @@ extern "C" {
|
||||||
#include "pcf7931.h"
|
#include "pcf7931.h"
|
||||||
#include "desfire.h"
|
#include "desfire.h"
|
||||||
#include "iso14443b.h"
|
#include "iso14443b.h"
|
||||||
//#include "iso14443a.h"
|
|
||||||
#include "emvcard.h"
|
#include "emvcard.h"
|
||||||
|
|
||||||
extern int rsamples; // = 0;
|
extern int rsamples; // = 0;
|
||||||
|
|
|
@ -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) {
|
void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
|
||||||
uint8_t blockNo = arg0 & 0xff;
|
#define STD_SEARCH 1
|
||||||
uint8_t keyType = (arg0 >> 8) & 0xff;
|
#define EXT_SEARCH 2
|
||||||
bool clearTrace = arg1;
|
|
||||||
|
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;
|
uint8_t keyCount = arg2;
|
||||||
uint64_t ui64Key = 0;
|
uint64_t ui64Key = 0;
|
||||||
|
|
||||||
|
@ -1026,8 +1030,16 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// found a key.
|
||||||
|
//
|
||||||
|
//if ( searchType == EXT_SEARCH) {
|
||||||
|
|
||||||
|
//}
|
||||||
|
//else {
|
||||||
isOK = 1;
|
isOK = 1;
|
||||||
break;
|
break;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
#define OPTIMIZED_CIPHER_H
|
#define OPTIMIZED_CIPHER_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -721,7 +721,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
|
||||||
|
|
||||||
int CmdHF14AMfNested(const char *Cmd) {
|
int CmdHF14AMfNested(const char *Cmd) {
|
||||||
int i, j, res, iterations;
|
int i, j, res, iterations;
|
||||||
sector *e_sector = NULL;
|
sector_t *e_sector = NULL;
|
||||||
uint8_t blockNo = 0;
|
uint8_t blockNo = 0;
|
||||||
uint8_t keyType = 0;
|
uint8_t keyType = 0;
|
||||||
uint8_t trgBlockNo = 0;
|
uint8_t trgBlockNo = 0;
|
||||||
|
@ -823,7 +823,7 @@ int CmdHF14AMfNested(const char *Cmd) {
|
||||||
time_t start, end;
|
time_t start, end;
|
||||||
time(&start);
|
time(&start);
|
||||||
|
|
||||||
e_sector = calloc(SectorsCnt, sizeof(sector));
|
e_sector = calloc(SectorsCnt, sizeof(sector_t));
|
||||||
if (e_sector == NULL) return 1;
|
if (e_sector == NULL) return 1;
|
||||||
|
|
||||||
//test current key and additional standard keys first
|
//test current key and additional standard keys first
|
||||||
|
@ -1083,7 +1083,7 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||||
uint8_t *keyBlock = NULL, *p;
|
uint8_t *keyBlock = NULL, *p;
|
||||||
uint8_t stKeyBlock = 20;
|
uint8_t stKeyBlock = 20;
|
||||||
|
|
||||||
sector *e_sector = NULL;
|
sector_t *e_sector = NULL;
|
||||||
|
|
||||||
int i, res;
|
int i, res;
|
||||||
int keycnt = 0;
|
int keycnt = 0;
|
||||||
|
@ -1230,7 +1230,7 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize storage for found keys
|
// initialize storage for found keys
|
||||||
e_sector = calloc(SectorsCnt, sizeof(sector));
|
e_sector = calloc(SectorsCnt, sizeof(sector_t));
|
||||||
if (e_sector == NULL) {
|
if (e_sector == NULL) {
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1362,13 +1362,13 @@ int CmdHF14AMfChk(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sector *k_sector = NULL;
|
sector_t *k_sector = NULL;
|
||||||
uint8_t k_sectorsCount = 16;
|
uint8_t k_sectorsCount = 16;
|
||||||
static void emptySectorTable(){
|
static void emptySectorTable(){
|
||||||
|
|
||||||
// initialize storage for found keys
|
// initialize storage for found keys
|
||||||
if (k_sector == NULL)
|
if (k_sector == NULL)
|
||||||
k_sector = calloc(k_sectorsCount, sizeof(sector));
|
k_sector = calloc(k_sectorsCount, sizeof(sector_t));
|
||||||
if (k_sector == NULL)
|
if (k_sector == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1720,7 +1720,7 @@ int CmdHF14AMfKeyBrute(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printKeyTable( uint8_t sectorscnt, sector *e_sector ){
|
void printKeyTable( uint8_t sectorscnt, sector_t *e_sector ){
|
||||||
PrintAndLog("|---|----------------|---|----------------|---|");
|
PrintAndLog("|---|----------------|---|----------------|---|");
|
||||||
PrintAndLog("|sec|key A |res|key B |res|");
|
PrintAndLog("|sec|key A |res|key B |res|");
|
||||||
PrintAndLog("|---|----------------|---|----------------|---|");
|
PrintAndLog("|---|----------------|---|----------------|---|");
|
||||||
|
|
|
@ -16,14 +16,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
|
|
||||||
#include "iso14443crc.h"
|
#include "iso14443crc.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "cmdparser.h"
|
#include "cmdparser.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
//#include "mifarehost.h"
|
|
||||||
#include "mifare.h" // nonces_t struct
|
#include "mifare.h" // nonces_t struct
|
||||||
#include "cmdhfmfhard.h"
|
#include "cmdhfmfhard.h"
|
||||||
#include "nonce2key/nonce2key.h"
|
#include "nonce2key/nonce2key.h"
|
||||||
|
@ -63,5 +61,5 @@ int CmdHf14MfDecryptBytes(const char *Cmd);
|
||||||
|
|
||||||
void showSectorTable(void);
|
void showSectorTable(void);
|
||||||
void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose);
|
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
|
#endif
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
# define HOST_LITTLE_ENDIAN
|
# define HOST_LITTLE_ENDIAN
|
||||||
#else
|
#else
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef SLEEP_H__
|
#ifndef SLEEP_H__
|
||||||
#define SLEEP_H__
|
#define SLEEP_H__
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define sleep(n) Sleep(1000 * n)
|
#define sleep(n) Sleep(1000 * n)
|
||||||
#define msleep(n) Sleep(n)
|
#define msleep(n) Sleep(n)
|
||||||
|
|
|
@ -451,6 +451,9 @@ local _keys = {
|
||||||
'0ffbf65b5a14',
|
'0ffbf65b5a14',
|
||||||
'c5cfe06d9ea3',
|
'c5cfe06d9ea3',
|
||||||
'c0dece673829',
|
'c0dece673829',
|
||||||
|
--[[
|
||||||
|
--]]
|
||||||
|
'a56c2df9a26d',
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -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){
|
int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key){
|
||||||
|
#define STD_SEARCH 1
|
||||||
|
#define EXT_SEARCH 2
|
||||||
*key = 0;
|
*key = 0;
|
||||||
UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType<<8)), clear_trace, keycnt}};
|
UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), ((EXT_SEARCH << 8) | clear_trace), keycnt}};
|
||||||
memcpy(c.d.asBytes, keyBlock, 6 * keycnt);
|
memcpy(c.d.asBytes, keyBlock, 6 * keycnt);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
|
@ -58,7 +58,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t Key[2];
|
uint64_t Key[2];
|
||||||
int foundKey[2];
|
int foundKey[2];
|
||||||
} sector;
|
} sector_t;
|
||||||
|
|
||||||
extern int compar_int(const void * a, const void * b);
|
extern int compar_int(const void * a, const void * b);
|
||||||
extern char logHexFileName[FILE_PATH_SIZE];
|
extern char logHexFileName[FILE_PATH_SIZE];
|
||||||
|
|
|
@ -30,6 +30,7 @@ If you want to add more, just put them inside /lualibs/mf_default_keys.lua\n"):f
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
-h : this help
|
-h : this help
|
||||||
|
-p : print keys
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local TIMEOUT = 10000 -- 10 seconds
|
local TIMEOUT = 10000 -- 10 seconds
|
||||||
|
@ -179,12 +180,20 @@ local function dumptofile(results)
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
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)
|
local function main( args)
|
||||||
|
|
||||||
-- Arguments for the script
|
-- 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 == "h" then return help() end
|
||||||
|
if o == "p" then return printkeys() end
|
||||||
end
|
end
|
||||||
|
|
||||||
result, err = reader.read1443a()
|
result, err = reader.read1443a()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue