mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
move idteck to its own file
This commit is contained in:
parent
a3282b940b
commit
4e10c9ec0a
10 changed files with 178 additions and 107 deletions
|
@ -253,6 +253,7 @@ set (TARGET_SOURCES
|
|||
${PM3_ROOT}/client/src/cmdlfguard.c
|
||||
${PM3_ROOT}/client/src/cmdlfhid.c
|
||||
${PM3_ROOT}/client/src/cmdlfhitag.c
|
||||
${PM3_ROOT}/client/src/cmdlfidteck.c
|
||||
${PM3_ROOT}/client/src/cmdlfindala.c
|
||||
${PM3_ROOT}/client/src/cmdlfio.c
|
||||
${PM3_ROOT}/client/src/cmdlfjablotron.c
|
||||
|
|
|
@ -447,6 +447,7 @@ SRCS = aidsearch.c \
|
|||
cmdlfgallagher.c \
|
||||
cmdlfhid.c \
|
||||
cmdlfhitag.c \
|
||||
cmdlfidteck.c \
|
||||
cmdlfindala.c \
|
||||
cmdlfio.c \
|
||||
cmdlfjablotron.c \
|
||||
|
|
|
@ -132,6 +132,7 @@ add_library(pm3rrg_rdv4 SHARED
|
|||
${PM3_ROOT}/client/src/cmdlfguard.c
|
||||
${PM3_ROOT}/client/src/cmdlfhid.c
|
||||
${PM3_ROOT}/client/src/cmdlfhitag.c
|
||||
${PM3_ROOT}/client/src/cmdlfidteck.c
|
||||
${PM3_ROOT}/client/src/cmdlfindala.c
|
||||
${PM3_ROOT}/client/src/cmdlfio.c
|
||||
${PM3_ROOT}/client/src/cmdlfjablotron.c
|
||||
|
|
|
@ -1277,73 +1277,6 @@ int PSKDemod(int clk, int invert, int maxErr, bool verbose) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int demodIdteck(bool verbose) {
|
||||
(void) verbose; // unused so far
|
||||
if (PSKDemod(0, 0, 100, false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
|
||||
//get binary from PSK1 wave
|
||||
int idx = detectIdteck(DemodBuffer, &size);
|
||||
if (idx < 0) {
|
||||
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
|
||||
else if (idx == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: just noise");
|
||||
else if (idx == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: preamble not found");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %zu", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx);
|
||||
|
||||
// if didn't find preamble try again inverting
|
||||
if (PSKDemod(0, 1, 100, false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
idx = detectIdteck(DemodBuffer, &size);
|
||||
if (idx < 0) {
|
||||
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
|
||||
else if (idx == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: just noise");
|
||||
else if (idx == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: preamble not found");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %zu", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx);
|
||||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 64, idx);
|
||||
|
||||
//got a good demod
|
||||
uint32_t id = 0;
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
|
||||
//parity check (TBD)
|
||||
//checksum check (TBD)
|
||||
|
||||
//output
|
||||
PrintAndLogEx(SUCCESS, "IDTECK Tag Found: Card ID %u , Raw: %08X%08X", id, raw1, raw2);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
static int CmdIdteckDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodIdteck();
|
||||
}
|
||||
*/
|
||||
|
||||
// by marshmellow
|
||||
// takes 3 arguments - clock, invert, maxErr as integers
|
||||
// attempts to demodulate nrz only
|
||||
|
|
|
@ -80,7 +80,6 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose);
|
|||
void setClockGrid(uint32_t clk, int offset);
|
||||
int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down);
|
||||
int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||
int demodIdteck(bool verbose);
|
||||
|
||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
|
|
|
@ -33,28 +33,29 @@
|
|||
#include "cmdlfem4x50.h" // for em4x50
|
||||
#include "cmdlfhid.h" // for hid menu
|
||||
#include "cmdlfhitag.h" // for hitag menu
|
||||
#include "cmdlfidteck.h" // for idteck menu
|
||||
#include "cmdlfio.h" // for ioprox menu
|
||||
#include "cmdlft55xx.h" // for t55xx menu
|
||||
#include "cmdlfti.h" // for ti menu
|
||||
#include "cmdlfpresco.h" // for presco menu
|
||||
#include "cmdlfpcf7931.h" // for pcf7931 menu
|
||||
#include "cmdlfpyramid.h" // for pyramid menu
|
||||
#include "cmdlfviking.h" // for viking menu
|
||||
#include "cmdlfnedap.h" // for NEDAP menu
|
||||
#include "cmdlfjablotron.h" // for JABLOTRON menu
|
||||
#include "cmdlfvisa2000.h" // for VISA2000 menu
|
||||
#include "cmdlfnoralsy.h" // for NORALSY meny
|
||||
#include "cmdlfcotag.h" // for COTAG meny
|
||||
#include "cmdlfindala.h" // for indala menu
|
||||
#include "cmdlfguard.h" // for gproxii menu
|
||||
#include "cmdlffdx.h" // for fdx-b menu
|
||||
#include "cmdlfparadox.h" // for paradox menu
|
||||
#include "cmdlfnexwatch.h" // for nexwatch menu
|
||||
#include "cmdlfsecurakey.h" // for securakey menu
|
||||
#include "cmdlfpac.h" // for pac menu
|
||||
#include "cmdlfgallagher.h" // for GALLAGHER menu
|
||||
#include "cmdlfguard.h" // for gproxii menu
|
||||
#include "cmdlfindala.h" // for indala menu
|
||||
#include "cmdlfjablotron.h" // for JABLOTRON menu
|
||||
#include "cmdlfkeri.h" // for keri menu
|
||||
#include "cmdlfmotorola.h" // for Motorola menu
|
||||
#include "cmdlfgallagher.h" // for GALLAGHER menu
|
||||
#include "cmdlfnedap.h" // for NEDAP menu
|
||||
#include "cmdlfnexwatch.h" // for nexwatch menu
|
||||
#include "cmdlfnoralsy.h" // for NORALSY meny
|
||||
#include "cmdlfpac.h" // for pac menu
|
||||
#include "cmdlfparadox.h" // for paradox menu
|
||||
#include "cmdlfpcf7931.h" // for pcf7931 menu
|
||||
#include "cmdlfpresco.h" // for presco menu
|
||||
#include "cmdlfpyramid.h" // for pyramid menu
|
||||
#include "cmdlfsecurakey.h" // for securakey menu
|
||||
#include "cmdlft55xx.h" // for t55xx menu
|
||||
#include "cmdlfti.h" // for ti menu
|
||||
#include "cmdlfviking.h" // for viking menu
|
||||
#include "cmdlfvisa2000.h" // for VISA2000 menu
|
||||
|
||||
#define LF_CMDREAD_MAX_EXTRA_SYMBOLS 4
|
||||
static bool g_lf_threshold_set = false;
|
||||
|
@ -1531,6 +1532,7 @@ static command_t CommandTable[] = {
|
|||
{"gproxii", CmdLFGuard, AlwaysAvailable, "{ Guardall Prox II RFIDs... }"},
|
||||
{"hid", CmdLFHID, AlwaysAvailable, "{ HID Prox RFIDs... }"},
|
||||
{"hitag", CmdLFHitag, AlwaysAvailable, "{ Hitag CHIPs... }"},
|
||||
{"idteck", CmdLFIdteck, AlwaysAvailable, "{ Idteck RFIDs... }"},
|
||||
{"indala", CmdLFINDALA, AlwaysAvailable, "{ Indala RFIDs... }"},
|
||||
{"io", CmdLFIO, AlwaysAvailable, "{ ioProx RFIDs... }"},
|
||||
{"jablotron", CmdLFJablotron, AlwaysAvailable, "{ Jablotron RFIDs... }"},
|
||||
|
|
136
client/src/cmdlfidteck.c
Normal file
136
client/src/cmdlfidteck.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Iceman,
|
||||
//
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Low frequency Idteck tag commands
|
||||
// PSK
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "cmdlfidteck.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "cmdparser.h" // command_t
|
||||
#include "comms.h"
|
||||
#include "ui.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
#include "lfdemod.h"
|
||||
#include "commonutil.h" // num_to_bytes
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int demodIdteck(bool verbose) {
|
||||
(void) verbose; // unused so far
|
||||
if (PSKDemod(0, 0, 100, false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
|
||||
//get binary from PSK1 wave
|
||||
int idx = detectIdteck(DemodBuffer, &size);
|
||||
if (idx < 0) {
|
||||
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
|
||||
else if (idx == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: just noise");
|
||||
else if (idx == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: preamble not found");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %zu", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx);
|
||||
|
||||
// if didn't find preamble try again inverting
|
||||
if (PSKDemod(0, 1, 100, false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
idx = detectIdteck(DemodBuffer, &size);
|
||||
if (idx < 0) {
|
||||
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
|
||||
else if (idx == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: just noise");
|
||||
else if (idx == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: preamble not found");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %zu", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx);
|
||||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 64, idx);
|
||||
|
||||
//got a good demod
|
||||
uint32_t id = 0;
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
|
||||
//parity check (TBD)
|
||||
//checksum check (TBD)
|
||||
|
||||
//output
|
||||
PrintAndLogEx(SUCCESS, "IDTECK Tag Found: Card ID %u , Raw: %08X%08X", id, raw1, raw2);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdIdteckDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodIdteck(true);
|
||||
}
|
||||
|
||||
static int CmdIdteckRead(const char *Cmd) {
|
||||
(void)Cmd;
|
||||
lf_read(false, 5000);
|
||||
return demodIdteck(true);
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"demod", CmdIdteckDemod, AlwaysAvailable, "Demodulate an Idteck tag from the GraphBuffer"},
|
||||
{"read", CmdIdteckRead, IfPm3Lf, "Attempt to read and Extract tag data from the antenna"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFIdteck(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
// Find IDTEC PSK1, RF Preamble == 0x4944544B, Demodsize 64bits
|
||||
// by iceman
|
||||
int detectIdteck(uint8_t *dest, size_t *size) {
|
||||
//make sure buffer has data
|
||||
if (*size < 64 * 2) return -1;
|
||||
|
||||
if (getSignalProperties()->isnoise) return -2;
|
||||
|
||||
size_t start_idx = 0;
|
||||
uint8_t preamble[] = {0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1};
|
||||
|
||||
//preamble not found
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &start_idx))
|
||||
return -3;
|
||||
|
||||
// wrong demoded size
|
||||
if (*size != 64) return -4;
|
||||
return (int)start_idx;
|
||||
}
|
19
client/src/cmdlfidteck.h
Normal file
19
client/src/cmdlfidteck.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Low frequency Idteck tag commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CMDLFIDTECK_H__
|
||||
#define CMDLFIDTECK_H__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int CmdLFIdteck(const char *Cmd);
|
||||
|
||||
int demodIdteck(bool verbose);
|
||||
int detectIdteck(uint8_t *dest, size_t *size);
|
||||
|
||||
#endif
|
|
@ -2168,26 +2168,6 @@ int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32
|
|||
return (int)start_idx;
|
||||
}
|
||||
|
||||
// Find IDTEC PSK1, RF Preamble == 0x4944544B, Demodsize 64bits
|
||||
// by iceman
|
||||
int detectIdteck(uint8_t *dest, size_t *size) {
|
||||
//make sure buffer has data
|
||||
if (*size < 64 * 2) return -1;
|
||||
|
||||
if (signalprop.isnoise) return -2;
|
||||
|
||||
size_t start_idx = 0;
|
||||
uint8_t preamble[] = {0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1};
|
||||
|
||||
//preamble not found
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &start_idx))
|
||||
return -3;
|
||||
|
||||
// wrong demoded size
|
||||
if (*size != 64) return -4;
|
||||
return (int)start_idx;
|
||||
}
|
||||
|
||||
int detectIOProx(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
||||
//make sure buffer has data
|
||||
if (*size < 66 * 64) return -1;
|
||||
|
|
|
@ -78,7 +78,6 @@ size_t removeParity(uint8_t *bits, size_t startIdx, uint8_t pLen, uint8_t pTyp
|
|||
int detectAWID(uint8_t *dest, size_t *size, int *waveStartIdx);
|
||||
int Em410xDecode(uint8_t *bits, size_t *size, size_t *start_idx, uint32_t *hi, uint64_t *lo);
|
||||
int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo, int *waveStartIdx);
|
||||
int detectIdteck(uint8_t *dest, size_t *size);
|
||||
int detectIOProx(uint8_t *dest, size_t *size, int *waveStartIdx);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue