mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
monster merge...
all those changes marshmellow did.. and more...
This commit is contained in:
+12
-4
@@ -930,7 +930,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
setSamplingConfig((sample_config *) c->d.asBytes);
|
||||
break;
|
||||
case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
||||
cmd_send(CMD_ACK, SampleLF(c->arg[0]),0,0,0,0);
|
||||
cmd_send(CMD_ACK,SampleLF(c->arg[0], c->arg[1]),0,0,0,0);
|
||||
break;
|
||||
case CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
||||
ModThenAcquireRawAdcSamples125k(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
|
||||
@@ -1085,7 +1085,15 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
LegicRfInfo();
|
||||
break;
|
||||
case CMD_LEGIC_ESET:
|
||||
LegicEMemSet(c->arg[0], c->arg[1], c->d.asBytes);
|
||||
//-----------------------------------------------------------------------------
|
||||
// Note: we call FpgaDownloadAndGo(FPGA_BITSTREAM_HF) here although FPGA is not
|
||||
// involved in dealing with emulator memory. But if it is called later, it might
|
||||
// destroy the Emulator Memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
// arg0 = offset
|
||||
// arg1 = num of bytes
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
emlSet(c->d.asBytes, c->arg[0], c->arg[1]);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1499,9 +1507,9 @@ void __attribute__((noreturn)) AppMain(void)
|
||||
for(;;) {
|
||||
if ( usb_poll_validate_length() ) {
|
||||
rx_len = usb_read(rx, sizeof(UsbCommand));
|
||||
if (rx_len) {
|
||||
|
||||
if (rx_len)
|
||||
UsbPacketReceived(rx, rx_len);
|
||||
}
|
||||
}
|
||||
WDT_HIT();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ extern "C" {
|
||||
#include "iso14443b.h"
|
||||
#include "emvcard.h"
|
||||
|
||||
extern const uint8_t OddByteParity[256];
|
||||
extern int rsamples; // = 0;
|
||||
extern int tracing; // = TRUE;
|
||||
extern uint8_t trigger;
|
||||
|
||||
+107
-98
@@ -77,7 +77,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t periods, uint3
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
|
||||
|
||||
// now do the read
|
||||
DoAcquisition_config(false);
|
||||
DoAcquisition_config(false, 0);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
}
|
||||
@@ -459,7 +459,6 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
|
||||
OUT:
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LED_D_OFF();
|
||||
DbpString("Simulation stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -784,6 +783,7 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
size_t size = 0;
|
||||
uint32_t hi2=0, hi=0, lo=0;
|
||||
int idx=0;
|
||||
int dummyIdx = 0;
|
||||
// Configure to go in 125Khz listen mode
|
||||
LFSetupFPGAForADC(95, true);
|
||||
|
||||
@@ -795,10 +795,10 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
WDT_HIT();
|
||||
if (ledcontrol) LED_A_ON();
|
||||
|
||||
DoAcquisition_default(0, true);
|
||||
DoAcquisition_default(-1,true);
|
||||
// FSK demodulator
|
||||
size = 50*128*2; //big enough to catch 2 sequences of largest format
|
||||
idx = HIDdemodFSK(dest, &size, &hi2, &hi, &lo);
|
||||
idx = HIDdemodFSK(dest, &size, &hi2, &hi, &lo, &dummyIdx);
|
||||
|
||||
if (idx>0 && lo>0 && (size==96 || size==192)){
|
||||
// go over previously decoded manchester data and decode into usable tag ID
|
||||
@@ -880,7 +880,7 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
{
|
||||
uint8_t *dest = BigBuf_get_addr();
|
||||
size_t size;
|
||||
int idx=0;
|
||||
int idx=0, dummyIdx=0;
|
||||
//clear read buffer
|
||||
BigBuf_Clear_keep_EM();
|
||||
// Configure to go in 125Khz listen mode
|
||||
@@ -894,87 +894,74 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
DoAcquisition_default(-1,true);
|
||||
// FSK demodulator
|
||||
size = 50*128*2; //big enough to catch 2 sequences of largest format
|
||||
idx = AWIDdemodFSK(dest, &size);
|
||||
idx = detectAWID(dest, &size, &dummyIdx);
|
||||
|
||||
if (idx<=0 || size!=96) continue;
|
||||
// Index map
|
||||
// 0 10 20 30 40 50 60
|
||||
// | | | | | | |
|
||||
// 01234567 890 1 234 5 678 9 012 3 456 7 890 1 234 5 678 9 012 3 456 7 890 1 234 5 678 9 012 3 - to 96
|
||||
// -----------------------------------------------------------------------------
|
||||
// 00000001 000 1 110 1 101 1 011 1 101 1 010 0 000 1 000 1 010 0 001 0 110 1 100 0 000 1 000 1
|
||||
// premable bbb o bbb o bbw o fff o fff o ffc o ccc o ccc o ccc o ccc o ccc o wxx o xxx o xxx o - to 96
|
||||
// |---26 bit---| |-----117----||-------------142-------------|
|
||||
// b = format bit len, o = odd parity of last 3 bits
|
||||
// f = facility code, c = card number
|
||||
// w = wiegand parity
|
||||
// (26 bit format shown)
|
||||
// Index map
|
||||
// 0 10 20 30 40 50 60
|
||||
// | | | | | | |
|
||||
// 01234567 890 1 234 5 678 9 012 3 456 7 890 1 234 5 678 9 012 3 456 7 890 1 234 5 678 9 012 3 - to 96
|
||||
// -----------------------------------------------------------------------------
|
||||
// 00000001 000 1 110 1 101 1 011 1 101 1 010 0 000 1 000 1 010 0 001 0 110 1 100 0 000 1 000 1
|
||||
// premable bbb o bbb o bbw o fff o fff o ffc o ccc o ccc o ccc o ccc o ccc o wxx o xxx o xxx o - to 96
|
||||
// |---26 bit---| |-----117----||-------------142-------------|
|
||||
// b = format bit len, o = odd parity of last 3 bits
|
||||
// f = facility code, c = card number
|
||||
// w = wiegand parity
|
||||
// (26 bit format shown)
|
||||
|
||||
//get raw ID before removing parities
|
||||
uint32_t rawLo = bytebits_to_byte(dest+idx+64,32);
|
||||
uint32_t rawHi = bytebits_to_byte(dest+idx+32,32);
|
||||
uint32_t rawHi2 = bytebits_to_byte(dest+idx,32);
|
||||
//get raw ID before removing parities
|
||||
uint32_t rawLo = bytebits_to_byte(dest+idx+64,32);
|
||||
uint32_t rawHi = bytebits_to_byte(dest+idx+32,32);
|
||||
uint32_t rawHi2 = bytebits_to_byte(dest+idx,32);
|
||||
|
||||
size = removeParity(dest, idx+8, 4, 1, 88);
|
||||
size = removeParity(dest, idx+8, 4, 1, 88);
|
||||
if (size != 66) continue;
|
||||
// ok valid card found!
|
||||
|
||||
// Index map
|
||||
// 0 10 20 30 40 50 60
|
||||
// | | | | | | |
|
||||
// 01234567 8 90123456 7890123456789012 3 456789012345678901234567890123456
|
||||
// -----------------------------------------------------------------------------
|
||||
// 00011010 1 01110101 0000000010001110 1 000000000000000000000000000000000
|
||||
// bbbbbbbb w ffffffff cccccccccccccccc w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// |26 bit| |-117--| |-----142------|
|
||||
//
|
||||
// 00110010 0 0000011111010000000000000001000100101000100001111 0 00000000
|
||||
// bbbbbbbb w ffffffffffffffffccccccccccccccccccccccccccccccccc w xxxxxxxx
|
||||
// |50 bit| |----4000------||-----------2248975-------------|
|
||||
//
|
||||
// b = format bit len, o = odd parity of last 3 bits
|
||||
// f = facility code, c = card number
|
||||
// w = wiegand parity
|
||||
// Index map
|
||||
// 0 10 20 30 40 50 60
|
||||
// | | | | | | |
|
||||
// 01234567 8 90123456 7890123456789012 3 456789012345678901234567890123456
|
||||
// -----------------------------------------------------------------------------
|
||||
// 00011010 1 01110101 0000000010001110 1 000000000000000000000000000000000
|
||||
// bbbbbbbb w ffffffff cccccccccccccccc w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// |26 bit| |-117--| |-----142------|
|
||||
// b = format bit len, o = odd parity of last 3 bits
|
||||
// f = facility code, c = card number
|
||||
// w = wiegand parity
|
||||
// (26 bit format shown)
|
||||
|
||||
uint32_t fc = 0;
|
||||
uint32_t cardnum = 0;
|
||||
uint32_t code1 = 0;
|
||||
uint32_t code2 = 0;
|
||||
uint8_t fmtLen = bytebits_to_byte(dest,8);
|
||||
switch(fmtLen) {
|
||||
case 26:
|
||||
fc = bytebits_to_byte(dest + 9, 8);
|
||||
cardnum = bytebits_to_byte(dest + 17, 16);
|
||||
code1 = bytebits_to_byte(dest + 8,fmtLen);
|
||||
Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %u - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
|
||||
break;
|
||||
case 50:
|
||||
fc = bytebits_to_byte(dest + 9, 16);
|
||||
cardnum = bytebits_to_byte(dest + 25, 32);
|
||||
code1 = bytebits_to_byte(dest + 8, (fmtLen-32) );
|
||||
code2 = bytebits_to_byte(dest + 8 + (fmtLen-32), 32);
|
||||
Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %u - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, code2, rawHi2, rawHi, rawLo);
|
||||
break;
|
||||
default:
|
||||
if (fmtLen > 32 ) {
|
||||
cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
|
||||
code1 = bytebits_to_byte(dest+8,fmtLen-32);
|
||||
code2 = bytebits_to_byte(dest+8+(fmtLen-32),32);
|
||||
Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
|
||||
} else {
|
||||
cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
|
||||
code1 = bytebits_to_byte(dest+8,fmtLen);
|
||||
Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
|
||||
}
|
||||
break;
|
||||
uint32_t fc = 0;
|
||||
uint32_t cardnum = 0;
|
||||
uint32_t code1 = 0;
|
||||
uint32_t code2 = 0;
|
||||
uint8_t fmtLen = bytebits_to_byte(dest,8);
|
||||
if (fmtLen==26){
|
||||
fc = bytebits_to_byte(dest+9, 8);
|
||||
cardnum = bytebits_to_byte(dest+17, 16);
|
||||
code1 = bytebits_to_byte(dest+8,fmtLen);
|
||||
Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
|
||||
} else {
|
||||
cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
|
||||
if (fmtLen>32){
|
||||
code1 = bytebits_to_byte(dest+8,fmtLen-32);
|
||||
code2 = bytebits_to_byte(dest+8+(fmtLen-32),32);
|
||||
Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
|
||||
} else{
|
||||
code1 = bytebits_to_byte(dest+8,fmtLen);
|
||||
Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
|
||||
}
|
||||
if (findone)
|
||||
break;
|
||||
|
||||
}
|
||||
if (findone){
|
||||
if (ledcontrol) LED_A_OFF();
|
||||
break;
|
||||
}
|
||||
// reset
|
||||
idx = 0;
|
||||
WDT_HIT();
|
||||
}
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
DbpString("Stopped");
|
||||
if (ledcontrol) LED_A_OFF();
|
||||
}
|
||||
@@ -1044,14 +1031,15 @@ void CmdEM410xdemod(int findone, int *high, int *low, int ledcontrol)
|
||||
void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
{
|
||||
uint8_t *dest = BigBuf_get_addr();
|
||||
int idx=0;
|
||||
int dummyIdx = 0;
|
||||
int idx = 0;
|
||||
uint32_t code=0, code2=0;
|
||||
uint8_t version=0;
|
||||
uint8_t facilitycode=0;
|
||||
uint16_t number=0;
|
||||
uint8_t crc = 0;
|
||||
uint16_t calccrc = 0;
|
||||
|
||||
size_t size = BigBuf_max_traceLen();
|
||||
//clear read buffer
|
||||
BigBuf_Clear_keep_EM();
|
||||
|
||||
@@ -1064,7 +1052,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
DoAcquisition_default(-1,true);
|
||||
//fskdemod and get start index
|
||||
WDT_HIT();
|
||||
idx = IOdemodFSK(dest, BigBuf_max_traceLen());
|
||||
idx = detectIOProx(dest, &size, &dummyIdx);
|
||||
if (idx<0) continue;
|
||||
//valid tag found
|
||||
|
||||
@@ -1210,7 +1198,7 @@ void T55xxResetRead(void) {
|
||||
TurnReadLFOn(READ_GAP);
|
||||
|
||||
// Acquisition
|
||||
doT55x7Acquisition(BigBuf_max_traceLen());
|
||||
DoPartialAcquisition(0, true, BigBuf_max_traceLen());
|
||||
|
||||
// Turn the field off
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
|
||||
@@ -1223,6 +1211,7 @@ void T55xxWriteBlockExt(uint32_t Data, uint8_t Block, uint32_t Pwd, uint8_t arg)
|
||||
LED_A_ON();
|
||||
bool PwdMode = arg & 0x1;
|
||||
uint8_t Page = (arg & 0x2)>>1;
|
||||
bool testMode = arg & 0x4;
|
||||
uint32_t i = 0;
|
||||
|
||||
// Set up FPGA, 125kHz
|
||||
@@ -1234,9 +1223,11 @@ void T55xxWriteBlockExt(uint32_t Data, uint8_t Block, uint32_t Pwd, uint8_t arg)
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
WaitUS(START_GAP);
|
||||
|
||||
// Opcode 10
|
||||
T55xxWriteBit(1);
|
||||
T55xxWriteBit(Page); //Page 0
|
||||
if (testMode) Dbprintf("TestMODE");
|
||||
// Std Opcode 10
|
||||
T55xxWriteBit(testMode ? 0 : 1);
|
||||
T55xxWriteBit(testMode ? 1 : Page); //Page 0
|
||||
|
||||
if (PwdMode){
|
||||
// Send Pwd
|
||||
for (i = 0x80000000; i != 0; i >>= 1)
|
||||
@@ -1255,12 +1246,32 @@ void T55xxWriteBlockExt(uint32_t Data, uint8_t Block, uint32_t Pwd, uint8_t arg)
|
||||
|
||||
// Perform write (nominal is 5.6 ms for T55x7 and 18ms for E5550,
|
||||
// so wait a little more)
|
||||
TurnReadLFOn(20 * 1000);
|
||||
|
||||
// "there is a clock delay before programming"
|
||||
// - programming takes ~5.6ms for t5577 ~18ms for E5550 or t5567
|
||||
// so we should wait 1 clock + 5.6ms then read response?
|
||||
// but we need to know we are dealing with t5577 vs t5567 vs e5550 (or q5) marshmellow...
|
||||
if (testMode) {
|
||||
//TESTMODE TIMING TESTS:
|
||||
// <566us does nothing
|
||||
// 566-568 switches between wiping to 0s and doing nothing
|
||||
// 5184 wipes and allows 1 block to be programmed.
|
||||
// indefinite power on wipes and then programs all blocks with bitshifted data sent.
|
||||
TurnReadLFOn(5184);
|
||||
|
||||
} else {
|
||||
TurnReadLFOn(20 * 1000);
|
||||
|
||||
//could attempt to do a read to confirm write took
|
||||
// as the tag should repeat back the new block
|
||||
// until it is reset, but to confirm it we would
|
||||
// need to know the current block 0 config mode
|
||||
//could attempt to do a read to confirm write took
|
||||
// as the tag should repeat back the new block
|
||||
// until it is reset, but to confirm it we would
|
||||
// need to know the current block 0 config mode for
|
||||
// modulation clock an other details to demod the response...
|
||||
// response should be (for t55x7) a 0 bit then (ST if on)
|
||||
// block data written in on repeat until reset.
|
||||
|
||||
//DoPartialAcquisition(20, true, 12000);
|
||||
}
|
||||
|
||||
// turn field off
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
@@ -1279,7 +1290,7 @@ void T55xxReadBlock(uint16_t arg0, uint8_t Block, uint32_t Pwd) {
|
||||
bool PwdMode = arg0 & 0x1;
|
||||
uint8_t Page = (arg0 & 0x2) >> 1;
|
||||
uint32_t i = 0;
|
||||
bool RegReadMode = (Block == 0xFF);
|
||||
bool RegReadMode = (Block == 0xFF);//regular read mode
|
||||
|
||||
//clear buffer now so it does not interfere with timing later
|
||||
BigBuf_Clear_keep_EM();
|
||||
@@ -1319,7 +1330,8 @@ void T55xxReadBlock(uint16_t arg0, uint8_t Block, uint32_t Pwd) {
|
||||
TurnReadLFOn(210*8);
|
||||
|
||||
// Acquisition
|
||||
doT55x7Acquisition(7679);
|
||||
// Now do the acquisition
|
||||
DoPartialAcquisition(0, true, 12000);
|
||||
|
||||
// Turn the field off
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
|
||||
@@ -1398,7 +1410,7 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
|
||||
data[0] = T55x7_BITRATE_RF_50 | T55x7_MODULATION_FSK2a | last_block << T55x7_MAXBLOCK_SHIFT;
|
||||
|
||||
//TODO add selection of chip for Q5 or T55x7
|
||||
// data[0] = (((50-2)>>1)<<T5555_BITRATE_SHIFT) | T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | last_block << T5555_MAXBLOCK_SHIFT;
|
||||
// data[0] = T5555_SET_BITRATE(50) | T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | last_block << T5555_MAXBLOCK_SHIFT;
|
||||
|
||||
LED_D_ON();
|
||||
WriteT55xx(data, 0, last_block+1);
|
||||
@@ -1408,8 +1420,7 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
|
||||
void CopyIOtoT55x7(uint32_t hi, uint32_t lo) {
|
||||
uint32_t data[] = {T55x7_BITRATE_RF_64 | T55x7_MODULATION_FSK2a | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo};
|
||||
//TODO add selection of chip for Q5 or T55x7
|
||||
//t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
|
||||
// data[0] = ( ((64-2)>>1) << T5555_BITRATE_SHIFT) | T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
// data[0] = T5555_SET_BITRATE(64) | T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
|
||||
LED_D_ON();
|
||||
// Program the data blocks for supplied ID
|
||||
@@ -1424,7 +1435,7 @@ void CopyIndala64toT55x7(uint32_t hi, uint32_t lo) {
|
||||
// and the Config for Indala 64 format (RF/32;PSK1 with RF/2;Maxblock=2)
|
||||
uint32_t data[] = { T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK1 | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo};
|
||||
//TODO add selection of chip for Q5 or T55x7
|
||||
// data[0] = (((32-2)>>1)<<T5555_BITRATE_SHIFT) | T5555_MODULATION_PSK1 | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
// data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK1 | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
|
||||
WriteT55xx(data, 0, 3);
|
||||
//Alternative config for Indala (Extended mode;RF/32;PSK1 with RF/2;Maxblock=2;Inverse data)
|
||||
@@ -1446,8 +1457,7 @@ void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t
|
||||
// clone viking tag to T55xx
|
||||
void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) {
|
||||
uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), block1, block2};
|
||||
//t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
|
||||
if (Q5) data[0] = (((32-2)>>1) << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
if (Q5) data[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
// Program the data blocks for supplied ID and the block 0 config
|
||||
WriteT55xx(data, 0, 3);
|
||||
LED_D_OFF();
|
||||
@@ -1531,8 +1541,7 @@ void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo) {
|
||||
}
|
||||
data[0] = clock | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT);
|
||||
} else { //t5555 (Q5)
|
||||
// t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
|
||||
data[0] = ( ((clock-2) >> 1) << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | (2 << T5555_MAXBLOCK_SHIFT);
|
||||
data[0] = T5555_SET_BITRATE(clock) | T5555_MODULATION_MANCHESTER | (2 << T5555_MAXBLOCK_SHIFT);
|
||||
}
|
||||
|
||||
WriteT55xx(data, 0, 3);
|
||||
@@ -1818,7 +1827,7 @@ void Cotag(uint32_t arg0) {
|
||||
switch(rawsignal) {
|
||||
case 0: doCotagAcquisition(50000); break;
|
||||
case 1: doCotagAcquisitionManchester(); break;
|
||||
case 2: DoAcquisition_config(true); break;
|
||||
case 2: DoAcquisition_config(true, 0); break;
|
||||
}
|
||||
|
||||
// Turn the field off
|
||||
|
||||
+7
-7
@@ -209,33 +209,33 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
|
||||
uint32_t DoAcquisition_default(int trigger_threshold, bool silent) {
|
||||
return DoAcquisition(1, 8, 0,trigger_threshold, silent, 0);
|
||||
}
|
||||
uint32_t DoAcquisition_config( bool silent) {
|
||||
uint32_t DoAcquisition_config( bool silent, int sample_size) {
|
||||
return DoAcquisition(config.decimation
|
||||
,config.bits_per_sample
|
||||
,config.averaging
|
||||
,config.trigger_threshold
|
||||
,silent
|
||||
,0);
|
||||
,sample_size);
|
||||
}
|
||||
|
||||
uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size) {
|
||||
return DoAcquisition(1, 8, 0, trigger_threshold, silent, sample_size);
|
||||
}
|
||||
|
||||
uint32_t ReadLF(bool activeField, bool silent) {
|
||||
uint32_t ReadLF(bool activeField, bool silent, int sample_size) {
|
||||
if (!silent)
|
||||
printConfig();
|
||||
LFSetupFPGAForADC(config.divisor, activeField);
|
||||
return DoAcquisition_config(silent);
|
||||
return DoAcquisition_config(silent, sample_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the FPGA for reader-mode (field on), and acquires the samples.
|
||||
* @return number of bits sampled
|
||||
**/
|
||||
uint32_t SampleLF(bool printCfg) {
|
||||
uint32_t SampleLF(bool printCfg, int sample_size) {
|
||||
BigBuf_Clear_ext(false);
|
||||
uint32_t ret = ReadLF(true, printCfg);
|
||||
uint32_t ret = ReadLF(true, printCfg, sample_size);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
return ret;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ uint32_t SampleLF(bool printCfg) {
|
||||
**/
|
||||
uint32_t SnoopLF() {
|
||||
BigBuf_Clear_ext(false);
|
||||
uint32_t ret = ReadLF(false, true);
|
||||
uint32_t ret = ReadLF(false, true, 0);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-3
@@ -27,13 +27,12 @@ void doT55x7Acquisition(size_t sample_size);
|
||||
* Initializes the FPGA for reader-mode (field on), and acquires the samples.
|
||||
* @return number of bits sampled
|
||||
**/
|
||||
uint32_t SampleLF(bool silent);
|
||||
uint32_t SampleLF(bool silent, int sample_size);
|
||||
|
||||
/**
|
||||
* Initializes the FPGA for snoop-mode (field off), and acquires the samples.
|
||||
* @return number of bits sampled
|
||||
**/
|
||||
|
||||
uint32_t SnoopLF();
|
||||
|
||||
// adds sample size to default options
|
||||
@@ -55,7 +54,7 @@ uint32_t DoAcquisition_default(int trigger_threshold, bool silent);
|
||||
* @return number of bits sampled
|
||||
*/
|
||||
|
||||
uint32_t DoAcquisition_config( bool silent);
|
||||
uint32_t DoAcquisition_config(bool silent, int sample_size);
|
||||
|
||||
/**
|
||||
* Setup the FPGA to listen for samples. This method downloads the FPGA bitstream
|
||||
|
||||
+5
-3
@@ -82,8 +82,8 @@ CORESRCS = uart_posix.c \
|
||||
uart_win32.c \
|
||||
util.c \
|
||||
util_posix.c \
|
||||
scandir.c \
|
||||
sleep.c
|
||||
scandir.c
|
||||
|
||||
|
||||
CMDSRCS = crapto1/crapto1.c \
|
||||
crapto1/crypto1.c \
|
||||
@@ -133,11 +133,13 @@ CMDSRCS = crapto1/crapto1.c \
|
||||
cmdlfhid.c \
|
||||
cmdlfhitag.c \
|
||||
cmdlfio.c \
|
||||
cmdlfindala.c \
|
||||
cmdlfjablotron.c \
|
||||
cmdlfnexwatch.c \
|
||||
cmdlfnedap.c \
|
||||
cmdlfnoralsy.c \
|
||||
cmdlfpac.c \
|
||||
cmdlfparadox.c \
|
||||
cmdlfpcf7931.c \
|
||||
cmdlfpresco.c \
|
||||
cmdlfpyramid.c \
|
||||
@@ -181,7 +183,7 @@ ifeq ($(MULTIARCHSRCS), )
|
||||
endif
|
||||
|
||||
ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
|
||||
ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
|
||||
ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
|
||||
#-DDEBUG -Dverbose=1
|
||||
|
||||
QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include "sleep.h"
|
||||
#include "util_posix.h"
|
||||
#include "ui.h"
|
||||
//#include "proxusb.h"
|
||||
#include "cmdmain.h"
|
||||
|
||||
@@ -7,23 +7,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// CRC Calculations from the software reveng commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO 0
|
||||
# endif /* STDIN_FILENO */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "cmdmain.h"
|
||||
#include "cmdcrc.h"
|
||||
#include "reveng/reveng.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
|
||||
#define MAX_ARGS 20
|
||||
|
||||
|
||||
+23
-4
@@ -11,9 +11,28 @@
|
||||
#ifndef CMDCRC_H__
|
||||
#define CMDCRC_H__
|
||||
|
||||
int CmdCrc(const char *Cmd);
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO 0
|
||||
# endif /* STDIN_FILENO */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
int CmdrevengSearch(const char *Cmd);
|
||||
int GetModels(char *Models[], int *count, uint8_t *width);
|
||||
int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *result);
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "cmdmain.h"
|
||||
#include "reveng/reveng.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
|
||||
extern int CmdCrc(const char *Cmd);
|
||||
|
||||
extern int CmdrevengSearch(const char *Cmd);
|
||||
extern int GetModels(char *Models[], int *count, uint8_t *width);
|
||||
extern int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *result);
|
||||
#endif
|
||||
|
||||
+325
-987
File diff suppressed because it is too large
Load Diff
+7
-16
@@ -31,15 +31,17 @@
|
||||
#include "crc.h" // for pyramid checksum maxim
|
||||
#include "crc16.h" // for FDXB demod checksum
|
||||
#include "loclass/cipherutils.h" // for decimating samples in getsamples
|
||||
#include "cmdlfem4x.h" // askem410xdecode
|
||||
|
||||
command_t * CmdDataCommands();
|
||||
|
||||
int CmdData(const char *Cmd);
|
||||
void printDemodBuff(void);
|
||||
void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx);
|
||||
int CmdAskEM410xDemod(const char *Cmd);
|
||||
int CmdVikingDemod(const char *Cmd);
|
||||
int CmdG_Prox_II_Demod(const char *Cmd);
|
||||
bool getDemodBuf(uint8_t *buff, size_t *size);
|
||||
void save_restoreDB(uint8_t saveOpt);// option '1' to save DemodBuffer any other to restore
|
||||
int CmdPrintDemodBuff(const char *Cmd);
|
||||
|
||||
int Cmdaskrawdemod(const char *Cmd);
|
||||
int Cmdaskmandemod(const char *Cmd);
|
||||
int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph, bool verbose);
|
||||
@@ -50,12 +52,6 @@ int CmdBitsamples(const char *Cmd);
|
||||
int CmdBuffClear(const char *Cmd);
|
||||
int CmdDec(const char *Cmd);
|
||||
int CmdDetectClockRate(const char *Cmd);
|
||||
int CmdFDXBdemodBI(const char *Cmd);
|
||||
int CmdFSKdemodAWID(const char *Cmd);
|
||||
int CmdFSKdemodHID(const char *Cmd);
|
||||
int CmdFSKdemodIO(const char *Cmd);
|
||||
int CmdFSKdemodParadox(const char *Cmd);
|
||||
int CmdFSKdemodPyramid(const char *Cmd);
|
||||
int CmdFSKrawdemod(const char *Cmd);
|
||||
int CmdPSK1rawDemod(const char *Cmd);
|
||||
int CmdPSK2rawDemod(const char *Cmd);
|
||||
@@ -80,19 +76,14 @@ int CmdSave(const char *Cmd);
|
||||
int CmdScale(const char *Cmd);
|
||||
int CmdDirectionalThreshold(const char *Cmd);
|
||||
int CmdZerocrossings(const char *Cmd);
|
||||
int CmdIndalaDecode(const char *Cmd);
|
||||
int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo );
|
||||
int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose);
|
||||
int ASKbiphaseDemod(const char *Cmd, bool verbose);
|
||||
int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType);
|
||||
int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType, bool *stCheck);
|
||||
int FSKrawDemod(const char *Cmd, bool verbose);
|
||||
int PSKDemod(const char *Cmd, bool verbose);
|
||||
int NRZrawDemod(const char *Cmd, bool verbose);
|
||||
void printEM410x(uint32_t hi, uint64_t id);
|
||||
int getSamples(const char *Cmd, bool silent);
|
||||
|
||||
void setGrid_Clock(uint8_t clock);
|
||||
int getSamples(int n, bool silent);
|
||||
void setClockGrid(int clk, int offset);
|
||||
int directionalThreshold(const int* in, int *out, size_t len, int8_t up, int8_t down);
|
||||
extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||
|
||||
|
||||
+23
-44
@@ -7,26 +7,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "proxmark3.h"
|
||||
#include "graph.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhf.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "cmdhf14b.h"
|
||||
#include "cmdhf15.h"
|
||||
#include "cmdhfepa.h"
|
||||
#include "cmdhflegic.h" // LEGIC
|
||||
#include "cmdhficlass.h" // ICLASS
|
||||
#include "cmdhfmf.h" // CLASSIC
|
||||
#include "cmdhfmfu.h" // ULTRALIGHT/NTAG etc
|
||||
#include "cmdhfmfdes.h" // DESFIRE
|
||||
#include "cmdhftopaz.h" // TOPAZ
|
||||
#include "cmdhfemv.h" // EMV
|
||||
#include "protocols.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
@@ -658,14 +639,8 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui
|
||||
|
||||
for (int j = 0; j < data_len && j/16 < 16; j++) {
|
||||
|
||||
int oddparity = 0x01;
|
||||
int k;
|
||||
|
||||
for (k=0 ; k<8 ; k++) {
|
||||
oddparity ^= (((frame[j] & 0xFF) >> k) & 0x01);
|
||||
}
|
||||
uint8_t parityBits = parityBytes[j>>3];
|
||||
if (protocol != LEGIC && protocol != ISO_14443B && protocol != ISO_7816_4 && (isResponse || protocol == ISO_14443A) && (oddparity != ((parityBits >> (7-(j&0x0007))) & 0x01))) {
|
||||
if (protocol != LEGIC && protocol != ISO_14443B && protocol != ISO_7816_4 && (isResponse || protocol == ISO_14443A) && (oddparity8(frame[j]) != ((parityBits >> (7-(j&0x0007))) & 0x01))) {
|
||||
snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]);
|
||||
} else {
|
||||
snprintf(line[j/16]+(( j % 16) * 4),110, "%02x ", frame[j]);
|
||||
@@ -751,6 +726,10 @@ int usage_hf_list(){
|
||||
PrintAndLog(" 14a - interpret data as iso14443a communications");
|
||||
PrintAndLog(" 14b - interpret data as iso14443b communications");
|
||||
PrintAndLog(" des - interpret data as DESFire communications");
|
||||
#ifdef WITH_EMV
|
||||
PrintAndLog(" emv - interpret data as EMV / communications");
|
||||
#endif
|
||||
|
||||
PrintAndLog(" iclass - interpret data as iclass communications");
|
||||
PrintAndLog(" topaz - interpret data as topaz communications");
|
||||
PrintAndLog(" 7816 - interpret data as iso7816-4 communications");
|
||||
@@ -809,14 +788,14 @@ int CmdHFList(const char *Cmd) {
|
||||
param_getstr(Cmd,0,type);
|
||||
|
||||
// validate type of output
|
||||
if(strcmp(type, "iclass") == 0) protocol = ICLASS;
|
||||
else if(strcmp(type, "14a") == 0) protocol = ISO_14443A;
|
||||
else if(strcmp(type, "14b") == 0) protocol = ISO_14443B;
|
||||
else if(strcmp(type, "topaz")== 0) protocol = TOPAZ;
|
||||
else if(strcmp(type, "7816")== 0) protocol = ISO_7816_4;
|
||||
else if(strcmp(type,"des")== 0) protocol = MFDES;
|
||||
else if(strcmp(type,"legic")==0) protocol = LEGIC;
|
||||
else if(strcmp(type, "raw")== 0) protocol = -1;//No crc, no annotations
|
||||
if (strcmp(type, "iclass") == 0) protocol = ICLASS;
|
||||
else if(strcmp(type, "14a") == 0) protocol = ISO_14443A;
|
||||
else if(strcmp(type, "14b") == 0) protocol = ISO_14443B;
|
||||
else if(strcmp(type, "topaz")== 0) protocol = TOPAZ;
|
||||
else if(strcmp(type, "7816")== 0) protocol = ISO_7816_4;
|
||||
else if(strcmp(type, "des")== 0) protocol = MFDES;
|
||||
else if(strcmp(type, "legic")==0) protocol = LEGIC;
|
||||
else if(strcmp(type, "raw")== 0) protocol = -1;//No crc, no annotations
|
||||
else errors = true;
|
||||
|
||||
if (errors) return usage_hf_list();
|
||||
@@ -923,19 +902,19 @@ int CmdHFSnoop(const char *Cmd) {
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"14a", CmdHF14A, 1, "{ ISO14443A RFIDs... }"},
|
||||
{"14b", CmdHF14B, 1, "{ ISO14443B RFIDs... }"},
|
||||
{"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"},
|
||||
{"14a", CmdHF14A, 1, "{ ISO14443A RFIDs... }"},
|
||||
{"14b", CmdHF14B, 1, "{ ISO14443B RFIDs... }"},
|
||||
{"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"},
|
||||
{"epa", CmdHFEPA, 1, "{ German Identification Card... }"},
|
||||
#ifdef WITH_EMV
|
||||
{"emv", CmdHFEmv, 1, "{ EMV RFIDs... }"},
|
||||
{"emv", CmdHFEmv, 1, "{ EMV RFIDs... }"},
|
||||
#endif
|
||||
{"legic", CmdHFLegic, 1, "{ LEGIC RFIDs... }"},
|
||||
{"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"},
|
||||
{"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
|
||||
{"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
|
||||
{"mfdes", CmdHFMFDes, 1, "{ MIFARE Desfire RFIDs... }"},
|
||||
{"topaz", CmdHFTopaz, 1, "{ TOPAZ (NFC Type 1) RFIDs... }"},
|
||||
{"legic", CmdHFLegic, 1, "{ LEGIC RFIDs... }"},
|
||||
{"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"},
|
||||
{"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
|
||||
{"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
|
||||
{"mfdes", CmdHFMFDes, 1, "{ MIFARE Desfire RFIDs... }"},
|
||||
{"topaz", CmdHFTopaz, 1, "{ TOPAZ (NFC Type 1) RFIDs... }"},
|
||||
{"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"},
|
||||
{"list", CmdHFList, 1, "List protocol data in trace buffer"},
|
||||
{"search", CmdHFSearch, 1, "Search for known HF tags [preliminary]"},
|
||||
|
||||
+27
-1
@@ -11,8 +11,34 @@
|
||||
#ifndef CMDHF_H__
|
||||
#define CMDHF_H__
|
||||
|
||||
int CmdHF(const char *Cmd);
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "proxmark3.h"
|
||||
#include "graph.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "cmdhf14b.h"
|
||||
#include "cmdhf15.h"
|
||||
#include "cmdhfepa.h"
|
||||
#include "cmdhflegic.h" // LEGIC
|
||||
#include "cmdhficlass.h" // ICLASS
|
||||
#include "cmdhfmf.h" // CLASSIC
|
||||
#include "cmdhfmfu.h" // ULTRALIGHT/NTAG etc
|
||||
#include "cmdhfmfdes.h" // DESFIRE
|
||||
#include "cmdhftopaz.h" // TOPAZ
|
||||
#include "cmdhfemv.h" // EMV
|
||||
#include "protocols.h"
|
||||
#include "parity.h" // oddparity
|
||||
|
||||
extern int CmdHF(const char *Cmd);
|
||||
extern int CmdHFTune(const char *Cmd);
|
||||
extern int CmdHFList(const char *Cmd);
|
||||
extern int CmdHFSearch(const char *Cmd);
|
||||
extern int CmdHFSnoop(const char *Cmd);
|
||||
|
||||
extern int usage_hf_list();
|
||||
extern int usage_hf_search();
|
||||
extern int usage_hf_snoop();
|
||||
#endif
|
||||
|
||||
+2
-20
@@ -9,25 +9,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency ISO14443A commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "util.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "data.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "common.h"
|
||||
#include "cmdmain.h"
|
||||
#include "mifare.h"
|
||||
#include "cmdhfmf.h"
|
||||
#include "cmdhfmfu.h"
|
||||
#include "mifarehost.h"
|
||||
#include "cmdhf.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static void waitCmd(uint8_t iLen);
|
||||
@@ -430,7 +412,7 @@ int CmdHF14ACUIDs(const char *Cmd) {
|
||||
n = n > 0 ? n : 1;
|
||||
|
||||
PrintAndLog("Collecting %d UIDs", n);
|
||||
PrintAndLog("Start: %u", time(NULL));
|
||||
PrintAndLog("Start: %" PRIu64, msclock()/1000);
|
||||
// repeat n times
|
||||
for (int i = 0; i < n; i++) {
|
||||
// execute anticollision procedure
|
||||
@@ -453,7 +435,7 @@ int CmdHF14ACUIDs(const char *Cmd) {
|
||||
PrintAndLog("%s", uid_string);
|
||||
}
|
||||
}
|
||||
PrintAndLog("End: %u", time(NULL));
|
||||
PrintAndLog("End: %" PRIu64, msclock()/1000);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+31
-12
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// 2011, Merlok
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||
//
|
||||
// 2015,216,2017 iceman, marshmellow, piwi
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
@@ -12,17 +12,36 @@
|
||||
#ifndef CMDHF14A_H__
|
||||
#define CMDHF14A_H__
|
||||
|
||||
int CmdHF14A(const char *Cmd);
|
||||
int CmdHF14AList(const char *Cmd);
|
||||
int CmdHF14AMifare(const char *Cmd);
|
||||
int CmdHF14AReader(const char *Cmd);
|
||||
int CmdHF14ASim(const char *Cmd);
|
||||
int CmdHF14ASniff(const char *Cmd);
|
||||
int CmdHF14AEMVTransaction(const char *Cmd);
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "proxmark3.h"
|
||||
#include "common.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdmain.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "data.h"
|
||||
#include "mifare.h"
|
||||
#include "cmdhfmf.h"
|
||||
#include "cmdhfmfu.h"
|
||||
#include "cmdhf.h" // list cmd
|
||||
#include "mifarehost.h"
|
||||
|
||||
char* getTagInfo(uint8_t uid);
|
||||
extern int CmdHF14A(const char *Cmd);
|
||||
extern int CmdHF14AList(const char *Cmd);
|
||||
extern int CmdHF14AReader(const char *Cmd);
|
||||
extern int CmdHF14ASim(const char *Cmd);
|
||||
extern int CmdHF14ASniff(const char *Cmd);
|
||||
extern int CmdHF14ACmdRaw(const char *Cmd);
|
||||
extern int CmdHF14ACUIDs(const char *Cmd);
|
||||
|
||||
int usage_hf_14a_sim(void);
|
||||
int usage_hf_14a_sniff(void);
|
||||
int usage_hf_14a_raw(void);
|
||||
extern char* getTagInfo(uint8_t uid);
|
||||
|
||||
extern int usage_hf_14a_sim(void);
|
||||
extern int usage_hf_14a_sniff(void);
|
||||
extern int usage_hf_14a_raw(void);
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -221,10 +221,10 @@ int CmdHF14BCmdRaw (const char *Cmd) {
|
||||
bool success = true;
|
||||
// get back iso14b_card_select_t, don't print it.
|
||||
if (select)
|
||||
success = waitCmd(false);
|
||||
success = waitCmd14b(false);
|
||||
|
||||
// get back response from the raw bytes you sent.
|
||||
if (success && datalen>0) waitCmd(true);
|
||||
if (success && datalen>0) waitCmd14b(true);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -802,7 +802,7 @@ int srix4kValid(const char *Cmd){
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool waitCmd(bool verbose) {
|
||||
bool waitCmd14b(bool verbose) {
|
||||
|
||||
bool crc = false;
|
||||
uint8_t b1 = 0, b2 = 0;
|
||||
|
||||
+1
-1
@@ -54,5 +54,5 @@ int CmdHF14BCmdRaw (const char *Cmd);
|
||||
int CmdHF14BReadSri(const char *Cmd);
|
||||
int CmdHF14BWriteSri(const char *Cmd);
|
||||
|
||||
bool waitCmd(bool verbose);
|
||||
bool waitCmd14b(bool verbose);
|
||||
#endif
|
||||
|
||||
+16
-35
@@ -7,16 +7,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands related to the German electronic Identification Card
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "cmdhfepa.h"
|
||||
#include <time.h>
|
||||
#include "util.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
#include "cmdmain.h"
|
||||
#include "sleep.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
@@ -24,11 +15,11 @@ static int CmdHelp(const char *Cmd);
|
||||
int CmdHFEPACollectPACENonces(const char *Cmd)
|
||||
{
|
||||
// requested nonce size
|
||||
unsigned int m = 0;
|
||||
uint32_t m = 0;
|
||||
// requested number of Nonces
|
||||
unsigned int n = 0;
|
||||
uint32_t n = 0;
|
||||
// delay between requests
|
||||
unsigned int d = 0;
|
||||
uint32_t d = 0;
|
||||
|
||||
sscanf(Cmd, "%u %u %u", &m, &n, &d);
|
||||
|
||||
@@ -37,14 +28,14 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
||||
n = n > 0 ? n : 1;
|
||||
|
||||
PrintAndLog("Collecting %u %u byte nonces", n, m);
|
||||
PrintAndLog("Start: %u", time(NULL));
|
||||
PrintAndLog("Start: %" PRIu64, msclock()/1000);
|
||||
// repeat n times
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
// execute PACE
|
||||
UsbCommand c = {CMD_EPA_PACE_COLLECT_NONCE, {(int)m, 0, 0}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
|
||||
WaitForResponse(CMD_ACK,&resp);
|
||||
|
||||
// check if command failed
|
||||
@@ -64,13 +55,10 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
||||
sleep(d);
|
||||
}
|
||||
}
|
||||
PrintAndLog("End: %u", time(NULL));
|
||||
PrintAndLog("End: %" PRIu64, msclock()/1000);
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////The commands lie below here/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// perform the PACE protocol by replaying APDUs
|
||||
int CmdHFEPAPACEReplay(const char *Cmd)
|
||||
{
|
||||
@@ -139,6 +127,8 @@ int CmdHFEPAPACEReplay(const char *Cmd)
|
||||
memcpy(usb_cmd.d.asBytes, // + (j * sizeof(usb_cmd.d.asBytes)),
|
||||
apdus[i] + (j * sizeof(usb_cmd.d.asBytes)),
|
||||
packet_length);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&usb_cmd);
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
if (resp.arg[0] != 0) {
|
||||
@@ -150,6 +140,7 @@ int CmdHFEPAPACEReplay(const char *Cmd)
|
||||
|
||||
// now perform the replay
|
||||
usb_cmd.arg[0] = 0;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&usb_cmd);
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
if (resp.arg[0] != 0) {
|
||||
@@ -168,35 +159,25 @@ int CmdHFEPAPACEReplay(const char *Cmd)
|
||||
PrintAndLog("GA Perform Key Agreement: %u us", resp.d.asDwords[3]);
|
||||
PrintAndLog("GA Mutual Authenticate: %u us", resp.d.asDwords[4]);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////The new commands lie above here/////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// UI-related stuff
|
||||
|
||||
static const command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"cnonces", CmdHFEPACollectPACENonces, 0,
|
||||
"<m> <n> <d> Acquire n>0 encrypted PACE nonces of size m>0 with d sec pauses"},
|
||||
{"preplay", CmdHFEPAPACEReplay, 0,
|
||||
"<mse> <get> <map> <pka> <ma> Perform PACE protocol by replaying given APDUs"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"cnonces", CmdHFEPACollectPACENonces, 0, "<m> <n> <d> Acquire n>0 encrypted PACE nonces of size m>0 with d sec pauses"},
|
||||
{"preplay", CmdHFEPAPACEReplay, 0, "<mse> <get> <map> <pka> <ma> Perform PACE protocol by replaying given APDUs"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
int CmdHelp(const char *Cmd) {
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHFEPA(const char *Cmd) {
|
||||
// flush
|
||||
clearCommandBuffer();
|
||||
//WaitForResponseTimeout(CMD_ACK,NULL,100);
|
||||
// parse
|
||||
CmdsParse(CommandTable, Cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+16
-2
@@ -11,8 +11,22 @@
|
||||
#ifndef CMDHFEPA_H__
|
||||
#define CMDHFEPA_H__
|
||||
|
||||
int CmdHFEPA(const char *Cmd);
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "util.h"
|
||||
#include "proxmark3.h"
|
||||
#include "common.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdmain.h"
|
||||
#include "util_posix.h"
|
||||
|
||||
int CmdHFEPACollectPACENonces(const char *Cmd);
|
||||
|
||||
extern int CmdHFEPA(const char *Cmd);
|
||||
extern int CmdHFEPACollectPACENonces(const char *Cmd);
|
||||
extern int CmdHFEPAPACEReplay(const char *Cmd);
|
||||
|
||||
#endif // CMDHFEPA_H__
|
||||
|
||||
+31
-12
@@ -319,6 +319,7 @@ int HFiClassReader(const char *Cmd, bool loop, bool verbose) {
|
||||
c.arg[0] |= FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_ONE_TRY;
|
||||
UsbCommand resp;
|
||||
while (!ukbhit()){
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp, 4500)) {
|
||||
@@ -336,8 +337,23 @@ int HFiClassReader(const char *Cmd, bool loop, bool verbose) {
|
||||
PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
tagFound = true;
|
||||
}
|
||||
if( readStatus & FLAG_ICLASS_READER_CC) PrintAndLog("CC: %s", sprint_hex(data+16, 8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CONF) printIclassDumpInfo(data);
|
||||
if( readStatus & FLAG_ICLASS_READER_CC) {
|
||||
PrintAndLog(" CC: %s",sprint_hex(data+16,8));
|
||||
}
|
||||
if( readStatus & FLAG_ICLASS_READER_CONF) {
|
||||
printIclassDumpInfo(data);
|
||||
}
|
||||
if (readStatus & FLAG_ICLASS_READER_AA) {
|
||||
bool legacy = true;
|
||||
PrintAndLog(" AppIA: %s",sprint_hex(data+8*5,8));
|
||||
for (int i = 0; i<8; i++) {
|
||||
if (data[8*5+i] != 0xFF) {
|
||||
legacy = false;
|
||||
}
|
||||
}
|
||||
PrintAndLog(" : Possible iClass %s",(legacy) ? "(legacy tag)" : "(NOT legacy tag)");
|
||||
}
|
||||
|
||||
if (tagFound && !loop) return 1;
|
||||
} else {
|
||||
if (verbose) PrintAndLog("Command execute timeout");
|
||||
@@ -876,9 +892,6 @@ int CmdHFiClassReader_Dump(const char *Cmd) {
|
||||
// add diversified keys to dump
|
||||
if (have_debit_key) memcpy(tag_data+(3*8),div_key,8);
|
||||
if (have_credit_key) memcpy(tag_data+(4*8),c_div_key,8);
|
||||
|
||||
printf("Num of bytes: %zu\n", gotBytes);
|
||||
|
||||
// print the dump
|
||||
printf("------+--+-------------------------+\n");
|
||||
printf("CSN |00| %s|\n", sprint_hex(tag_data, 8));
|
||||
@@ -1160,20 +1173,21 @@ int CmdHFiClassCloneTag(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool verbose) {
|
||||
static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool verbose, bool auth) {
|
||||
uint8_t MAC[4]={0x00,0x00,0x00,0x00};
|
||||
uint8_t div_key[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||
|
||||
// block 0,1 should always be able to read, and block 5 on some cards.
|
||||
if (blockno >= 2 ) {
|
||||
if (auth || blockno >= 2) {
|
||||
if (!select_and_auth(KEY, MAC, div_key, (keyType==0x18), elite, rawkey, verbose))
|
||||
return 0;
|
||||
} else {
|
||||
uint8_t CSN[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||
uint8_t CCNR[12]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||
if (!select_only(CSN, CCNR, false, verbose))
|
||||
return false;
|
||||
if (!select_only(CSN, CCNR, (keyType==0x18), verbose))
|
||||
return 0;
|
||||
}
|
||||
|
||||
UsbCommand resp;
|
||||
UsbCommand w = {CMD_ICLASS_READBLOCK, {blockno}};
|
||||
clearCommandBuffer();
|
||||
@@ -1203,6 +1217,7 @@ int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
bool elite = false;
|
||||
bool rawkey = false;
|
||||
bool errors = false;
|
||||
bool auth = false;
|
||||
uint8_t cmdp = 0;
|
||||
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch(param_getchar(Cmd, cmdp)) {
|
||||
@@ -1229,6 +1244,7 @@ int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
break;
|
||||
case 'k':
|
||||
case 'K':
|
||||
auth = true;
|
||||
dataLen = param_getstr(Cmd, cmdp+1, tempStr);
|
||||
if (dataLen == 16) {
|
||||
errors = param_gethex(tempStr, 0, KEY, dataLen);
|
||||
@@ -1259,7 +1275,10 @@ int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
}
|
||||
if (errors || cmdp < 4) return usage_hf_iclass_readblock();
|
||||
|
||||
return ReadBlock(KEY, blockno, keyType, elite, rawkey, true);
|
||||
|
||||
if (!auth)
|
||||
PrintAndLog("warning: no authentication used with read, only a few specific blocks can be read accurately without authentication.");
|
||||
return ReadBlock(KEY, blockno, keyType, elite, rawkey, true, auth);
|
||||
}
|
||||
|
||||
int CmdHFiClass_loclass(const char *Cmd) {
|
||||
@@ -1597,8 +1616,8 @@ int CmdHFiClassManageKeys(const char *Cmd) {
|
||||
case 'n':
|
||||
case 'N':
|
||||
keyNbr = param_get8(Cmd, cmdp+1);
|
||||
if (keyNbr == 0) {
|
||||
PrintAndLog("Wrong block number");
|
||||
if (keyNbr >= ICLASS_KEYS_MAX) {
|
||||
PrintAndLog("Invalid block number");
|
||||
errors = true;
|
||||
}
|
||||
cmdp += 2;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user