mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
ADD: Added a new main command group "analyse", first one is the find the missing XOR in a LCR, it was a python script under /tools/xorfind.py
This commit is contained in:
parent
8085377413
commit
812513bf90
5 changed files with 100 additions and 8 deletions
|
@ -140,7 +140,9 @@ CMDSRCS = nonce2key/crapto1.c \
|
||||||
tea.c \
|
tea.c \
|
||||||
prng.c \
|
prng.c \
|
||||||
radixsort.c \
|
radixsort.c \
|
||||||
bucketsort.c
|
bucketsort.c \
|
||||||
|
cmdanalyse.c
|
||||||
|
|
||||||
ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
|
ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
|
||||||
ZLIB_FLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
|
ZLIB_FLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
|
||||||
#-DDEBUG -Dverbose=1
|
#-DDEBUG -Dverbose=1
|
||||||
|
|
64
client/cmdanalyse.c
Normal file
64
client/cmdanalyse.c
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2016 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.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Analyse bytes commands
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#include "cmdanalyse.h"
|
||||||
|
|
||||||
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
|
int usage_analyse_lcr(void) {
|
||||||
|
PrintAndLog("Specifying the bytes of a UID with a known LRC will find the last byte value");
|
||||||
|
PrintAndLog("needed to generate that LRC with a rolling XOR. All bytes should be specified in HEX.");
|
||||||
|
PrintAndLog("");
|
||||||
|
PrintAndLog("Usage: analyse lcr [h] <bytes>");
|
||||||
|
PrintAndLog("Options:");
|
||||||
|
PrintAndLog(" h This help");
|
||||||
|
PrintAndLog(" <bytes> bytes to calc missing XOR in a LCR");
|
||||||
|
PrintAndLog("");
|
||||||
|
PrintAndLog("Samples:");
|
||||||
|
PrintAndLog(" analyse lcr 04008064BA");
|
||||||
|
PrintAndLog("expected output: Target (BA) requires final LRC XOR byte value: 5A");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static uint8_t calculateLRC( uint8_t* bytes, uint8_t len) {
|
||||||
|
uint8_t LRC = 0;
|
||||||
|
for (uint8_t i = 0; i < len; i++)
|
||||||
|
LRC ^= bytes[i];
|
||||||
|
return LRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CmdAnalyseLCR(const char *Cmd) {
|
||||||
|
uint8_t data[50];
|
||||||
|
char cmdp = param_getchar(Cmd, 0);
|
||||||
|
if (strlen(Cmd) == 0|| cmdp == 'h' || cmdp == 'H') return usage_analyse_lcr();
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
|
param_gethex_ex(Cmd, 0, data, &len);
|
||||||
|
if ( len%2 ) return usage_analyse_lcr();
|
||||||
|
len >>= 1;
|
||||||
|
uint8_t finalXor = calculateLRC(data, len);
|
||||||
|
PrintAndLog("Target [%02X] requires final LRC XOR byte value: 0x%02X",data[len-1] ,finalXor);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static command_t CommandTable[] = {
|
||||||
|
{"help", CmdHelp, 1, "This help"},
|
||||||
|
{"lcr", CmdAnalyseLCR, 0, "Generate final byte for XOR LRC"},
|
||||||
|
{NULL, NULL, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
int CmdAnalyse(const char *Cmd) {
|
||||||
|
clearCommandBuffer();
|
||||||
|
CmdsParse(CommandTable, Cmd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CmdHelp(const char *Cmd) {
|
||||||
|
CmdsHelp(CommandTable);
|
||||||
|
return 0;
|
||||||
|
}
|
24
client/cmdanalyse.h
Normal file
24
client/cmdanalyse.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Data and Graph commands
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef CMDANALYSE_H__
|
||||||
|
#define CMDANALYSE_H__
|
||||||
|
|
||||||
|
#include <stdlib.h> //size_t
|
||||||
|
#include <string.h>
|
||||||
|
#include "cmdmain.h"
|
||||||
|
#include "proxmark3.h"
|
||||||
|
#include "ui.h" // PrintAndLog
|
||||||
|
command_t * CmdDataCommands();
|
||||||
|
|
||||||
|
int CmdAnalyse(const char *Cmd);
|
||||||
|
int CmdAnalyseLCR(const char *Cmd);
|
||||||
|
|
||||||
|
#endif
|
|
@ -109,7 +109,7 @@ int CmdLFNedapDemod(const char *Cmd) {
|
||||||
|
|
||||||
/* Index map O
|
/* Index map O
|
||||||
preamble enc tag type encrypted uid P d 33 d 90 d 04 d 71 d 40 d 45 d E7 P
|
preamble enc tag type encrypted uid P d 33 d 90 d 04 d 71 d 40 d 45 d E7 P
|
||||||
1111111110 00101101000001011 01000110010010000101101010011010110 0 1 0 00110011 0 10010000 0 00000100 0 01110001 0 01000000 0 01000101 0 11100111 1
|
1111111110 0010110100000101101000110010010000101101010011010110 0 1 0 00110011 0 10010000 0 00000100 0 01110001 0 01000000 0 01000101 0 11100111 1
|
||||||
uid2 uid1 uid0 I I R R
|
uid2 uid1 uid0 I I R R
|
||||||
Tag ID is 049033
|
Tag ID is 049033
|
||||||
I = Identical on all tags
|
I = Identical on all tags
|
||||||
|
@ -261,6 +261,8 @@ int CmdLFNedapSim(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int CmdLFNedapChk(const char *Cmd){
|
int CmdLFNedapChk(const char *Cmd){
|
||||||
|
|
||||||
uint8_t data[256] = { 0x30, 0x16, 0x00, 0x71, 0x40, 0x21, 0xBE};
|
uint8_t data[256] = { 0x30, 0x16, 0x00, 0x71, 0x40, 0x21, 0xBE};
|
||||||
|
@ -271,10 +273,9 @@ int CmdLFNedapChk(const char *Cmd){
|
||||||
|
|
||||||
PrintAndLog("Input: [%d] %s", len, sprint_hex(data, len));
|
PrintAndLog("Input: [%d] %s", len, sprint_hex(data, len));
|
||||||
|
|
||||||
uint8_t last = GetParity(data, EVEN, 62);
|
//uint8_t last = GetParity(data, EVEN, 62);
|
||||||
PrintAndLog("TEST PARITY:: %d | %d ", DemodBuffer[62], last);
|
//PrintAndLog("TEST PARITY:: %d | %d ", DemodBuffer[62], last);
|
||||||
|
|
||||||
return 1;
|
|
||||||
uint8_t cl = 0x1D, ch = 0x1D, carry = 0;
|
uint8_t cl = 0x1D, ch = 0x1D, carry = 0;
|
||||||
uint8_t al, bl, temp;
|
uint8_t al, bl, temp;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "cmdscript.h"
|
#include "cmdscript.h"
|
||||||
#include "cmdcrc.h"
|
#include "cmdcrc.h"
|
||||||
|
#include "cmdanalyse.h"
|
||||||
|
|
||||||
unsigned int current_command = CMD_UNKNOWN;
|
unsigned int current_command = CMD_UNKNOWN;
|
||||||
|
|
||||||
|
@ -45,11 +45,12 @@ static int cmd_tail;//Starts as 0
|
||||||
static command_t CommandTable[] =
|
static command_t CommandTable[] =
|
||||||
{
|
{
|
||||||
{"help", CmdHelp, 1, "This help. Use '<command> help' for details of a particular command."},
|
{"help", CmdHelp, 1, "This help. Use '<command> help' for details of a particular command."},
|
||||||
|
{"analyse", CmdAnalyse, 1, "{ Analyse bytes... }"},
|
||||||
{"data", CmdData, 1, "{ Plot window / data buffer manipulation... }"},
|
{"data", CmdData, 1, "{ Plot window / data buffer manipulation... }"},
|
||||||
{"hf", CmdHF, 1, "{ High Frequency commands... }"},
|
{"hf", CmdHF, 1, "{ High Frequency commands... }"},
|
||||||
{"hw", CmdHW, 1, "{ Hardware commands... }"},
|
{"hw", CmdHW, 1, "{ Hardware commands... }"},
|
||||||
{"lf", CmdLF, 1, "{ Low Frequency commands... }"},
|
{"lf", CmdLF, 1, "{ Low Frequency commands... }"},
|
||||||
{"reveng", CmdRev, 1, "Crc calculations from the software reveng 1.30"},
|
{"reveng", CmdRev, 1, "Crc calculations from the software reveng 1.40"},
|
||||||
{"script", CmdScript, 1, "{ Scripting commands }"},
|
{"script", CmdScript, 1, "{ Scripting commands }"},
|
||||||
{"quit", CmdQuit, 1, "Exit program"},
|
{"quit", CmdQuit, 1, "Exit program"},
|
||||||
{"exit", CmdQuit, 1, "Exit program"},
|
{"exit", CmdQuit, 1, "Exit program"},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue