mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Merge branch 'master' into allin
update
This commit is contained in:
commit
d6471f2231
5 changed files with 97 additions and 39 deletions
|
@ -46,6 +46,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "ticks.h"
|
#include "ticks.h"
|
||||||
#include "commonutil.h"
|
#include "commonutil.h"
|
||||||
|
#include "crc16.h"
|
||||||
|
|
||||||
#ifdef WITH_LCD
|
#ifdef WITH_LCD
|
||||||
#include "LCD.h"
|
#include "LCD.h"
|
||||||
|
@ -1654,13 +1655,44 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
}
|
}
|
||||||
case CMD_SMART_UPLOAD: {
|
case CMD_SMART_UPLOAD: {
|
||||||
// upload file from client
|
// upload file from client
|
||||||
|
struct p {
|
||||||
|
uint32_t idx;
|
||||||
|
uint32_t bytes_in_packet;
|
||||||
|
uint16_t crc;
|
||||||
|
uint8_t data[400];
|
||||||
|
} PACKED;
|
||||||
|
struct p *payload = (struct p *)packet->data.asBytes;
|
||||||
uint8_t *mem = BigBuf_get_addr();
|
uint8_t *mem = BigBuf_get_addr();
|
||||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, PM3_CMD_DATA_SIZE);
|
memcpy(mem + payload->idx, payload->data, payload->bytes_in_packet);
|
||||||
reply_mix(CMD_ACK, 1, 0, 0, 0, 0);
|
|
||||||
|
uint8_t a = 0, b = 0;
|
||||||
|
compute_crc(CRC_14443_A, mem + payload->idx, payload->bytes_in_packet, &a, &b);
|
||||||
|
int res = PM3_SUCCESS;
|
||||||
|
if (payload->crc != (a << 8 | b)) {
|
||||||
|
DbpString("CRC Failed");
|
||||||
|
res = PM3_ESOFT;
|
||||||
|
}
|
||||||
|
reply_ng(CMD_SMART_UPLOAD, res, NULL, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_SMART_UPGRADE: {
|
case CMD_SMART_UPGRADE: {
|
||||||
SmartCardUpgrade(packet->oldarg[0]);
|
struct p {
|
||||||
|
uint16_t fw_size;
|
||||||
|
uint16_t crc;
|
||||||
|
} PACKED;
|
||||||
|
struct p *payload = (struct p *)packet->data.asBytes;
|
||||||
|
|
||||||
|
uint8_t *fwdata = BigBuf_get_addr();
|
||||||
|
uint8_t a = 0, b = 0;
|
||||||
|
compute_crc(CRC_14443_A, fwdata, payload->fw_size, &a, &b);
|
||||||
|
|
||||||
|
if (payload->crc != (a << 8 | b)) {
|
||||||
|
Dbprintf("CRC Failed, 0x[%04x] != 0x[%02x%02x]", payload->crc, a, b);
|
||||||
|
reply_ng(CMD_SMART_UPGRADE, PM3_ESOFT, NULL, 0);
|
||||||
|
} else {
|
||||||
|
SmartCardUpgrade(payload->fw_size);
|
||||||
|
}
|
||||||
|
fwdata = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -219,7 +219,7 @@ static bool I2C_WaitForSim(void) {
|
||||||
// 8051 speaks with smart card.
|
// 8051 speaks with smart card.
|
||||||
// 1000*50*3.07 = 153.5ms
|
// 1000*50*3.07 = 153.5ms
|
||||||
// 1byte transfer == 1ms with max frame being 256bytes
|
// 1byte transfer == 1ms with max frame being 256bytes
|
||||||
if (!WaitSCL_H_delay(20 * 1000 * 50))
|
if (!WaitSCL_H_delay(10 * 1000 * 50))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -807,7 +807,7 @@ void SmartCardUpgrade(uint64_t arg0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// writing takes time.
|
// writing takes time.
|
||||||
WaitMS(100);
|
WaitMS(50);
|
||||||
|
|
||||||
// read
|
// read
|
||||||
res = I2C_ReadFW(verfiydata, size, msb, lsb, I2C_DEVICE_ADDRESS_BOOT);
|
res = I2C_ReadFW(verfiydata, size, msb, lsb, I2C_DEVICE_ADDRESS_BOOT);
|
||||||
|
@ -827,7 +827,8 @@ void SmartCardUpgrade(uint64_t arg0) {
|
||||||
length -= size;
|
length -= size;
|
||||||
pos += size;
|
pos += size;
|
||||||
}
|
}
|
||||||
reply_mix(CMD_ACK, isOK, pos, 0, 0, 0);
|
|
||||||
|
reply_ng(CMD_SMART_UPGRADE, (isOK) ? PM3_SUCCESS : PM3_ESOFT, NULL, 0);
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ add_library(pm3rrg_rdv4 SHARED
|
||||||
${PM3_ROOT}/client/src/cmdlfcotag.c
|
${PM3_ROOT}/client/src/cmdlfcotag.c
|
||||||
${PM3_ROOT}/client/src/cmdlfdestron.c
|
${PM3_ROOT}/client/src/cmdlfdestron.c
|
||||||
${PM3_ROOT}/client/src/cmdlfem4x.c
|
${PM3_ROOT}/client/src/cmdlfem4x.c
|
||||||
|
${PM3_ROOT}/client/src/cmdlfem4x05.c
|
||||||
${PM3_ROOT}/client/src/cmdlfem4x50.c
|
${PM3_ROOT}/client/src/cmdlfem4x50.c
|
||||||
${PM3_ROOT}/client/src/cmdlffdxb.c
|
${PM3_ROOT}/client/src/cmdlffdxb.c
|
||||||
${PM3_ROOT}/client/src/cmdlfgallagher.c
|
${PM3_ROOT}/client/src/cmdlfgallagher.c
|
||||||
|
@ -150,7 +151,6 @@ add_library(pm3rrg_rdv4 SHARED
|
||||||
${PM3_ROOT}/client/src/cmdlfsecurakey.c
|
${PM3_ROOT}/client/src/cmdlfsecurakey.c
|
||||||
${PM3_ROOT}/client/src/cmdlft55xx.c
|
${PM3_ROOT}/client/src/cmdlft55xx.c
|
||||||
${PM3_ROOT}/client/src/cmdlfti.c
|
${PM3_ROOT}/client/src/cmdlfti.c
|
||||||
${PM3_ROOT}/client/src/cmdlfverichip.c
|
|
||||||
${PM3_ROOT}/client/src/cmdlfviking.c
|
${PM3_ROOT}/client/src/cmdlfviking.c
|
||||||
${PM3_ROOT}/client/src/cmdlfvisa2000.c
|
${PM3_ROOT}/client/src/cmdlfvisa2000.c
|
||||||
${PM3_ROOT}/client/src/cmdmain.c
|
${PM3_ROOT}/client/src/cmdmain.c
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
static char *g_android_executable_directory = NULL;
|
static char *g_android_executable_directory = NULL;
|
||||||
static char *g_android_user_directory = NULL;
|
static char *g_android_user_directory = NULL;
|
||||||
|
|
||||||
char version_information[] = {"ANDROID_LIBRARY 1.4.6 build by DXL"};
|
char version_information[] = {""};
|
||||||
|
|
||||||
const char *get_my_executable_directory(void) {
|
const char *get_my_executable_directory(void) {
|
||||||
if (g_android_executable_directory == NULL) {
|
if (g_android_executable_directory == NULL) {
|
||||||
|
@ -86,7 +86,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
||||||
char *cmd = (char *)((*env)->GetStringUTFChars(env, cmd_, 0));
|
char *cmd = (char *) ((*env)->GetStringUTFChars(env, cmd_, 0));
|
||||||
int ret = CommandReceived(cmd);
|
int ret = CommandReceived(cmd);
|
||||||
if (ret == 99) {
|
if (ret == 99) {
|
||||||
// exit / quit
|
// exit / quit
|
||||||
|
@ -102,7 +102,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||||
* Is client running!
|
* Is client running!
|
||||||
* */
|
* */
|
||||||
jboolean IsClientRunning(JNIEnv *env, jobject instance) {
|
jboolean IsClientRunning(JNIEnv *env, jobject instance) {
|
||||||
return (jboolean)((jboolean) conn.run);
|
return (jboolean) ((jboolean) conn.run);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -114,7 +114,7 @@ jboolean TestPm3(JNIEnv *env, jobject instance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ret = (TestProxmark() == PM3_SUCCESS);
|
bool ret = (TestProxmark() == PM3_SUCCESS);
|
||||||
return (jboolean)(ret);
|
return (jboolean) (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,18 +141,18 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
}
|
}
|
||||||
jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4");
|
jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4");
|
||||||
JNINativeMethod methods[] = {
|
JNINativeMethod methods[] = {
|
||||||
{"startExecute", "(Ljava/lang/String;)I", (void *) Console},
|
{"startExecute", "(Ljava/lang/String;)I", (void *) Console},
|
||||||
{"stopExecute", "()V", (void *) ClosePm3},
|
{"stopExecute", "()V", (void *) ClosePm3},
|
||||||
{"isExecuting", "()Z", (void *) IsClientRunning}
|
{"isExecuting", "()Z", (void *) IsClientRunning}
|
||||||
};
|
};
|
||||||
|
|
||||||
JNINativeMethod methods1[] = {
|
JNINativeMethod methods1[] = {
|
||||||
{"testPm3", "()Z", (void *) TestPm3},
|
{"testPm3", "()Z", (void *) TestPm3},
|
||||||
{"closePm3", "()V", ClosePm3}
|
{"closePm3", "()V", ClosePm3}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) !=
|
if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) !=
|
||||||
JNI_OK) {
|
JNI_OK) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
// Proxmark3 RDV40 Smartcard module commands
|
// Proxmark3 RDV40 Smartcard module commands
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "cmdsmartcard.h"
|
#include "cmdsmartcard.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "cmdparser.h" // command_t
|
||||||
#include "cmdparser.h" // command_t
|
#include "commonutil.h" // ARRAYLEN
|
||||||
#include "commonutil.h" // ARRAYLEN
|
|
||||||
#include "protocols.h"
|
#include "protocols.h"
|
||||||
#include "cmdtrace.h"
|
#include "cmdtrace.h"
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
|
@ -23,6 +21,7 @@
|
||||||
#include "emv/dump.h"
|
#include "emv/dump.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
|
#include "crc16.h" // crc
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
|
@ -626,45 +625,72 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Sim module firmware uploading to PM3");
|
PrintAndLogEx(SUCCESS, "Sim module firmware uploading to PM3");
|
||||||
|
|
||||||
|
PacketResponseNG resp;
|
||||||
|
|
||||||
//Send to device
|
//Send to device
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
uint32_t bytes_sent = 0;
|
uint32_t bytes_sent = 0;
|
||||||
uint32_t bytes_remaining = firmware_size;
|
uint32_t bytes_remaining = firmware_size;
|
||||||
|
|
||||||
// fast push mode
|
|
||||||
conn.block_after_ACK = true;
|
|
||||||
|
|
||||||
while (bytes_remaining > 0) {
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
|
||||||
if (bytes_in_packet == bytes_remaining) {
|
struct {
|
||||||
// Disable fast mode on last packet
|
uint32_t idx;
|
||||||
conn.block_after_ACK = false;
|
uint32_t bytes_in_packet;
|
||||||
}
|
uint16_t crc;
|
||||||
|
uint8_t data[400];
|
||||||
|
} PACKED upload;
|
||||||
|
|
||||||
|
uint32_t bytes_in_packet = MIN(sizeof(upload.data), bytes_remaining);
|
||||||
|
|
||||||
|
upload.idx = index + bytes_sent;
|
||||||
|
upload.bytes_in_packet = bytes_in_packet;
|
||||||
|
memcpy(upload.data, firmware + bytes_sent, bytes_in_packet);
|
||||||
|
|
||||||
|
uint8_t a = 0, b = 0;
|
||||||
|
compute_crc(CRC_14443_A, upload.data, bytes_in_packet, &a, &b);
|
||||||
|
upload.crc = (a << 8 | b);
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_SMART_UPLOAD, index + bytes_sent, bytes_in_packet, 0, firmware + bytes_sent, bytes_in_packet);
|
SendCommandNG(CMD_SMART_UPLOAD, (uint8_t *)&upload, sizeof(upload));
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2000)) {
|
if (!WaitForResponseTimeout(CMD_SMART_UPLOAD, &resp, 2000)) {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||||
free(firmware);
|
free(firmware);
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resp.status != PM3_SUCCESS) {
|
||||||
|
PrintAndLogEx(WARNING, "uploading to device failed");
|
||||||
|
free(firmware);
|
||||||
|
return resp.status;
|
||||||
|
}
|
||||||
bytes_remaining -= bytes_in_packet;
|
bytes_remaining -= bytes_in_packet;
|
||||||
bytes_sent += bytes_in_packet;
|
bytes_sent += bytes_in_packet;
|
||||||
PrintAndLogEx(INPLACE, "%d bytes sent", bytes_sent);
|
PrintAndLogEx(INPLACE, "%d bytes sent", bytes_sent);
|
||||||
}
|
}
|
||||||
free(firmware);
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(SUCCESS, "Sim module firmware updating, don\'t turn off your PM3!");
|
PrintAndLogEx(SUCCESS, "Sim module firmware updating, don\'t turn off your PM3!");
|
||||||
|
|
||||||
// trigger the firmware upgrade
|
// trigger the firmware upgrade
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_SMART_UPGRADE, firmware_size, 0, 0, NULL, 0);
|
struct {
|
||||||
PacketResponseNG resp;
|
uint16_t fw_size;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
uint16_t crc;
|
||||||
|
} PACKED payload;
|
||||||
|
payload.fw_size = firmware_size;
|
||||||
|
|
||||||
|
uint8_t a = 0, b = 0;
|
||||||
|
compute_crc(CRC_14443_A, firmware, firmware_size, &a, &b);
|
||||||
|
payload.crc = (a << 8 | b);
|
||||||
|
|
||||||
|
free(firmware);
|
||||||
|
SendCommandNG(CMD_SMART_UPGRADE, (uint8_t *)&payload, sizeof(payload));
|
||||||
|
if (!WaitForResponseTimeout(CMD_SMART_UPGRADE, &resp, 2500)) {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
if ((resp.oldarg[0] & 0xFF)) {
|
|
||||||
|
if (resp.status == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(SUCCESS, "Sim module firmware upgrade " _GREEN_("successful"));
|
PrintAndLogEx(SUCCESS, "Sim module firmware upgrade " _GREEN_("successful"));
|
||||||
PrintAndLogEx(HINT, "run " _YELLOW_("`hw status`") " to validate the fw version ");
|
PrintAndLogEx(HINT, "run " _YELLOW_("`hw status`") " to validate the fw version ");
|
||||||
} else {
|
} else {
|
||||||
|
@ -814,7 +840,6 @@ static int CmdSmartSetClock(const char *Cmd) {
|
||||||
struct {
|
struct {
|
||||||
uint32_t new_clk;
|
uint32_t new_clk;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
|
|
||||||
payload.new_clk = new_clk;
|
payload.new_clk = new_clk;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue