This commit is contained in:
iceman1001 2018-06-03 23:32:02 +02:00
parent d2d126878e
commit a2c7158f78
13 changed files with 25 additions and 30 deletions

View file

@ -779,8 +779,10 @@ bool NestedCheckKey(uint64_t key, TAuthData *ad, uint8_t *cmd, uint8_t cmdsize,
uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ad->ar_enc; uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ad->ar_enc;
uint32_t at1 = crypto1_word(pcs, 0, 0) ^ ad->at_enc; uint32_t at1 = crypto1_word(pcs, 0, 0) ^ ad->at_enc;
if (!(ar == ar1 && at == at1 && NTParityChk(ad, nt1))) if (!(ar == ar1 && at == at1 && NTParityChk(ad, nt1))) {
crypto1_destroy(pcs);
return false; return false;
}
memcpy(buf, cmd, cmdsize); memcpy(buf, cmd, cmdsize);
mf_crypto1_decrypt(pcs, buf, cmdsize, 0); mf_crypto1_decrypt(pcs, buf, cmdsize, 0);

View file

@ -271,13 +271,11 @@ void GetKeySettings( uint8_t *aid){
char *str = messStr; char *str = messStr;
uint8_t isOK = 0; uint8_t isOK = 0;
uint32_t options = NONE; uint32_t options = NONE;
UsbCommand c; UsbCommand c = {CMD_MIFARE_DESFIRE};
UsbCommand resp; UsbCommand resp;
//memset(messStr, 0x00, 512); //memset(messStr, 0x00, 512);
c.cmd = CMD_MIFARE_DESFIRE;
if ( aid == NULL ){ if ( aid == NULL ){
PrintAndLogEx(NORMAL, " CMK - PICC, Card Master Key settings "); PrintAndLogEx(NORMAL, " CMK - PICC, Card Master Key settings ");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");

View file

@ -267,7 +267,6 @@ static void init_bitflip_bitarrays(void)
if (bytesread != filesize) { if (bytesread != filesize) {
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name); PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
fclose(statesfile); fclose(statesfile);
inflateEnd(&compressed_stream);
exit(5); exit(5);
} }
fclose(statesfile); fclose(statesfile);

View file

@ -2322,7 +2322,7 @@ int CmdHF14AMfucSetPwd(const char *Cmd){
// //
int CmdHF14AMfucSetUid(const char *Cmd){ int CmdHF14AMfucSetUid(const char *Cmd){
UsbCommand c; UsbCommand c = {CMD_MIFAREU_READBL};
UsbCommand resp; UsbCommand resp;
uint8_t uid[7] = {0x00}; uint8_t uid[7] = {0x00};
char cmdp = param_getchar(Cmd, 0); char cmdp = param_getchar(Cmd, 0);
@ -2335,7 +2335,6 @@ int CmdHF14AMfucSetUid(const char *Cmd){
} }
// read block2. // read block2.
c.cmd = CMD_MIFAREU_READBL;
c.arg[0] = 2; c.arg[0] = 2;
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);

View file

@ -255,7 +255,7 @@ int CmdHIDClone(const char *Cmd) {
uint32_t hi2 = 0, hi = 0, lo = 0; uint32_t hi2 = 0, hi = 0, lo = 0;
uint32_t n = 0, i = 0; uint32_t n = 0, i = 0;
UsbCommand c; UsbCommand c = {CMD_HID_CLONE_TAG);
uint8_t ctmp = param_getchar(Cmd, 0); uint8_t ctmp = param_getchar(Cmd, 0);
if ( strlen(Cmd) == 0 || ctmp == 'H' || ctmp == 'h' ) return usage_lf_hid_clone(); if ( strlen(Cmd) == 0 || ctmp == 'H' || ctmp == 'h' ) return usage_lf_hid_clone();
@ -280,7 +280,6 @@ int CmdHIDClone(const char *Cmd) {
c.d.asBytes[0] = 0; c.d.asBytes[0] = 0;
} }
c.cmd = CMD_HID_CLONE_TAG;
c.arg[0] = hi2; c.arg[0] = hi2;
c.arg[1] = hi; c.arg[1] = hi;
c.arg[2] = lo; c.arg[2] = lo;

View file

@ -182,8 +182,8 @@ int CmdLFHitagSim(const char *Cmd) {
return 1; return 1;
} }
tag_mem_supplied = true; tag_mem_supplied = true;
size_t bytes_read = fread(c.d.asBytes, 48, 1, f); size_t bytes_read = fread(c.d.asBytes, 1, 48, f);
if ( bytes_read == 0) { if ( bytes_read == 48) {
PrintAndLogEx(WARNING, "Error: File reading error"); PrintAndLogEx(WARNING, "Error: File reading error");
fclose(f); fclose(f);
return 1; return 1;
@ -306,8 +306,8 @@ int CmdLFHitagSimS(const char *Cmd) {
return 1; return 1;
} }
tag_mem_supplied = true; tag_mem_supplied = true;
size_t bytes_read = fread(c.d.asBytes, 4*64, 1, f); size_t bytes_read = fread(c.d.asBytes, 1, 4*64, f);
if ( bytes_read == 0) { if ( bytes_read == 4*64) {
PrintAndLogEx(WARNING, "Error: File reading error"); PrintAndLogEx(WARNING, "Error: File reading error");
fclose(f); fclose(f);
return 1; return 1;
@ -341,8 +341,8 @@ int CmdLFHitagCheckChallenges(const char *Cmd) {
return 1; return 1;
} }
file_given = true; file_given = true;
size_t bytes_read = fread(c.d.asBytes, 8*60, 1, f); size_t bytes_read = fread(c.d.asBytes, 1, 8*60, f);
if ( bytes_read == 0) { if ( bytes_read == 8*60) {
PrintAndLogEx(WARNING, "Error: File reading error"); PrintAndLogEx(WARNING, "Error: File reading error");
fclose(f); fclose(f);
return 1; return 1;

View file

@ -419,7 +419,7 @@ int CmdIndalaSim(const char *Cmd) {
// iceman - needs refactoring // iceman - needs refactoring
int CmdIndalaClone(const char *Cmd) { int CmdIndalaClone(const char *Cmd) {
UsbCommand c; UsbCommand c = {0};
uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7; uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7;
uid1 = uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0; uid1 = uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;
uint32_t n = 0, i = 0; uint32_t n = 0, i = 0;

View file

@ -105,7 +105,7 @@ static struct crypto_pk *crypto_pk_polarssl_open_rsa(va_list vl)
int res = rsa_check_pubkey(&cp->ctx); int res = rsa_check_pubkey(&cp->ctx);
if(res != 0) { if(res != 0) {
fprintf(stderr, "PolarSSL public key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen); fprintf(stderr, "PolarSSL public key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);
free(cp);
return NULL; return NULL;
} }
@ -150,6 +150,7 @@ static struct crypto_pk *crypto_pk_polarssl_open_priv_rsa(va_list vl)
int res = rsa_check_privkey(&cp->ctx); int res = rsa_check_privkey(&cp->ctx);
if(res != 0) { if(res != 0) {
fprintf(stderr, "PolarSSL private key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen); fprintf(stderr, "PolarSSL private key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);
free(cp);
return NULL; return NULL;
} }
@ -184,6 +185,7 @@ static struct crypto_pk *crypto_pk_polarssl_genkey_rsa(va_list vl)
int res = rsa_gen_key(&cp->ctx, &myrand, NULL, nbits, exp); int res = rsa_gen_key(&cp->ctx, &myrand, NULL, nbits, exp);
if (res) { if (res) {
fprintf(stderr, "PolarSSL private key generation error res=%x exp=%d nbits=%d.\n", res * -1, exp, nbits); fprintf(stderr, "PolarSSL private key generation error res=%x exp=%d nbits=%d.\n", res * -1, exp, nbits);
free(cp);
return NULL; return NULL;
} }
@ -214,8 +216,9 @@ static unsigned char *crypto_pk_polarssl_encrypt(const struct crypto_pk *_cp, co
} }
res = rsa_public(&cp->ctx, buf, result); res = rsa_public(&cp->ctx, buf, result);
if(res) { if (res) {
printf("RSA encrypt failed. Error: %x data len: %zu key len: %zu\n", res * -1, len, keylen); printf("RSA encrypt failed. Error: %x data len: %zu key len: %zu\n", res * -1, len, keylen);
free(result);
return NULL; return NULL;
} }
@ -242,6 +245,7 @@ static unsigned char *crypto_pk_polarssl_decrypt(const struct crypto_pk *_cp, co
res = rsa_private(&cp->ctx, buf, result); // CHECK??? res = rsa_private(&cp->ctx, buf, result); // CHECK???
if(res) { if(res) {
printf("RSA decrypt failed. Error: %x data len: %zu key len: %zu\n", res * -1, len, keylen); printf("RSA decrypt failed. Error: %x data len: %zu key len: %zu\n", res * -1, len, keylen);
free(result);
return NULL; return NULL;
} }

View file

@ -107,7 +107,7 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
for(uint16_t j = 0; j < num_infiles; j++) { for(uint16_t j = 0; j < num_infiles; j++) {
for(uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) { for(uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) {
c = fgetc(infile[j]); c = (uint8_t)fgetc(infile[j]);
if (!feof(infile[j])) { if (!feof(infile[j])) {
fpga_config[i++] = c; fpga_config[i++] = c;
} else if (num_infiles > 1) { } else if (num_infiles > 1) {

View file

@ -264,10 +264,8 @@ fail:
// Get the state of the proxmark, backwards compatible // Get the state of the proxmark, backwards compatible
static int get_proxmark_state(uint32_t *state) static int get_proxmark_state(uint32_t *state)
{ {
UsbCommand c; UsbCommand c = {CMD_DEVICE_INFO};
c.cmd = CMD_DEVICE_INFO;
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
ReceiveCommand(&resp); ReceiveCommand(&resp);

View file

@ -62,13 +62,9 @@ extern "C" void MainGraphics(void)
extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool usb_present) extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool usb_present)
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
bool useGUI = getenv("DISPLAY") != 0; if (getenv("DISPLAY") == NULL)
#else
bool useGUI = true;
#endif
if (!useGUI)
return; return;
#endif
main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present); main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present);
gui = new ProxGuiQT(argc, argv, main_loop_thread); gui = new ProxGuiQT(argc, argv, main_loop_thread);
} }

View file

@ -113,7 +113,7 @@ class ProxGuiQT : public QObject
ProxWidget *plotwidget; ProxWidget *plotwidget;
int argc; int argc;
char **argv; char **argv;
void (*main_func)(void); //void (*main_func)(void);
WorkerThread *proxmarkThread; WorkerThread *proxmarkThread;
public: public:

View file

@ -118,7 +118,7 @@ uint64_t msclock(void) {
#include <sys/timeb.h> #include <sys/timeb.h>
struct _timeb t; struct _timeb t;
_ftime(&t); _ftime(&t);
return 1000 * t.time + t.millitm; return 1000 * (uint64_t)t.time + t.millitm;
// NORMAL CODE (use _ftime_s) // NORMAL CODE (use _ftime_s)
//struct _timeb t; //struct _timeb t;