recovered snapshot from suspended aaronjaworski710 (history unavailable)
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
from patchright.sync_api import sync_playwright
|
||||
import os, json, shutil, base64, time
|
||||
|
||||
EMAIL = json.load(open("viktor_gws_user.json"))["email"]
|
||||
secret = open("_gv.txt").read().strip()
|
||||
PDIR = os.environ.get("PROFILE_DIR", "browser_profile")
|
||||
shutil.rmtree(PDIR, ignore_errors=True)
|
||||
URL = "https://api.viktor.com/oauth/google/login?app_url=https%3A%2F%2Fapp.viktor.com&simple_flow=true&user_type=ai_coworker&intent=signup"
|
||||
|
||||
def dump_buttons(page, tag):
|
||||
try:
|
||||
btns = page.eval_on_selector_all("button, [role=button], c-wiz button", "els=>els.map(e=>(e.innerText||e.getAttribute('aria-label')||'').trim()).filter(x=>x)")
|
||||
print(f"[{tag}] BUTTONS:", btns[:15])
|
||||
except Exception as e:
|
||||
print("btn dump err", str(e)[:60])
|
||||
|
||||
with sync_playwright() as p:
|
||||
ctx = p.chromium.launch_persistent_context(PDIR, headless=False, no_viewport=True, channel="chromium")
|
||||
page = ctx.new_page()
|
||||
page.goto(URL, timeout=90000)
|
||||
page.wait_for_timeout(7000)
|
||||
|
||||
# step 1: email
|
||||
ident = page.locator("input[type=email], input[name=identifier]").first
|
||||
ident.type(EMAIL, delay=50); page.wait_for_timeout(1200)
|
||||
page.evaluate("document.querySelector('#identifierNext button')?.click()")
|
||||
page.wait_for_timeout(8000)
|
||||
print("after email:", page.url[:100])
|
||||
|
||||
# step 2: password
|
||||
pwf = page.locator("input[type=password], input[name=Passwd]").first
|
||||
if pwf.is_visible(timeout=10000):
|
||||
pwf.type(secret, delay=50); page.wait_for_timeout(1200)
|
||||
page.evaluate("document.querySelector('#passwordNext button')?.click()")
|
||||
page.wait_for_timeout(10000)
|
||||
print("after pw:", page.url[:120])
|
||||
|
||||
# step 3: handle workspace ToS / consent loops (up to 6 rounds)
|
||||
for i in range(6):
|
||||
url = page.url
|
||||
if "viktor.com" in url and "google" not in url and "signin" not in url:
|
||||
print("REACHED VIKTOR:", url[:150]); break
|
||||
dump_buttons(page, f"round{i}")
|
||||
body = page.inner_text("body")[:200].replace("\n"," | ")
|
||||
clicked = False
|
||||
for t in ["Понятно", "I understand", "Understood", "Accept", "Continue", "Allow", "Далее", "Принять", "Я понимаю", "Продолжить", "Разрешить"]:
|
||||
try:
|
||||
el = page.locator(f"button:has-text('{t}')").first
|
||||
if el.is_visible(timeout=1500):
|
||||
el.click(); page.wait_for_timeout(5000); print(f"round{i} clicked '{t}' -> {page.url[:90]}"); clicked=True; break
|
||||
except Exception:
|
||||
pass
|
||||
if not clicked:
|
||||
print(f"round{i} nothing to click; body:", body); break
|
||||
if page.url == url and i > 0:
|
||||
print("stuck at", url[:100]); break
|
||||
|
||||
page.wait_for_timeout(4000)
|
||||
print("FINAL URL:", page.url[:200])
|
||||
print("FINAL BODY:", page.inner_text("body")[:500].replace("\n", " | "))
|
||||
|
||||
# verify session via app
|
||||
page.goto("https://app.viktor.com/web-chat?thread=ghF347dQjKCFXyfPiJ9Rzy", wait_until="domcontentloaded", timeout=90000)
|
||||
page.wait_for_timeout(9000)
|
||||
print("APP URL:", page.url[:200])
|
||||
print("APP BODY:", page.inner_text("body")[:700].replace("\n", " | "))
|
||||
|
||||
cookies = ctx.cookies()
|
||||
vk = {c["name"]: c["value"] for c in cookies if "viktor" in c.get("domain", "")}
|
||||
json.dump({"email": EMAIL, "cookies": cookies, "app_url": page.url}, open("viktor_final_session.json", "w"))
|
||||
sess = vk.get("session", "")
|
||||
is_anon = "anon" in vk.get("anon_session_id", "")
|
||||
print("HAS session cookie:", bool(sess), "| anon?:", is_anon)
|
||||
# try decode as JWT-like (3 parts)
|
||||
if sess.count(".") == 2:
|
||||
for idx in (0, 1):
|
||||
try:
|
||||
pl = sess.split(".")[idx]; pl += "=" * (-len(pl) % 4)
|
||||
dec = base64.urlsafe_b64decode(pl).decode(errors="replace")
|
||||
print(f"session part{idx}:", dec[:250])
|
||||
except Exception:
|
||||
pass
|
||||
page.screenshot(path="viktor_final2.png")
|
||||
ctx.close()
|
||||
Reference in New Issue
Block a user