2010-02-21 08:47:22 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2010-02-26 05:57:35 +08:00
|
|
|
// Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
|
2010-02-21 08:47:22 +08:00
|
|
|
// 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.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Main binary
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-04-09 14:43:20 +08:00
|
|
|
#include <stdio.h>
|
2010-02-07 08:31:32 +08:00
|
|
|
#include <stdlib.h>
|
2009-04-09 14:43:20 +08:00
|
|
|
#include <string.h>
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
#include <pthread.h>
|
2011-06-18 02:39:54 +08:00
|
|
|
#include <unistd.h>
|
2009-04-09 14:43:20 +08:00
|
|
|
#include <readline/readline.h>
|
|
|
|
#include <readline/history.h>
|
2015-01-06 18:17:02 +08:00
|
|
|
|
2009-04-09 14:43:20 +08:00
|
|
|
#include "proxmark3.h"
|
|
|
|
#include "proxgui.h"
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
#include "cmdmain.h"
|
2012-12-05 07:39:18 +08:00
|
|
|
#include "uart.h"
|
|
|
|
#include "ui.h"
|
2013-03-14 23:03:04 +08:00
|
|
|
#include "sleep.h"
|
2014-03-27 05:35:25 +08:00
|
|
|
#include "cmdparser.h"
|
2015-06-25 18:22:34 +08:00
|
|
|
#include "cmdhw.h"
|
2012-12-05 07:39:18 +08:00
|
|
|
|
2013-09-15 17:33:17 +08:00
|
|
|
// a global mutex to prevent interlaced printing from different threads
|
|
|
|
pthread_mutex_t print_lock;
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
static serial_port sp;
|
2012-12-07 20:22:05 +08:00
|
|
|
static UsbCommand txcmd;
|
2013-06-05 16:53:20 +08:00
|
|
|
volatile static bool txcmd_pending = false;
|
2012-12-05 07:39:18 +08:00
|
|
|
|
|
|
|
void SendCommand(UsbCommand *c) {
|
2015-01-07 04:20:41 +08:00
|
|
|
#if 0
|
2016-01-21 00:45:42 +08:00
|
|
|
printf("Sending %d bytes\n", sizeof(UsbCommand));
|
2015-01-07 04:20:41 +08:00
|
|
|
#endif
|
2015-01-08 05:51:34 +08:00
|
|
|
|
|
|
|
if (offline) {
|
2016-01-21 00:45:42 +08:00
|
|
|
PrintAndLog("Sending bytes to proxmark failed - offline");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/**
|
2014-10-24 00:36:44 +08:00
|
|
|
The while-loop below causes hangups at times, when the pm3 unit is unresponsive
|
|
|
|
or disconnected. The main console thread is alive, but comm thread just spins here.
|
|
|
|
Not good.../holiman
|
|
|
|
**/
|
2016-01-21 00:45:42 +08:00
|
|
|
while(txcmd_pending);
|
|
|
|
|
|
|
|
txcmd = *c;
|
|
|
|
txcmd_pending = true;
|
2012-12-05 07:39:18 +08:00
|
|
|
}
|
2009-04-09 14:43:20 +08:00
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
struct receiver_arg {
|
2016-09-09 17:56:20 +08:00
|
|
|
int run;
|
2009-04-09 14:43:20 +08:00
|
|
|
};
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
struct main_loop_arg {
|
2016-09-09 17:56:20 +08:00
|
|
|
int usb_present;
|
|
|
|
char *script_cmds_file;
|
2009-04-09 17:37:34 +08:00
|
|
|
};
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
byte_t rx[0x1000000];
|
2012-12-07 20:51:19 +08:00
|
|
|
byte_t* prx = rx;
|
2012-12-05 07:39:18 +08:00
|
|
|
|
2016-09-09 17:56:20 +08:00
|
|
|
// static void showBanner(void){
|
|
|
|
// printf("██████╗ ███╗ ███╗ ████╗ ...Iceman fork\n");
|
|
|
|
// printf("██╔══██╗████╗ ████║ ══█║\n");
|
|
|
|
// printf("██████╔╝██╔████╔██║ ████╔╝\n");
|
|
|
|
// printf("██╔═══╝ ██║╚██╔╝██║ ══█║ iceman@icesql.net\n");
|
|
|
|
// printf("██║ ██║ ╚═╝ ██║ ████╔╝ https://github.com/iceman1001/proxmark3\n");
|
|
|
|
// printf("╚═╝ ╚═╝ ╚═╝ ╚═══╝v1.6.4\n");
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
static void *uart_receiver(void *targ) {
|
2016-01-21 00:45:42 +08:00
|
|
|
struct receiver_arg *arg = (struct receiver_arg*)targ;
|
|
|
|
size_t rxlen;
|
|
|
|
size_t cmd_count;
|
|
|
|
|
|
|
|
while (arg->run) {
|
|
|
|
|
|
|
|
rxlen = sizeof(UsbCommand);
|
2015-01-07 04:20:41 +08:00
|
|
|
|
|
|
|
if (uart_receive(sp, prx, &rxlen)) {
|
2016-01-21 00:45:42 +08:00
|
|
|
prx += rxlen;
|
|
|
|
if (((prx-rx) % sizeof(UsbCommand)) != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cmd_count = (prx-rx) / sizeof(UsbCommand);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < cmd_count; i++)
|
|
|
|
UsbCommandReceived((UsbCommand*)( rx + ( i * sizeof(UsbCommand))));
|
|
|
|
|
|
|
|
}
|
|
|
|
prx = rx;
|
|
|
|
|
|
|
|
if (txcmd_pending) {
|
|
|
|
if ( !uart_send(sp, (byte_t*) &txcmd, sizeof(UsbCommand))) {
|
|
|
|
PrintAndLog("Sending bytes to proxmark failed");
|
|
|
|
}
|
|
|
|
txcmd_pending = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pthread_exit(NULL);
|
|
|
|
return NULL;
|
2009-04-09 14:43:20 +08:00
|
|
|
}
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
static void *main_loop(void *targ) {
|
2016-01-21 00:45:42 +08:00
|
|
|
struct main_loop_arg *arg = (struct main_loop_arg*)targ;
|
|
|
|
struct receiver_arg rarg;
|
|
|
|
char *cmd = NULL;
|
|
|
|
pthread_t reader_thread;
|
2012-12-05 07:39:18 +08:00
|
|
|
|
2016-01-21 00:45:42 +08:00
|
|
|
if (arg->usb_present == 1) {
|
2015-01-07 04:20:41 +08:00
|
|
|
rarg.run = 1;
|
2016-01-21 00:45:42 +08:00
|
|
|
pthread_create(&reader_thread, NULL, &uart_receiver, &rarg);
|
2015-06-25 18:22:34 +08:00
|
|
|
// cache Version information now:
|
|
|
|
CmdVersion(NULL);
|
2016-01-21 00:45:42 +08:00
|
|
|
}
|
2015-01-07 04:20:41 +08:00
|
|
|
|
2016-01-21 00:45:42 +08:00
|
|
|
FILE *script_file = NULL;
|
|
|
|
char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest
|
2015-01-07 04:20:41 +08:00
|
|
|
|
2015-01-08 05:51:34 +08:00
|
|
|
if (arg->script_cmds_file) {
|
2016-01-21 00:45:42 +08:00
|
|
|
script_file = fopen(arg->script_cmds_file, "r");
|
|
|
|
|
|
|
|
if (script_file)
|
|
|
|
printf("using 'scripting' commands file %s\n", arg->script_cmds_file);
|
|
|
|
}
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2011-06-18 02:39:54 +08:00
|
|
|
read_history(".history");
|
2015-01-08 05:51:34 +08:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
2016-01-21 00:45:42 +08:00
|
|
|
// If there is a script file
|
2016-02-17 17:46:08 +08:00
|
|
|
if (script_file) {
|
|
|
|
|
2015-01-08 05:51:34 +08:00
|
|
|
if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), script_file)) {
|
2016-01-21 00:45:42 +08:00
|
|
|
fclose(script_file);
|
|
|
|
script_file = NULL;
|
2015-01-08 05:51:34 +08:00
|
|
|
} else {
|
2016-01-21 00:45:42 +08:00
|
|
|
char *nl;
|
|
|
|
nl = strrchr(script_cmd_buf, '\r');
|
|
|
|
if (nl)
|
|
|
|
*nl = '\0';
|
2015-01-08 06:52:33 +08:00
|
|
|
|
2016-01-21 00:45:42 +08:00
|
|
|
nl = strrchr(script_cmd_buf, '\n');
|
|
|
|
|
|
|
|
if (nl)
|
|
|
|
*nl = '\0';
|
2016-02-17 17:46:08 +08:00
|
|
|
|
|
|
|
int newlen = strlen(script_cmd_buf);
|
|
|
|
if ((cmd = (char*) malloc( newlen + 1)) != NULL) {
|
|
|
|
memset(cmd, 0x00, newlen);
|
2016-01-21 00:45:42 +08:00
|
|
|
strcpy(cmd, script_cmd_buf);
|
|
|
|
printf("%s\n", cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cmd = readline(PROXPROMPT);
|
2011-09-01 17:03:20 +08:00
|
|
|
}
|
|
|
|
|
2016-02-20 05:31:35 +08:00
|
|
|
// this one should pick up all non-null cmd...
|
|
|
|
// why is there a
|
2011-06-18 02:39:54 +08:00
|
|
|
if (cmd) {
|
2016-10-21 06:43:43 +08:00
|
|
|
if (strlen(cmd) > 0) {
|
|
|
|
while(cmd[strlen(cmd) - 1] == ' ')
|
|
|
|
cmd[strlen(cmd) - 1] = 0x00;
|
|
|
|
}
|
2016-01-21 00:45:42 +08:00
|
|
|
|
2011-06-18 02:39:54 +08:00
|
|
|
if (cmd[0] != 0x00) {
|
2015-11-10 04:46:57 +08:00
|
|
|
int ret = CommandReceived(cmd);
|
|
|
|
add_history(cmd);
|
2016-01-21 00:45:42 +08:00
|
|
|
|
|
|
|
// exit or quit
|
|
|
|
if (ret == 99)
|
2011-06-18 02:39:54 +08:00
|
|
|
break;
|
2016-02-27 16:21:19 +08:00
|
|
|
}
|
2016-02-19 03:48:24 +08:00
|
|
|
free(cmd);
|
2016-02-20 05:31:35 +08:00
|
|
|
cmd = 0;
|
2011-06-18 02:39:54 +08:00
|
|
|
} else {
|
|
|
|
printf("\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-02-17 17:46:08 +08:00
|
|
|
|
|
|
|
if (script_file) {
|
|
|
|
fclose(script_file);
|
|
|
|
script_file = NULL;
|
|
|
|
}
|
|
|
|
|
2011-06-24 00:49:39 +08:00
|
|
|
write_history(".history");
|
2016-01-26 03:22:00 +08:00
|
|
|
|
|
|
|
free(cmd);
|
2016-02-20 05:31:35 +08:00
|
|
|
cmd = 0;
|
2016-01-26 03:22:00 +08:00
|
|
|
|
2016-01-21 00:45:42 +08:00
|
|
|
if (arg->usb_present == 1) {
|
|
|
|
rarg.run = 0;
|
|
|
|
pthread_join(reader_thread, NULL);
|
|
|
|
}
|
2015-01-07 04:20:41 +08:00
|
|
|
|
2016-01-21 00:45:42 +08:00
|
|
|
ExitGraphics();
|
|
|
|
pthread_exit(NULL);
|
|
|
|
return NULL;
|
2009-04-09 14:43:20 +08:00
|
|
|
}
|
|
|
|
|
2014-03-27 06:35:53 +08:00
|
|
|
static void dumpAllHelp(int markdown)
|
2014-03-27 05:08:55 +08:00
|
|
|
{
|
2016-01-21 00:45:42 +08:00
|
|
|
printf("\n%sProxmark3 command dump%s\n\n",markdown?"# ":"",markdown?"":"\n======================");
|
|
|
|
printf("Some commands are available only if a Proxmark is actually connected.%s\n",markdown?" ":"");
|
|
|
|
printf("Check column \"offline\" for their availability.\n");
|
|
|
|
printf("\n");
|
|
|
|
command_t *cmds = getTopLevelCommandTable();
|
|
|
|
dumpCommandsRecursive(cmds, markdown);
|
2014-03-27 05:08:55 +08:00
|
|
|
}
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
int main(int argc, char* argv[]) {
|
2013-09-15 17:33:17 +08:00
|
|
|
srand(time(0));
|
2013-03-01 06:22:24 +08:00
|
|
|
|
2013-09-15 17:33:17 +08:00
|
|
|
if (argc < 2) {
|
|
|
|
printf("syntax: %s <port>\n\n",argv[0]);
|
|
|
|
printf("\tLinux example:'%s /dev/ttyACM0'\n\n", argv[0]);
|
2014-03-27 06:35:53 +08:00
|
|
|
printf("help: %s -h\n\n", argv[0]);
|
|
|
|
printf("\tDump all interactive help at once\n");
|
|
|
|
printf("markdown: %s -m\n\n", argv[0]);
|
|
|
|
printf("\tDump all interactive help at once in markdown syntax\n");
|
2013-09-15 17:33:17 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2014-03-27 06:35:53 +08:00
|
|
|
if (strcmp(argv[1], "-h") == 0) {
|
|
|
|
printf("syntax: %s <port>\n\n",argv[0]);
|
|
|
|
printf("\tLinux example:'%s /dev/ttyACM0'\n\n", argv[0]);
|
|
|
|
dumpAllHelp(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (strcmp(argv[1], "-m") == 0) {
|
|
|
|
dumpAllHelp(1);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-15 17:33:17 +08:00
|
|
|
// Make sure to initialize
|
|
|
|
struct main_loop_arg marg = {
|
|
|
|
.usb_present = 0,
|
|
|
|
.script_cmds_file = NULL
|
|
|
|
};
|
2016-01-21 00:45:42 +08:00
|
|
|
|
2015-11-10 04:46:57 +08:00
|
|
|
pthread_t main_loop_threat;
|
2011-09-01 17:03:20 +08:00
|
|
|
|
2016-10-07 06:17:18 +08:00
|
|
|
sp = uart_open(argv[1]);
|
2013-09-15 17:33:17 +08:00
|
|
|
if (sp == INVALID_SERIAL_PORT) {
|
|
|
|
printf("ERROR: invalid serial port\n");
|
|
|
|
marg.usb_present = 0;
|
|
|
|
offline = 1;
|
|
|
|
} else if (sp == CLAIMED_SERIAL_PORT) {
|
|
|
|
printf("ERROR: serial port is claimed by another process\n");
|
|
|
|
marg.usb_present = 0;
|
|
|
|
offline = 1;
|
|
|
|
} else {
|
|
|
|
marg.usb_present = 1;
|
|
|
|
offline = 0;
|
|
|
|
}
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2013-09-15 17:33:17 +08:00
|
|
|
// If the user passed the filename of the 'script' to execute, get it
|
|
|
|
if (argc > 2 && argv[2]) {
|
2013-10-09 02:30:01 +08:00
|
|
|
if (argv[2][0] == 'f' && //buzzy, if a word 'flush' passed, flush the output after every log entry.
|
|
|
|
argv[2][1] == 'l' &&
|
|
|
|
argv[2][2] == 'u' &&
|
|
|
|
argv[2][3] == 's' &&
|
|
|
|
argv[2][4] == 'h')
|
|
|
|
{
|
|
|
|
printf("Output will be flushed after every print.\n");
|
|
|
|
flushAfterWrite = 1;
|
|
|
|
}
|
2016-01-21 00:45:42 +08:00
|
|
|
else {
|
|
|
|
marg.script_cmds_file = argv[2];
|
|
|
|
}
|
2013-09-15 17:33:17 +08:00
|
|
|
}
|
2013-10-09 02:30:01 +08:00
|
|
|
|
2013-09-15 17:33:17 +08:00
|
|
|
// create a mutex to avoid interlacing print commands from our different threads
|
|
|
|
pthread_mutex_init(&print_lock, NULL);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2015-11-10 04:46:57 +08:00
|
|
|
pthread_create(&main_loop_threat, NULL, &main_loop, &marg);
|
2013-09-15 17:33:17 +08:00
|
|
|
InitGraphics(argc, argv);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2013-09-15 17:33:17 +08:00
|
|
|
MainGraphics();
|
|
|
|
|
2015-11-10 04:46:57 +08:00
|
|
|
pthread_join(main_loop_threat, NULL);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2013-09-15 17:33:17 +08:00
|
|
|
// Clean up the port
|
2016-01-21 00:45:42 +08:00
|
|
|
if (offline == 0)
|
|
|
|
uart_close(sp);
|
2013-09-15 17:33:17 +08:00
|
|
|
|
|
|
|
// clean up mutex
|
|
|
|
pthread_mutex_destroy(&print_lock);
|
2016-02-09 21:48:42 +08:00
|
|
|
|
2015-11-10 04:46:57 +08:00
|
|
|
exit(0);
|
2009-04-09 14:43:20 +08:00
|
|
|
}
|