mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-01 02:27:21 +08:00
Small fixes,
Fix: removed a call to free, which I think made linux people unhappy during "lf t55xx rd 0"... Add: "lf t55xx fsk" now kind of outputs binary from "FSK2a R/40 R/50"..
This commit is contained in:
parent
7737657747
commit
7bd30f12ac
13 changed files with 346 additions and 185 deletions
|
@ -64,6 +64,8 @@
|
|||
#include "string.h"
|
||||
#include "../common/iso15693tools.h"
|
||||
#include "../common/cmd.h"
|
||||
#include "crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
|
||||
#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
|
@ -600,10 +602,10 @@ static void BuildIdentifyRequest(void);
|
|||
//-----------------------------------------------------------------------------
|
||||
void AcquireRawAdcSamplesIso15693(void)
|
||||
{
|
||||
int c = 0;
|
||||
uint8_t *dest = (uint8_t *)BigBuf;
|
||||
int getNext = 0;
|
||||
uint8_t *dest = mifare_get_bigbufptr();
|
||||
|
||||
int c = 0;
|
||||
int getNext = 0;
|
||||
int8_t prev = 0;
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
@ -682,10 +684,10 @@ void AcquireRawAdcSamplesIso15693(void)
|
|||
|
||||
void RecordRawAdcSamplesIso15693(void)
|
||||
{
|
||||
int c = 0;
|
||||
uint8_t *dest = (uint8_t *)BigBuf;
|
||||
int getNext = 0;
|
||||
uint8_t *dest = mifare_get_bigbufptr();
|
||||
|
||||
int c = 0;
|
||||
int getNext = 0;
|
||||
int8_t prev = 0;
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
|
130
armsrc/lfops.c
130
armsrc/lfops.c
|
@ -54,11 +54,11 @@ void SnoopLFRawAdcSamples(int divisor, int trigger_threshold)
|
|||
// split into two routines so we can avoid timing issues after sending commands //
|
||||
void DoAcquisition125k(int trigger_threshold)
|
||||
{
|
||||
uint8_t *dest = (uint8_t *)BigBuf;
|
||||
int n = sizeof(BigBuf);
|
||||
uint8_t *dest = mifare_get_bigbufptr();
|
||||
int n = 8000;
|
||||
int i;
|
||||
|
||||
memset(dest, 0, n);
|
||||
memset(dest, 0x00, n);
|
||||
i = 0;
|
||||
for(;;) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||
|
@ -77,6 +77,7 @@ void DoAcquisition125k(int trigger_threshold)
|
|||
}
|
||||
Dbprintf("buffer samples: %02x %02x %02x %02x %02x %02x %02x %02x ...",
|
||||
dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
|
||||
|
||||
}
|
||||
|
||||
void ModThenAcquireRawAdcSamples125k(int delay_off, int period_0, int period_1, uint8_t *command)
|
||||
|
@ -829,24 +830,12 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
|
||||
void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
||||
{
|
||||
uint8_t *dest = (uint8_t *)BigBuf;
|
||||
uint8_t *dest = mifare_get_bigbufptr();
|
||||
int m=0, n=0, i=0, idx=0, lastval=0;
|
||||
int found=0;
|
||||
uint32_t code=0, code2=0;
|
||||
//uint32_t hi2=0, hi=0, lo=0;
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
|
||||
|
||||
// Connect the A/D to the peak-detected low-frequency path.
|
||||
SetAdcMuxFor(GPIO_MUXSEL_LOPKD);
|
||||
|
||||
// Give it a bit of time for the resonant antenna to settle.
|
||||
SpinDelay(50);
|
||||
|
||||
// Now set up the SSC to get the ADC samples that are now streaming at us.
|
||||
FpgaSetupSsc();
|
||||
LFSetupFPGAForADC(0, true);
|
||||
|
||||
for(;;) {
|
||||
WDT_HIT();
|
||||
|
@ -860,7 +849,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
}
|
||||
|
||||
i = 0;
|
||||
m = sizeof(BigBuf);
|
||||
m = 30000;
|
||||
memset(dest,128,m);
|
||||
for(;;) {
|
||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||
|
@ -872,15 +861,14 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
dest[i] = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
// we don't care about actual value, only if it's more or less than a
|
||||
// threshold essentially we capture zero crossings for later analysis
|
||||
if(dest[i] < 127) dest[i] = 0; else dest[i] = 1;
|
||||
i++;
|
||||
dest[i] = (dest[i] < 127) ? 0 : 1;
|
||||
++i;
|
||||
if (ledcontrol)
|
||||
LED_D_OFF();
|
||||
if(i >= m) {
|
||||
if(i >= m)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FSK demodulator
|
||||
|
||||
|
@ -898,12 +886,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
for( i=0; idx<m; idx++) {
|
||||
if (dest[idx-1]<dest[idx]) {
|
||||
dest[i]=idx-lastval;
|
||||
if (dest[i] <= 8) {
|
||||
dest[i]=1;
|
||||
} else {
|
||||
dest[i]=0;
|
||||
}
|
||||
|
||||
dest[i] = (dest[i] <= 8) ? 1:0;
|
||||
lastval=idx;
|
||||
i++;
|
||||
}
|
||||
|
@ -931,90 +914,23 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
} else {
|
||||
n=(n+1)/6; // fc/10 in sets of 6
|
||||
}
|
||||
switch (n) { // stuff appropriate bits in buffer
|
||||
case 0:
|
||||
case 1: // one bit
|
||||
|
||||
// stuff appropriate bits in buffer
|
||||
if ( n==0 )
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
//Dbprintf("%d",dest[idx-1]);
|
||||
break;
|
||||
case 2: // two bits
|
||||
else {
|
||||
if ( n < 13){
|
||||
for(int j=0; j<n; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
//Dbprintf("%d",dest[idx-1]);
|
||||
//Dbprintf("%d",dest[idx-1]);
|
||||
break;
|
||||
case 3: // 3 bit start of frame markers
|
||||
for(int j=0; j<3; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for(int j=0; j<4; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
for(int j=0; j<5; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
for(int j=0; j<6; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
for(int j=0; j<7; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for(int j=0; j<8; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
for(int j=0; j<9; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
for(int j=0; j<10; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
for(int j=0; j<11; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
for(int j=0; j<12; j++){
|
||||
dest[i++]=dest[idx-1]^1;
|
||||
// Dbprintf("%d",dest[idx-1]);
|
||||
}
|
||||
break;
|
||||
default: // this shouldn't happen, don't stuff any bits
|
||||
//Dbprintf("%d",dest[idx-1]);
|
||||
break;
|
||||
}
|
||||
|
||||
n=0;
|
||||
lastval=dest[idx];
|
||||
}
|
||||
}//end for
|
||||
/*for(int j=0; j<64;j+=8){
|
||||
Dbprintf("%d%d%d%d%d%d%d%d",dest[j],dest[j+1],dest[j+2],dest[j+3],dest[j+4],dest[j+5],dest[j+6],dest[j+7]);
|
||||
}
|
||||
Dbprintf("\n");*/
|
||||
|
||||
m=i;
|
||||
WDT_HIT();
|
||||
|
||||
|
@ -1045,7 +961,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
unknown <<=1;
|
||||
if (dest[idx+j]) unknown |= 1;
|
||||
}
|
||||
for(int j=36;j<45;j++){
|
||||
for(int j=37;j<45;j++){
|
||||
//Dbprintf("%d",dest[idx+j]);
|
||||
number <<=1;
|
||||
if (dest[idx+j]) number |= 1;
|
||||
|
@ -1055,6 +971,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
number <<=1;
|
||||
if (dest[idx+j]) number |= 1;
|
||||
}
|
||||
|
||||
for(int j=0; j<32; j++){
|
||||
code <<=1;
|
||||
if(dest[idx+j]) code |= 1;
|
||||
|
@ -1070,17 +987,12 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
|
|||
}
|
||||
// if we're only looking for one tag
|
||||
if (findone){
|
||||
//*high = hi;
|
||||
//*low = lo;
|
||||
LED_A_OFF();
|
||||
return;
|
||||
}
|
||||
|
||||
//hi=0;
|
||||
//lo=0;
|
||||
found=0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
WDT_HIT();
|
||||
|
|
|
@ -13,13 +13,13 @@ CXX=g++
|
|||
VPATH = ../common
|
||||
OBJDIR = obj
|
||||
|
||||
LDLIBS = -L/mingw/lib -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lreadline -lpthread -lcrypto -lgdi32
|
||||
LDLIBS = -L/mingw/lib -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lm -lreadline -lpthread -lcrypto -lgdi32
|
||||
LDFLAGS = $(COMMON_FLAGS)
|
||||
CFLAGS = -std=c99 -I. -I../include -I../common -I/mingw/include -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4 $(ICE_FLAGS)
|
||||
LUAPLATFORM = generic
|
||||
|
||||
ifneq (,$(findstring MINGW,$(platform)))
|
||||
CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets
|
||||
CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets -I/mingw/include
|
||||
QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
|
||||
MOC = $(QTDIR)/bin/moc
|
||||
LUAPLATFORM = mingw
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#define Crc(data,datalen) Iso15693Crc(data,datalen)
|
||||
#define AddCrc(data,datalen) Iso15693AddCrc(data,datalen)
|
||||
#define sprintUID(target,uid) Iso15693sprintUID(target,uid)
|
||||
#define TRACE_BUFF_SIZE 12000
|
||||
|
||||
// structure and database for uid -> tagtype lookups
|
||||
typedef struct {
|
||||
|
@ -252,6 +253,17 @@ int CmdHF15Read(const char *Cmd)
|
|||
{
|
||||
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693};
|
||||
SendCommand(&c);
|
||||
|
||||
uint8_t data[TRACE_BUFF_SIZE] = {0x00};
|
||||
|
||||
GetFromBigBuf(data,TRACE_BUFF_SIZE,3560); //3560 -- should be offset..
|
||||
WaitForResponseTimeout(CMD_ACK,NULL, 1500);
|
||||
|
||||
for (int j = 0; j < TRACE_BUFF_SIZE; j++) {
|
||||
GraphBuffer[j] = ((int)data[j]) ;
|
||||
}
|
||||
GraphTraceLen = TRACE_BUFF_SIZE;
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -260,6 +272,17 @@ int CmdHF15Record(const char *Cmd)
|
|||
{
|
||||
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693};
|
||||
SendCommand(&c);
|
||||
|
||||
uint8_t data[TRACE_BUFF_SIZE] = {0x00};
|
||||
|
||||
GetFromBigBuf(data,TRACE_BUFF_SIZE,3560); //3560 -- should be offset..
|
||||
WaitForResponseTimeout(CMD_ACK,NULL, 1500);
|
||||
|
||||
for (int j = 0; j < TRACE_BUFF_SIZE; j++) {
|
||||
GraphBuffer[j] = ((int)data[j]) ;
|
||||
}
|
||||
GraphTraceLen = TRACE_BUFF_SIZE;
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -421,8 +444,9 @@ int CmdHF15CmdInquiry(const char *Cmd)
|
|||
int CmdHF15CmdDebug( const char *cmd) {
|
||||
int debug=atoi(cmd);
|
||||
if (strlen(cmd)<1) {
|
||||
PrintAndLog("Usage: hf 15 cmd debug <0/1>");
|
||||
PrintAndLog(" 0..no debugging output 1..turn debugging on");
|
||||
PrintAndLog("Usage: hf 15 cmd debug <0|1>");
|
||||
PrintAndLog(" 0 no debugging");
|
||||
PrintAndLog(" 1 turn debugging on");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -522,12 +522,12 @@ int CmdHF14AMfDump(const char *Cmd)
|
|||
int size = GetCardSize();
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
|
||||
PrintAndLog("Got %d",size);
|
||||
|
||||
return 0;
|
||||
|
||||
if ( size > -1)
|
||||
cmdp = (char)48+size;
|
||||
cmdp = (char)(48+size);
|
||||
|
||||
PrintAndLog("Got %d",cmdp);
|
||||
|
||||
switch (cmdp) {
|
||||
case '0' : numSectors = 5; break;
|
||||
|
|
|
@ -468,6 +468,18 @@ int CmdLFSnoop(const char *Cmd)
|
|||
}
|
||||
SendCommand(&c);
|
||||
WaitForResponse(CMD_ACK,NULL);
|
||||
|
||||
size_t BUFF_SIZE = 8000;
|
||||
uint8_t data[BUFF_SIZE];
|
||||
|
||||
GetFromBigBuf(data,BUFF_SIZE,3560); //3560 -- should be offset..
|
||||
WaitForResponseTimeout(CMD_ACK,NULL, 1500);
|
||||
|
||||
for (int j = 0; j < BUFF_SIZE; j++) {
|
||||
GraphBuffer[j] = ((int)data[j]);
|
||||
}
|
||||
GraphTraceLen = BUFF_SIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -551,22 +563,27 @@ static command_t CommandTable[] =
|
|||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"cmdread", CmdLFCommandRead, 0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},
|
||||
{"em4x", CmdLFEM4X, 1, "{ EM4X RFIDs... }"},
|
||||
|
||||
{"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"},
|
||||
{"hid", CmdLFHID, 1, "{ HID RFIDs... }"},
|
||||
{"io", CmdLFIO, 1, "{ ioProx tags... }"},
|
||||
{"indalademod", CmdIndalaDemod, 1, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
|
||||
{"indalaclone", CmdIndalaClone, 1, "<UID> ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"},
|
||||
{"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
|
||||
|
||||
|
||||
{"read", CmdLFRead, 0, "['h' or <divisor>] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134, alternatively: f=12MHz/(divisor+1))"},
|
||||
{"sim", CmdLFSim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},
|
||||
{"simbidir", CmdLFSimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
|
||||
{"simman", CmdLFSimManchester, 0, "<Clock> <Bitstream> [GAP] Simulate arbitrary Manchester LF tag"},
|
||||
{"snoop", CmdLFSnoop, 0, "['l'|'h'|<divisor>] [trigger threshold]-- Snoop LF (l:125khz, h:134khz)"},
|
||||
{"ti", CmdLFTI, 1, "{ TI RFIDs... }"},
|
||||
{"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders... }"},
|
||||
{"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
|
||||
{"t55xx", CmdLFT55XX, 1, "{ T55xx RFIDs... }"},
|
||||
{"pcf7931", CmdLFPCF7931, 1, "{PCF7931 RFIDs...}"},
|
||||
|
||||
{"em4x", CmdLFEM4X, 1, "{ EM4X tags }"},
|
||||
{"hid", CmdLFHID, 1, "{ HID tags }"},
|
||||
{"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders }"},
|
||||
{"io", CmdLFIO, 1, "{ ioProx tags }"},
|
||||
{"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 tags }"},
|
||||
{"ti", CmdLFTI, 1, "{ TI tags }"},
|
||||
{"t55xx", CmdLFT55XX, 1, "{ T55xx tags }"},
|
||||
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -21,20 +21,14 @@ int CmdIODemodFSK(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CmdIOProxDemod(const char *Cmd){
|
||||
if (GraphTraceLen < 4800) {
|
||||
PrintAndLog("too short; need at least 4800 samples");
|
||||
return 0;
|
||||
}
|
||||
|
||||
GraphTraceLen = 4800;
|
||||
for (int i = 0; i < GraphTraceLen; ++i) {
|
||||
if (GraphBuffer[i] < 0) {
|
||||
GraphBuffer[i] = 0;
|
||||
} else {
|
||||
GraphBuffer[i] = 1;
|
||||
}
|
||||
GraphBuffer[i] = (GraphBuffer[i] < 0) ? 0 : 1;
|
||||
}
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
|
|
|
@ -304,7 +304,6 @@ int CmdDump(const char *Cmd){
|
|||
char s[20];
|
||||
uint8_t pwd[4] = {0x00};
|
||||
|
||||
|
||||
if (strlen(Cmd)>1 || cmdp == 'h' || cmdp == 'H') {
|
||||
PrintAndLog("Usage: lf t55xx dump <password>");
|
||||
PrintAndLog(" sample: lf t55xx dump FFFFFFFF");
|
||||
|
@ -320,7 +319,6 @@ int CmdDump(const char *Cmd){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for ( int i = 0; i <8; ++i){
|
||||
*s = 0;
|
||||
if ( hasPwd ) {
|
||||
|
@ -334,6 +332,15 @@ int CmdDump(const char *Cmd){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdIceFsk(const char *Cmd){
|
||||
//uint8_t bits[1000] = {0x00};
|
||||
//uint8_t * bitstream = bits;
|
||||
iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE);
|
||||
|
||||
RepaintGraphWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * GetBitRateStr(uint32_t id){
|
||||
static char buf[40];
|
||||
char *retStr = buf;
|
||||
|
@ -390,7 +397,7 @@ char * GetModulationStr( uint32_t id){
|
|||
|
||||
switch (id){
|
||||
case 0:
|
||||
sprintf(retStr,"%d - direct",id);
|
||||
sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id);
|
||||
break;
|
||||
case 1:
|
||||
sprintf(retStr,"%d - PSK 1 phase change when input changes",id);
|
||||
|
@ -444,13 +451,14 @@ uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){
|
|||
static command_t CommandTable[] =
|
||||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"rd", CmdReadBlk, 0, "<Block> -- Read T55xx block data (page 0)"},
|
||||
{"rdPWD", CmdReadBlkPWD, 0, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},
|
||||
{"wr", CmdWriteBlk, 0, "<Data> <Block> -- Write T55xx block data (page 0)"},
|
||||
{"wrPWD", CmdWriteBlkPWD, 0, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},
|
||||
{"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1)"},
|
||||
{"info", CmdInfo, 0, "Read T55xx configuration data (page 0 / block 0"},
|
||||
{"dump", CmdDump, 0, "Dump T55xx card block 0-7 (is possible)"},
|
||||
{"rd", CmdReadBlk, 0, "<block> -- Read T55xx block data (page 0)"},
|
||||
{"rdPWD", CmdReadBlkPWD, 0, "<block> <password> -- Read T55xx block data with password mode"},
|
||||
{"wr", CmdWriteBlk, 0, "<data> <block> -- Write T55xx block data (page 0)"},
|
||||
{"wrPWD", CmdWriteBlkPWD, 0, "<data> <block> <password> -- Write T55xx block data with password"},
|
||||
{"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1 / blk 0-1)"},
|
||||
{"info", CmdInfo, 0, "Read T55xx configuration data (page0 /blk 0)"},
|
||||
{"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. optional with password"},
|
||||
{"fsk", CmdIceFsk, 0, "FSK demod"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ int CmdWriteBlk(const char *Cmd);
|
|||
int CmdWriteBLkPWD(const char *Cmd);
|
||||
int CmdReadTrace(const char *Cmd);
|
||||
int CmdInfo(const char *Cmd);
|
||||
int CmdIceFsk(const char *Cmd);
|
||||
char * GetBitRateStr(uint32_t id);
|
||||
char * GetSaferStr(uint32_t id);
|
||||
char * GetModulationStr( uint32_t id);
|
||||
|
|
|
@ -22,22 +22,6 @@ void GetFromBigBuf(uint8_t *dest, int bytes, int start_index)
|
|||
{
|
||||
sample_buf_len = 0;
|
||||
sample_buf = dest;
|
||||
// start_index = ((start_index/12)*12);
|
||||
// int n = start_index + bytes;
|
||||
/*
|
||||
if (n % 48 != 0) {
|
||||
PrintAndLog("bad len in GetFromBigBuf");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}};
|
||||
SendCommand(&c);
|
||||
/*
|
||||
for (int i = start_index; i < n; i += 48) {
|
||||
UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {i, 0, 0}};
|
||||
SendCommand(&c);
|
||||
// WaitForResponse(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K);
|
||||
// memcpy(dest+(i*4), sample_buf, 48);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
220
client/ui.c
220
client/ui.c
|
@ -16,8 +16,11 @@
|
|||
#include <time.h>
|
||||
#include <readline/readline.h>
|
||||
#include <pthread.h>
|
||||
#include "ui.h"
|
||||
#include "loclass/cipherutils.h"
|
||||
#include "ui.h"
|
||||
|
||||
//#include <liquid/liquid.h>
|
||||
#define M_PI 3.14159265358979323846264338327
|
||||
|
||||
double CursorScaleFactor;
|
||||
int PlotGridX, PlotGridY, PlotGridXdefault= 64, PlotGridYdefault= 64;
|
||||
|
@ -125,8 +128,6 @@ int manchester_decode( int * data, const size_t len, uint8_t * dataout){
|
|||
// PrintPaddedManchester(bitStream, bitlength, clock);
|
||||
|
||||
memcpy(dataout, bitStream, bitlength);
|
||||
|
||||
free(bitStream);
|
||||
return bitlength;
|
||||
}
|
||||
|
||||
|
@ -393,3 +394,216 @@ void PrintPaddedManchester( uint8_t* bitStream, size_t len, size_t blocksize){
|
|||
if ( mod > 0 )
|
||||
PrintAndLog(" %s", sprint_bin(bitStream+i, mod) );
|
||||
}
|
||||
|
||||
void iceFsk(int * data, const size_t len){
|
||||
|
||||
//34359738 == 125khz (2^32 / 125) =
|
||||
|
||||
// parameters
|
||||
float phase_offset = 0.00f; // carrier phase offset
|
||||
float frequency_offset = 0.30f; // carrier frequency offset
|
||||
float wn = 0.01f; // pll bandwidth
|
||||
float zeta = 0.707f; // pll damping factor
|
||||
float K = 1000; // pll loop gain
|
||||
size_t n = len; // number of samples
|
||||
|
||||
// generate loop filter parameters (active PI design)
|
||||
float t1 = K/(wn*wn); // tau_1
|
||||
float t2 = 2*zeta/wn; // tau_2
|
||||
|
||||
// feed-forward coefficients (numerator)
|
||||
float b0 = (4*K/t1)*(1.+t2/2.0f);
|
||||
float b1 = (8*K/t1);
|
||||
float b2 = (4*K/t1)*(1.-t2/2.0f);
|
||||
|
||||
// feed-back coefficients (denominator)
|
||||
// a0 = 1.0 is implied
|
||||
float a1 = -2.0f;
|
||||
float a2 = 1.0f;
|
||||
|
||||
// filter buffer
|
||||
float v0=0.0f, v1=0.0f, v2=0.0f;
|
||||
|
||||
// initialize states
|
||||
float phi = phase_offset; // input signal's initial phase
|
||||
float phi_hat = 0.0f; // PLL's initial phase
|
||||
|
||||
unsigned int i;
|
||||
float complex x,y;
|
||||
float complex output[n];
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
// INPUT SIGNAL
|
||||
x = data[i];
|
||||
phi += frequency_offset;
|
||||
|
||||
// generate complex sinusoid
|
||||
y = cosf(phi_hat) + _Complex_I*sinf(phi_hat);
|
||||
|
||||
output[i] = y;
|
||||
|
||||
// compute error estimate
|
||||
float delta_phi = cargf( x * conjf(y) );
|
||||
|
||||
|
||||
// print results to standard output
|
||||
printf(" %6u %12.8f %12.8f %12.8f %12.8f %12.8f\n",
|
||||
i,
|
||||
crealf(x), cimagf(x),
|
||||
crealf(y), cimagf(y),
|
||||
delta_phi);
|
||||
|
||||
// push result through loop filter, updating phase estimate
|
||||
|
||||
// advance buffer
|
||||
v2 = v1; // shift center register to upper register
|
||||
v1 = v0; // shift lower register to center register
|
||||
|
||||
// compute new lower register
|
||||
v0 = delta_phi - v1*a1 - v2*a2;
|
||||
|
||||
// compute new output
|
||||
phi_hat = v0*b0 + v1*b1 + v2*b2;
|
||||
|
||||
}
|
||||
|
||||
for (i=0; i<len; ++i){
|
||||
data[i] = (int)crealf(output[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Sliding DFT
|
||||
Smooths out
|
||||
*/
|
||||
void iceFsk2(int * data, const size_t len){
|
||||
|
||||
int i, j;
|
||||
int output[len];
|
||||
|
||||
// for (i=0; i<len-5; ++i){
|
||||
// for ( j=1; j <=5; ++j) {
|
||||
// output[i] += data[i*j];
|
||||
// }
|
||||
// output[i] /= 5;
|
||||
// }
|
||||
int rest = 127;
|
||||
int tmp =0;
|
||||
for (i=0; i<len; ++i){
|
||||
if ( data[i] < 127)
|
||||
output[i] = 0;
|
||||
else {
|
||||
tmp = (100 * (data[i]-rest)) / rest;
|
||||
output[i] = (tmp > 60)? 100:0;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0; j<len; ++j)
|
||||
data[j] = output[j];
|
||||
}
|
||||
|
||||
void iceFsk3(int * data, const size_t len){
|
||||
|
||||
int i,j;
|
||||
int output[len];
|
||||
float fc = 0.1125f; // center frequency
|
||||
|
||||
// create very simple low-pass filter to remove images (2nd-order Butterworth)
|
||||
float complex iir_buf[3] = {0,0,0};
|
||||
float b[3] = {0.003621681514929, 0.007243363029857, 0.003621681514929};
|
||||
float a[3] = {1.000000000000000, -1.822694925196308, 0.837181651256023};
|
||||
|
||||
// process entire input file one sample at a time
|
||||
float sample = 0; // input sample read from file
|
||||
float complex x_prime = 1.0f; // save sample for estimating frequency
|
||||
float complex x;
|
||||
|
||||
for (i=0; i<len; ++i) {
|
||||
|
||||
sample = data[i];
|
||||
|
||||
// remove DC offset and mix to complex baseband
|
||||
x = (sample - 127.5f) * cexpf( _Complex_I * 2 * M_PI * fc * i );
|
||||
|
||||
// apply low-pass filter, removing spectral image (IIR using direct-form II)
|
||||
iir_buf[2] = iir_buf[1];
|
||||
iir_buf[1] = iir_buf[0];
|
||||
iir_buf[0] = x - a[1]*iir_buf[1] - a[2]*iir_buf[2];
|
||||
x = b[0]*iir_buf[0] +
|
||||
b[1]*iir_buf[1] +
|
||||
b[2]*iir_buf[2];
|
||||
|
||||
// compute instantaneous frequency by looking at phase difference
|
||||
// between adjacent samples
|
||||
float freq = cargf(x*conjf(x_prime));
|
||||
x_prime = x; // retain this sample for next iteration
|
||||
|
||||
output[i] =(freq > 0)? 10 : -10;
|
||||
}
|
||||
|
||||
// show data
|
||||
for (j=0; j<len; ++j)
|
||||
data[j] = output[j];
|
||||
|
||||
CmdLtrim("30");
|
||||
|
||||
// zero crossings.
|
||||
for (j=0; j<len; ++j){
|
||||
if ( data[j] == 10) break;
|
||||
}
|
||||
int startOne =j;
|
||||
|
||||
for (;j<len; ++j){
|
||||
if ( data[j] == -10 ) break;
|
||||
}
|
||||
int stopOne = j-1;
|
||||
|
||||
int fieldlen = stopOne-startOne;
|
||||
printf("FIELD Length: %d \n", fieldlen);
|
||||
|
||||
|
||||
// FSK sequence start == 000111
|
||||
int startPos = 0;
|
||||
for (i =0; i<len; ++i){
|
||||
int dec = 0;
|
||||
for ( j = 0; j < 6*fieldlen; ++j){
|
||||
dec += data[i + j];
|
||||
}
|
||||
if (dec == 0) {
|
||||
startPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("000111 position: %d \n", startPos);
|
||||
|
||||
startPos += 6*fieldlen+1;
|
||||
|
||||
printf("BINARY\n");
|
||||
printf("R/40 : ");
|
||||
for (i =startPos ; i < len; i += 40){
|
||||
if ( data[i] > 0 )
|
||||
printf("1");
|
||||
else
|
||||
printf("0");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("R/50 : ");
|
||||
for (i =startPos ; i < len; i += 50){
|
||||
if ( data[i] > 0 )
|
||||
printf("1");
|
||||
else
|
||||
printf("0");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
float complex cexpf (float complex Z)
|
||||
{
|
||||
float complex Res;
|
||||
double rho = exp (__real__ Z);
|
||||
__real__ Res = rho * cosf(__imag__ Z);
|
||||
__imag__ Res = rho * sinf(__imag__ Z);
|
||||
return Res;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#ifndef UI_H__
|
||||
#define UI_H__
|
||||
|
||||
#include <math.h>
|
||||
#include <complex.h>
|
||||
#include "util.h"
|
||||
|
||||
void ShowGui(void);
|
||||
|
@ -32,4 +34,7 @@ void PrintPaddedManchester( uint8_t * bitStream, size_t len, size_t blocksize);
|
|||
void ManchesterDiffDecodedString( const uint8_t *bitStream, size_t len, uint8_t invert );
|
||||
int ManchesterConvertFrom255(const int * data, const size_t len, uint8_t * dataout, int high, int low, int clock, int startIndex);
|
||||
int ManchesterConvertFrom1(const int * data, const size_t len, uint8_t * dataout, int clock, int startIndex);
|
||||
void iceFsk(int * data, const size_t len);
|
||||
void iceFsk2(int * data, const size_t len);
|
||||
void iceFsk3(int * data, const size_t len);
|
||||
#endif
|
||||
|
|
|
@ -16,7 +16,7 @@ my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
|
|||
my $clean = 2;
|
||||
my @compiletime = gmtime();
|
||||
|
||||
my $fullgitinfo = $gitbranch . '/' . $gitversion;
|
||||
my $fullgitinfo = 'iceman' . $gitbranch . '/' . $gitversion;
|
||||
|
||||
$fullgitinfo =~ s/(\s)//g;
|
||||
|
||||
|
|
Loading…
Reference in a new issue