doescap 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- doescap/__init__.py +26 -0
- doescap/browser.py +187 -0
- doescap/cdp.py +156 -0
- doescap/cli.py +125 -0
- doescap/client.py +670 -0
- doescap/config.py +104 -0
- doescap/network.py +87 -0
- doescap/py.typed +1 -0
- doescap/server.py +199 -0
- doescap/templates.py +651 -0
- doescap-1.0.0.dist-info/METADATA +235 -0
- doescap-1.0.0.dist-info/RECORD +16 -0
- doescap-1.0.0.dist-info/WHEEL +5 -0
- doescap-1.0.0.dist-info/entry_points.txt +2 -0
- doescap-1.0.0.dist-info/licenses/LICENSE +21 -0
- doescap-1.0.0.dist-info/top_level.txt +1 -0
doescap/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DoesCap: A lightweight, cross-platform hCaptcha relay and solver library.
|
|
3
|
+
|
|
4
|
+
Works natively on Windows, macOS, Linux, and Android (Termux).
|
|
5
|
+
Provides both Direct In-Browser solving (zero overhead, 60/120Hz native touch)
|
|
6
|
+
and Headless CDP Screencast mode.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from .config import RelayConfig, SolveResult
|
|
12
|
+
from .client import DoesCap, HCaptchaRelay, solve_captcha, async_solve_captcha
|
|
13
|
+
from .network import get_local_ip
|
|
14
|
+
|
|
15
|
+
__version__ = "1.0.0"
|
|
16
|
+
__author__ = "GhoSty"
|
|
17
|
+
__all__ = [
|
|
18
|
+
"DoesCap",
|
|
19
|
+
"HCaptchaRelay",
|
|
20
|
+
"RelayConfig",
|
|
21
|
+
"SolveResult",
|
|
22
|
+
"solve_captcha",
|
|
23
|
+
"async_solve_captcha",
|
|
24
|
+
"get_local_ip",
|
|
25
|
+
"__version__",
|
|
26
|
+
]
|
doescap/browser.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Cross-platform browser launcher and binary detector."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import webbrowser
|
|
10
|
+
from typing import Optional, Tuple
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def is_android_termux() -> bool:
|
|
14
|
+
"""Check if execution environment is running inside Android or Termux."""
|
|
15
|
+
return (
|
|
16
|
+
"ANDROID_ROOT" in os.environ
|
|
17
|
+
or "TERMUX_VERSION" in os.environ
|
|
18
|
+
or "com.termux" in os.environ.get("PREFIX", "")
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def open_browser(url: str) -> bool:
|
|
23
|
+
"""Open the given URL in the default browser across all operating systems.
|
|
24
|
+
|
|
25
|
+
Supports Android/Termux via termux tools and Android Activity Manager (am),
|
|
26
|
+
Linux via xdg-open, and standard systems via Python's webbrowser module.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
url: Full HTTP/HTTPS URL string to open.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
True if an opener command was initiated successfully, False otherwise.
|
|
33
|
+
"""
|
|
34
|
+
candidates = [
|
|
35
|
+
# Termux URL openers
|
|
36
|
+
["termux-open-url", url],
|
|
37
|
+
["termux-open", url],
|
|
38
|
+
# Android Chrome intent
|
|
39
|
+
["am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", url, "-n", "com.android.chrome/com.google.android.apps.chrome.Main"],
|
|
40
|
+
["am", "start", "-a", "android.intent.action.VIEW", "-d", url, "-n", "com.android.chrome/com.google.android.apps.chrome.Main"],
|
|
41
|
+
# Android generic VIEW intent
|
|
42
|
+
["am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", url],
|
|
43
|
+
["am", "start", "-a", "android.intent.action.VIEW", "-d", url],
|
|
44
|
+
# Explicit system path for am on rooted or restricted devices
|
|
45
|
+
["/system/bin/am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", url, "-n", "com.android.chrome/com.google.android.apps.chrome.Main"],
|
|
46
|
+
["/system/bin/am", "start", "-a", "android.intent.action.VIEW", "-d", url, "-n", "com.android.chrome/com.google.android.apps.chrome.Main"],
|
|
47
|
+
["/system/bin/am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", url],
|
|
48
|
+
["/system/bin/am", "start", "-a", "android.intent.action.VIEW", "-d", url],
|
|
49
|
+
# Linux desktop
|
|
50
|
+
["xdg-open", url],
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
for cmd in candidates:
|
|
54
|
+
try:
|
|
55
|
+
exe = shutil.which(cmd[0]) or (cmd[0] if os.path.exists(cmd[0]) else None)
|
|
56
|
+
if exe:
|
|
57
|
+
subprocess.Popen(
|
|
58
|
+
[exe] + cmd[1:],
|
|
59
|
+
stdout=subprocess.DEVNULL,
|
|
60
|
+
stderr=subprocess.DEVNULL,
|
|
61
|
+
)
|
|
62
|
+
return True
|
|
63
|
+
except Exception:
|
|
64
|
+
continue
|
|
65
|
+
|
|
66
|
+
# Fallback to standard Python webbrowser
|
|
67
|
+
try:
|
|
68
|
+
webbrowser.open(url, new=2)
|
|
69
|
+
return True
|
|
70
|
+
except Exception:
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def find_browser(override_path: Optional[str] = None) -> Tuple[Optional[str], Optional[str]]:
|
|
75
|
+
"""Locate an installed Chromium-compatible browser executable.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
override_path: Optional explicit file path or keyword binary name.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
Tuple of (executable_path, friendly_name), or (None, None) if not found.
|
|
82
|
+
"""
|
|
83
|
+
if override_path:
|
|
84
|
+
clean = override_path.strip().strip('"').strip("'")
|
|
85
|
+
if os.path.isfile(clean):
|
|
86
|
+
return clean, "Custom Browser"
|
|
87
|
+
|
|
88
|
+
kw = clean.lower()
|
|
89
|
+
which_path = shutil.which(kw)
|
|
90
|
+
if which_path and "WindowsApps" not in which_path and os.path.isfile(which_path):
|
|
91
|
+
return which_path, f"{kw.capitalize()} (PATH)"
|
|
92
|
+
|
|
93
|
+
# Termux does not host full desktop Chromium with CDP by default
|
|
94
|
+
if is_android_termux():
|
|
95
|
+
return None, None
|
|
96
|
+
|
|
97
|
+
if os.name == "nt":
|
|
98
|
+
prog = os.environ.get("PROGRAMFILES", r"C:\Program Files")
|
|
99
|
+
prog86 = os.environ.get("PROGRAMFILES(X86)", r"C:\Program Files (x86)")
|
|
100
|
+
local = os.environ.get("LOCALAPPDATA", "")
|
|
101
|
+
|
|
102
|
+
chrome_candidates = [
|
|
103
|
+
os.path.join(prog, "Google", "Chrome", "Application", "chrome.exe"),
|
|
104
|
+
os.path.join(prog86, "Google", "Chrome", "Application", "chrome.exe"),
|
|
105
|
+
os.path.join(local, "Google", "Chrome", "Application", "chrome.exe"),
|
|
106
|
+
os.path.join(local, "Google", "Chrome SxS", "Application", "chrome.exe"),
|
|
107
|
+
]
|
|
108
|
+
for p in chrome_candidates:
|
|
109
|
+
if os.path.isfile(p):
|
|
110
|
+
return p, "Google Chrome"
|
|
111
|
+
|
|
112
|
+
brave_candidates = [
|
|
113
|
+
os.path.join(prog, "BraveSoftware", "Brave-Browser", "Application", "brave.exe"),
|
|
114
|
+
os.path.join(local, "BraveSoftware", "Brave-Browser", "Application", "brave.exe"),
|
|
115
|
+
os.path.join(prog86, "BraveSoftware", "Brave-Browser", "Application", "brave.exe"),
|
|
116
|
+
]
|
|
117
|
+
for p in brave_candidates:
|
|
118
|
+
if os.path.isfile(p):
|
|
119
|
+
return p, "Brave Browser"
|
|
120
|
+
|
|
121
|
+
chromium_candidates = [
|
|
122
|
+
os.path.join(local, "Chromium", "Application", "chrome.exe"),
|
|
123
|
+
os.path.join(prog, "Chromium", "Application", "chrome.exe"),
|
|
124
|
+
os.path.join(prog86, "Chromium", "Application", "chrome.exe"),
|
|
125
|
+
]
|
|
126
|
+
for p in chromium_candidates:
|
|
127
|
+
if os.path.isfile(p):
|
|
128
|
+
return p, "Chromium"
|
|
129
|
+
|
|
130
|
+
edge_candidates = [
|
|
131
|
+
os.path.join(prog86, "Microsoft", "Edge", "Application", "msedge.exe"),
|
|
132
|
+
os.path.join(prog, "Microsoft", "Edge", "Application", "msedge.exe"),
|
|
133
|
+
os.path.join(local, "Microsoft", "Edge", "Application", "msedge.exe"),
|
|
134
|
+
]
|
|
135
|
+
for p in edge_candidates:
|
|
136
|
+
if os.path.isfile(p):
|
|
137
|
+
return p, "Microsoft Edge"
|
|
138
|
+
|
|
139
|
+
opera_candidates = [
|
|
140
|
+
os.path.join(local, "Programs", "Opera", "opera.exe"),
|
|
141
|
+
os.path.join(local, "Programs", "Opera GX", "opera.exe"),
|
|
142
|
+
os.path.join(prog, "Opera", "launcher.exe"),
|
|
143
|
+
os.path.join(prog86, "Opera", "launcher.exe"),
|
|
144
|
+
]
|
|
145
|
+
for p in opera_candidates:
|
|
146
|
+
if os.path.isfile(p):
|
|
147
|
+
return p, "Opera"
|
|
148
|
+
|
|
149
|
+
vivaldi_candidates = [
|
|
150
|
+
os.path.join(local, "Vivaldi", "Application", "vivaldi.exe"),
|
|
151
|
+
os.path.join(prog, "Vivaldi", "Application", "vivaldi.exe"),
|
|
152
|
+
os.path.join(prog86, "Vivaldi", "Application", "vivaldi.exe"),
|
|
153
|
+
]
|
|
154
|
+
for p in vivaldi_candidates:
|
|
155
|
+
if os.path.isfile(p):
|
|
156
|
+
return p, "Vivaldi"
|
|
157
|
+
|
|
158
|
+
if sys.platform == "darwin":
|
|
159
|
+
mac_paths = [
|
|
160
|
+
("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "Google Chrome"),
|
|
161
|
+
("/Applications/Brave Browser.app/Contents/MacOS/Brave Browser", "Brave Browser"),
|
|
162
|
+
("/Applications/Chromium.app/Contents/MacOS/Chromium", "Chromium"),
|
|
163
|
+
("/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "Microsoft Edge"),
|
|
164
|
+
("/Applications/Opera.app/Contents/MacOS/Opera", "Opera"),
|
|
165
|
+
("/Applications/Vivaldi.app/Contents/MacOS/Vivaldi", "Vivaldi"),
|
|
166
|
+
]
|
|
167
|
+
for p, name in mac_paths:
|
|
168
|
+
if os.path.isfile(p):
|
|
169
|
+
return p, name
|
|
170
|
+
|
|
171
|
+
linux_names = [
|
|
172
|
+
("google-chrome-stable", "Google Chrome"),
|
|
173
|
+
("google-chrome", "Google Chrome"),
|
|
174
|
+
("brave-browser", "Brave Browser"),
|
|
175
|
+
("brave", "Brave Browser"),
|
|
176
|
+
("chromium", "Chromium"),
|
|
177
|
+
("chromium-browser", "Chromium"),
|
|
178
|
+
("msedge", "Microsoft Edge"),
|
|
179
|
+
("opera", "Opera"),
|
|
180
|
+
("vivaldi", "Vivaldi"),
|
|
181
|
+
]
|
|
182
|
+
for binary_name, friendly_name in linux_names:
|
|
183
|
+
p = shutil.which(binary_name)
|
|
184
|
+
if p and "WindowsApps" not in p and os.path.isfile(p):
|
|
185
|
+
return p, friendly_name
|
|
186
|
+
|
|
187
|
+
return None, None
|
doescap/cdp.py
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Chrome DevTools Protocol (CDP) client for headless screencast mode."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import threading
|
|
7
|
+
from typing import Any, Dict, Optional, Tuple
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import websocket
|
|
11
|
+
HAVE_WEBSOCKET = True
|
|
12
|
+
except ImportError:
|
|
13
|
+
websocket = None
|
|
14
|
+
HAVE_WEBSOCKET = False
|
|
15
|
+
|
|
16
|
+
CDP_USER_AGENT = (
|
|
17
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
18
|
+
"(KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
CDP_BOOT_SCRIPT = """
|
|
22
|
+
(() => {{
|
|
23
|
+
if (window.__hcrBoot && document.getElementById('hcr-box')) return 'ok';
|
|
24
|
+
window.__hcrBoot = 1;
|
|
25
|
+
window.__hcrToken = null;
|
|
26
|
+
let host = document.getElementById('hcr-box');
|
|
27
|
+
const rq = {rqdata};
|
|
28
|
+
if (!host) {{
|
|
29
|
+
host = document.createElement('div');
|
|
30
|
+
host.id = 'hcr-box';
|
|
31
|
+
host.style.cssText = 'position:fixed;left:20px;top:80px;z-index:2147483647';
|
|
32
|
+
if (rq) host.setAttribute('data-rqdata', rq);
|
|
33
|
+
host.setAttribute('data-sitekey', {sitekey});
|
|
34
|
+
document.body.appendChild(host);
|
|
35
|
+
}}
|
|
36
|
+
|
|
37
|
+
window.__hcrReady = () => {{
|
|
38
|
+
if (!window.hcaptcha || !window.hcaptcha.render) return setTimeout(window.__hcrReady, 100);
|
|
39
|
+
const opts = {{
|
|
40
|
+
sitekey: {sitekey},
|
|
41
|
+
callback: function(token) {{ window.__hcrToken = token; }},
|
|
42
|
+
"error-callback": function(e) {{ console.error('hcr error', e); }},
|
|
43
|
+
"expired-callback": function() {{ window.__hcrToken = null; }}
|
|
44
|
+
}};
|
|
45
|
+
if (rq) opts.rqdata = rq;
|
|
46
|
+
try {{
|
|
47
|
+
window.__hcrId = hcaptcha.render('hcr-box', opts);
|
|
48
|
+
if (rq && window.hcaptcha && window.hcaptcha.setData) {{
|
|
49
|
+
try {{ window.hcaptcha.setData(window.__hcrId, {{ rqdata: rq }}); }} catch(e) {{}}
|
|
50
|
+
}}
|
|
51
|
+
}} catch (e) {{
|
|
52
|
+
console.error('render failed', e);
|
|
53
|
+
}}
|
|
54
|
+
}};
|
|
55
|
+
|
|
56
|
+
if (window.hcaptcha && window.hcaptcha.render) {{
|
|
57
|
+
window.__hcrReady();
|
|
58
|
+
}} else {{
|
|
59
|
+
const s = document.createElement('script');
|
|
60
|
+
s.src = 'https://js.hcaptcha.com/1/api.js?onload=__hcrReady&render=explicit';
|
|
61
|
+
document.head.appendChild(s);
|
|
62
|
+
}}
|
|
63
|
+
return 'ok';
|
|
64
|
+
}})()
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
CDP_RECT_SCRIPT = """(() => {
|
|
68
|
+
const frames = Array.from(document.querySelectorAll('iframe'));
|
|
69
|
+
const challengeFrame = frames.find(f => (f.title === 'hCaptcha challenge' || (f.src && f.src.includes('frame=challenge'))) && f.getBoundingClientRect().width > 100 && f.getBoundingClientRect().y > -500);
|
|
70
|
+
if (challengeFrame) {
|
|
71
|
+
const r = challengeFrame.getBoundingClientRect();
|
|
72
|
+
if (r.width > 100 && r.height > 100) {
|
|
73
|
+
return { x: r.x, y: r.y, w: r.width, h: r.height };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const checkboxFrame = document.querySelector('#hcr-box iframe') || frames.find(f => f.title && f.title.includes('checkbox'));
|
|
77
|
+
if (!checkboxFrame) return null;
|
|
78
|
+
const r = checkboxFrame.getBoundingClientRect();
|
|
79
|
+
if (!r.width || !r.height) return null;
|
|
80
|
+
return { x: r.x, y: r.y, w: r.width, h: r.height };
|
|
81
|
+
})()"""
|
|
82
|
+
|
|
83
|
+
CDP_TOKEN_SCRIPT = """(() => {
|
|
84
|
+
if (window.__hcrToken) return window.__hcrToken;
|
|
85
|
+
const hResp = document.querySelector('textarea[name="h-captcha-response"]');
|
|
86
|
+
if (hResp && hResp.value) return hResp.value;
|
|
87
|
+
const gResp = document.querySelector('textarea[name="g-recaptcha-response"]');
|
|
88
|
+
if (gResp && gResp.value) return gResp.value;
|
|
89
|
+
return '';
|
|
90
|
+
})()"""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class CdpClient:
|
|
94
|
+
"""Thread-safe Chrome DevTools Protocol client using WebSocket."""
|
|
95
|
+
|
|
96
|
+
def __init__(self, ws_url: str):
|
|
97
|
+
if not HAVE_WEBSOCKET:
|
|
98
|
+
raise ImportError(
|
|
99
|
+
"The 'websocket-client' package is required for Headless Screencast mode. "
|
|
100
|
+
"Install it via: pip install websocket-client"
|
|
101
|
+
)
|
|
102
|
+
self._id = 0
|
|
103
|
+
self._pending: Dict[int, Tuple[threading.Event, Dict[str, Any]]] = {}
|
|
104
|
+
self.ws = websocket.create_connection(ws_url, timeout=10)
|
|
105
|
+
self._closed = False
|
|
106
|
+
threading.Thread(target=self._read_loop, daemon=True).start()
|
|
107
|
+
|
|
108
|
+
def _read_loop(self) -> None:
|
|
109
|
+
while not self._closed:
|
|
110
|
+
try:
|
|
111
|
+
raw = self.ws.recv()
|
|
112
|
+
except Exception:
|
|
113
|
+
break
|
|
114
|
+
if not raw:
|
|
115
|
+
continue
|
|
116
|
+
try:
|
|
117
|
+
msg = json.loads(raw)
|
|
118
|
+
except Exception:
|
|
119
|
+
continue
|
|
120
|
+
|
|
121
|
+
mid = msg.get("id")
|
|
122
|
+
if mid is not None and mid in self._pending:
|
|
123
|
+
evt, slot = self._pending.pop(mid)
|
|
124
|
+
slot["result"] = msg.get("result")
|
|
125
|
+
slot["error"] = msg.get("error")
|
|
126
|
+
evt.set()
|
|
127
|
+
|
|
128
|
+
def send(self, method: str, params: Optional[dict] = None, timeout: float = 10.0) -> dict:
|
|
129
|
+
"""Send a synchronous JSON-RPC command over CDP and await its response."""
|
|
130
|
+
self._id += 1
|
|
131
|
+
mid = self._id
|
|
132
|
+
slot: Dict[str, Any] = {}
|
|
133
|
+
evt = threading.Event()
|
|
134
|
+
self._pending[mid] = (evt, slot)
|
|
135
|
+
|
|
136
|
+
payload = json.dumps({"id": mid, "method": method, "params": params or {}})
|
|
137
|
+
self.ws.send(payload)
|
|
138
|
+
|
|
139
|
+
if not evt.wait(timeout):
|
|
140
|
+
raise TimeoutError(f"CDP call {method} timed out after {timeout}s")
|
|
141
|
+
if slot.get("error"):
|
|
142
|
+
raise RuntimeError(f"CDP command {method} failed: {slot['error']}")
|
|
143
|
+
return slot.get("result") or {}
|
|
144
|
+
|
|
145
|
+
def evaluate(self, expression: str) -> Any:
|
|
146
|
+
"""Evaluate a JavaScript expression in the page context."""
|
|
147
|
+
res = self.send("Runtime.evaluate", {"expression": expression, "returnByValue": True})
|
|
148
|
+
return res.get("result", {}).get("value")
|
|
149
|
+
|
|
150
|
+
def close(self) -> None:
|
|
151
|
+
"""Gracefully disconnect WebSocket."""
|
|
152
|
+
self._closed = True
|
|
153
|
+
try:
|
|
154
|
+
self.ws.close()
|
|
155
|
+
except Exception:
|
|
156
|
+
pass
|
doescap/cli.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Command-line interface (CLI) for DoesCap."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from .client import DoesCap
|
|
8
|
+
from .config import RelayConfig
|
|
9
|
+
from .network import get_local_ip
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main() -> int:
|
|
13
|
+
parser = argparse.ArgumentParser(
|
|
14
|
+
prog="doescap",
|
|
15
|
+
description="DoesCap: Lightweight cross-platform hCaptcha relay and solver tool.",
|
|
16
|
+
)
|
|
17
|
+
parser.add_argument(
|
|
18
|
+
"--sitekey",
|
|
19
|
+
"-s",
|
|
20
|
+
required=True,
|
|
21
|
+
help="Target hCaptcha sitekey.",
|
|
22
|
+
)
|
|
23
|
+
parser.add_argument(
|
|
24
|
+
"--rqdata",
|
|
25
|
+
"-r",
|
|
26
|
+
default=None,
|
|
27
|
+
help="Optional rqdata payload string.",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--host",
|
|
31
|
+
default="0.0.0.0",
|
|
32
|
+
help="Relay server bind address (default: 0.0.0.0).",
|
|
33
|
+
)
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"--port",
|
|
36
|
+
"-p",
|
|
37
|
+
type=int,
|
|
38
|
+
default=8787,
|
|
39
|
+
help="Relay server port (default: 8787).",
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"--no-browser",
|
|
43
|
+
action="store_true",
|
|
44
|
+
help="Disable automatic browser opening.",
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"--browser",
|
|
48
|
+
default=None,
|
|
49
|
+
help="Path or keyword for browser to use in screencast mode.",
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"--timeout",
|
|
53
|
+
"-t",
|
|
54
|
+
type=int,
|
|
55
|
+
default=300,
|
|
56
|
+
help="Timeout in seconds (default: 300).",
|
|
57
|
+
)
|
|
58
|
+
parser.add_argument(
|
|
59
|
+
"--title",
|
|
60
|
+
default="DoesCap Relay",
|
|
61
|
+
help="Web UI title header.",
|
|
62
|
+
)
|
|
63
|
+
parser.add_argument(
|
|
64
|
+
"--custom-html",
|
|
65
|
+
default=None,
|
|
66
|
+
help="File path to custom HTML page template.",
|
|
67
|
+
)
|
|
68
|
+
parser.add_argument(
|
|
69
|
+
"--assets-dir",
|
|
70
|
+
default=None,
|
|
71
|
+
help="Directory path containing custom static assets served at /assets/*.",
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
args = parser.parse_args()
|
|
75
|
+
|
|
76
|
+
config = RelayConfig(
|
|
77
|
+
host=args.host,
|
|
78
|
+
port=args.port,
|
|
79
|
+
auto_open_browser=not args.no_browser,
|
|
80
|
+
browser_path=args.browser,
|
|
81
|
+
timeout=args.timeout,
|
|
82
|
+
title=args.title,
|
|
83
|
+
custom_html_path=args.custom_html,
|
|
84
|
+
custom_assets_dir=args.assets_dir,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
relay = DoesCap(config=config)
|
|
88
|
+
local_ip = get_local_ip()
|
|
89
|
+
|
|
90
|
+
print("==================================================")
|
|
91
|
+
print(" DOESCAP RELAY SOLVER")
|
|
92
|
+
print("==================================================")
|
|
93
|
+
print(f"[*] Local access: http://127.0.0.1:{config.port}/")
|
|
94
|
+
print(f"[*] Network access: http://{local_ip}:{config.port}/")
|
|
95
|
+
print(f"[*] Sitekey: {args.sitekey}")
|
|
96
|
+
if args.rqdata:
|
|
97
|
+
print(f"[*] rqdata: {args.rqdata[:30]}...")
|
|
98
|
+
if args.custom_html:
|
|
99
|
+
print(f"[*] Custom HTML: {args.custom_html}")
|
|
100
|
+
if args.assets_dir:
|
|
101
|
+
print(f"[*] Assets Dir: {args.assets_dir}")
|
|
102
|
+
print(f"[*] Timeout: {args.timeout}s")
|
|
103
|
+
print("--------------------------------------------------")
|
|
104
|
+
print("[*] Waiting for verification in browser...")
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
result = relay.solve(sitekey=args.sitekey, rqdata=args.rqdata)
|
|
108
|
+
if result and result.token:
|
|
109
|
+
print("[+] Solved successfully!")
|
|
110
|
+
print(f"[+] Elapsed: {result.elapsed_seconds:.2f}s")
|
|
111
|
+
print(f"[+] Token:\n{result.token}")
|
|
112
|
+
relay.mark_completed("Verification successful!")
|
|
113
|
+
return 0
|
|
114
|
+
else:
|
|
115
|
+
print(f"[-] Solve failed: {result.error if result else 'Timed out'}", file=sys.stderr)
|
|
116
|
+
return 1
|
|
117
|
+
except KeyboardInterrupt:
|
|
118
|
+
print("\n[!] Cancelled by user.")
|
|
119
|
+
return 130
|
|
120
|
+
finally:
|
|
121
|
+
relay.close()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
sys.exit(main())
|