This commit is contained in:
iceman1001 2023-10-18 20:34:35 +02:00
commit 1f3cf80898
16 changed files with 139 additions and 107 deletions

View file

@ -113,7 +113,8 @@ int sam_picopass_get_pacs(void) {
clear_trace();
I2C_Reset_EnterMainProgram(); StopTicks();
I2C_Reset_EnterMainProgram();
StopTicks();
uint8_t *resp = BigBuf_calloc(ISO7816_MAX_FRAME);
@ -227,7 +228,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 1",resp, resp_len);
print_dbg("-- 1", resp, resp_len);
// -----------------------------------------------------------------------------
// second
@ -237,7 +238,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 2",resp, resp_len);
print_dbg("-- 2", resp, resp_len);
// TAG response
// -- 0c 05 de64 // read block 5
@ -256,7 +257,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 3",resp, resp_len);
print_dbg("-- 3", resp, resp_len);
// 88 02 -- readcheck (block2 epurse, start of auth)
// Tag|c00a140a000000a10ea10c8002 8802 8102 0004 820201f4 9000
@ -272,13 +273,13 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 4",resp, resp_len);
print_dbg("-- 4", resp, resp_len);
uint8_t nr_mac[9] = {0};
memcpy(nr_mac, resp + 11, sizeof(nr_mac));
// resp here hold the whole NR/MAC
// 05 9bcd475e965ee20e // CHECK (w key)
print_dbg("NR/MAC",nr_mac, sizeof(nr_mac));
print_dbg("NR/MAC", nr_mac, sizeof(nr_mac));
// c00a140a000000a115a1138009 059bcd475e965ee20e 8102 0004 820201f4 9000
@ -292,7 +293,7 @@ int sam_picopass_get_pacs(void) {
if (g_dbglevel == DBG_DEBUG) {
uint8_t wb[16] = {0};
memcpy(wb, hdr.epurse, sizeof(hdr.epurse));
memcpy(wb + sizeof(hdr.epurse), nr_mac+1, 4);
memcpy(wb + sizeof(hdr.epurse), nr_mac + 1, 4);
print_dbg("cc_nr...", wb, sizeof(wb));
doMAC_N(wb, sizeof(wb), div_key, mac);
print_dbg("Calc MAC...", mac, sizeof(mac));
@ -316,7 +317,7 @@ int sam_picopass_get_pacs(void) {
}
// store MAC
memcpy(mac, resp, sizeof(mac));
print_dbg("Got MAC",mac,sizeof(mac));
print_dbg("Got MAC", mac, sizeof(mac));
// -----------------------------------------------------------------------------
// fifth send received MAC
@ -328,7 +329,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 5",resp, resp_len);
print_dbg("-- 5", resp, resp_len);
uint8_t tmp_p1[4] = {0};
uint8_t tmp_p2[4] = {0};
@ -350,7 +351,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 6",resp, resp_len);
print_dbg("-- 6", resp, resp_len);
// c1 61 c1 00 00 a1 10 a1 0e 80 04 0c 06 45 56 81 02 00 04 82 02 01 f4 90 00
// read block 6
@ -364,7 +365,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("Block 6 from Picopass",resp, resp_len);
print_dbg("Block 6 from Picopass", resp, resp_len);
// -----------------------------------------------------------------------------
// eight send block 6 config to SAM
@ -391,7 +392,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("Block 6-9 from Picopass",resp, resp_len);
print_dbg("Block 6-9 from Picopass", resp, resp_len);
// -----------------------------------------------------------------------------
// nine send credential blocks to SAM
@ -403,7 +404,7 @@ int sam_picopass_get_pacs(void) {
res = PM3_ECARDEXCHANGE;
goto out;
}
print_dbg("-- 8",resp, resp_len);
print_dbg("-- 8", resp, resp_len);
// -----------------------------------------------------------------------------

View file

@ -4478,7 +4478,7 @@ static int CmdHFiClassSAM(const char *Cmd) {
uint8_t *d = resp.data.asBytes;
uint8_t n = d[1] - 1; // skip length byte
uint8_t pad = d[2];
char *binstr = (char*)calloc((n * 8) + 1 , sizeof(uint8_t));
char *binstr = (char *)calloc((n * 8) + 1, sizeof(uint8_t));
if (binstr == NULL) {
return PM3_EMALLOC;
}
@ -4494,7 +4494,7 @@ static int CmdHFiClassSAM(const char *Cmd) {
size_t hexlen = 0;
uint8_t hex[16] = {0};
binstr_2_bytes(hex, &hexlen,binstr);
binstr_2_bytes(hex, &hexlen, binstr);
PrintAndLogEx(SUCCESS, "hex.......... " _GREEN_("%s"), sprint_hex_inrow(hex, hexlen));
uint32_t top = 0, mid = 0, bot = 0;

View file

@ -42,8 +42,9 @@ const static vocabulary_t vocabulary[] = {
{ 1, "prefs help" },
{ 1, "prefs show" },
{ 1, "prefs get barmode" },
{ 1, "prefs get clientdebug" },
{ 1, "prefs get clientdelay" },
{ 1, "prefs get client.debug" },
{ 1, "prefs get client.delay" },
{ 1, "prefs get client.timeout" },
{ 1, "prefs get color" },
{ 1, "prefs get savepaths" },
{ 1, "prefs get emoji" },
@ -52,8 +53,9 @@ const static vocabulary_t vocabulary[] = {
{ 1, "prefs get plotsliders" },
{ 1, "prefs set help" },
{ 1, "prefs set barmode" },
{ 1, "prefs set clientdebug" },
{ 1, "prefs set clientdelay" },
{ 1, "prefs set client.debug" },
{ 1, "prefs set client.delay" },
{ 1, "prefs set client.timeout" },
{ 1, "prefs set color" },
{ 1, "prefs set emoji" },
{ 1, "prefs set hints" },

View file

@ -1,13 +1,13 @@
#include "ringbuffer.h"
#include <stdlib.h>
RingBuffer* RingBuf_create(int capacity) {
RingBuffer* buffer = (RingBuffer*)malloc(sizeof(RingBuffer));
RingBuffer *RingBuf_create(int capacity) {
RingBuffer *buffer = (RingBuffer *)malloc(sizeof(RingBuffer));
if (!buffer) {
return NULL;
}
buffer->data = (uint8_t*)calloc(capacity, sizeof(uint8_t));
buffer->data = (uint8_t *)calloc(capacity, sizeof(uint8_t));
if (!buffer->data) {
free(buffer);
return NULL;
@ -21,15 +21,15 @@ RingBuffer* RingBuf_create(int capacity) {
return buffer;
}
inline bool RingBuf_isFull(RingBuffer* buffer) {
inline bool RingBuf_isFull(RingBuffer *buffer) {
return buffer->size == buffer->capacity;
}
inline bool RingBuf_isEmpty(RingBuffer* buffer) {
inline bool RingBuf_isEmpty(RingBuffer *buffer) {
return buffer->size == 0;
}
bool RingBuf_enqueue(RingBuffer* buffer, uint8_t value) {
bool RingBuf_enqueue(RingBuffer *buffer, uint8_t value) {
if (RingBuf_isFull(buffer)) {
return false;
}
@ -40,7 +40,7 @@ bool RingBuf_enqueue(RingBuffer* buffer, uint8_t value) {
return true;
}
bool RingBuf_dequeue(RingBuffer* buffer, uint8_t* value) {
bool RingBuf_dequeue(RingBuffer *buffer, uint8_t *value) {
if (RingBuf_isEmpty(buffer)) {
return false;
}
@ -51,7 +51,7 @@ bool RingBuf_dequeue(RingBuffer* buffer, uint8_t* value) {
return true;
}
int RingBuf_enqueueBatch(RingBuffer* buffer, const uint8_t* values, int count) {
int RingBuf_enqueueBatch(RingBuffer *buffer, const uint8_t *values, int count) {
int processed = 0;
if (RingBuf_getAvailableSize(buffer) < count) {
@ -69,7 +69,7 @@ int RingBuf_enqueueBatch(RingBuffer* buffer, const uint8_t* values, int count) {
return processed;
}
int RingBuf_dequeueBatch(RingBuffer* buffer, uint8_t* values, int count) {
int RingBuf_dequeueBatch(RingBuffer *buffer, uint8_t *values, int count) {
int processed = 0;
if (buffer->size < count) {
@ -87,32 +87,32 @@ int RingBuf_dequeueBatch(RingBuffer* buffer, uint8_t* values, int count) {
return processed;
}
inline int RingBuf_getUsedSize(RingBuffer* buffer) {
inline int RingBuf_getUsedSize(RingBuffer *buffer) {
return buffer->size;
}
inline int RingBuf_getAvailableSize(RingBuffer* buffer) {
inline int RingBuf_getAvailableSize(RingBuffer *buffer) {
return (buffer->capacity) - (buffer->size);
}
void RingBuf_destroy(RingBuffer* buffer) {
void RingBuf_destroy(RingBuffer *buffer) {
if (buffer != NULL)
free(buffer->data);
free(buffer);
}
inline int RingBuf_getContinousAvailableSize(RingBuffer* buffer) {
inline int RingBuf_getContinousAvailableSize(RingBuffer *buffer) {
const int availableSize = RingBuf_getAvailableSize(buffer);
const int continousSize = (buffer->capacity) - (buffer->rear);
return (availableSize < continousSize) ? availableSize : continousSize;
}
inline void RingBuf_postEnqueueBatch(RingBuffer* buffer, int count) {
inline void RingBuf_postEnqueueBatch(RingBuffer *buffer, int count) {
// no check there
buffer->rear = (buffer->rear + count) % buffer->capacity;
buffer->size += count;
}
inline uint8_t* RingBuf_getRearPtr(RingBuffer* buffer) {
inline uint8_t *RingBuf_getRearPtr(RingBuffer *buffer) {
return buffer->data + buffer->rear;
}

View file

@ -5,27 +5,27 @@
#include <stdint.h>
typedef struct {
uint8_t* data;
uint8_t *data;
int capacity;
int size;
int front;
int rear;
} RingBuffer;
RingBuffer* RingBuf_create(int capacity);
bool RingBuf_isFull(RingBuffer* buffer);
bool RingBuf_isEmpty(RingBuffer* buffer);
bool RingBuf_enqueue(RingBuffer* buffer, uint8_t value);
bool RingBuf_dequeue(RingBuffer* buffer, uint8_t* value);
int RingBuf_enqueueBatch(RingBuffer* buffer, const uint8_t* values, int count);
int RingBuf_dequeueBatch(RingBuffer* buffer, uint8_t* values, int count);
int RingBuf_getUsedSize(RingBuffer* buffer);
int RingBuf_getAvailableSize(RingBuffer* buffer);
void RingBuf_destroy(RingBuffer* buffer);
RingBuffer *RingBuf_create(int capacity);
bool RingBuf_isFull(RingBuffer *buffer);
bool RingBuf_isEmpty(RingBuffer *buffer);
bool RingBuf_enqueue(RingBuffer *buffer, uint8_t value);
bool RingBuf_dequeue(RingBuffer *buffer, uint8_t *value);
int RingBuf_enqueueBatch(RingBuffer *buffer, const uint8_t *values, int count);
int RingBuf_dequeueBatch(RingBuffer *buffer, uint8_t *values, int count);
int RingBuf_getUsedSize(RingBuffer *buffer);
int RingBuf_getAvailableSize(RingBuffer *buffer);
void RingBuf_destroy(RingBuffer *buffer);
// for direct write
int RingBuf_getContinousAvailableSize(RingBuffer* buffer);
void RingBuf_postEnqueueBatch(RingBuffer* buffer, int count);
uint8_t* RingBuf_getRearPtr(RingBuffer* buffer);
int RingBuf_getContinousAvailableSize(RingBuffer *buffer);
void RingBuf_postEnqueueBatch(RingBuffer *buffer, int count);
uint8_t *RingBuf_getRearPtr(RingBuffer *buffer);
#endif

View file

@ -56,7 +56,7 @@ typedef struct {
int fd; // Serial port file descriptor
term_info tiOld; // Terminal info before using the port
term_info tiNew; // Terminal info during the transaction
RingBuffer* udpBuffer;
RingBuffer *udpBuffer;
} serial_port_unix_t_t;
// see pm3_cmd.h
@ -519,7 +519,7 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
*pszRxLen = 0;
do {
int res;
if(spu->udpBuffer != NULL) {
if (spu->udpBuffer != NULL) {
// for UDP connection, try to use the data from the buffer
byteCount = RingBuf_getAvailableSize(spu->udpBuffer);

View file

@ -38,7 +38,7 @@ typedef struct {
DCB dcb; // Device control settings
COMMTIMEOUTS ct; // Serial port time-out configuration
SOCKET hSocket; // Socket handle
RingBuffer* udpBuffer; // Buffer for UDP
RingBuffer *udpBuffer; // Buffer for UDP
} serial_port_windows_t;
// this is for TCP connection
@ -473,7 +473,7 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
*pszRxLen = 0;
do {
int res;
if(spw->udpBuffer != NULL) {
if (spw->udpBuffer != NULL) {
// for UDP connection, try to use the data from the buffer
byteCount = RingBuf_getAvailableSize(spw->udpBuffer);

View file

@ -7580,15 +7580,15 @@
"description": "Set the communication timeout on the client side",
"notes": [
"hw timeout -> Show current timeout",
"hw timeout -t 20 -> Set the timeout to 20ms",
"hw timeout -t 500 -> Set the timeout to 500ms"
"hw timeout -m 20 -> Set the timeout to 20ms",
"hw timeout --ms 500 -> Set the timeout to 500ms"
],
"offline": true,
"options": [
"-h, --help This help",
"-t, --timeout <dec> timeout in ms"
"-m, --ms <ms> timeout in micro seconds"
],
"usage": "hw timeout [-h] [-t <dec>]"
"usage": "hw timeout [-h] [-m <ms>]"
},
"hw tune": {
"command": "hw tune",
@ -11220,29 +11220,41 @@
],
"usage": "prefs get barmode [-h]"
},
"prefs get clientdebug": {
"command": "prefs get clientdebug",
"prefs get client.debug": {
"command": "prefs get client.debug",
"description": "Get preference of using clientside debug level",
"notes": [
"prefs get clientdebug"
"prefs get client.debug"
],
"offline": true,
"options": [
"-h, --help This help"
],
"usage": "prefs get clientdebug [-h]"
"usage": "prefs get client.debug [-h]"
},
"prefs get clientdelay": {
"command": "prefs get clientdelay",
"prefs get client.delay": {
"command": "prefs get client.delay",
"description": "Get preference of delay time before execution of a command in the client",
"notes": [
"prefs get clientdelay"
"prefs get client.delay"
],
"offline": true,
"options": [
"-h, --help This help"
],
"usage": "prefs get clientdelay [-h]"
"usage": "prefs get client.delay [-h]"
},
"prefs get client.timeout": {
"command": "prefs get client.timeout",
"description": "Get preference of delay time before execution of a command in the client",
"notes": [
"prefs get client.timeout"
],
"offline": true,
"options": [
"-h, --help This help"
],
"usage": "prefs get client.timeout [-h]"
},
"prefs get color": {
"command": "prefs get color",
@ -11331,11 +11343,11 @@
],
"usage": "prefs set barmode [-h] [--bar] [--mix] [--val]"
},
"prefs set clientdebug": {
"command": "prefs set clientdebug",
"prefs set client.debug": {
"command": "prefs set client.debug",
"description": "Set persistent preference of using clientside debug level",
"notes": [
"prefs set clientdebug --simple"
"prefs set client.debug --simple"
],
"offline": true,
"options": [
@ -11344,21 +11356,36 @@
"--simple simple debug messages",
"--full full debug messages"
],
"usage": "prefs set clientdebug [-h] [--off] [--simple] [--full]"
"usage": "prefs set client.debug [-h] [--off] [--simple] [--full]"
},
"prefs set clientdelay": {
"command": "prefs set clientdelay",
"prefs set client.delay": {
"command": "prefs set client.delay",
"description": "Set persistent preference of delay before executing a command in the client",
"notes": [
"prefs set clientdelay --ms 0 -> unsets any delay",
"prefs set clientdelay --ms 1000 -> sets 1000ms delay"
"prefs set client.delay --ms 0 -> unsets any delay",
"prefs set client.delay --ms 1000 -> sets 1000ms delay"
],
"offline": true,
"options": [
"-h, --help This help",
"--ms <ms> delay in micro seconds"
],
"usage": "prefs set clientdelay [-h] [--ms <ms>]"
"usage": "prefs set client.delay [-h] [--ms <ms>]"
},
"prefs set client.timeout": {
"command": "prefs set client.timeout",
"description": "Set persistent preference of client communication timeout",
"notes": [
"prefs set client.timeout --ms 0 -> unsets any timeout",
"prefs set client.timeout -m 20 -> Set the timeout to 20ms",
"prefs set client.timeout --ms 500 -> Set the timeout to 500ms"
],
"offline": true,
"options": [
"-h, --help This help",
"-m, --ms <ms> timeout in micro seconds"
],
"usage": "prefs set client.timeout [-h] [-m <ms>]"
},
"prefs set color": {
"command": "prefs set color",
@ -11854,8 +11881,8 @@
}
},
"metadata": {
"commands_extracted": 687,
"commands_extracted": 689,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2023-10-15T15:14:39"
"extracted_on": "2023-10-18T18:30:58"
}
}

View file

@ -37,8 +37,9 @@ Check column "offline" for their availability.
|command |offline |description
|------- |------- |-----------
|`prefs get barmode `|Y |`Get bar mode preference`
|`prefs get clientdebug `|Y |`Get client debug level preference`
|`prefs get clientdelay `|Y |`Get client execution delay preference`
|`prefs get client.debug `|Y |`Get client debug level preference`
|`prefs get client.delay `|Y |`Get client execution delay preference`
|`prefs get client.timeout`|Y |`Get client execution delay preference`
|`prefs get color `|Y |`Get color support preference`
|`prefs get savepaths `|Y |`Get file folder `
|`prefs get emoji `|Y |`Get emoji display preference`
@ -55,8 +56,9 @@ Check column "offline" for their availability.
|------- |------- |-----------
|`prefs set help `|Y |`This help`
|`prefs set barmode `|Y |`Set bar mode`
|`prefs set clientdebug `|Y |`Set client debug level`
|`prefs set clientdelay `|Y |`Set client execution delay`
|`prefs set client.debug `|Y |`Set client debug level`
|`prefs set client.delay `|Y |`Set client execution delay`
|`prefs set client.timeout`|Y |`Set client communication timeout`
|`prefs set color `|Y |`Set color support`
|`prefs set emoji `|Y |`Set emoji display`
|`prefs set hints `|Y |`Set hint display`