mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 22:33:48 -07:00
modified the CLI prompt to also show if TCP/UDP is used in the communication
This commit is contained in:
parent
b9ae38f888
commit
a35bfbb13e
6 changed files with 54 additions and 9 deletions
|
@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- Changed the CLI prompt to show tcp/udp if used (@iceman1001)
|
||||||
|
- Changed `hw ping` - now shows transfer time (@doegox)
|
||||||
- Added `hf mf encodehid` - writes HID legacy credential to a empty MFC (@iceman1001)
|
- Added `hf mf encodehid` - writes HID legacy credential to a empty MFC (@iceman1001)
|
||||||
- Added `hf iclass sam` - Added support for HID SAM Picopass communications (@iceman1001)
|
- Added `hf iclass sam` - Added support for HID SAM Picopass communications (@iceman1001)
|
||||||
- Add support for quoted arguments in the CLI, allowing spaces in them which
|
- Add support for quoted arguments in the CLI, allowing spaces in them which
|
||||||
|
|
|
@ -54,6 +54,13 @@ typedef enum {
|
||||||
FPGA_MEM,
|
FPGA_MEM,
|
||||||
} DeviceMemType_t;
|
} DeviceMemType_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PM3_TCPv4,
|
||||||
|
PM3_TCPv6,
|
||||||
|
PM3_UDPv4,
|
||||||
|
PM3_NONE,
|
||||||
|
} CommunicationProtol_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool run; // If TRUE, continue running the uart_communication thread
|
bool run; // If TRUE, continue running the uart_communication thread
|
||||||
bool block_after_ACK; // if true, block after receiving an ACK package
|
bool block_after_ACK; // if true, block after receiving an ACK package
|
||||||
|
@ -62,6 +69,8 @@ typedef struct {
|
||||||
bool send_with_crc_on_fpc;
|
bool send_with_crc_on_fpc;
|
||||||
// "Session" flag, to tell via which interface next msgs are sent: USB or FPC USART
|
// "Session" flag, to tell via which interface next msgs are sent: USB or FPC USART
|
||||||
bool send_via_fpc_usart;
|
bool send_via_fpc_usart;
|
||||||
|
// to tell if we are using TCP/UDP/TCPv6
|
||||||
|
CommunicationProtol_t send_via_ip;
|
||||||
// To memorise baudrate
|
// To memorise baudrate
|
||||||
uint32_t uart_speed;
|
uint32_t uart_speed;
|
||||||
uint16_t last_command;
|
uint16_t last_command;
|
||||||
|
|
|
@ -127,9 +127,10 @@ static void showBanner(void) {
|
||||||
|
|
||||||
static const char *prompt_dev = "";
|
static const char *prompt_dev = "";
|
||||||
static const char *prompt_ctx = "";
|
static const char *prompt_ctx = "";
|
||||||
|
static const char *prompt_net = "";
|
||||||
|
|
||||||
static void prompt_compose(char *buf, size_t buflen, const char *promptctx, const char *promptdev) {
|
static void prompt_compose(char *buf, size_t buflen, const char *promptctx, const char *promptdev, const char *promptnet) {
|
||||||
snprintf(buf, buflen - 1, PROXPROMPT_COMPOSE, promptdev, promptctx);
|
snprintf(buf, buflen - 1, PROXPROMPT_COMPOSE, promptdev, promptnet, promptctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_comm(void) {
|
static int check_comm(void) {
|
||||||
|
@ -138,7 +139,7 @@ static int check_comm(void) {
|
||||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n");
|
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n");
|
||||||
prompt_dev = PROXPROMPT_DEV_OFFLINE;
|
prompt_dev = PROXPROMPT_DEV_OFFLINE;
|
||||||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev, prompt_net);
|
||||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
|
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
|
||||||
pm3line_update_prompt(prompt_filtered);
|
pm3line_update_prompt(prompt_filtered);
|
||||||
|
@ -265,10 +266,27 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||||
|
|
||||||
bool printprompt = false;
|
bool printprompt = false;
|
||||||
if (g_session.pm3_present) {
|
if (g_session.pm3_present) {
|
||||||
if (g_conn.send_via_fpc_usart == false)
|
|
||||||
prompt_dev = PROXPROMPT_DEV_USB;
|
switch(g_conn.send_via_ip) {
|
||||||
else
|
case PM3_TCPv4:
|
||||||
|
prompt_net = PROXPROMPT_NET_TCPV4;
|
||||||
|
break;
|
||||||
|
case PM3_TCPv6:
|
||||||
|
prompt_net = PROXPROMPT_NET_TCPV6;
|
||||||
|
break;
|
||||||
|
case PM3_UDPv4:
|
||||||
|
prompt_net = PROXPROMPT_NET_UDPV4;
|
||||||
|
break;
|
||||||
|
case PM3_NONE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_conn.send_via_fpc_usart)
|
||||||
prompt_dev = PROXPROMPT_DEV_FPC;
|
prompt_dev = PROXPROMPT_DEV_FPC;
|
||||||
|
else
|
||||||
|
prompt_dev = PROXPROMPT_DEV_USB;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
prompt_dev = PROXPROMPT_DEV_OFFLINE;
|
prompt_dev = PROXPROMPT_DEV_OFFLINE;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +359,7 @@ check_script:
|
||||||
pm3line_check(check_comm);
|
pm3line_check(check_comm);
|
||||||
prompt_ctx = PROXPROMPT_CTX_INTERACTIVE;
|
prompt_ctx = PROXPROMPT_CTX_INTERACTIVE;
|
||||||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev, prompt_net);
|
||||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
|
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
|
||||||
g_pendingPrompt = true;
|
g_pendingPrompt = true;
|
||||||
|
@ -391,7 +409,7 @@ check_script:
|
||||||
g_printAndLog &= PRINTANDLOG_LOG;
|
g_printAndLog &= PRINTANDLOG_LOG;
|
||||||
}
|
}
|
||||||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev, prompt_net);
|
||||||
// always filter RL magic separators if not using readline
|
// always filter RL magic separators if not using readline
|
||||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||||
memcpy_filter_rlmarkers(prompt_filtered, prompt, sizeof(prompt_filtered));
|
memcpy_filter_rlmarkers(prompt_filtered, prompt, sizeof(prompt_filtered));
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#define PROXPROMPT_MAX_SIZE 255
|
#define PROXPROMPT_MAX_SIZE 255
|
||||||
|
|
||||||
#define PROXPROMPT_COMPOSE "[" "%s%s" "] pm3 --> "
|
#define PROXPROMPT_COMPOSE "[" "%s%s%s" "] pm3 --> "
|
||||||
|
|
||||||
#define PROXPROMPT_CTX_SCRIPTFILE "|" _RL_GREEN_("script")
|
#define PROXPROMPT_CTX_SCRIPTFILE "|" _RL_GREEN_("script")
|
||||||
#define PROXPROMPT_CTX_SCRIPTCMD "|" _RL_GREEN_("script")
|
#define PROXPROMPT_CTX_SCRIPTCMD "|" _RL_GREEN_("script")
|
||||||
|
@ -35,6 +35,11 @@
|
||||||
#define PROXPROMPT_DEV_FPC _RL_BOLD_GREEN_("fpc")
|
#define PROXPROMPT_DEV_FPC _RL_BOLD_GREEN_("fpc")
|
||||||
#define PROXPROMPT_DEV_OFFLINE _RL_BOLD_RED_("offline")
|
#define PROXPROMPT_DEV_OFFLINE _RL_BOLD_RED_("offline")
|
||||||
|
|
||||||
|
#define PROXPROMPT_NET_TCPV4 "|" _RL_BOLD_GREEN_("tcp")
|
||||||
|
#define PROXPROMPT_NET_UDPV4 "|" _RL_BOLD_GREEN_("udp")
|
||||||
|
#define PROXPROMPT_NET_TCPV6 "|" _RL_BOLD_GREEN_("tcp v6")
|
||||||
|
|
||||||
|
|
||||||
#define PROXHISTORY "history.txt"
|
#define PROXHISTORY "history.txt"
|
||||||
#define PROXLOG "log_%Y%m%d%H%M%S.txt"
|
#define PROXLOG "log_%Y%m%d%H%M%S.txt"
|
||||||
#define MAX_NESTED_CMDSCRIPT 10
|
#define MAX_NESTED_CMDSCRIPT 10
|
||||||
|
|
|
@ -206,6 +206,8 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
free(sp);
|
free(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_conn.send_via_ip = PM3_TCPv4;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +315,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
sp->fd = sfd;
|
sp->fd = sfd;
|
||||||
sp->udpBuffer = RingBuf_create(MAX(sizeof(PacketResponseNGRaw), sizeof(PacketResponseOLD)) * 30);
|
sp->udpBuffer = RingBuf_create(MAX(sizeof(PacketResponseNGRaw), sizeof(PacketResponseOLD)) * 30);
|
||||||
|
|
||||||
|
g_conn.send_via_ip = PM3_UDPv4;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +363,8 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sp->fd = sfd;
|
sp->fd = sfd;
|
||||||
|
|
||||||
|
g_conn.send_via_ip = PM3_NONE;
|
||||||
return sp;
|
return sp;
|
||||||
#else // HAVE_BLUEZ
|
#else // HAVE_BLUEZ
|
||||||
PrintAndLogEx(ERR, "Sorry, this client doesn't support native Bluetooth addresses");
|
PrintAndLogEx(ERR, "Sorry, this client doesn't support native Bluetooth addresses");
|
||||||
|
@ -411,6 +416,8 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sp->fd = localsocket;
|
sp->fd = localsocket;
|
||||||
|
|
||||||
|
g_conn.send_via_ip = PM3_NONE;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,6 +487,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_conn.uart_speed = uart_get_speed(sp);
|
g_conn.uart_speed = uart_get_speed(sp);
|
||||||
|
g_conn.send_via_ip = PM3_NONE;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
free(sp);
|
free(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
g_conn.send_via_ip = PM3_TCPv4;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,6 +346,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
sp->hSocket = hSocket;
|
sp->hSocket = hSocket;
|
||||||
sp->udpBuffer = RingBuf_create(MAX(sizeof(PacketResponseNGRaw), sizeof(PacketResponseOLD)) * 30);
|
sp->udpBuffer = RingBuf_create(MAX(sizeof(PacketResponseNGRaw), sizeof(PacketResponseOLD)) * 30);
|
||||||
|
|
||||||
|
g_conn.send_via_ip = PM3_UDPv4;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,6 +392,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_conn.uart_speed = uart_get_speed(sp);
|
g_conn.uart_speed = uart_get_speed(sp);
|
||||||
|
g_conn.send_via_ip = PM3_NONE;
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue