make style

This commit is contained in:
merlokk 2022-06-28 11:45:48 +03:00
commit 67fc919c72
5 changed files with 100 additions and 74 deletions

View file

@ -84,7 +84,7 @@ int HfReadADC(uint32_t samplesCount, bool ledcontrol) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
uint32_t scnt = getSampleCounter();
reply_ng(CMD_HF_ACQ_RAW_ADC, PM3_SUCCESS, (uint8_t*)&scnt, 4);
reply_ng(CMD_HF_ACQ_RAW_ADC, PM3_SUCCESS, (uint8_t *)&scnt, 4);
if (ledcontrol) LEDsoff();
return 0;

View file

@ -25,9 +25,9 @@
#include "cmdparser.h" // command_t
#include "comms.h"
#include "ui.h"
#include "cmdhf14a.h"
#include "cmddata.h"
#include "graph.h"
#include "cmdhf14a.h"
#include "cmddata.h"
#include "graph.h"
#define TEXKOM_NOISE_THRESHOLD (10)
@ -101,12 +101,12 @@ static bool TexkomCorrelate(uint32_t indx, uint32_t threshold) {
uint32_t g5 = GetGraphBuffer(indx + 2);
return (
(g3 > threshold) &&
(g3 >= g2) && (g3 >= g1) && (g3 > g4) && (g3 > g5)
);
(g3 > threshold) &&
(g3 >= g2) && (g3 >= g1) && (g3 > g4) && (g3 > g5)
);
}
static bool TexkomCalculateMaxMin(uint32_t* data, uint32_t len, uint32_t* dmax, uint32_t* dmin) {
static bool TexkomCalculateMaxMin(uint32_t *data, uint32_t len, uint32_t *dmax, uint32_t *dmin) {
*dmax = 0;
*dmin = 0xffffffff;
for (size_t i = 0; i < len; i++) {
@ -119,7 +119,7 @@ static bool TexkomCalculateMaxMin(uint32_t* data, uint32_t len, uint32_t* dmax,
return (*dmax != 0) && (*dmin != 0xffffffff) && (*dmax > *dmin);
}
static bool TexkomCalculateBitLengths(uint32_t* data, uint32_t len, uint32_t* hi, uint32_t* low, uint32_t* lmax, uint32_t* lmin) {
static bool TexkomCalculateBitLengths(uint32_t *data, uint32_t len, uint32_t *hi, uint32_t *low, uint32_t *lmax, uint32_t *lmin) {
*hi = 0;
*low = 0;
@ -155,19 +155,19 @@ static bool TexkomCalculateBitLengths(uint32_t* data, uint32_t len, uint32_t* hi
}
inline bool TexcomCalculateBit(uint32_t data, uint32_t bitlen, uint32_t threshold) {
return
(data < (bitlen + threshold)) &&
return
(data < (bitlen + threshold)) &&
(data > (bitlen - threshold));
}
// code from https://github.com/li0ard/crclib/blob/main/index.js
static uint8_t TexcomTK13CRC(uint8_t* data) {
static uint8_t TexcomTK13CRC(uint8_t *data) {
uint8_t crc = 0;
uint8_t indx = 0;
while (indx < 4) {
crc = crc ^ data[indx++];
for (uint8_t i = 0; i < 8; i++)
for (uint8_t i = 0; i < 8; i++)
if (crc & 0x80) {
crc = 0x31 ^ (crc << 1);
} else
@ -177,71 +177,68 @@ static uint8_t TexcomTK13CRC(uint8_t* data) {
return crc;
}
static unsigned char dallas_crc8(const unsigned char * data, const unsigned int size)
{
static unsigned char dallas_crc8(const unsigned char *data, const unsigned int size) {
unsigned char crc = 0;
for ( unsigned int i = 0; i < size; ++i )
{
for (unsigned int i = 0; i < size; ++i) {
unsigned char inbyte = data[i];
for ( unsigned char j = 0; j < 8; ++j )
{
for (unsigned char j = 0; j < 8; ++j) {
unsigned char mix = (crc ^ inbyte) & 0x01;
crc >>= 1;
if ( mix ) crc ^= 0x8C;
if (mix) crc ^= 0x8C;
inbyte >>= 1;
}
}
PrintAndLogEx(WARNING, "--crc %x", crc);
PrintAndLogEx(WARNING, "--crc %x", crc);
return crc;
}
// code from https://github.com/li0ard/crclib/blob/main/index.js
static uint8_t TexcomTK17CRC(uint8_t* data) {
static uint8_t TexcomTK17CRC(uint8_t *data) {
uint8_t ddata[8] = {0x00, 0x00, 0x00, data[0], data[1], data[2], data[3], 0x00};
/*
dallas (arrby) {
var arrby2 = [];
if (arrby.length < 8) {
return "FF";
}
var n = 0;
var n2 = 7;
while (n < 7){
arrby2[n] = arrby[n2];
++n;
--n2;
}
var n3 = 0;
var n4 = 0;
do {
var n5 = 255 & arrby2[n3];
var n6 = n4;
for (var n7 = 0; n7 < 8; n7 = Number(n7 + 1)) {
var n8 = 1 & (255 & (n6 ^ n5));
n6 = 255 & n6 >> 1;
n5 = 255 & n5 >> 1;
if (n8 != 1) continue;
n6 ^= 140;
}
if ((n3 = Number(n3 + 1)) >= 7) {
return n6.toString(16).toUpperCase();
}
n4 = n6;
} while (true);
}
tk17(arrby) {
if(arrby.length < 8) {
return "FF"
}
return this.dallas( [0x00, arrby[1], arrby[2], arrby[3], arrby[4], 0x00, 0x00, 0x00] )
}
*/
/*
dallas (arrby) {
var arrby2 = [];
if (arrby.length < 8) {
return "FF";
}
var n = 0;
var n2 = 7;
while (n < 7){
arrby2[n] = arrby[n2];
++n;
--n2;
}
var n3 = 0;
var n4 = 0;
do {
var n5 = 255 & arrby2[n3];
var n6 = n4;
for (var n7 = 0; n7 < 8; n7 = Number(n7 + 1)) {
var n8 = 1 & (255 & (n6 ^ n5));
n6 = 255 & n6 >> 1;
n5 = 255 & n5 >> 1;
if (n8 != 1) continue;
n6 ^= 140;
}
if ((n3 = Number(n3 + 1)) >= 7) {
return n6.toString(16).toUpperCase();
}
n4 = n6;
} while (true);
}
tk17(arrby) {
if(arrby.length < 8) {
return "FF"
}
return this.dallas( [0x00, arrby[1], arrby[2], arrby[3], arrby[4], 0x00, 0x00, 0x00] )
}
*/
return dallas_crc8(ddata, 8);
}
static bool TexcomTK13Decode(uint32_t* implengths, uint32_t implengthslen, char* bitstring, char* cbitstring, bool verbose) {
static bool TexcomTK13Decode(uint32_t *implengths, uint32_t implengthslen, char *bitstring, char *cbitstring, bool verbose) {
bitstring[0] = 0;
cbitstring[0] = 0;
@ -275,7 +272,7 @@ static bool TexcomTK13Decode(uint32_t* implengths, uint32_t implengthslen, char*
// add trailing impulse (some tags just ignore it)
if (strlen(bitstring) % 2 != 0) {
if (bitstring[strlen(bitstring) - 1] == '1')
if (bitstring[strlen(bitstring) - 1] == '1')
strcat(bitstring, "0");
else
strcat(bitstring, "1");
@ -316,7 +313,7 @@ inline int TexcomTK17Get2Bits(uint32_t len1, uint32_t len2) {
return TK17Bit11;
}
static bool TexcomTK17Decode(uint32_t* implengths, uint32_t implengthslen, char* bitstring, char* cbitstring, bool verbose) {
static bool TexcomTK17Decode(uint32_t *implengths, uint32_t implengthslen, char *bitstring, char *cbitstring, bool verbose) {
bitstring[0] = 0;
cbitstring[0] = 0;
@ -324,7 +321,7 @@ static bool TexcomTK17Decode(uint32_t* implengths, uint32_t implengthslen, char*
int dbit = TexcomTK17Get2Bits(implengths[i], implengths[i + 1]);
if (dbit == TK17WrongBit)
return false;
switch (dbit) {
case TK17Bit00:
strcat(bitstring, "00");
@ -359,8 +356,7 @@ static bool TexcomTK17Decode(uint32_t* implengths, uint32_t implengthslen, char*
return (strlen(bitstring) == 64) && (strncmp(cbitstring, "1111111111111111", 16) == 0);
}
static bool TexcomGeneralDecode(uint32_t* implengths, uint32_t implengthslen, char* bitstring, bool verbose) {
static bool TexcomGeneralDecode(uint32_t *implengths, uint32_t implengthslen, char *bitstring, bool verbose) {
uint32_t hilength = 0;
uint32_t lowlength = 0;
if (!TexkomCalculateBitLengths(implengths, implengthslen, &hilength, &lowlength, NULL, NULL))
@ -400,7 +396,6 @@ static void TexcomReverseCode(const uint8_t *code, int length, uint8_t *reverse_
}
};
static int CmdHFTexkomReader(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf texkom reader",
@ -461,7 +456,7 @@ static int CmdHFTexkomReader(const char *Cmd) {
noiselvl = TEXKOM_NOISE_THRESHOLD;
//PrintAndLogEx(WARNING, "--- indx: %d, len: %d, max: %d, noise: %d", sindx, slen, maxlvl, noiselvl);
uint32_t implengths[256] = {};
uint32_t implengthslen = 0;
uint32_t impulseindx = 0;

View file

@ -38,4 +38,4 @@ enum TexkomModulation {
int CmdHFTexkom(const char *Cmd);
#endif
#endif

View file

@ -2661,7 +2661,7 @@
},
"hf help": {
"command": "hf help",
"description": "-------- ----------------------- High Frequency ----------------------- 14a { ISO14443A RFIDs... } 14b { ISO14443B RFIDs... } 15 { ISO15693 RFIDs... } cipurse { Cipurse transport Cards... } epa { German Identification Card... } emrtd { Machine Readable Travel Document... } felica { ISO18092 / FeliCa RFIDs... } fido { FIDO and FIDO2 authenticators... } gallagher { Gallagher DESFire RFIDs... } ksx6924 { KS X 6924 (T-Money, Snapper+) RFIDs } jooki { Jooki RFIDs... } iclass { ICLASS RFIDs... } legic { LEGIC RFIDs... } lto { LTO Cartridge Memory RFIDs... } mf { MIFARE RFIDs... } mfp { MIFARE Plus RFIDs... } mfu { MIFARE Ultralight RFIDs... } mfdes { MIFARE Desfire RFIDs... } ntag424 { NXP NTAG 4242 DNA RFIDs... } seos { SEOS RFIDs... } st25ta { ST25TA RFIDs... } thinfilm { Thinfilm RFIDs... } topaz { TOPAZ (NFC Type 1) RFIDs... } waveshare { Waveshare NFC ePaper... } ----------- --------------------- General --------------------- help This help list List protocol data in trace buffer search Search for known HF tags",
"description": "-------- ----------------------- High Frequency ----------------------- 14a { ISO14443A RFIDs... } 14b { ISO14443B RFIDs... } 15 { ISO15693 RFIDs... } cipurse { Cipurse transport Cards... } epa { German Identification Card... } emrtd { Machine Readable Travel Document... } felica { ISO18092 / FeliCa RFIDs... } fido { FIDO and FIDO2 authenticators... } gallagher { Gallagher DESFire RFIDs... } ksx6924 { KS X 6924 (T-Money, Snapper+) RFIDs } jooki { Jooki RFIDs... } iclass { ICLASS RFIDs... } legic { LEGIC RFIDs... } lto { LTO Cartridge Memory RFIDs... } mf { MIFARE RFIDs... } mfp { MIFARE Plus RFIDs... } mfu { MIFARE Ultralight RFIDs... } mfdes { MIFARE Desfire RFIDs... } ntag424 { NXP NTAG 4242 DNA RFIDs... } seos { SEOS RFIDs... } st25ta { ST25TA RFIDs... } thinfilm { Thinfilm RFIDs... } topaz { TOPAZ (NFC Type 1) RFIDs... } texkom { Texkom RFIDs... } waveshare { Waveshare NFC ePaper... } ----------- --------------------- General --------------------- help This help list List protocol data in trace buffer search Search for known HF tags",
"notes": [],
"offline": true,
"options": [],
@ -6302,6 +6302,27 @@
],
"usage": "hf st25ta sim [-h] -u <hex>"
},
"hf texkom help": {
"command": "hf texkom help",
"description": "help This help",
"notes": [],
"offline": true,
"options": [],
"usage": ""
},
"hf texkom reader": {
"command": "hf texkom reader",
"description": "Read a texkom tag",
"notes": [
"hf texkom reader"
],
"offline": false,
"options": [
"-h, --help This help",
"-v, --verbose Verbose scan and output"
],
"usage": "hf texkom reader [-hv]"
},
"hf thinfilm help": {
"command": "hf thinfilm help",
"description": "help This help list List NFC Barcode / Thinfilm history - not correct",
@ -6528,8 +6549,8 @@
"command": "hw connect",
"description": "Connects to a Proxmark3 device via specified serial port. Baudrate here is only for physical UART or UART-BT, NOT for USB-CDC or blue shark add-on",
"notes": [
"hw connect -p /dev/ttyACM0",
"hw connect -p /dev/ttyACM0 -b 115200"
"hw connect -p /dev/ttyacm0",
"hw connect -p /dev/ttyacm0 -b 115200"
],
"offline": true,
"options": [
@ -10998,8 +11019,8 @@
}
},
"metadata": {
"commands_extracted": 693,
"commands_extracted": 695,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2022-06-12T09:54:12"
"extracted_on": "2022-06-28T08:43:20"
}
}

View file

@ -646,6 +646,16 @@ Check column "offline" for their availability.
|`hf topaz raw `|N |`Send raw hex data to tag`
### hf texkom
{ Texkom RFIDs... }
|command |offline |description
|------- |------- |-----------
|`hf texkom help `|Y |`This help`
|`hf texkom reader `|N |`Act like a Texkom reader`
### hf waveshare
{ Waveshare NFC ePaper... }