test_final / remote_debug.py
sigyllly's picture
Upload 21 files
a108fe5 verified
Raw
History Blame Contribute Delete
3.12 kB
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()