]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdanalyse.c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2016 iceman
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // Analyse bytes commands
9 //-----------------------------------------------------------------------------
10 #include "cmdanalyse.h"
12 static int CmdHelp(const char *Cmd
);
14 int usage_analyse_lcr(void) {
15 PrintAndLog("Specifying the bytes of a UID with a known LRC will find the last byte value");
16 PrintAndLog("needed to generate that LRC with a rolling XOR. All bytes should be specified in HEX.");
18 PrintAndLog("Usage: analyse lcr [h] <bytes>");
19 PrintAndLog("Options:");
20 PrintAndLog(" h This help");
21 PrintAndLog(" <bytes> bytes to calc missing XOR in a LCR");
23 PrintAndLog("Samples:");
24 PrintAndLog(" analyse lcr 04008064BA");
25 PrintAndLog("expected output: Target (BA) requires final LRC XOR byte value: 5A");
28 static uint8_t calculateLRC( uint8_t* bytes
, uint8_t len
) {
30 for (uint8_t i
= 0; i
< len
; i
++)
35 int CmdAnalyseLCR(const char *Cmd
) {
37 char cmdp
= param_getchar(Cmd
, 0);
38 if (strlen(Cmd
) == 0|| cmdp
== 'h' || cmdp
== 'H') return usage_analyse_lcr();
41 param_gethex_ex(Cmd
, 0, data
, &len
);
42 if ( len
%2 ) return usage_analyse_lcr();
44 uint8_t finalXor
= calculateLRC(data
, len
);
45 PrintAndLog("Target [%02X] requires final LRC XOR byte value: 0x%02X",data
[len
-1] ,finalXor
);
49 int CmdAnalyseDates(const char *Cmd
){
50 // look for datestamps in a given array of bytes
51 PrintAndLog("To be implemented. If you feel to contribute!");
55 static command_t CommandTable
[] = {
56 {"help", CmdHelp
, 1, "This help"},
57 {"lcr", CmdAnalyseLCR
, 0, "Generate final byte for XOR LRC"},
58 {"dates", CmdAnalyseDates
, 0, "Look for datestamps in a given array of bytes"},
62 int CmdAnalyse(const char *Cmd
) {
64 CmdsParse(CommandTable
, Cmd
);
68 int CmdHelp(const char *Cmd
) {
69 CmdsHelp(CommandTable
);