File size: 3,116 Bytes
a108fe5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import time
import socket
import requests
import sys

print("[*] Loading modules...")
try:
    from cloakbrowser import launch, launch_persistent_context 
except ImportError:
    print("[!] CloakBrowser is not installed! Run: pip install cloakbrowser")
    sys.exit(1)

def get_lan_ip():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.connect(("8.8.8.8", 80))
        return s.getsockname()[0]
    finally:
        s.close()

# --- Defined variables before they are used ---
PC_IP = get_lan_ip()
PORT = 9222

print("=" * 70)
print("[*] Initializing Stealth CloakBrowser Binary...")
print("[*] NOTE: If this is your first run, it will silently download")
print("[*] a ~200MB custom Chromium binary. Please wait a moment...")
print("=" * 70)

try:
    context = launch_persistent_context(
        "c:\\Users\\Nobel\\Downloads\\cloak_profile", 
        headless=True,  
        humanize=True,  
        args=[
            f"--remote-debugging-port={PORT}",
            "--remote-debugging-address=0.0.0.0",
            "--remote-allow-origins=*",
            "--disable-gpu"
        ]
    )
    print("[] CloakBrowser Binary Engine started successfully!")
except Exception as e:
    print(f"[X] Launch Error: {e}")
    sys.exit(1)

# Open the Google / YouTube authentication page
page = context.new_page()
page.set_viewport_size({"width": 360, "height": 740}) 
print("[*] Navigating headlessly to Google Authentication page...")
page.goto("https://accounts.google.com")

time.sleep(3)  # Extra room for the local debugger socket to spin up

try:
    # Extract target details
    targets = requests.get(f"http://127.0.0.1:{PORT}/json").json()
    target = next(t for t in targets if "accounts.google.com" in t["url"] or "google" in t["url"])
    page_id = target["id"]

    clean_android_url = f"http://{PC_IP}:{PORT}/devtools/inspector.html?ws={PC_IP}:{PORT}/devtools/page/{page_id}"

    print("\n" + "=" * 70)
    print("OPEN THIS URL IN CHROME ON YOUR ANDROID PHONE:")
    print("=" * 70)
    print(clean_android_url)
    print("=" * 70)
except Exception as e:
    print(f"[X] Socket Mapping Error: Could not read DevTools JSON panel. Details: {e}")

print("\nPress Ctrl+C in this terminal when finished to dump cookies.txt.")

try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("\n[Saving] Extracting cookies to Netscape format...")
    cookies = context.cookies()
    
    with open("cookies.txt", "w", encoding="utf-8") as f:
        f.write("# Netscape HTTP Cookie File\n")
        for cookie in cookies:
            domain = cookie['domain']
            sub = "TRUE" if domain.startswith(".") else "FALSE"
            path = cookie['path']
            sec = "TRUE" if cookie['secure'] else "FALSE"
            exp = str(int(cookie.get('expires', -1)))
            f.write(f"{domain}\t{sub}\t{path}\t{sec}\t{exp}\t{cookie['name']}\t{cookie['value']}\n")
            
    print("[✓] Success! cookies.txt written. Closing CloakBrowser safely.")
    context.close()