This may be pretty far outside what you were looking for, but you could also do this in C. Here's a sample program that sends the bytes in your example:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
/* You'd need to change the following values to match your environment */
#define DESTINATION_ADDRESS "127.0.0.1"
#define DESTINATION_PORT 8080
#define MAX_MESSAGE_LENGTH 11
struct message {
int length;
char bytes[MAX_MESSAGE_LENGTH];
};
int main(void)
{
const int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) {
perror("socket");
exit(EXIT_FAILURE);
}
const struct message messageList[] = {
{ .length = 7, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0xd0, 0x02} },
{ .length = 7, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0xd0, 0x02} },
{ .length = 7, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0xd0, 0x02} },
{ .length = 11, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00} },
{ .length = 11, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00} },
{ .length = 7, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0x10, 0x00} },
{ .length = 7, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0xd0, 0x01} },
{ .length = 7, .bytes = { 0x4a, 0x48, 0x43, 0x4d, 0x44, 0xd0, 0x01} },
{ },
};
const struct sockaddr_in servaddr = {
.sin_family = AF_INET,
.sin_port = htons(DESTINATION_PORT),
.sin_addr.s_addr = inet_addr(DESTINATION_ADDRESS),
};
for (int i = 0; messageList[i].length != 0; ++i) {
if (sendto(sockfd,
messageList[i].bytes,
messageList[i].length,
0,
(const struct sockaddr*) &servaddr,
sizeof(servaddr)) < 0) {
perror("sendto");
}
}
close(sockfd);
return EXIT_SUCCESS;
}
The program creates an array of messages called messageList
. Each entry in the array includes (1) the length of the message, and (2) an array of the bytes in the message. A message of length 0 terminates the list.
Next the program creates an object named servaddr
that describe where to send the message and the protocol.
Finally the program loops over the messages, one by one, and sends them to the target.
To compile the program:
$ gcc client.c
That's produce a program called a.out
.
You can set up tcpdump
to watch the messages:
$ sudo tcpdump -i lo -Xn '(udp port 8080)'
dropped privs to tcpdump
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes
Then run a.out
:
$ ./a.out
And I get the following output from tcpdump
:
20:18:19.429320 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 7
0x0000: 4500 0023 bf9f 4000 4011 7d28 7f00 0001 E..#..@.@.}(....
0x0010: 7f00 0001 e623 1f90 000f fe22 4a48 434d .....#....."JHCM
0x0020: 44d0 02 D..
20:18:19.429629 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 7
0x0000: 4500 0023 bfa0 4000 4011 7d27 7f00 0001 E..#..@.@.}'....
0x0010: 7f00 0001 e623 1f90 000f fe22 4a48 434d .....#....."JHCM
0x0020: 44d0 02 D..
20:18:19.429842 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 7
0x0000: 4500 0023 bfa1 4000 4011 7d26 7f00 0001 E..#..@.@.}&....
0x0010: 7f00 0001 e623 1f90 000f fe22 4a48 434d .....#....."JHCM
0x0020: 44d0 02 D..
20:18:19.429906 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 11
0x0000: 4500 0027 bfa2 4000 4011 7d21 7f00 0001 E..'..@.@.}!....
0x0010: 7f00 0001 e623 1f90 0013 fe26 4a48 434d .....#.....&JHCM
0x0020: 4420 0000 0000 00 D......
20:18:19.429979 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 11
0x0000: 4500 0027 bfa3 4000 4011 7d20 7f00 0001 E..'..@.@.}.....
0x0010: 7f00 0001 e623 1f90 0013 fe26 4a48 434d .....#.....&JHCM
0x0020: 4420 0000 0000 00 D......
20:18:19.430086 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 7
0x0000: 4500 0023 bfa4 4000 4011 7d23 7f00 0001 E..#..@.@.}#....
0x0010: 7f00 0001 e623 1f90 000f fe22 4a48 434d .....#....."JHCM
0x0020: 4410 00 D..
20:18:19.430539 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 7
0x0000: 4500 0023 bfa5 4000 4011 7d22 7f00 0001 E..#..@.@.}"....
0x0010: 7f00 0001 e623 1f90 000f fe22 4a48 434d .....#....."JHCM
0x0020: 44d0 01 D..
20:18:19.430652 IP 127.0.0.1.58915 > 127.0.0.1.8080: UDP, length 7
0x0000: 4500 0023 bfa6 4000 4011 7d21 7f00 0001 E..#..@.@.}!....
0x0010: 7f00 0001 e623 1f90 000f fe22 4a48 434d .....#....."JHCM
0x0020: 44d0 01 D..
Notice that each message begins with JHCMD
-- that might be interesting as part of your investigation (e.g., https://shkspr.mobi/blog/2020/06/review-wifi-endoscope/).