mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-15 19:17:26 -07:00
skeleton for ZX8211
This commit is contained in:
parent
7668d99300
commit
69ea599fee
11 changed files with 253 additions and 1 deletions
|
@ -304,6 +304,7 @@ set (TARGET_SOURCES
|
|||
${PM3_ROOT}/client/src/cmdlfti.c
|
||||
${PM3_ROOT}/client/src/cmdlfviking.c
|
||||
${PM3_ROOT}/client/src/cmdlfvisa2000.c
|
||||
${PM3_ROOT}/client/src/cmdlfzx8211.c
|
||||
${PM3_ROOT}/client/src/cmdmain.c
|
||||
${PM3_ROOT}/client/src/cmdnfc.c
|
||||
${PM3_ROOT}/client/src/cmdparser.c
|
||||
|
|
|
@ -556,6 +556,7 @@ SRCS = mifare/aiddesfire.c \
|
|||
cmdlfti.c \
|
||||
cmdlfviking.c \
|
||||
cmdlfvisa2000.c \
|
||||
cmdlfzx8211.c \
|
||||
cmdmain.c \
|
||||
cmdnfc.c \
|
||||
cmdparser.c \
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "cmdlfti.h" // for ti menu
|
||||
#include "cmdlfviking.h" // for viking menu
|
||||
#include "cmdlfvisa2000.h" // for VISA2000 menu
|
||||
#include "cmdlfzx8211.h" // for ZX8211 menu
|
||||
#include "crc.h"
|
||||
#include "pm3_cmd.h" // for LF_CMDREAD_MAX_EXTRA_SYMBOLS
|
||||
|
||||
|
@ -1825,6 +1826,7 @@ static command_t CommandTable[] = {
|
|||
{"t55xx", CmdLFT55XX, AlwaysAvailable, "{ T55xx CHIPs... }"},
|
||||
{"viking", CmdLFViking, AlwaysAvailable, "{ Viking RFIDs... }"},
|
||||
{"visa2000", CmdLFVisa2k, AlwaysAvailable, "{ Visa2000 RFIDs... }"},
|
||||
{"zx", CmdLFZx8211, AlwaysAvailable, "{ ZX8211 RFIDs... }"},
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"},
|
||||
{"config", CmdLFConfig, IfPm3Lf, "Get/Set config for LF sampling, bit/sample, decimation, frequency"},
|
||||
{"cmdread", CmdLFCommandRead, IfPm3Lf, "Modulate LF reader field to send command before read"},
|
||||
|
|
154
client/src/cmdlfzx8211.c
Normal file
154
client/src/cmdlfzx8211.c
Normal file
|
@ -0,0 +1,154 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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 ZX8211 tag commands
|
||||
// by iceman, doegox
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "cmdlfzx8211.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "common.h"
|
||||
#include "cmdparser.h" // command_t
|
||||
#include "comms.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
#include "protocols.h" // for T55xx config register definitions
|
||||
#include "lfdemod.h" // parityTest
|
||||
#include "cmdlft55xx.h" // write verify
|
||||
#include "cmdlfem4x05.h" //
|
||||
#include "cliparser.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
//see ASKDemod for what args are accepted
|
||||
int demodzx(bool verbose) {
|
||||
(void) verbose; // unused so far
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
|
||||
//CmdAskEdgeDetect("");
|
||||
|
||||
//ASK / Manchester
|
||||
bool st = true;
|
||||
if (ASKDemod_ext(64, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: ASK/Manchester Demod failed");
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectzx(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: too few bits found");
|
||||
else if (ans == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: preamble not found");
|
||||
else if (ans == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: Size not correct: %zu", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - ZX: ans: %d", ans);
|
||||
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
|
||||
// chksum
|
||||
|
||||
// test checksums
|
||||
|
||||
PrintAndLogEx(SUCCESS, "ZX8211 - Card " _GREEN_("%u") ", Raw: %08X", raw1);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int lf_Zx_read(void) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdZxDemod(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf zx demod",
|
||||
"Try to find zx8211 preamble, if found decode / descramble data",
|
||||
"lf zx demod"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
return demodzx(true);
|
||||
}
|
||||
|
||||
static int CmdzxReader(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf zx reader",
|
||||
"read a zx tag",
|
||||
"lf zx reader -@ -> continuous reader mode"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("@", NULL, "optional - continuous reader mode"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool cm = arg_get_lit(ctx, 1);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (cm) {
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
||||
}
|
||||
|
||||
do {
|
||||
lf_Zx_read();
|
||||
demodzx(!cm);
|
||||
} while (cm && !kbd_enter_pressed());
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"demod", CmdZxDemod, AlwaysAvailable, "demodulate an ZX 8211 tag from the GraphBuffer"},
|
||||
{"reader", CmdzxReader, IfPm3Lf, "attempt to read and extract tag data"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFZx8211(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
// find Visa2000 preamble in already demoded data
|
||||
int detectzx(uint8_t *dest, size_t *size) {
|
||||
if (*size < 96) return -1; //make sure buffer has data
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -2; //preamble not found
|
||||
if (*size != 96) return -3; //wrong demoded size
|
||||
//return start position
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
|
20
client/src/cmdlfzx8211.h
Normal file
20
client/src/cmdlfzx8211.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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 ZX8211 commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CMDLFZX8211_H__
|
||||
#define CMDLFZX8211_H__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int CmdLFZx8211(const char *Cmd);
|
||||
|
||||
int demodzx(bool verbose);
|
||||
int detectzx(uint8_t *dest, size_t *size);
|
||||
|
||||
#endif
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue