Merge pull request #24 from RfidResearchGroup/master

Update
This commit is contained in:
mwalker33 2019-10-27 11:11:46 +11:00 committed by GitHub
commit 9125024dbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 119 additions and 64 deletions

View file

@ -6,6 +6,8 @@
// Fonts for the LCD // Fonts for the LCD
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "fonts.h"
const char FONT6x8[97][8] = { const char FONT6x8[97][8] = {
{0x06, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00}, // columns, rows, bytes per char {0x06, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00}, // columns, rows, bytes per char
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // space {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // space

View file

@ -1,3 +1,4 @@
#include "hfsnoop.h"
#include "proxmark3_arm.h" #include "proxmark3_arm.h"
#include "BigBuf.h" #include "BigBuf.h"
#include "fpgaloader.h" #include "fpgaloader.h"

View file

@ -9,6 +9,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// LEGIC RF simulation code // LEGIC RF simulation code
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "legicrfsim.h"
#include "legicrf.h" #include "legicrf.h"
#include "crc.h" /* legic crc-4 */ #include "crc.h" /* legic crc-4 */

View file

@ -60,7 +60,7 @@ static uint64_t timeout_start_time;
static uint64_t last_packet_time; static uint64_t last_packet_time;
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd); static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
// Simple alias to track usages linked to the Bootloader, these commands must not be migrated. // Simple alias to track usages linked to the Bootloader, these commands must not be migrated.
// - commands sent to enter bootloader mode as we might have to talk to old firmwares // - commands sent to enter bootloader mode as we might have to talk to old firmwares
@ -778,30 +778,30 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
switch (memtype) { switch (memtype) {
case BIG_BUF: { case BIG_BUF: {
SendCommandMIX(CMD_DOWNLOAD_BIGBUF, start_index, bytes, 0, NULL, 0); SendCommandMIX(CMD_DOWNLOAD_BIGBUF, start_index, bytes, 0, NULL, 0);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_BIGBUF); return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_BIGBUF);
} }
case BIG_BUF_EML: { case BIG_BUF_EML: {
SendCommandMIX(CMD_DOWNLOAD_EML_BIGBUF, start_index, bytes, 0, NULL, 0); SendCommandMIX(CMD_DOWNLOAD_EML_BIGBUF, start_index, bytes, 0, NULL, 0);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_EML_BIGBUF); return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_EML_BIGBUF);
} }
case SPIFFS: { case SPIFFS: {
SendCommandMIX(CMD_SPIFFS_DOWNLOAD, start_index, bytes, 0, data, datalen); SendCommandMIX(CMD_SPIFFS_DOWNLOAD, start_index, bytes, 0, data, datalen);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_SPIFFS_DOWNLOADED); return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_SPIFFS_DOWNLOADED);
} }
case FLASH_MEM: { case FLASH_MEM: {
SendCommandMIX(CMD_FLASHMEM_DOWNLOAD, start_index, bytes, 0, NULL, 0); SendCommandMIX(CMD_FLASHMEM_DOWNLOAD, start_index, bytes, 0, NULL, 0);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED); return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED);
} }
case SIM_MEM: { case SIM_MEM: {
//SendCommandMIX(CMD_DOWNLOAD_SIM_MEM, start_index, bytes, 0, NULL, 0); //SendCommandMIX(CMD_DOWNLOAD_SIM_MEM, start_index, bytes, 0, NULL, 0);
//return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM); //return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM);
return false; return false;
} }
} }
return false; return false;
} }
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd) { static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd) {
uint32_t bytes_completed = 0; uint32_t bytes_completed = 0;
__atomic_store_n(&timeout_start_time, msclock(), __ATOMIC_SEQ_CST); __atomic_store_n(&timeout_start_time, msclock(), __ATOMIC_SEQ_CST);

View file

@ -1,3 +1,4 @@
#include "hash1_brute.h"
#include <stdio.h> #include <stdio.h>
#include "cipherutils.h" #include "cipherutils.h"
#include <stdint.h> #include <stdint.h>
@ -54,7 +55,7 @@ static void calc_score(uint8_t *csn, uint8_t *k) {
} }
} }
static void brute_hash1(void) { void brute_hash1(void) {
uint16_t a, b, c, d; uint16_t a, b, c, d;
uint8_t csn[8] = {0, 0, 0, 0, 0xf7, 0xff, 0x12, 0xe0}; uint8_t csn[8] = {0, 0, 0, 0, 0xf7, 0xff, 0x12, 0xe0};
uint8_t k[8] = {0, 0, 0, 0, 0, 0, 0, 0}; uint8_t k[8] = {0, 0, 0, 0, 0, 0, 0, 0};

View file

@ -422,7 +422,7 @@ typedef struct {
uint8_t div_key[8]; uint8_t div_key[8];
} Testcase; } Testcase;
static int testDES(Testcase testcase, mbedtls_des_context ctx_enc, mbedtls_des_context ctx_dec) { static int testDES(Testcase testcase) {
uint8_t des_encrypted_csn[8] = {0}; uint8_t des_encrypted_csn[8] = {0};
uint8_t decrypted[8] = {0}; uint8_t decrypted[8] = {0};
uint8_t div_key[8] = {0}; uint8_t div_key[8] = {0};
@ -562,7 +562,7 @@ static int testKeyDiversificationWithMasterkeyTestcases() {
PrintAndLogEx(INFO, "Testing encryption/decryption"); PrintAndLogEx(INFO, "Testing encryption/decryption");
for (i = 0; memcmp(testcases + i, empty, 8); i++) for (i = 0; memcmp(testcases + i, empty, 8); i++)
error += testDES(testcases[i], ctx_enc, ctx_dec); error += testDES(testcases[i]);
if (error) if (error)
PrintAndLogEx(FAILED, "%d errors occurred (%d testcases)", error, i); PrintAndLogEx(FAILED, "%d errors occurred (%d testcases)", error, i);

View file

@ -90,7 +90,7 @@ static FILE *current_cmdscriptfile() {
return cmdscriptfile[cmdscriptfile_idx]; return cmdscriptfile[cmdscriptfile_idx];
} }
bool pop_cmdscriptfile() { static bool pop_cmdscriptfile() {
fclose(cmdscriptfile[cmdscriptfile_idx]); fclose(cmdscriptfile[cmdscriptfile_idx]);
cmdscriptfile[cmdscriptfile_idx--] = NULL; cmdscriptfile[cmdscriptfile_idx--] = NULL;
if (cmdscriptfile_idx == 0) if (cmdscriptfile_idx == 0)
@ -151,7 +151,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
// loops every time enter is pressed... // loops every time enter is pressed...
while (1) { while (1) {
bool printprompt = false; bool printprompt = false;
char *prompt = PROXPROMPT; const char *prompt = PROXPROMPT;
check_script: check_script:
// If there is a script file // If there is a script file
@ -321,7 +321,7 @@ static void set_my_executable_path(void) {
} }
} }
static char *my_user_directory = NULL; static const char *my_user_directory = NULL;
const char *get_my_user_directory(void) { const char *get_my_user_directory(void) {
return my_user_directory; return my_user_directory;
@ -473,10 +473,15 @@ finish2:
// Check if windows AnsiColor Support is enabled in the registery // Check if windows AnsiColor Support is enabled in the registery
// [HKEY_CURRENT_USER\Console] // [HKEY_CURRENT_USER\Console]
// "VirtualTerminalLevel"=dword:00000001 // "VirtualTerminalLevel"=dword:00000001
// 2nd Key needs to be enabled... This key takes the console out of legacy mode.
// [HKEY_CURRENT_USER\Console]
// "ForceV2"=dword:00000001
static bool DetectWindowsAnsiSupport(void) { static bool DetectWindowsAnsiSupport(void) {
bool ret = false; bool ret = false;
#if defined(_WIN32) #if defined(_WIN32)
HKEY hKey = NULL; HKEY hKey = NULL;
bool virtualTerminalLevelSet = false;
bool forceV2Set = false;
if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) { if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) {
DWORD dwType = REG_SZ; DWORD dwType = REG_SZ;
@ -490,11 +495,31 @@ static bool DetectWindowsAnsiSupport(void) {
Data += KeyValue[i] << (8 * i); Data += KeyValue[i] << (8 * i);
if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled
ret = true; virtualTerminalLevelSet = true;
} }
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) {
DWORD dwType = REG_SZ;
BYTE KeyValue[sizeof(dwType)];
DWORD len = sizeof(KeyValue);
if (RegQueryValueEx(hKey, "ForceV2", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) {
uint8_t i;
uint32_t Data = 0;
for (i = 0; i < 4; i++)
Data += KeyValue[i] << (8 * i);
if (Data == 1) { // Reg key is set to 1, Not using legacy Mode.
forceV2Set = true;
}
}
RegCloseKey(hKey);
}
// If both VirtualTerminalLevel and ForceV2 is set, AnsiColor should work
ret = virtualTerminalLevelSet && forceV2Set;
#endif #endif
return ret; return ret;
} }

View file

@ -134,7 +134,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
char *token = NULL; char *token = NULL;
char *tmp_ptr = NULL; char *tmp_ptr = NULL;
FILE *stream = stdout; FILE *stream = stdout;
char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")}; const char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")};
switch (level) { switch (level) {
case ERR: case ERR:
strncpy(prefix, _RED_("[!!]"), sizeof(prefix) - 1); strncpy(prefix, _RED_("[!!]"), sizeof(prefix) - 1);

View file

@ -10,7 +10,7 @@
#include "wiegand_formats.h" #include "wiegand_formats.h"
#include "commonutil.h" #include "commonutil.h"
bool Pack_H10301(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_H10301(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0xFF) return false; // Can't encode FC. if (card->FacilityCode > 0xFF) return false; // Can't encode FC.
@ -26,7 +26,7 @@ bool Pack_H10301(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_H10301(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_H10301(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 26) return false; // Wrong length? Stop here. if (packed->Length != 26) return false; // Wrong length? Stop here.
@ -38,7 +38,7 @@ bool Unpack_H10301(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_Tecom27(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_Tecom27(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x7FF) return false; // Can't encode FC. if (card->FacilityCode > 0x7FF) return false; // Can't encode FC.
@ -52,7 +52,7 @@ bool Pack_Tecom27(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_Tecom27(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_Tecom27(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 27) return false; // Wrong length? Stop here. if (packed->Length != 27) return false; // Wrong length? Stop here.
@ -62,7 +62,7 @@ bool Unpack_Tecom27(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_2804W(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_2804W(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x0FF) return false; // Can't encode FC. if (card->FacilityCode > 0x0FF) return false; // Can't encode FC.
@ -85,7 +85,7 @@ bool Pack_2804W(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_2804W(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_2804W(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 28) return false; // Wrong length? Stop here. if (packed->Length != 28) return false; // Wrong length? Stop here.
@ -99,7 +99,7 @@ bool Unpack_2804W(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_ATSW30(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_ATSW30(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0xFFF) return false; // Can't encode FC. if (card->FacilityCode > 0xFFF) return false; // Can't encode FC.
@ -119,7 +119,7 @@ bool Pack_ATSW30(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_ATSW30(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_ATSW30(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 30) return false; // Wrong length? Stop here. if (packed->Length != 30) return false; // Wrong length? Stop here.
@ -132,7 +132,7 @@ bool Unpack_ATSW30(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_ADT31(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_ADT31(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x0F) return false; // Can't encode FC. if (card->FacilityCode > 0x0F) return false; // Can't encode FC.
@ -147,7 +147,7 @@ bool Pack_ADT31(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_ADT31(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_ADT31(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 31) return false; // Wrong length? Stop here. if (packed->Length != 31) return false; // Wrong length? Stop here.
@ -156,7 +156,7 @@ bool Unpack_ADT31(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_Kastle(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_Kastle(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x00FF) return false; // Can't encode FC. if (card->FacilityCode > 0x00FF) return false; // Can't encode FC.
@ -174,7 +174,7 @@ bool Pack_Kastle(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_Kastle(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_Kastle(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 32) return false; // Wrong length? Stop here. if (packed->Length != 32) return false; // Wrong length? Stop here.
@ -189,7 +189,7 @@ bool Unpack_Kastle(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_D10202(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_D10202(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x007F) return false; // Can't encode FC. if (card->FacilityCode > 0x007F) return false; // Can't encode FC.
@ -205,7 +205,7 @@ bool Pack_D10202(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_D10202(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_D10202(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 33) return false; // Wrong length? Stop here. if (packed->Length != 33) return false; // Wrong length? Stop here.
@ -218,7 +218,7 @@ bool Unpack_D10202(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_H10306(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_H10306(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0xFFFF) return false; // Can't encode FC. if (card->FacilityCode > 0xFFFF) return false; // Can't encode FC.
@ -235,7 +235,7 @@ bool Pack_H10306(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_H10306(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_H10306(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 34) return false; // Wrong length? Stop here. if (packed->Length != 34) return false; // Wrong length? Stop here.
@ -248,7 +248,7 @@ bool Unpack_H10306(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_N10002(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_N10002(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0xFF) return false; // Can't encode FC. if (card->FacilityCode > 0xFF) return false; // Can't encode FC.
@ -262,7 +262,7 @@ bool Pack_N10002(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_N10002(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_N10002(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 34) return false; // Wrong length? Stop here. if (packed->Length != 34) return false; // Wrong length? Stop here.
@ -272,7 +272,7 @@ bool Unpack_N10002(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_C1k35s(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_C1k35s(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0xFFF) return false; // Can't encode FC. if (card->FacilityCode > 0xFFF) return false; // Can't encode FC.
@ -290,7 +290,7 @@ bool Pack_C1k35s(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_C1k35s(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_C1k35s(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 35) return false; // Wrong length? Stop here. if (packed->Length != 35) return false; // Wrong length? Stop here.
@ -304,7 +304,7 @@ bool Unpack_C1k35s(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_H10320(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_H10320(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0) return false; // Can't encode FC. (none in this format) if (card->FacilityCode > 0) return false; // Can't encode FC. (none in this format)
@ -332,7 +332,7 @@ bool Pack_H10320(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_H10320(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_H10320(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 36) return false; // Wrong length? Stop here. if (packed->Length != 36) return false; // Wrong length? Stop here.
@ -356,7 +356,7 @@ bool Unpack_H10320(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_S12906(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_S12906(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0xFF) return false; // Can't encode FC. if (card->FacilityCode > 0xFF) return false; // Can't encode FC.
@ -373,7 +373,7 @@ bool Pack_S12906(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_S12906(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_S12906(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 36) return false; // Wrong length? Stop here. if (packed->Length != 36) return false; // Wrong length? Stop here.
@ -387,7 +387,7 @@ bool Unpack_S12906(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_Sie36(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_Sie36(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x0003FFFF) return false; // Can't encode FC. if (card->FacilityCode > 0x0003FFFF) return false; // Can't encode FC.
@ -407,7 +407,7 @@ bool Pack_Sie36(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_Sie36(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_Sie36(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 36) return false; // Wrong length? Stop here. if (packed->Length != 36) return false; // Wrong length? Stop here.
@ -420,7 +420,7 @@ bool Unpack_Sie36(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_C15001(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_C15001(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x000000FF) return false; // Can't encode FC. if (card->FacilityCode > 0x000000FF) return false; // Can't encode FC.
@ -437,7 +437,7 @@ bool Pack_C15001(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_C15001(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_C15001(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 36) return false; // Wrong length? Stop here. if (packed->Length != 36) return false; // Wrong length? Stop here.
@ -451,7 +451,7 @@ bool Unpack_C15001(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_H10302(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_H10302(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0) return false; // Can't encode FC. (none in this format) if (card->FacilityCode > 0) return false; // Can't encode FC. (none in this format)
@ -466,7 +466,7 @@ bool Pack_H10302(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_H10302(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_H10302(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 37) return false; // Wrong length? Stop here. if (packed->Length != 37) return false; // Wrong length? Stop here.
@ -478,7 +478,7 @@ bool Unpack_H10302(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
if (card->FacilityCode > 0x0000FFFF) return false; // Can't encode FC. if (card->FacilityCode > 0x0000FFFF) return false; // Can't encode FC.
@ -495,7 +495,7 @@ bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_H10304(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_H10304(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 37) return false; // Wrong length? Stop here. if (packed->Length != 37) return false; // Wrong length? Stop here.
@ -508,7 +508,7 @@ bool Unpack_H10304(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_P10001(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_P10001(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
@ -530,7 +530,7 @@ bool Pack_P10001(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_P10001(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_P10001(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
@ -547,7 +547,7 @@ bool Unpack_P10001(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
bool Pack_C1k48s(wiegand_card_t *card, wiegand_message_t *packed) { static bool Pack_C1k48s(wiegand_card_t *card, wiegand_message_t *packed) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
@ -566,7 +566,7 @@ bool Pack_C1k48s(wiegand_card_t *card, wiegand_message_t *packed) {
return add_HID_header(packed); return add_HID_header(packed);
} }
bool Unpack_C1k48s(wiegand_message_t *packed, wiegand_card_t *card) { static bool Unpack_C1k48s(wiegand_message_t *packed, wiegand_card_t *card) {
memset(card, 0, sizeof(wiegand_card_t)); memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 48) return false; // Wrong length? Stop here. if (packed->Length != 48) return false; // Wrong length? Stop here.

View file

@ -218,6 +218,7 @@ uint16_t Crc16ex(CrcType_t ct, const uint8_t *d, size_t n) {
case CRC_LEGIC: case CRC_LEGIC:
// TODO // TODO
return 0; return 0;
case CRC_NONE:
default: default:
break; break;
} }
@ -230,7 +231,7 @@ uint16_t Crc16ex(CrcType_t ct, const uint8_t *d, size_t n) {
// n length (including crc) // n length (including crc)
// //
// This function uses the message + crc bytes in order to compare the "residue" afterwards. // This function uses the message + crc bytes in order to compare the "residue" afterwards.
// crc16 algos like CRC-A become 0x000 // crc16 algos like CRC-A become 0x0000
// while CRC-15693 become 0x0F47 // while CRC-15693 become 0x0F47
// If calculated with crc bytes, the residue should be 0xF0B8 // If calculated with crc bytes, the residue should be 0xF0B8
bool check_crc(CrcType_t ct, const uint8_t *d, size_t n) { bool check_crc(CrcType_t ct, const uint8_t *d, size_t n) {
@ -254,9 +255,12 @@ bool check_crc(CrcType_t ct, const uint8_t *d, size_t n) {
return (crc16_xmodem(d, n) == 0); return (crc16_xmodem(d, n) == 0);
case CRC_CCITT: case CRC_CCITT:
return (crc16_ccitt(d, n) == 0); return (crc16_ccitt(d, n) == 0);
case CRC_KERMIT:
return (crc16_kermit(d, n) == 0);
case CRC_LEGIC: case CRC_LEGIC:
// TODO // TODO
return false; return false;
case CRC_NONE:
default: default:
break; break;
} }

View file

@ -19,6 +19,7 @@
/* Possible inflate modes between inflate() calls */ /* Possible inflate modes between inflate() calls */
typedef enum { typedef enum {
HEAD = 16180, /* i: waiting for magic header */ HEAD = 16180, /* i: waiting for magic header */
#ifdef GUNZIP
FLAGS, /* i: waiting for method and flags (gzip) */ FLAGS, /* i: waiting for method and flags (gzip) */
TIME, /* i: waiting for modification time (gzip) */ TIME, /* i: waiting for modification time (gzip) */
OS, /* i: waiting for extra flags and operating system (gzip) */ OS, /* i: waiting for extra flags and operating system (gzip) */
@ -27,6 +28,7 @@ typedef enum {
NAME, /* i: waiting for end of file name (gzip) */ NAME, /* i: waiting for end of file name (gzip) */
COMMENT, /* i: waiting for end of comment (gzip) */ COMMENT, /* i: waiting for end of comment (gzip) */
HCRC, /* i: waiting for header crc (gzip) */ HCRC, /* i: waiting for header crc (gzip) */
#endif
DICTID, /* i: waiting for dictionary check value */ DICTID, /* i: waiting for dictionary check value */
DICT, /* waiting for inflateSetDictionary() call */ DICT, /* waiting for inflateSetDictionary() call */
TYPE, /* i: waiting for type bits, including last-flag bit */ TYPE, /* i: waiting for type bits, including last-flag bit */
@ -45,7 +47,9 @@ typedef enum {
MATCH, /* o: waiting for output space to copy string */ MATCH, /* o: waiting for output space to copy string */
LIT, /* o: waiting for output space to write literal */ LIT, /* o: waiting for output space to write literal */
CHECK, /* i: waiting for 32-bit check value */ CHECK, /* i: waiting for 32-bit check value */
#ifdef GUNZIP
LENGTH, /* i: waiting for 32-bit length (gzip) */ LENGTH, /* i: waiting for 32-bit length (gzip) */
#endif
DONE, /* finished check, done -- remain here until reset */ DONE, /* finished check, done -- remain here until reset */
BAD, /* got a data error -- remain here until reset */ BAD, /* got a data error -- remain here until reset */
MEM, /* got an inflate() memory error -- remain here until reset */ MEM, /* got an inflate() memory error -- remain here until reset */

View file

@ -191,7 +191,8 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
extra = lext; extra = lext;
match = 257; match = 257;
break; break;
default: /* DISTS */ case DISTS:
default:
base = dbase; base = dbase;
extra = dext; extra = dext;
match = 0; match = 0;

View file

@ -923,6 +923,10 @@ charf *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */ ulg stored_len; /* length of input block */
int last; /* one if this is the last block for a file */ int last; /* one if this is the last block for a file */
{ {
#ifdef ZLIB_PM3_TUNED
(void) buf;
(void) stored_len;
#endif
int max_blindex = 0; /* index of last bit length code of non zero freq */ int max_blindex = 0; /* index of last bit length code of non zero freq */
#ifndef ZLIB_PM3_TUNED #ifndef ZLIB_PM3_TUNED
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */

View file

@ -39,8 +39,10 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
CFLAGS = -c $(INCLUDE) -Wall -Werror -pedantic -Wunused -std=c99 $(APP_CFLAGS) -Os CFLAGS ?= -Wall -Werror -pedantic -Wunused -Os -mthumb-interwork
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-gc-sections -n CFLAGS += -c $(INCLUDE) -std=c99 $(APP_CFLAGS)
LDFLAGS += -nostartfiles -nodefaultlibs -Wl,-gc-sections -n
LIBS = -lgcc LIBS = -lgcc
# Flags to generate temporary dependency files # Flags to generate temporary dependency files
@ -55,21 +57,21 @@ VERSIONOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(VERSIONSRC)))
$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
$(info [-] CC $<) $(info [-] CC $<)
$(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -mthumb -mthumb-interwork -o $@ $< $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -mthumb -o $@ $<
$(Q)$(POSTCOMPILE) $(Q)$(POSTCOMPILE)
$(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) $(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
$(info [-] CC $<) $(info [-] CC $<)
$(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -mthumb-interwork -o $@ $< $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -o $@ $<
$(Q)$(POSTCOMPILE) $(Q)$(POSTCOMPILE)
$(ASMOBJ): $(OBJDIR)/%.o: %.s $(ASMOBJ): $(OBJDIR)/%.o: %.s
$(info [-] CC $<) $(info [-] CC $<)
$(Q)$(CC) $(CFLAGS) -mthumb-interwork -o $@ $< $(Q)$(CC) $(CFLAGS) -o $@ $<
$(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) $(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
$(info [-] CC $<) $(info [-] CC $<)
$(Q)$(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $< $(Q)$(CC) $(CFLAGS) -mthumb -o $@ $<
# This objcopy call translates physical flash addresses to logical addresses # This objcopy call translates physical flash addresses to logical addresses
# without touching start address or RAM addresses (.bss and .data sections) # without touching start address or RAM addresses (.bss and .data sections)

View file

@ -135,4 +135,12 @@ In later versions of windows 10 you may be able to get color to work by setting
[HKEY_CURRENT_USER\Console] [HKEY_CURRENT_USER\Console]
"VirtualTerminalLevel"=dword:00000001 "VirtualTerminalLevel"=dword:00000001
``` ```
If after setting this key (and restarting proxmark3.exe) you get extra characters and no color text, either delete the key or set the value to 0 You also need to disable "use legacy console" in the cmd.exe properties, or set the following registry key
```
[HKEY_CURRENT_USER\Console]
"ForceV2"=dword:00000001
```
After making these changes, you will need to start a new command prompt (cmd.exe) to ensure its using the new settings.
If after making these changes (and restarting proxmark3.exe) you get extra characters and no color text, set either key to 0 or enable legacy mode again (and restart the command prompt).

View file

@ -53,11 +53,13 @@ static void usage(void) {
static voidpf fpga_deflate_malloc(voidpf opaque, uInt items, uInt size) { static voidpf fpga_deflate_malloc(voidpf opaque, uInt items, uInt size) {
(void) opaque;
return calloc(items * size, sizeof(uint8_t)); return calloc(items * size, sizeof(uint8_t));
} }
static void fpga_deflate_free(voidpf opaque, voidpf address) { static void fpga_deflate_free(voidpf opaque, voidpf address) {
(void) opaque;
free(address); free(address);
} }
@ -72,7 +74,7 @@ static bool all_feof(FILE *infile[], uint8_t num_infiles) {
} }
int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardnested_mode) { static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardnested_mode) {
uint8_t *fpga_config; uint8_t *fpga_config;
uint32_t i; uint32_t i;
int32_t ret; int32_t ret;
@ -182,7 +184,7 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
} }
int zlib_decompress(FILE *infile, FILE *outfile) { static int zlib_decompress(FILE *infile, FILE *outfile) {
#define DECOMPRESS_BUF_SIZE 1024 #define DECOMPRESS_BUF_SIZE 1024
uint8_t outbuf[DECOMPRESS_BUF_SIZE]; uint8_t outbuf[DECOMPRESS_BUF_SIZE];
uint8_t inbuf[DECOMPRESS_BUF_SIZE]; uint8_t inbuf[DECOMPRESS_BUF_SIZE];

View file

@ -38,7 +38,7 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < encc; i++) { for (int i = 0; i < encc; i++) {
enclen[i] = strlen(argv[i + 6]) / 2; enclen[i] = strlen(argv[i + 6]) / 2;
for (int i2 = 0; i2 < enclen[i]; i2++) { for (int i2 = 0; i2 < enclen[i]; i2++) {
sscanf(argv[i + 6] + i2 * 2, "%2x", (unsigned int *)&enc[i][i2]); sscanf(argv[i + 6] + i2 * 2, "%2hhx", &enc[i][i2]);
} }
} }