crc64.c \
iso14443crc.c \
iso15693tools.c \
- data.c \
graph.c \
ui.c \
cmddata.c \
#include <string.h> // also included in util.h
#include <inttypes.h>
#include <limits.h> // for CmdNorm INT_MIN && INT_MAX
-#include "data.h" // also included in util.h
#include "cmddata.h"
#include "util.h"
#include "cmdmain.h"
int cnt = 0;
uint8_t got[12288];
- GetFromBigBuf(got,sizeof(got),0);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(got, sizeof(got), 0 , NULL, -1, false);
for (int j = 0; j < sizeof(got); j++) {
for (int k = 0; k < 8; k++) {
return 0;
}
- GetFromBigBuf(got,requested,offset);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(got, requested, offset, NULL, -1, false);
i = 0;
for (j = 0; j < requested; j++) {
n = sizeof(got);
if (!silent) PrintAndLog("Reading %d bytes from device memory\n", n);
- GetFromBigBuf(got,n,0);
- if (!silent) PrintAndLog("Data fetched");
UsbCommand response;
- WaitForResponse(CMD_ACK, &response);
+ GetFromBigBuf(got, n, 0, &response, -1, false);
+ if (!silent) PrintAndLog("Data fetched");
uint8_t bits_per_sample = 8;
//Old devices without this feature would send 0 at arg[0]
#include <string.h>
#include "proxmark3.h"
#include "util.h"
-#include "data.h"
#include "ui.h"
#include "iso14443crc.h"
#include "parity.h"
trace = malloc(USB_CMD_DATA_SIZE);
// Query for the size of the trace
UsbCommand response;
- GetFromBigBuf(trace, USB_CMD_DATA_SIZE, 0);
- WaitForResponse(CMD_ACK, &response);
+ GetFromBigBuf(trace, USB_CMD_DATA_SIZE, 0, &response, -1, false);
traceLen = response.arg[2];
if (traceLen > USB_CMD_DATA_SIZE) {
uint8_t *p = realloc(trace, traceLen);
return 2;
}
trace = p;
- GetFromBigBuf(trace, traceLen, 0);
- WaitForResponse(CMD_ACK, NULL);
+ GetFromBigBuf(trace, traceLen, 0, NULL, -1, false);
}
}
#include "util.h"
#include "util_posix.h"
#include "iso14443crc.h"
-#include "data.h"
#include "proxmark3.h"
#include "ui.h"
#include "cmdparser.h"
#include <stdint.h>
#include "iso14443crc.h"
#include "proxmark3.h"
-#include "data.h"
#include "graph.h"
#include "util.h"
#include "ui.h"
#include <stdint.h>
#include "proxmark3.h"
-#include "data.h"
#include "graph.h"
#include "ui.h"
#include "util.h"
#include <sys/stat.h>
#include <ctype.h>
#include "iso14443crc.h" // Can also be used for iClass, using 0xE012 as CRC-type
-#include "data.h"
#include "proxmark3.h"
#include "ui.h"
#include "cmdparser.h"
blocksRead = (sizeof(tag_data)/8) - blockno;
}
// response ok - now get bigbuf content of the dump
- GetFromBigBuf(tag_data+(blockno*8), blocksRead*8, startindex);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(tag_data+(blockno*8), blocksRead*8, startindex, NULL, -1, false);
size_t gotBytes = blocksRead*8 + blockno*8;
// try AA2
blocksRead = (sizeof(tag_data) - gotBytes)/8;
}
// get dumped data from bigbuf
- GetFromBigBuf(tag_data+gotBytes, blocksRead*8, startindex);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(tag_data+gotBytes, blocksRead*8, startindex, NULL, -1, false);
gotBytes += blocksRead*8;
} else { //field is still on - turn it off...
#include <string.h>
#include <inttypes.h>
#include "proxmark3.h"
-#include "data.h"
#include "ui.h"
#include "cmdparser.h"
#include "cmdhflegic.h"
char token_type[4];
// copy data from proxmark into buffer
- GetFromBigBuf(data_buf,sizeof(data_buf),0);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(data_buf, sizeof(data_buf), 0, NULL, -1, false);
// Output CDF System area (9 bytes) plus remaining header area (12 bytes)
return -1;
}
- GetFromBigBuf(got,requested,offset);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(got, requested, offset, NULL, -1, false);
for (int j = 0; j < requested; j += 8) {
fprintf(f, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
#include <stdint.h>
#include <stdbool.h>
#include "util.h"
-#include "data.h"
#include "ui.h"
#include "iso14443crc.h"
#include "parity.h"
#include "mifare.h"
#include "util.h"
#include "protocols.h"
-#include "data.h"
#define MAX_UL_BLOCKS 0x0f
#define MAX_ULC_BLOCKS 0x2b
PrintAndLog("Data exceeded Buffer size!");
bufferSize = sizeof(data);
}
- GetFromBigBuf(data, bufferSize, startindex);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(data, bufferSize, startindex, NULL, -1, false);
Pages = bufferSize/4;
// Load lock bytes.
#include "cmdhw.h"
#include "cmdmain.h"
#include "cmddata.h"
-#include "data.h"
/* low-level hardware control */
int CmdStatus(const char *Cmd)
{
- uint8_t speed_test_buffer[USB_CMD_DATA_SIZE];
- sample_buf = speed_test_buffer;
-
clearCommandBuffer();
UsbCommand c = {CMD_STATUS};
SendCommand(&c);
- if (!WaitForResponseTimeout(CMD_ACK,&c,1900)) {
+ if (!WaitForResponseTimeout(CMD_ACK, &c, 1900)) {
PrintAndLog("Status command failed. USB Speed Test timed out");
}
return 0;
#include "graph.h" // for graph data
#include "cmdparser.h" // for getting cli commands included in cmdmain.h
#include "cmdmain.h" // for sending cmds to device
-#include "data.h" // for GetFromBigBuf
#include "cmddata.h" // for `lf search`
#include "cmdlfawid.h" // for awid menu
#include "cmdlfem4x.h" // for em4x menu
#include "proxmark3.h"
#include "ui.h"
#include "cmddata.h"
-#include "data.h"
#include "cmdlfcotag.h"
#include "lfdemod.h"
#include "usb_cmd.h"
getSamples(0, true); break;
}
case 1: {
- GetFromBigBuf(DemodBuffer, COTAG_BITS, 0);
- DemodBufferLen = COTAG_BITS;
UsbCommand response;
- if ( !WaitForResponseTimeout(CMD_ACK, &response, 1000) ) {
+ DemodBufferLen = COTAG_BITS;
+ if (!GetFromBigBuf(DemodBuffer, COTAG_BITS, 0, &response, 1000, true)) {
PrintAndLog("timeout while waiting for reply.");
return -1;
}
#include "proxmark3.h"
#include "ui.h"
#include "util.h"
-#include "data.h"
#include "graph.h"
#include "cmdparser.h"
#include "cmddata.h"
bool downloadSamplesEM() {
// 8 bit preamble + 32 bit word response (max clock (128) * 40bits = 5120 samples)
uint8_t got[6000];
- GetFromBigBuf(got, sizeof(got), 0);
- if ( !WaitForResponseTimeout(CMD_ACK, NULL, 4000) ) {
+ if (!GetFromBigBuf(got, sizeof(got), 0, NULL, 4000, true)) {
PrintAndLog("command execution time out");
return false;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "data.h"
#include "proxmark3.h"
#include "ui.h"
#include "cmdparser.h"
// Query for the actual size of the trace
UsbCommand response;
- GetFromBigBuf(got, USB_CMD_DATA_SIZE, 0);
- WaitForResponse(CMD_ACK, &response);
+ GetFromBigBuf(got, USB_CMD_DATA_SIZE, 0, &response, -1, false);
uint16_t traceLen = response.arg[2];
if (traceLen > USB_CMD_DATA_SIZE) {
uint8_t *p = realloc(got, traceLen);
return 2;
}
got = p;
- GetFromBigBuf(got, traceLen, 0);
- WaitForResponse(CMD_ACK,NULL);
+ GetFromBigBuf(got, traceLen, 0, NULL, -1, false);
}
PrintAndLog("recorded activity (TraceLen = %d bytes):");
#include <limits.h>
#include "cmdlfio.h"
#include "proxmark3.h"
-#include "data.h"
#include "graph.h"
#include "ui.h"
#include "cmdparser.h"
#include "cmdlf.h"\r
#include "cmdlft55xx.h"\r
#include "util.h"\r
-#include "data.h"\r
#include "lfdemod.h"\r
#include "cmdhf14a.h" //for getTagInfo\r
#include "protocols.h"\r
}\r
\r
uint8_t got[BIGBUF_SIZE-1];\r
- GetFromBigBuf(got,sizeof(got),0);\r
- WaitForResponse(CMD_ACK,NULL);\r
+ GetFromBigBuf(got, sizeof(got), 0, NULL, -1 , 0);\r
setGraphBuf(got, sizeof(got));\r
return 1;\r
}\r
// Low frequency TI commands
//-----------------------------------------------------------------------------
+#include "cmdlfti.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "crc16.h"
#include "proxmark3.h"
-#include "data.h"
#include "ui.h"
#include "graph.h"
#include "cmdparser.h"
-#include "cmdlfti.h"
+#include "util.h"
static int CmdHelp(const char *Cmd);
#include <string.h>
#include "cmdparser.h"
#include "proxmark3.h"
-#include "data.h"
#include "usb_cmd.h"
#include "ui.h"
#include "cmdhf.h"
#include "proxmark3.h"
#include "scripting.h"
-#include "data.h"
#include "ui.h"
#include "graph.h"
#include "cmdparser.h"
#include "uart.h"
#include "ui.h"
#include "common.h"
-#include "data.h"
#include "util_posix.h"
// Declare globals.
}
+//----------------------------------------------------------------------------------
+// Entry point into our code: called whenever we received a packet over USB.
+// Handle debug commands directly, store all other commands in circular buffer.
+//----------------------------------------------------------------------------------
static void UsbCommandReceived(UsbCommand *UC)
{
switch(UC->cmd) {
return;
} break;
- case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K: {
- // FIXME: This does unsanitised copies into memory when we don't know
- // the size of the buffer.
- memcpy(sample_buf+(UC->arg[0]),UC->d.asBytes,UC->arg[1]);
- return;
- } break;
-
default:
storeCommand(UC);
break;
}
+
+/**
+ * Data transfer from Proxmark to client. This method times out after
+ * ms_timeout milliseconds.
+ * @brief GetFromBigBuf
+ * @param dest Destination address for transfer
+ * @param bytes number of bytes to be transferred
+ * @param start_index offset into Proxmark3 BigBuf[]
+ * @param response struct to copy last command (CMD_ACK) into
+ * @param ms_timeout timeout in milliseconds
+ * @param show_warning display message after 2 seconds
+ * @return true if command was returned, otherwise false
+ */
+bool GetFromBigBuf(uint8_t *dest, int bytes, int start_index, UsbCommand *response, size_t ms_timeout, bool show_warning)
+{
+ UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}};
+ SendCommand(&c);
+
+ uint64_t start_time = msclock();
+
+ UsbCommand resp;
+ if (response == NULL) {
+ response = &resp;
+ }
+
+ int bytes_completed = 0;
+ while(true) {
+ if (getCommand(response)) {
+ if (response->cmd == CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {
+ int copy_bytes = MIN(bytes - bytes_completed, response->arg[1]);
+ memcpy(dest + response->arg[0], response->d.asBytes, copy_bytes);
+ bytes_completed += copy_bytes;
+ } else if (response->cmd == CMD_ACK) {
+ return true;
+ }
+ }
+
+ if (msclock() - start_time > ms_timeout) {
+ break;
+ }
+
+ if (msclock() - start_time > 2000 && show_warning) {
+ PrintAndLog("Waiting for a response from the proxmark...");
+ PrintAndLog("You can cancel this operation by pressing the pm3 button");
+ show_warning = false;
+ }
+ }
+
+ return false;
+}
+
+
/**
* Waits for a certain response type. This method waits for a maximum of
* ms_timeout milliseconds for a specified response command.
* @param cmd command to wait for, or CMD_UNKNOWN to take any command.
* @param response struct to copy received command into.
* @param ms_timeout
- * @param show_warning
+ * @param show_warning display message after 2 seconds
* @return true if command was returned, otherwise false
*/
bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand* response, size_t ms_timeout, bool show_warning) {
bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand* response, size_t ms_timeout, bool show_warning);
bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout);
bool WaitForResponse(uint32_t cmd, UsbCommand* response);
+bool GetFromBigBuf(uint8_t *dest, int bytes, int start_index, UsbCommand *response, size_t ms_timeout, bool show_warning);
#endif // COMMS_H_
+++ /dev/null
-//-----------------------------------------------------------------------------
-// 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 utilities
-//-----------------------------------------------------------------------------
-
-#include <string.h>
-#include <stdint.h>
-#include "data.h"
-#include "ui.h"
-#include "proxmark3.h"
-#include "cmdmain.h"
-
-uint8_t* sample_buf;
-
-void GetFromBigBuf(uint8_t *dest, int bytes, int start_index)
-{
- sample_buf = dest;
- UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}};
- SendCommand(&c);
-}
+++ /dev/null
-//-----------------------------------------------------------------------------
-// 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 utilities
-//-----------------------------------------------------------------------------
-
-#ifndef DATA_H__
-#define DATA_H__
-
-#include <stdint.h>
-
-#define FILE_PATH_SIZE 1000
-
-extern uint8_t* sample_buf;
-#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
-
-void GetFromBigBuf(uint8_t *dest, int bytes, int start_index);
-
-#endif
\r
#include <stdint.h>\r
#include <stdbool.h>\r
-#include "data.h"\r
#include "crapto1/crapto1.h"\r
+#include "util.h"\r
\r
// defaults\r
// timeout in units. (ms * 106)/10 or us*0.0106\r
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
-#include "data.h"
#ifdef _WIN32
#include <windows.h>
#ifndef MAX
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
+#ifndef arraylen
+#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
+#endif
#define EVEN 0
#define ODD 1
+#ifndef FILE_PATH_SIZE
+#define FILE_PATH_SIZE 2000
+#endif
+
extern int ukbhit(void);
extern void AddLogLine(char *fileName, char *extData, char *c);