mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
make style
This commit is contained in:
parent
5cca8616cb
commit
182f239d21
7 changed files with 82 additions and 82 deletions
|
@ -1374,7 +1374,7 @@ int doIClassSimulation(int simulationMode, uint8_t *reader_mac_buf) {
|
||||||
// Use application data from block 5
|
// Use application data from block 5
|
||||||
memcpy(aia_data, emulator + (8 * 5), 8);
|
memcpy(aia_data, emulator + (8 * 5), 8);
|
||||||
|
|
||||||
// older 2K / 16K tags has its application issuer data on block 2
|
// older 2K / 16K tags has its application issuer data on block 2
|
||||||
}
|
}
|
||||||
AddCrc(aia_data, 8);
|
AddCrc(aia_data, 8);
|
||||||
|
|
||||||
|
|
|
@ -1101,13 +1101,13 @@ void CmdASKsimTAG(uint8_t encoding, uint8_t invert, uint8_t separator, uint8_t c
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
Dbprintf("Simulating with clk: %d, invert: %d, encoding: %s (%d), separator: %d, n: %d"
|
Dbprintf("Simulating with clk: %d, invert: %d, encoding: %s (%d), separator: %d, n: %d"
|
||||||
, clk
|
, clk
|
||||||
, invert
|
, invert
|
||||||
, (encoding == 2) ? "BI" : (encoding == 1) ? "ASK" : "RAW"
|
, (encoding == 2) ? "BI" : (encoding == 1) ? "ASK" : "RAW"
|
||||||
, encoding
|
, encoding
|
||||||
, separator
|
, separator
|
||||||
, n
|
, n
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ledcontrol) LED_A_ON();
|
if (ledcontrol) LED_A_ON();
|
||||||
SimulateTagLowFrequency(n, 0, ledcontrol);
|
SimulateTagLowFrequency(n, 0, ledcontrol);
|
||||||
|
|
|
@ -2176,7 +2176,7 @@ void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tear-off attack against MFU.
|
// Tear-off attack against MFU.
|
||||||
// - Mobius et al
|
// - Moebius et al
|
||||||
void MifareU_Otp_Tearoff() {
|
void MifareU_Otp_Tearoff() {
|
||||||
|
|
||||||
// should the
|
// should the
|
||||||
|
@ -2184,8 +2184,8 @@ void MifareU_Otp_Tearoff() {
|
||||||
// optional authentication before?
|
// optional authentication before?
|
||||||
// optional data to be written?
|
// optional data to be written?
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_ERROR) DbpString("Preparing OTP tear-off");
|
if (DBGLEVEL >= DBG_ERROR) DbpString("Preparing OTP tear-off");
|
||||||
|
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||||
clear_trace();
|
clear_trace();
|
||||||
|
@ -2197,17 +2197,17 @@ void MifareU_Otp_Tearoff() {
|
||||||
#define OTP_BLK_NO 3
|
#define OTP_BLK_NO 3
|
||||||
|
|
||||||
// write cmd to send, include CRC
|
// write cmd to send, include CRC
|
||||||
// 1b write, 1b block, 4b data, 2 crc
|
// 1b write, 1b block, 4b data, 2 crc
|
||||||
uint8_t cmd[] = {MIFARE_ULC_WRITE, OTP_BLK_NO, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0};
|
uint8_t cmd[] = {MIFARE_ULC_WRITE, OTP_BLK_NO, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0};
|
||||||
|
|
||||||
// User specific data to write?
|
// User specific data to write?
|
||||||
// memcpy(block + 2, blockData, 4);
|
// memcpy(block + 2, blockData, 4);
|
||||||
|
|
||||||
AddCrc14A(cmd, sizeof(cmd) - 2);
|
AddCrc14A(cmd, sizeof(cmd) - 2);
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_ERROR) DbpString("Transmitting");
|
if (DBGLEVEL >= DBG_ERROR) DbpString("Transmitting");
|
||||||
|
|
||||||
// anticollision / select card
|
// anticollision / select card
|
||||||
if (!iso14443a_select_card(NULL, NULL, NULL, true, 0, true)) {
|
if (!iso14443a_select_card(NULL, NULL, NULL, true, 0, true)) {
|
||||||
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Can't select card");
|
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Can't select card");
|
||||||
OnError(1);
|
OnError(1);
|
||||||
|
@ -2225,18 +2225,18 @@ void MifareU_Otp_Tearoff() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// send
|
// send
|
||||||
ReaderTransmit(cmd, sizeof(cmd), NULL);
|
ReaderTransmit(cmd, sizeof(cmd), NULL);
|
||||||
|
|
||||||
// Wait before cutting power. aka tear-off
|
// Wait before cutting power. aka tear-off
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
WaitUS(OTP_TEAR_OFF_TIME);
|
WaitUS(OTP_TEAR_OFF_TIME);
|
||||||
switch_off();
|
switch_off();
|
||||||
|
|
||||||
reply_ng(CMD_HF_MFU_OTP_TEAROFF, PM3_SUCCESS, NULL, 0);
|
reply_ng(CMD_HF_MFU_OTP_TEAROFF, PM3_SUCCESS, NULL, 0);
|
||||||
StopTicks();
|
StopTicks();
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_ERROR) DbpString("Done");
|
if (DBGLEVEL >= DBG_ERROR) DbpString("Done");
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,13 +70,13 @@ json_t *AIDSearchGetElm(json_t *root, int elmindx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int AIDSearchFree(json_t *root) {
|
int AIDSearchFree(json_t *root) {
|
||||||
|
|
||||||
return closeAIDFile(root);
|
return closeAIDFile(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * jsonStrGet(json_t *data, char *name) {
|
const char *jsonStrGet(json_t *data, char *name) {
|
||||||
json_t *jstr;
|
json_t *jstr;
|
||||||
|
|
||||||
jstr = json_object_get(data, name);
|
jstr = json_object_get(data, name);
|
||||||
if (jstr == NULL)
|
if (jstr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -94,11 +94,11 @@ const char * jsonStrGet(json_t *data, char *name) {
|
||||||
bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
||||||
if (strcmp(aidlarge, aidsmall) == 0)
|
if (strcmp(aidlarge, aidsmall) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (strlen(aidlarge) > strlen(aidsmall))
|
if (strlen(aidlarge) > strlen(aidsmall))
|
||||||
if (strncmp(aidlarge, aidsmall, strlen(aidsmall)) == 0)
|
if (strncmp(aidlarge, aidsmall, strlen(aidsmall)) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen) {
|
||||||
const char *hexaid = jsonStrGet(data, "AID");
|
const char *hexaid = jsonStrGet(data, "AID");
|
||||||
if (hexaid == NULL || strlen(hexaid) == 0)
|
if (hexaid == NULL || strlen(hexaid) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int res = param_gethex_to_eol(hexaid, 0, aid, aidmaxlen, aidlen);
|
int res = param_gethex_to_eol(hexaid, 0, aid, aidmaxlen, aidlen);
|
||||||
if (res)
|
if (res)
|
||||||
return false;
|
return false;
|
||||||
|
@ -117,13 +117,13 @@ bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen) {
|
||||||
|
|
||||||
int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
||||||
int retval = PM3_SUCCESS;
|
int retval = PM3_SUCCESS;
|
||||||
|
|
||||||
json_t *root = xroot;
|
json_t *root = xroot;
|
||||||
if (root == NULL)
|
if (root == NULL)
|
||||||
root = AIDSearchInit(verbose);
|
root = AIDSearchInit(verbose);
|
||||||
if (root == NULL)
|
if (root == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
json_t *elm = NULL;
|
json_t *elm = NULL;
|
||||||
int maxaidlen = 0;
|
int maxaidlen = 0;
|
||||||
for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
||||||
|
@ -138,10 +138,10 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elm == NULL)
|
if (elm == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
// print here
|
// print here
|
||||||
const char *vaid = jsonStrGet(elm, "AID");
|
const char *vaid = jsonStrGet(elm, "AID");
|
||||||
const char *vendor = jsonStrGet(elm, "Vendor");
|
const char *vendor = jsonStrGet(elm, "Vendor");
|
||||||
|
@ -167,7 +167,7 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
||||||
if (description)
|
if (description)
|
||||||
PrintAndLogEx(SUCCESS, "Description: %s", description);
|
PrintAndLogEx(SUCCESS, "Description: %s", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (xroot == NULL)
|
if (xroot == NULL)
|
||||||
AIDSearchFree(root);
|
AIDSearchFree(root);
|
||||||
|
|
|
@ -2753,33 +2753,33 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// MFU TearOff against OTP
|
// MFU TearOff against OTP
|
||||||
// Mobeius et al
|
// Moebius et al
|
||||||
//
|
//
|
||||||
static int CmdHF14AMfuOtpTearoff(const char *Cmd){
|
static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = 0;
|
bool errors = 0;
|
||||||
uint32_t len = strtol(Cmd, NULL, 0);
|
uint32_t len = strtol(Cmd, NULL, 0);
|
||||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
|
||||||
case 'h':
|
|
||||||
return usage_hf_mfu_otp_tearoff();
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errors) return usage_hf_mfu_otp_tearoff();
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
|
case 'h':
|
||||||
|
return usage_hf_mfu_otp_tearoff();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clearCommandBuffer();
|
if (errors) return usage_hf_mfu_otp_tearoff();
|
||||||
SendCommandNG(CMD_HF_MFU_OTP_TEAROFF, data, len);
|
|
||||||
PacketResponseNG resp;
|
clearCommandBuffer();
|
||||||
if (!WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 4000)) {
|
SendCommandNG(CMD_HF_MFU_OTP_TEAROFF, data, len);
|
||||||
PrintAndLogEx(WARNING, "Failed");
|
PacketResponseNG resp;
|
||||||
return PM3_ESOFT;
|
if (!WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 4000)) {
|
||||||
}
|
PrintAndLogEx(WARNING, "Failed");
|
||||||
return PM3_SUCCESS;
|
return PM3_ESOFT;
|
||||||
|
}
|
||||||
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
|
|
|
@ -121,7 +121,7 @@ static int CmdJablotronDemod(const char *Cmd) {
|
||||||
uint8_t chksum = raw2 & 0xFF;
|
uint8_t chksum = raw2 & 0xFF;
|
||||||
bool isok = (chksum == jablontron_chksum(DemodBuffer));
|
bool isok = (chksum == jablontron_chksum(DemodBuffer));
|
||||||
|
|
||||||
PrintAndLogEx( isok ? SUCCESS : INFO,
|
PrintAndLogEx(isok ? SUCCESS : INFO,
|
||||||
"Checksum: %02X [ %s]",
|
"Checksum: %02X [ %s]",
|
||||||
chksum,
|
chksum,
|
||||||
isok ? _GREEN_("OK") : _RED_("Fail")
|
isok ? _GREEN_("OK") : _RED_("Fail")
|
||||||
|
|
|
@ -314,44 +314,44 @@ static int l_GetFromFlashMemSpiffs(lua_State *L) {
|
||||||
|
|
||||||
if (IfPm3Flash()) {
|
if (IfPm3Flash()) {
|
||||||
uint32_t start_index = 0, len = 0x40000; //FLASH_MEM_MAX_SIZE
|
uint32_t start_index = 0, len = 0x40000; //FLASH_MEM_MAX_SIZE
|
||||||
char destfilename[32] = {0};
|
char destfilename[32] = {0};
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
int n = lua_gettop(L);
|
int n = lua_gettop(L);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return returnToLuaWithError(L, "You need to supply the destination filename");
|
return returnToLuaWithError(L, "You need to supply the destination filename");
|
||||||
|
|
||||||
if (n >= 1) {
|
if (n >= 1) {
|
||||||
const char *p_filename = luaL_checklstring(L, 1, &size);
|
const char *p_filename = luaL_checklstring(L, 1, &size);
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
memcpy(destfilename, p_filename, 31);
|
memcpy(destfilename, p_filename, 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destfilename[0] == '\0')
|
if (destfilename[0] == '\0')
|
||||||
return returnToLuaWithError(L, "Filename missing or invalid");
|
return returnToLuaWithError(L, "Filename missing or invalid");
|
||||||
|
|
||||||
// get size from spiffs itself !
|
// get size from spiffs itself !
|
||||||
SendCommandMIX(CMD_SPIFFS_STAT, 0, 0, 0, (uint8_t *)destfilename, 32);
|
SendCommandMIX(CMD_SPIFFS_STAT, 0, 0, 0, (uint8_t *)destfilename, 32);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000))
|
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000))
|
||||||
return returnToLuaWithError(L, "No response from the device");
|
return returnToLuaWithError(L, "No response from the device");
|
||||||
|
|
||||||
|
len = resp.oldarg[0];
|
||||||
|
|
||||||
len = resp.oldarg[0];
|
|
||||||
|
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return returnToLuaWithError(L, "Filename invalid or empty");
|
return returnToLuaWithError(L, "Filename invalid or empty");
|
||||||
|
|
||||||
uint8_t *data = calloc(len, sizeof(uint8_t));
|
uint8_t *data = calloc(len, sizeof(uint8_t));
|
||||||
if (!data)
|
if (!data)
|
||||||
return returnToLuaWithError(L, "Allocating memory failed");
|
return returnToLuaWithError(L, "Allocating memory failed");
|
||||||
|
|
||||||
if (!GetFromDevice(SPIFFS, data, len, start_index, (uint8_t *)destfilename, 32, NULL, -1, true)) {
|
if (!GetFromDevice(SPIFFS, data, len, start_index, (uint8_t *)destfilename, 32, NULL, -1, true)) {
|
||||||
free(data);
|
free(data);
|
||||||
return returnToLuaWithError(L, "ERROR; downloading from spiffs(flashmemory)");
|
return returnToLuaWithError(L, "ERROR; downloading from spiffs(flashmemory)");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushlstring(L, (const char *)data, len);
|
lua_pushlstring(L, (const char *)data, len);
|
||||||
lua_pushunsigned(L, len);
|
lua_pushunsigned(L, len);
|
||||||
free(data);
|
free(data);
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue