Initial commit for em4x70 support.
Initially I only have an em4x70 variant used for car transponders. Also known as the ID48.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "cmdlfem410x.h" // for em4x menu
|
||||
#include "cmdlfem4x05.h" // for em4x05 / 4x69
|
||||
#include "cmdlfem4x50.h" // for em4x50
|
||||
#include "cmdlfem4x70.h" // for em4x70
|
||||
#include "cmdlfhid.h" // for hid menu
|
||||
#include "cmdlfhitag.h" // for hitag menu
|
||||
#include "cmdlfidteck.h" // for idteck menu
|
||||
@@ -1370,6 +1371,14 @@ static bool CheckChipType(bool getDeviceData) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
// check for em4x70 chips
|
||||
if (detect_4x70_block()) {
|
||||
PrintAndLogEx(SUCCESS, "Chipset detection: " _GREEN_("EM4x70"));
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf em 4x70`") " commands");
|
||||
retval = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "Couldn't identify a chipset");
|
||||
out:
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "cmdlfem410x.h"
|
||||
#include "cmdlfem4x05.h"
|
||||
#include "cmdlfem4x50.h"
|
||||
#include "cmdlfem4x70.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
@@ -26,6 +27,7 @@ static command_t CommandTable[] = {
|
||||
{"410x", CmdLFEM410X, AlwaysAvailable, "EM 410x commands..."},
|
||||
{"4x05", CmdLFEM4X05, AlwaysAvailable, "EM 4x05 commands..."},
|
||||
{"4x50", CmdLFEM4X50, AlwaysAvailable, "EM 4x50 commands..."},
|
||||
{"4x70", CmdLFEM4X70, AlwaysAvailable, "EM 4x70 commands..."},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "cmdlfem410x.h"
|
||||
#include "cmdlfem4x50.h"
|
||||
#include "cmdlfem4x70.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
151
client/src/cmdlfem4x70.c
Normal file
151
client/src/cmdlfem4x70.c
Normal file
@@ -0,0 +1,151 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020 sirloins
|
||||
//
|
||||
// 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 EM4x70 commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "cmdlfem4x70.h"
|
||||
#include <ctype.h>
|
||||
#include "cmdparser.h" // command_t
|
||||
#include "fileutils.h"
|
||||
#include "comms.h"
|
||||
#include "commonutil.h"
|
||||
#include "em4x70.h"
|
||||
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
||||
static int usage_lf_em4x70_info(void) {
|
||||
PrintAndLogEx(NORMAL, "Read all information of EM4x70. Tag must be on antenna.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x70_info [h] [v] [p <pwd>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " p - use even parity for commands");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x70_info"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x70_info p"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void print_info_result(uint8_t *data) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " ---------------------------");
|
||||
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
||||
|
||||
// data section
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, _YELLOW_("EM4x70 data:"));
|
||||
|
||||
for(int i=1; i <= 32; i+=2) {
|
||||
PrintAndLogEx(NORMAL, "%02X %02X", data[32-i], data[32-i-1]);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Tag ID: %02X %02X %02X %02X", data[7], data[6], data[5], data[4]);
|
||||
PrintAndLogEx(NORMAL, "Lockbit 0: %d", (data[3] & 0x40) ? 1:0);
|
||||
PrintAndLogEx(NORMAL, "Lockbit 1: %d", (data[3] & 0x80) ? 1:0);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
}
|
||||
|
||||
int em4x70_info(void) {
|
||||
|
||||
em4x70_data_t edata = {
|
||||
.parity = false // TODO: try both? or default to true
|
||||
};
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X70_INFO, (uint8_t *)&edata, sizeof(edata));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_LF_EM4X70_INFO, &resp, TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "(em4x70) timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status) {
|
||||
print_info_result(resp.data.asBytes);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//quick test for EM4x70 tag
|
||||
bool detect_4x70_block(void) {
|
||||
|
||||
return em4x70_info() == PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdEM4x70Info(const char *Cmd) {
|
||||
|
||||
// envoke reading of a EM4x70 tag which has to be on the antenna because
|
||||
// decoding is done by the device (not on client side)
|
||||
|
||||
bool errors = false;
|
||||
uint8_t cmdp = 0;
|
||||
|
||||
em4x70_data_t etd = {0};
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
|
||||
case 'h':
|
||||
return usage_lf_em4x70_info();
|
||||
|
||||
case 'p':
|
||||
etd.parity = true;
|
||||
cmdp +=1;
|
||||
break;
|
||||
|
||||
default:
|
||||
PrintAndLogEx(WARNING, " Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// validation
|
||||
if (errors)
|
||||
return usage_lf_em4x70_info();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X70_INFO, (uint8_t *)&etd, sizeof(etd));
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_LF_EM4X70_INFO, &resp, TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status) {
|
||||
print_info_result(resp.data.asBytes);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
PrintAndLogEx(FAILED, "reading tag " _RED_("failed"));
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"info", CmdEM4x70Info, IfPm3EM4x70, "tag information EM4x70"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFEM4X70(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
25
client/src/cmdlfem4x70.h
Normal file
25
client/src/cmdlfem4x70.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020 sirloins
|
||||
//
|
||||
// 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 EM4x70 commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDLFEM4X70_H__
|
||||
#define CMDLFEM4X70_H__
|
||||
|
||||
#include "common.h"
|
||||
#include "em4x50.h"
|
||||
|
||||
#define TIMEOUT 2000
|
||||
|
||||
int CmdLFEM4X70(const char *Cmd);
|
||||
int CmdEM4x70Info(const char *Cmd);
|
||||
|
||||
int em4x70_info(void);
|
||||
bool detect_4x70_block(void);
|
||||
|
||||
#endif
|
||||
@@ -101,6 +101,13 @@ bool IfPm3EM4x50(void) {
|
||||
return pm3_capabilities.compiled_with_em4x50;
|
||||
}
|
||||
|
||||
bool IfPm3EM4x70(void) {
|
||||
|
||||
if (!IfPm3Present())
|
||||
return false;
|
||||
return pm3_capabilities.compiled_with_em4x70;
|
||||
}
|
||||
|
||||
bool IfPm3Hfsniff(void) {
|
||||
if (!IfPm3Present())
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,7 @@ bool IfPm3FpcUsartFromUsb(void);
|
||||
bool IfPm3Lf(void);
|
||||
bool IfPm3Hitag(void);
|
||||
bool IfPm3EM4x50(void);
|
||||
bool IfPm3EM4x70(void);
|
||||
bool IfPm3Hfsniff(void);
|
||||
bool IfPm3Hfplot(void);
|
||||
bool IfPm3Iso14443a(void);
|
||||
|
||||
Reference in New Issue
Block a user