mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-14 02:26:59 -07:00
Add @Iceman1001 s cotag read
also needed to include some of icemans timer additions.
This commit is contained in:
parent
38cb7c71c5
commit
e04475c421
15 changed files with 468 additions and 22 deletions
|
@ -103,6 +103,7 @@ CMDSRCS = nonce2key/crapto1.c\
|
|||
cmdlfviking.c\
|
||||
cmdlfpresco.c\
|
||||
cmdlfpyramid.c\
|
||||
cmdlfcotag.c\
|
||||
pm3_binlib.c\
|
||||
scripting.c\
|
||||
cmdscript.c\
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "cmdlfpcf7931.h"// for pcf7931 menu
|
||||
#include "cmdlfpyramid.h"// for pyramid menu
|
||||
#include "cmdlfviking.h" // for viking menu
|
||||
#include "cmdlfcotag.h" // for COTAG menu
|
||||
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -1080,6 +1082,7 @@ int CmdVchDemod(const char *Cmd)
|
|||
int CmdLFfind(const char *Cmd)
|
||||
{
|
||||
int ans=0;
|
||||
size_t minLength = 1000;
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
char testRaw = param_getchar(Cmd, 1);
|
||||
if (strlen(Cmd) > 3 || cmdp == 'h' || cmdp == 'H') {
|
||||
|
@ -1098,7 +1101,7 @@ int CmdLFfind(const char *Cmd)
|
|||
if (!offline && (cmdp != '1')){
|
||||
CmdLFRead("s");
|
||||
getSamples("30000",false);
|
||||
} else if (GraphTraceLen < 1000) {
|
||||
} else if (GraphTraceLen < minLength) {
|
||||
PrintAndLog("Data in Graphbuffer was too small.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1108,6 +1111,24 @@ int CmdLFfind(const char *Cmd)
|
|||
PrintAndLog("False Positives ARE possible\n");
|
||||
PrintAndLog("\nChecking for known tags:\n");
|
||||
|
||||
size_t testLen = minLength;
|
||||
// only run if graphbuffer is just noise as it should be for hitag/cotag
|
||||
if (graphJustNoise(GraphBuffer, testLen)) {
|
||||
// only run these tests if we are in online mode
|
||||
if (!offline && (cmdp != '1')){
|
||||
ans=CmdLFHitagReader("26");
|
||||
if (ans==0) {
|
||||
return 1;
|
||||
}
|
||||
ans=CmdCOTAGRead("");
|
||||
if (ans>0){
|
||||
PrintAndLog("\nValid COTAG ID Found!");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ans=CmdFSKdemodIO("");
|
||||
if (ans>0) {
|
||||
PrintAndLog("\nValid IO Prox ID Found!");
|
||||
|
@ -1180,17 +1201,6 @@ int CmdLFfind(const char *Cmd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
size_t testLen = (GraphTraceLen < 500) ? GraphTraceLen : 500;
|
||||
// only run if graphbuffer is just noise as it should be for hitag
|
||||
if (graphJustNoise(GraphBuffer, testLen)) {
|
||||
if (!offline && (cmdp != '1')){
|
||||
ans=CmdLFHitagReader("26");
|
||||
if (ans==0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLog("\nNo Known Tags Found!\n");
|
||||
if (testRaw=='u' || testRaw=='U'){
|
||||
//test unknown tag formats (raw mode)
|
||||
|
@ -1228,6 +1238,7 @@ static command_t CommandTable[] =
|
|||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"awid", CmdLFAWID, 1, "{ AWID RFIDs... }"},
|
||||
{"cotag", CmdLFCOTAG, 1, "{ COTAG RFIDs... }"},
|
||||
{"em4x", CmdLFEM4X, 1, "{ EM4X RFIDs... }"},
|
||||
{"hid", CmdLFHID, 1, "{ HID RFIDs... }"},
|
||||
{"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders... }"},
|
||||
|
|
120
client/cmdlfcotag.c
Normal file
120
client/cmdlfcotag.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Authored by 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 COTAG commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "cmdlfcotag.h" // COTAG function declarations
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int usage_lf_cotag_read(void){
|
||||
PrintAndLog("Usage: lf COTAG read [h] <signaldata>");
|
||||
PrintAndLog("Options:");
|
||||
PrintAndLog(" h : This help");
|
||||
PrintAndLog(" <0|1|2> : 0 - HIGH/LOW signal; maxlength bigbuff");
|
||||
PrintAndLog(" : 1 - translation of HI/LO into bytes with manchester 0,1");
|
||||
PrintAndLog(" : 2 - raw signal; maxlength bigbuff");
|
||||
PrintAndLog("");
|
||||
PrintAndLog("Sample:");
|
||||
PrintAndLog(" lf cotag read 0");
|
||||
PrintAndLog(" lf cotag read 1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// COTAG demod should be able to use GraphBuffer,
|
||||
// when data load samples
|
||||
int CmdCOTAGDemod(const char *Cmd) {
|
||||
|
||||
uint8_t bits[COTAG_BITS] = {0};
|
||||
size_t bitlen = COTAG_BITS;
|
||||
memcpy(bits, DemodBuffer, COTAG_BITS);
|
||||
|
||||
int err = manrawdecode(bits, &bitlen, 1);
|
||||
if (err){
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - COTAG too many errors: %d", err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
setDemodBuf(bits, bitlen, 0);
|
||||
|
||||
//got a good demod
|
||||
uint16_t cn = bytebits_to_byteLSBF(bits+1, 16);
|
||||
uint32_t fc = bytebits_to_byteLSBF(bits+1+16, 8);
|
||||
|
||||
uint32_t raw1 = bytebits_to_byteLSBF(bits, 32);
|
||||
uint32_t raw2 = bytebits_to_byteLSBF(bits+32, 32);
|
||||
uint32_t raw3 = bytebits_to_byteLSBF(bits+64, 32);
|
||||
uint32_t raw4 = bytebits_to_byteLSBF(bits+96, 32);
|
||||
|
||||
/*
|
||||
fc 161: 1010 0001 -> LSB 1000 0101
|
||||
cn 33593 1000 0011 0011 1001 -> LSB 1001 1100 1100 0001
|
||||
cccc cccc cccc cccc ffffffff
|
||||
0 1001 1100 1100 0001 1000 0101 0000 0000 100001010000000001111011100000011010000010000000000000000000000000000000000000000000000000000000100111001100000110000101000
|
||||
1001 1100 1100 0001 10000101
|
||||
*/
|
||||
PrintAndLog("COTAG Found: FC %u, CN: %u Raw: %08X%08X%08X%08X", fc, cn, raw1 ,raw2, raw3, raw4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// When reading a COTAG.
|
||||
// 0 = HIGH/LOW signal - maxlength bigbuff
|
||||
// 1 = translation for HI/LO into bytes with manchester 0,1 - length 300
|
||||
// 2 = raw signal - maxlength bigbuff
|
||||
int CmdCOTAGRead(const char *Cmd) {
|
||||
|
||||
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_cotag_read();
|
||||
|
||||
uint32_t rawsignal = 1;
|
||||
sscanf(Cmd, "%u", &rawsignal);
|
||||
|
||||
UsbCommand c = {CMD_COTAG, {rawsignal, 0, 0}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK, NULL, 7000) ) {
|
||||
PrintAndLog("command execution time out");
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch ( rawsignal ){
|
||||
case 0:
|
||||
case 2: {
|
||||
CmdPlot("");
|
||||
CmdGrid("384");
|
||||
getSamples("", true); break;
|
||||
}
|
||||
case 1: {
|
||||
GetFromBigBuf(DemodBuffer, COTAG_BITS, 0);
|
||||
DemodBufferLen = COTAG_BITS;
|
||||
UsbCommand response;
|
||||
if ( !WaitForResponseTimeout(CMD_ACK, &response, 1000) ) {
|
||||
PrintAndLog("timeout while waiting for reply.");
|
||||
return -1;
|
||||
}
|
||||
return CmdCOTAGDemod("");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"demod", CmdCOTAGDemod, 1, "Tries to decode a COTAG signal"},
|
||||
{"read", CmdCOTAGRead, 0, "Attempt to read and extract tag data"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
int CmdLFCOTAG(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
CmdsParse(CommandTable, Cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHelp(const char *Cmd) {
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
32
client/cmdlfcotag.h
Normal file
32
client/cmdlfcotag.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Authored by 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 COTAG commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDLFCOTAG_H__
|
||||
#define CMDLFCOTAG_H__
|
||||
|
||||
#include "proxmark3.h"// Definitions, USB controls, COTAG_BITS
|
||||
#include "util.h" // FALSE / TRUE
|
||||
#include "cmddata.h" // getSamples
|
||||
#include "cmdparser.h"// CmdsParse, CmdsHelp
|
||||
#include "cmdmain.h"
|
||||
#include "ui.h" // PrintAndLog
|
||||
#include "cmdlf.h" // Setconfig
|
||||
#include "lfdemod.h" // manrawdecode, bytebits_tobyteLSBF
|
||||
|
||||
#ifndef COTAG_BITS
|
||||
#define COTAG_BITS 264
|
||||
#endif
|
||||
|
||||
int CmdLFCOTAG(const char *Cmd);
|
||||
int CmdCOTAGRead(const char *Cmd);
|
||||
int CmdCOTAGDemod(const char *Cmd);
|
||||
|
||||
int usage_lf_cotag_read(void);
|
||||
#endif
|
|
@ -270,7 +270,7 @@ uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose)
|
|||
}
|
||||
bool graphJustNoise(int *BitStream, int size)
|
||||
{
|
||||
static const uint8_t THRESHOLD = 10; //might not be high enough for noisy environments
|
||||
static const uint8_t THRESHOLD = 15; //might not be high enough for noisy environments
|
||||
//test samples are not just noise
|
||||
bool justNoise1 = 1;
|
||||
for(int idx=0; idx < size && justNoise1 ;idx++){
|
||||
|
|
|
@ -87,6 +87,7 @@ typedef struct {
|
|||
#define CMD_AWID_DEMOD_FSK 0x0221
|
||||
#define CMD_VIKING_CLONE_TAG 0x0223
|
||||
#define CMD_T55XX_WAKEUP 0x0224
|
||||
#define CMD_COTAG 0x0225
|
||||
|
||||
/* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ local _commands = {
|
|||
CMD_AWID_DEMOD_FSK = 0x0221,
|
||||
CMD_VIKING_CLONE_TAG = 0x0223,
|
||||
CMD_T55XX_WAKEUP = 0x0224,
|
||||
CMD_COTAG = 0x0225,
|
||||
--/* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */
|
||||
|
||||
--// For the 13.56 MHz tags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue