Skip to content

Commit

Permalink
added the udpv6 and also try to identify when v6 is used (tcp/udp)
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Oct 20, 2023
1 parent a35bfbb commit 0dc921c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions client/src/comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef enum {
PM3_TCPv4,
PM3_TCPv6,
PM3_UDPv4,
PM3_UDPv6,
PM3_NONE,
} CommunicationProtol_t;

Expand Down
3 changes: 3 additions & 0 deletions client/src/proxmark3.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
case PM3_UDPv4:
prompt_net = PROXPROMPT_NET_UDPV4;
break;
case PM3_UDPv6:
prompt_net = PROXPROMPT_NET_UDPV6;
break;
case PM3_NONE:
default:
break;
Expand Down
1 change: 1 addition & 0 deletions client/src/proxmark3.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#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 PROXPROMPT_NET_UDPV6 "|" _RL_BOLD_GREEN_("udp v6")


#define PROXHISTORY "history.txt"
Expand Down
13 changes: 9 additions & 4 deletions client/src/uart/uart_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
}
}


// assume v4
g_conn.send_via_ip = PM3_TCPv4;

// find the port
char *lColon = strchr(addrPortStr, ':');
char *rColon = strrchr(addrPortStr, ':');
Expand All @@ -151,6 +155,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
} else {
portstr = "18888";
}
g_conn.send_via_ip = PM3_TCPv6;
}

// handle the end of the address
Expand Down Expand Up @@ -207,7 +212,6 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
return INVALID_SERIAL_PORT;
}

g_conn.send_via_ip = PM3_TCPv4;
return sp;
}

Expand Down Expand Up @@ -244,6 +248,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
}
}

// Assume v4
g_conn.send_via_ip = PM3_UDPv4;

// find the port
char *lColon = strchr(addrPortStr, ':');
char *rColon = strrchr(addrPortStr, ':');
Expand All @@ -264,6 +271,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
} else {
portstr = "18888";
}
g_conn.send_via_ip = PM3_UDPv6;
}

// handle the end of the address
Expand All @@ -279,7 +287,6 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {

info.ai_family = PF_UNSPEC;
info.ai_socktype = SOCK_DGRAM;
// info.ai_protocol = SOL_UDP;

int s = getaddrinfo(addrstr, portstr, &info, &addr);
if (s != 0) {
Expand Down Expand Up @@ -314,8 +321,6 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {

sp->fd = sfd;
sp->udpBuffer = RingBuf_create(MAX(sizeof(PacketResponseNGRaw), sizeof(PacketResponseOLD)) * 30);

g_conn.send_via_ip = PM3_UDPv4;
return sp;
}

Expand Down
11 changes: 8 additions & 3 deletions client/src/uart/uart_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
}
}

// Assume v4
g_conn.send_via_ip = PM3_TCPv4;

// find the port
char *lColon = strchr(addrPortStr, ':');
char *rColon = strrchr(addrPortStr, ':');
Expand All @@ -155,6 +158,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
} else {
portstr = "18888";
}
g_conn.send_via_ip = PM3_TCPv6;
}

// handle the end of the address
Expand Down Expand Up @@ -225,7 +229,6 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
free(sp);
return INVALID_SERIAL_PORT;
}
g_conn.send_via_ip = PM3_TCPv4;
return sp;
}

Expand Down Expand Up @@ -263,6 +266,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
}
}

// Assume v4
g_conn.send_via_ip = PM3_UDPv4;

// find the port
char *lColon = strchr(addrPortStr, ':');
char *rColon = strrchr(addrPortStr, ':');
Expand All @@ -283,6 +289,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
} else {
portstr = "18888";
}
g_conn.send_via_ip = PM3_UDPv6;
}

// handle the end of the address
Expand Down Expand Up @@ -345,8 +352,6 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {

sp->hSocket = hSocket;
sp->udpBuffer = RingBuf_create(MAX(sizeof(PacketResponseNGRaw), sizeof(PacketResponseOLD)) * 30);

g_conn.send_via_ip = PM3_UDPv4;
return sp;
}

Expand Down

0 comments on commit 0dc921c

Please sign in to comment.