capiumbrowser 1.3.0__tar.gz → 1.3.2__tar.gz
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.
- {capiumbrowser-1.3.0/capiumbrowser.egg-info → capiumbrowser-1.3.2}/PKG-INFO +2 -2
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/README.md +1 -1
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/_version.py +1 -1
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/android-phones.json +64 -10
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/browser.py +36 -10
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/browser_async.py +16 -10
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/channels.json +7 -7
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/human/__init__.py +5 -3
- capiumbrowser-1.3.2/capiumbrowser/human/behavior.py +180 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/mobile.py +1 -1
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2/capiumbrowser.egg-info}/PKG-INFO +2 -2
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/pyproject.toml +1 -1
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_geoip_flags.py +17 -6
- capiumbrowser-1.3.0/capiumbrowser/human/behavior.py +0 -104
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/LICENSE +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/MANIFEST.in +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/__init__.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/__main__.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/_driver.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/browser-brands.json +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/config.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/desktop.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/errors.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/ios-phones.json +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/licensing/__init__.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/licensing/client.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/licensing/download.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/licensing/readiness.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/network/__init__.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser/network/proxy.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/SOURCES.txt +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/dependency_links.txt +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/entry_points.txt +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/requires.txt +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/top_level.txt +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/setup.cfg +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_channels_manifest.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_config_args.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_desktop_brands.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_download_contract.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_ios_profiles.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_launch_viewport.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_license_readiness.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_mobile_profiles.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_proxy.py +0 -0
- {capiumbrowser-1.3.0 → capiumbrowser-1.3.2}/tests/test_version_tables_consistent.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: capiumbrowser
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Drop-in stealth browser SDK on top of Playwright (Capium Chromium).
|
|
5
5
|
Author: Capzy
|
|
6
6
|
License: Capzy capiumbrowser SDK License
|
|
@@ -408,7 +408,7 @@ and `launch_persistent_context` forward everything to `launch`.
|
|
|
408
408
|
| Parameter | Type | Default | Description |
|
|
409
409
|
|---|---|---|---|
|
|
410
410
|
| `proxy` | `str` \| `dict` \| `"env"`/`True` \| `None` | `None` | HTTP/HTTPS/SOCKS5 URL with inline creds, a `{"server","username","password"}` dict, `"env"`/`True` (reads `CAPIUM_PROXY`), or `None`/`"none"`/`""`. |
|
|
411
|
-
| `geoip` | `bool` \| `None` | `None` | Geo coherence, resolved inside the binary. **`None` (default) — OFF**:
|
|
411
|
+
| `geoip` | `bool` \| `None` | `None` | Geo coherence, resolved inside the binary. **`None` (default) — ON whenever a proxy is set, OFF otherwise**: an uncorrected host timezone under a proxied identity (UTC on a server) is a far stronger detection signal than the lookup's one-off launch latency. **`True`** — ON even proxyless (pins timezone/geo/WebRTC/`navigator.languages` to the host IP). **`False`** — explicit opt-out. No SDK-side probe. |
|
|
412
412
|
| `timezone` | `str` \| `None` | `None` | IANA tz (e.g. `"America/New_York"`) → `--timezone`. **Overrides** `geoip`. |
|
|
413
413
|
| `locale` | `str` \| `None` | `None` | BCP-47 (e.g. `"en-US"`) → `--lang` + `--accept-lang`. **Overrides** `geoip`. |
|
|
414
414
|
|
|
@@ -345,7 +345,7 @@ and `launch_persistent_context` forward everything to `launch`.
|
|
|
345
345
|
| Parameter | Type | Default | Description |
|
|
346
346
|
|---|---|---|---|
|
|
347
347
|
| `proxy` | `str` \| `dict` \| `"env"`/`True` \| `None` | `None` | HTTP/HTTPS/SOCKS5 URL with inline creds, a `{"server","username","password"}` dict, `"env"`/`True` (reads `CAPIUM_PROXY`), or `None`/`"none"`/`""`. |
|
|
348
|
-
| `geoip` | `bool` \| `None` | `None` | Geo coherence, resolved inside the binary. **`None` (default) — OFF**:
|
|
348
|
+
| `geoip` | `bool` \| `None` | `None` | Geo coherence, resolved inside the binary. **`None` (default) — ON whenever a proxy is set, OFF otherwise**: an uncorrected host timezone under a proxied identity (UTC on a server) is a far stronger detection signal than the lookup's one-off launch latency. **`True`** — ON even proxyless (pins timezone/geo/WebRTC/`navigator.languages` to the host IP). **`False`** — explicit opt-out. No SDK-side probe. |
|
|
349
349
|
| `timezone` | `str` \| `None` | `None` | IANA tz (e.g. `"America/New_York"`) → `--timezone`. **Overrides** `geoip`. |
|
|
350
350
|
| `locale` | `str` \| `None` | `None` | BCP-47 (e.g. `"en-US"`) → `--lang` + `--accept-lang`. **Overrides** `geoip`. |
|
|
351
351
|
|
|
@@ -17,7 +17,7 @@ import json
|
|
|
17
17
|
import os
|
|
18
18
|
import platform as _platform
|
|
19
19
|
|
|
20
|
-
__version__ = "1.3.
|
|
20
|
+
__version__ = "1.3.2"
|
|
21
21
|
|
|
22
22
|
# Used only if channels.json can't be read (corrupt/removed install). ensure_binary() raises a
|
|
23
23
|
# clear error long before the "unsupported platform" case matters; this keeps lookups total.
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"schema_version": 2,
|
|
3
3
|
"minimum_release_year": 2022,
|
|
4
4
|
"browser": "chrome",
|
|
5
|
-
"status": "
|
|
6
|
-
"gpu_policy": "
|
|
7
|
-
"hardware_policy": "
|
|
5
|
+
"status": "catalog-emulation",
|
|
6
|
+
"gpu_policy": "catalog",
|
|
7
|
+
"hardware_policy": "catalog",
|
|
8
8
|
"physical_device_validation": "pending",
|
|
9
9
|
"default_profile_ids": [
|
|
10
10
|
"pixel-7",
|
|
@@ -13,6 +13,20 @@
|
|
|
13
13
|
"pixel-8a",
|
|
14
14
|
"pixel-9"
|
|
15
15
|
],
|
|
16
|
+
"font_core": [
|
|
17
|
+
"Roboto",
|
|
18
|
+
"Noto Sans",
|
|
19
|
+
"Noto Serif",
|
|
20
|
+
"Noto Sans Mono",
|
|
21
|
+
"Noto Color Emoji",
|
|
22
|
+
"Noto Sans JP",
|
|
23
|
+
"Noto Sans KR",
|
|
24
|
+
"Noto Sans SC",
|
|
25
|
+
"Noto Sans TC",
|
|
26
|
+
"Noto Naskh Arabic",
|
|
27
|
+
"Noto Sans Devanagari",
|
|
28
|
+
"Noto Sans Thai"
|
|
29
|
+
],
|
|
16
30
|
"sources": [
|
|
17
31
|
"https://support.google.com/pixelphone/answer/7158570?hl=en",
|
|
18
32
|
"https://news.samsung.com/global/samsung-galaxy-a55-5g-and-galaxy-a35-5g-awesome-innovations-and-security-engineered-for-everyone",
|
|
@@ -27,7 +41,12 @@
|
|
|
27
41
|
"platform_version": "13",
|
|
28
42
|
"width": 412,
|
|
29
43
|
"height": 915,
|
|
30
|
-
"dpr": 2.625
|
|
44
|
+
"dpr": 2.625,
|
|
45
|
+
"soc": "Tensor G2",
|
|
46
|
+
"cores": 8,
|
|
47
|
+
"memory_gb": 8,
|
|
48
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
49
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G710, OpenGL ES 3.2)"
|
|
31
50
|
},
|
|
32
51
|
{
|
|
33
52
|
"id": "pixel-8",
|
|
@@ -36,7 +55,12 @@
|
|
|
36
55
|
"platform_version": "14",
|
|
37
56
|
"width": 412,
|
|
38
57
|
"height": 915,
|
|
39
|
-
"dpr": 2.625
|
|
58
|
+
"dpr": 2.625,
|
|
59
|
+
"soc": "Tensor G3",
|
|
60
|
+
"cores": 9,
|
|
61
|
+
"memory_gb": 8,
|
|
62
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
63
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G715, OpenGL ES 3.2)"
|
|
40
64
|
},
|
|
41
65
|
{
|
|
42
66
|
"id": "pixel-8-pro",
|
|
@@ -45,7 +69,12 @@
|
|
|
45
69
|
"platform_version": "14",
|
|
46
70
|
"width": 448,
|
|
47
71
|
"height": 997,
|
|
48
|
-
"dpr": 3.0
|
|
72
|
+
"dpr": 3.0,
|
|
73
|
+
"soc": "Tensor G3",
|
|
74
|
+
"cores": 9,
|
|
75
|
+
"memory_gb": 12,
|
|
76
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
77
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G715, OpenGL ES 3.2)"
|
|
49
78
|
},
|
|
50
79
|
{
|
|
51
80
|
"id": "pixel-8a",
|
|
@@ -54,7 +83,12 @@
|
|
|
54
83
|
"platform_version": "14",
|
|
55
84
|
"width": 412,
|
|
56
85
|
"height": 915,
|
|
57
|
-
"dpr": 2.625
|
|
86
|
+
"dpr": 2.625,
|
|
87
|
+
"soc": "Tensor G3",
|
|
88
|
+
"cores": 9,
|
|
89
|
+
"memory_gb": 8,
|
|
90
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
91
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G715, OpenGL ES 3.2)"
|
|
58
92
|
},
|
|
59
93
|
{
|
|
60
94
|
"id": "pixel-9",
|
|
@@ -63,7 +97,12 @@
|
|
|
63
97
|
"platform_version": "14",
|
|
64
98
|
"width": 412,
|
|
65
99
|
"height": 924,
|
|
66
|
-
"dpr": 2.625
|
|
100
|
+
"dpr": 2.625,
|
|
101
|
+
"soc": "Tensor G4",
|
|
102
|
+
"cores": 8,
|
|
103
|
+
"memory_gb": 12,
|
|
104
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
105
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G715, OpenGL ES 3.2)"
|
|
67
106
|
},
|
|
68
107
|
{
|
|
69
108
|
"id": "samsung-galaxy-a55",
|
|
@@ -74,6 +113,11 @@
|
|
|
74
113
|
"width": 360,
|
|
75
114
|
"height": 800,
|
|
76
115
|
"dpr": 2.25,
|
|
116
|
+
"soc": "Exynos 1480",
|
|
117
|
+
"cores": 8,
|
|
118
|
+
"memory_gb": 8,
|
|
119
|
+
"gpu_vendor": "Google Inc. (Samsung Electronics Co., Ltd.)",
|
|
120
|
+
"gpu_renderer": "ANGLE (Samsung Electronics Co., Ltd., Xclipse 530, OpenGL ES 3.2)",
|
|
77
121
|
"geometry_status": "devtools-emulation-only",
|
|
78
122
|
"geometry_note": "These Chromium preset dimensions/DPR do not directly map to the published 1080x2340 panel; physical Chrome capture required."
|
|
79
123
|
},
|
|
@@ -84,7 +128,12 @@
|
|
|
84
128
|
"platform_version": "14",
|
|
85
129
|
"width": 427,
|
|
86
130
|
"height": 952,
|
|
87
|
-
"dpr": 3.0
|
|
131
|
+
"dpr": 3.0,
|
|
132
|
+
"soc": "Tensor G4",
|
|
133
|
+
"cores": 8,
|
|
134
|
+
"memory_gb": 16,
|
|
135
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
136
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G715, OpenGL ES 3.2)"
|
|
88
137
|
},
|
|
89
138
|
{
|
|
90
139
|
"id": "pixel-9-pro-xl",
|
|
@@ -93,7 +142,12 @@
|
|
|
93
142
|
"platform_version": "14",
|
|
94
143
|
"width": 448,
|
|
95
144
|
"height": 997,
|
|
96
|
-
"dpr": 3.0
|
|
145
|
+
"dpr": 3.0,
|
|
146
|
+
"soc": "Tensor G4",
|
|
147
|
+
"cores": 8,
|
|
148
|
+
"memory_gb": 16,
|
|
149
|
+
"gpu_vendor": "Google Inc. (ARM)",
|
|
150
|
+
"gpu_renderer": "ANGLE (ARM, Mali-G715, OpenGL ES 3.2)"
|
|
97
151
|
}
|
|
98
152
|
]
|
|
99
153
|
}
|
|
@@ -90,19 +90,22 @@ def _proxy_and_geo_args(spec, binpath, geoip_on, display):
|
|
|
90
90
|
would otherwise add up to 2.5s to every proxied launch. When it does run it resolves the
|
|
91
91
|
egress IP (proxy exit, else the host's real public IP) and pins WebRTC / timezone /
|
|
92
92
|
geolocation / language -- so the SDK adds no probe of its own. geoip_on is tri-state:
|
|
93
|
-
* None -> default:
|
|
94
|
-
|
|
93
|
+
* None -> default: ON whenever a proxy is set, OFF otherwise. An uncorrected host
|
|
94
|
+
timezone under a proxied identity (UTC on a server, or the operator's home
|
|
95
|
+
zone against a foreign exit) is a far stronger detection signal than the
|
|
96
|
+
one-off launch-latency cost of the lookup. Pass geoip=False to opt out.
|
|
95
97
|
* True -> ON with --geoip (resolves the egress -- proxy exit, or the host IP if proxyless).
|
|
96
98
|
* False -> OFF with --geoip=false, which the binary honors FIRST (explicit opt-out).
|
|
97
99
|
Returns (proxy_kwargs, [flags]).
|
|
98
100
|
"""
|
|
99
101
|
proxy_kwargs, out = _proxy.resolve_proxy_config(spec)
|
|
100
102
|
out = list(out)
|
|
103
|
+
explicit_off = geoip_on is False
|
|
101
104
|
if geoip_on is None:
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
geoip_on = bool(spec)
|
|
106
|
+
if geoip_on:
|
|
104
107
|
out.append("--geoip")
|
|
105
|
-
|
|
108
|
+
elif explicit_off:
|
|
106
109
|
out.append("--geoip=false")
|
|
107
110
|
return proxy_kwargs, out
|
|
108
111
|
|
|
@@ -163,14 +166,34 @@ def fit_window(browser, context, page):
|
|
|
163
166
|
pass
|
|
164
167
|
|
|
165
168
|
|
|
169
|
+
def _window_bounds_for_seed(seed, aw, ah):
|
|
170
|
+
"""Deterministic per-seed window geometry inside the seed's available screen area.
|
|
171
|
+
|
|
172
|
+
Every profile previously got the identical maximized-like window (exactly availWidth x
|
|
173
|
+
availHeight at 0,0), so all profiles sharing a pool screen were geometry-identical -- a
|
|
174
|
+
clusterable signature. Real users are a mix: most keep the browser maximized, a minority
|
|
175
|
+
run a windowed browser at an arbitrary size/position. Mirror that mix deterministically
|
|
176
|
+
per seed (the geometry is part of the profile's stable identity, like its screen)."""
|
|
177
|
+
import hashlib
|
|
178
|
+
d = hashlib.sha256(b"capium-window:%d" % int(seed)).digest()
|
|
179
|
+
if d[0] % 10 < 6: # most seeds: maximized-like (previous behavior)
|
|
180
|
+
return 0, 0, aw, ah
|
|
181
|
+
w = max(800, int(aw * (0.78 + (d[1] / 255.0) * 0.16))) # 78-94% of avail width
|
|
182
|
+
h = max(600, int(ah * (0.80 + (d[2] / 255.0) * 0.15))) # 80-95% of avail height
|
|
183
|
+
left = (aw - w) * d[3] // 255
|
|
184
|
+
top = (ah - h) * d[4] // 255
|
|
185
|
+
return int(left), int(top), int(w), int(h)
|
|
186
|
+
|
|
187
|
+
|
|
166
188
|
def _fit_window_to_screen(context):
|
|
167
189
|
"""Size the window to the seed's (coherent, per-seed) spoofed screen so viewport ~= screen.
|
|
168
190
|
|
|
169
191
|
With screen=None (the default), each persona uses its device-pool screen/dpr. Here we size the
|
|
170
|
-
window
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
window within that screen's available area -- maximized-like for most seeds, realistically
|
|
193
|
+
windowed for the rest (see _window_bounds_for_seed) -- via the page's CDP session
|
|
194
|
+
(works for persistent contexts, which have no browser() object). This keeps viewport<=screen
|
|
195
|
+
coherent in headless/container (avoids the browserscan 'screen != viewport' VM tell) AND stays
|
|
196
|
+
coherent in headed (Chrome clamps to the real display). Best-effort."""
|
|
174
197
|
s = None
|
|
175
198
|
try:
|
|
176
199
|
page = context.pages[0] if context.pages else None
|
|
@@ -180,10 +203,12 @@ def _fit_window_to_screen(context):
|
|
|
180
203
|
if not (scr and scr.get("w") and scr.get("h")):
|
|
181
204
|
return
|
|
182
205
|
aw, ah = int(scr["w"]), int(scr["h"])
|
|
206
|
+
left, top, w, h = _window_bounds_for_seed(
|
|
207
|
+
getattr(context, "_capium_seed", 0) or 0, aw, ah)
|
|
183
208
|
s = context.new_cdp_session(page)
|
|
184
209
|
wid = s.send("Browser.getWindowForTarget")["windowId"]
|
|
185
210
|
s.send("Browser.setWindowBounds", {"windowId": wid, "bounds": {
|
|
186
|
-
"left":
|
|
211
|
+
"left": left, "top": top, "width": w, "height": h, "windowState": "normal"}})
|
|
187
212
|
except Exception:
|
|
188
213
|
pass
|
|
189
214
|
finally:
|
|
@@ -470,6 +495,7 @@ def launch_context(seed=None, platform="windows", headless=False, url=None,
|
|
|
470
495
|
_human.humanize(context, preset=human_preset)
|
|
471
496
|
page = context.pages[0] if context.pages else context.new_page()
|
|
472
497
|
if not getattr(browser, "_capium_mobile", False):
|
|
498
|
+
context._capium_seed = getattr(browser, "_capium_seed", 0)
|
|
473
499
|
if headless:
|
|
474
500
|
_fit_window_to_screen(context) # per-seed screen fit (coherent viewport, not the tiny startup window)
|
|
475
501
|
else:
|
|
@@ -33,17 +33,18 @@ async def _license_preflight_async(license_key, license_server, do_preflight):
|
|
|
33
33
|
async def _proxy_and_geo_args_async(spec, binpath, geoip_on, display):
|
|
34
34
|
"""Return (proxy_kwargs, chrome_args). proxy_kwargs for Playwright auth; chrome_args for
|
|
35
35
|
native --proxy-server + geo flags. The binary's CapiumGeoipResolver runs at PreBrowserStart
|
|
36
|
-
ONLY when --geoip is present
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(--geoip=false, honored first)."""
|
|
36
|
+
ONLY when --geoip is present. geoip_on is tri-state: None = default ON whenever a proxy is
|
|
37
|
+
set and OFF otherwise (an uncorrected host timezone under a proxied identity -- UTC on a
|
|
38
|
+
server -- is a far stronger detection signal than the lookup's launch latency), True = ON
|
|
39
|
+
(--geoip), False = explicit opt-out (--geoip=false, honored first)."""
|
|
40
40
|
proxy_kwargs, out = _proxy.resolve_proxy_config(spec)
|
|
41
41
|
out = list(out)
|
|
42
|
+
explicit_off = geoip_on is False
|
|
42
43
|
if geoip_on is None:
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
geoip_on = bool(spec)
|
|
45
|
+
if geoip_on:
|
|
45
46
|
out.append("--geoip")
|
|
46
|
-
|
|
47
|
+
elif explicit_off:
|
|
47
48
|
out.append("--geoip=false")
|
|
48
49
|
return proxy_kwargs, out
|
|
49
50
|
|
|
@@ -164,18 +165,22 @@ async def _require_mobile_engine_async(context, mobile_device=None, seed=0, plat
|
|
|
164
165
|
|
|
165
166
|
|
|
166
167
|
async def _fit_window_to_screen_async(context):
|
|
167
|
-
"""Fit a
|
|
168
|
+
"""Fit a desktop window within its available screen (per-seed geometry, no emulation)."""
|
|
169
|
+
from .browser import _window_bounds_for_seed
|
|
168
170
|
session = None
|
|
169
171
|
try:
|
|
170
172
|
page = context.pages[0] if context.pages else await context.new_page()
|
|
171
173
|
screen = await page.evaluate("()=>({w:screen.availWidth,h:screen.availHeight})")
|
|
172
174
|
if not (screen and screen.get("w") and screen.get("h")):
|
|
173
175
|
return
|
|
176
|
+
left, top, w, h = _window_bounds_for_seed(
|
|
177
|
+
getattr(context, "_capium_seed", 0) or 0,
|
|
178
|
+
int(screen["w"]), int(screen["h"]))
|
|
174
179
|
session = await context.new_cdp_session(page)
|
|
175
180
|
window_id = (await session.send("Browser.getWindowForTarget"))["windowId"]
|
|
176
181
|
await session.send("Browser.setWindowBounds", {"windowId": window_id, "bounds": {
|
|
177
|
-
"left":
|
|
178
|
-
"height":
|
|
182
|
+
"left": left, "top": top, "width": w,
|
|
183
|
+
"height": h, "windowState": "normal"}})
|
|
179
184
|
except Exception:
|
|
180
185
|
pass
|
|
181
186
|
finally:
|
|
@@ -281,6 +286,7 @@ async def launch_context_async(seed=None, platform="windows", headless=False, ur
|
|
|
281
286
|
_human.humanize(context, preset=human_preset)
|
|
282
287
|
page = context.pages[0] if context.pages else await context.new_page()
|
|
283
288
|
if not getattr(browser, "_capium_mobile", False):
|
|
289
|
+
context._capium_seed = getattr(browser, "_capium_seed", 0)
|
|
284
290
|
await _fit_window_to_screen_async(context)
|
|
285
291
|
if url:
|
|
286
292
|
await page.goto(url, wait_until="domcontentloaded", timeout=60000)
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_comment": "SINGLE SOURCE OF TRUTH for the current stable Capium browser build per OS/arch. Each OS reaches stable independently -- edit one entry without touching the others. This file ships inside the wheel (the SDK reads it to pick each host's stable build) AND is published to the download server by the release pipeline. `version` is the reported Chromium version (what the browser reports to the customer, names the R2 folder); `engine_version` is the actual built Chromium engine (box_package verifies the binary against it) -- it differs from `version` when a platform reports a spoofed patch (Windows/macOS report .48 on the .47 engine). `revision` is our packaging counter -- the served R2 folder is chromium-v<version>.<revision>/, ALWAYS dotted-suffixed starting at 1. A Chromium version bump resets revision to 1. `published: false` means the tag is declared but no artifact exists yet.",
|
|
3
3
|
"schema": 1,
|
|
4
|
-
"updated": "2026-10-
|
|
4
|
+
"updated": "2026-10-27",
|
|
5
5
|
"channels": {
|
|
6
6
|
"stable": {
|
|
7
7
|
"windows-x64": {
|
|
8
8
|
"version": "156.0.8078.48",
|
|
9
9
|
"engine_version": "156.0.8078.47",
|
|
10
|
-
"revision":
|
|
11
|
-
"sha256": "
|
|
10
|
+
"revision": 3,
|
|
11
|
+
"sha256": "ad26bd1e62343ec741b3cd2ce8f73e00dfc6c25564654bfba828efb29a372a69",
|
|
12
12
|
"published": true,
|
|
13
13
|
"license_status_protocol": 1
|
|
14
14
|
},
|
|
15
15
|
"macos-arm64": {
|
|
16
16
|
"version": "156.0.8078.48",
|
|
17
17
|
"engine_version": "156.0.8078.47",
|
|
18
|
-
"revision":
|
|
19
|
-
"sha256": "
|
|
18
|
+
"revision": 3,
|
|
19
|
+
"sha256": "ce85cf43d57ff5ab4d35416b874d50560705c07e296c0b41b5cb78ee0d6f6eda",
|
|
20
20
|
"published": true,
|
|
21
21
|
"license_status_protocol": 1
|
|
22
22
|
},
|
|
23
23
|
"linux-x64": {
|
|
24
24
|
"version": "156.0.8078.47",
|
|
25
25
|
"engine_version": "156.0.8078.47",
|
|
26
|
-
"revision":
|
|
27
|
-
"sha256": "
|
|
26
|
+
"revision": 3,
|
|
27
|
+
"sha256": "0ecad673f91b68b251e1185d88df6c46da35be592c46f45f015e189cd57b3152",
|
|
28
28
|
"published": true,
|
|
29
29
|
"license_status_protocol": 1
|
|
30
30
|
},
|
|
@@ -16,11 +16,12 @@ Two ways to use it:
|
|
|
16
16
|
page.human_click("#login"); page.human_type("#user", "alice")
|
|
17
17
|
"""
|
|
18
18
|
from . import behavior
|
|
19
|
-
from .behavior import move, click, type_text, scroll, dwell
|
|
19
|
+
from .behavior import move, click, type_text, scroll, dwell, hold
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def humanize(target, preset="default"):
|
|
23
|
-
"""Attach page.human_move / human_click / human_type / human_scroll / human_dwell
|
|
23
|
+
"""Attach page.human_move / human_click / human_type / human_scroll / human_dwell /
|
|
24
|
+
human_hold.
|
|
24
25
|
|
|
25
26
|
target may be a Page or a BrowserContext (all current + future pages are patched).
|
|
26
27
|
Returns target (chainable). Does NOT override page.click/type so existing code is safe;
|
|
@@ -34,6 +35,7 @@ def humanize(target, preset="default"):
|
|
|
34
35
|
page.human_click = lambda sel, p=preset: click(page, sel, p)
|
|
35
36
|
page.human_type = lambda sel, text, p=preset: type_text(page, sel, text, p)
|
|
36
37
|
page.human_scroll = lambda dy, p=preset: scroll(page, dy, p)
|
|
38
|
+
page.human_hold = lambda sel, seconds, p=preset: hold(page, sel, seconds, p)
|
|
37
39
|
page.human_dwell = dwell
|
|
38
40
|
|
|
39
41
|
# context: patch existing + hook new pages
|
|
@@ -46,4 +48,4 @@ def humanize(target, preset="default"):
|
|
|
46
48
|
return target
|
|
47
49
|
|
|
48
50
|
|
|
49
|
-
__all__ = ["humanize", "move", "click", "type_text", "scroll", "dwell", "behavior"]
|
|
51
|
+
__all__ = ["humanize", "move", "click", "type_text", "scroll", "dwell", "hold", "behavior"]
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""
|
|
2
|
+
capium.human.behavior -- realistic mouse / typing / scroll / press-and-hold for Playwright pages.
|
|
3
|
+
|
|
4
|
+
Anti-bot systems increasingly score *behavior*, and the modern ones (PX/HUMAN press-and-hold,
|
|
5
|
+
DataDome slider) score pointer BIOMETRICS, not just "did a cursor arrive": velocity profile
|
|
6
|
+
(humans accelerate then decelerate into the target -- Fitts's law -- never constant speed),
|
|
7
|
+
orthogonal micro-jitter along the path, overshoot-and-correct on long moves, and physiological
|
|
8
|
+
tremor during a sustained press (a hand cannot hold a mouse perfectly still; a rock-still
|
|
9
|
+
multi-second hold is a machine signature). These helpers produce all of that with pure
|
|
10
|
+
Playwright input (page.mouse / page.keyboard) -- no CDP tricks, so the event stream stays
|
|
11
|
+
consistent with the stealth binary (isTrusted=true, normal coalescing).
|
|
12
|
+
|
|
13
|
+
Presets tune the timing:
|
|
14
|
+
"default" -> natural human pace
|
|
15
|
+
"careful" -> slower, more deliberate (harder to flag, but slower runs)
|
|
16
|
+
"""
|
|
17
|
+
import math
|
|
18
|
+
import random
|
|
19
|
+
import time
|
|
20
|
+
|
|
21
|
+
PRESETS = {
|
|
22
|
+
"default": {"move_steps": (18, 34), "step_ms": (6, 16), "key_ms": (45, 130),
|
|
23
|
+
"click_pause_ms": (40, 140), "scroll_step": (90, 220), "scroll_ms": (30, 90),
|
|
24
|
+
"tremor_px": 1.1, "tremor_ms": (35, 110)},
|
|
25
|
+
"careful": {"move_steps": (30, 55), "step_ms": (12, 28), "key_ms": (80, 220),
|
|
26
|
+
"click_pause_ms": (120, 320), "scroll_step": (50, 130), "scroll_ms": (60, 150),
|
|
27
|
+
"tremor_px": 0.9, "tremor_ms": (50, 140)},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _cfg(preset):
|
|
32
|
+
return PRESETS.get(preset, PRESETS["default"])
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _rand_ms(rng):
|
|
36
|
+
return random.uniform(rng[0], rng[1]) / 1000.0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _pos(page):
|
|
40
|
+
return getattr(page, "_capium_mouse", (random.randint(2, 60), random.randint(2, 60)))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _velocity_warp(t):
|
|
44
|
+
# Smoothstep time-warp: sampling the curve at these t values yields a bell-shaped
|
|
45
|
+
# velocity profile -- slow start, fast middle, decelerating arrival (Fitts-like) --
|
|
46
|
+
# instead of the constant speed that uniform sampling produces.
|
|
47
|
+
return t * t * (3.0 - 2.0 * t)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _bezier(x0, y0, x1, y1, steps):
|
|
51
|
+
# Two random control points -> a curved, non-linear path; velocity-warped sampling +
|
|
52
|
+
# orthogonal micro-jitter (largest mid-path, vanishing at the endpoints).
|
|
53
|
+
cx1 = x0 + (x1 - x0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
54
|
+
cy1 = y0 + (y1 - y0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
55
|
+
cx2 = x0 + (x1 - x0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
56
|
+
cy2 = y0 + (y1 - y0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
57
|
+
dx, dy = x1 - x0, y1 - y0
|
|
58
|
+
dist = math.hypot(dx, dy) or 1.0
|
|
59
|
+
nx, ny = -dy / dist, dx / dist # unit normal to the gross direction
|
|
60
|
+
jmax = min(1.6, dist / 120.0) # short hops barely wobble
|
|
61
|
+
pts = []
|
|
62
|
+
for i in range(1, steps + 1):
|
|
63
|
+
lt = i / steps
|
|
64
|
+
t = _velocity_warp(lt)
|
|
65
|
+
mt = 1 - t
|
|
66
|
+
x = mt**3 * x0 + 3 * mt**2 * t * cx1 + 3 * mt * t**2 * cx2 + t**3 * x1
|
|
67
|
+
y = mt**3 * y0 + 3 * mt**2 * t * cy1 + 3 * mt * t**2 * cy2 + t**3 * y1
|
|
68
|
+
j = math.sin(math.pi * lt) * random.uniform(-jmax, jmax)
|
|
69
|
+
pts.append((x + nx * j, y + ny * j))
|
|
70
|
+
return pts
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _run_path(page, pts, c):
|
|
74
|
+
for (px, py) in pts:
|
|
75
|
+
page.mouse.move(px, py)
|
|
76
|
+
d = _rand_ms(c["step_ms"])
|
|
77
|
+
if random.random() < 0.02: # occasional motor hitch
|
|
78
|
+
d += random.uniform(0.03, 0.08)
|
|
79
|
+
time.sleep(d)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def move(page, x, y, preset="default"):
|
|
83
|
+
"""Move the cursor to (x, y) along a human-like curved path.
|
|
84
|
+
|
|
85
|
+
Long moves overshoot the target by a few pixels and correct -- the
|
|
86
|
+
characteristic human "land past it, pull back" arrival that biometric
|
|
87
|
+
scorers look for (its absence over many moves is a tell)."""
|
|
88
|
+
c = _cfg(preset)
|
|
89
|
+
x0, y0 = _pos(page)
|
|
90
|
+
dist = math.hypot(x - x0, y - y0)
|
|
91
|
+
steps = random.randint(*c["move_steps"])
|
|
92
|
+
if dist > 180 and random.random() < 0.6:
|
|
93
|
+
ux, uy = (x - x0) / dist, (y - y0) / dist
|
|
94
|
+
over = random.uniform(3, 14)
|
|
95
|
+
ox, oy = x + ux * over, y + uy * over
|
|
96
|
+
_run_path(page, _bezier(x0, y0, ox, oy, steps), c)
|
|
97
|
+
_run_path(page, _bezier(ox, oy, x, y, random.randint(4, 8)), c)
|
|
98
|
+
else:
|
|
99
|
+
_run_path(page, _bezier(x0, y0, x, y, steps), c)
|
|
100
|
+
page._capium_mouse = (x, y)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _resolve_point(page, target):
|
|
104
|
+
"""Target: a selector string, or an (x, y) tuple/list."""
|
|
105
|
+
if isinstance(target, (tuple, list)) and len(target) == 2:
|
|
106
|
+
return float(target[0]), float(target[1])
|
|
107
|
+
el = page.wait_for_selector(target, state="visible")
|
|
108
|
+
box = el.bounding_box()
|
|
109
|
+
return (box["x"] + box["width"] * random.uniform(0.3, 0.7),
|
|
110
|
+
box["y"] + box["height"] * random.uniform(0.3, 0.7))
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def click(page, selector, preset="default"):
|
|
114
|
+
"""Move to a random point inside `selector` and click with a natural pause."""
|
|
115
|
+
c = _cfg(preset)
|
|
116
|
+
tx, ty = _resolve_point(page, selector)
|
|
117
|
+
move(page, tx, ty, preset)
|
|
118
|
+
time.sleep(_rand_ms(c["click_pause_ms"]))
|
|
119
|
+
page.mouse.down()
|
|
120
|
+
time.sleep(random.uniform(0.03, 0.09))
|
|
121
|
+
page.mouse.up()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def hold(page, target, seconds, preset="default"):
|
|
125
|
+
"""Press-and-hold on `target` (selector or (x, y)) for ~`seconds`, with tremor.
|
|
126
|
+
|
|
127
|
+
Built for press-and-hold challenges (PX/HUMAN and similar), which measure the
|
|
128
|
+
pointer DURING the press: a real hand drifts and trembles ~1px around the
|
|
129
|
+
anchor the whole time, and releases slightly late. A hold with zero pointer
|
|
130
|
+
events between mousedown and mouseup reads as synthetic no matter how good
|
|
131
|
+
the approach path was. `seconds` should be the challenge's required duration;
|
|
132
|
+
a natural human release lag is added on top."""
|
|
133
|
+
c = _cfg(preset)
|
|
134
|
+
tx, ty = _resolve_point(page, target)
|
|
135
|
+
move(page, tx, ty, preset)
|
|
136
|
+
time.sleep(_rand_ms(c["click_pause_ms"]))
|
|
137
|
+
page.mouse.down()
|
|
138
|
+
amp = c["tremor_px"]
|
|
139
|
+
ax, ay = tx, ty # slow random-walk drift anchor
|
|
140
|
+
end = time.monotonic() + float(seconds) + random.uniform(0.15, 0.45)
|
|
141
|
+
while time.monotonic() < end:
|
|
142
|
+
time.sleep(_rand_ms(c["tremor_ms"]))
|
|
143
|
+
if random.random() < 0.7: # tremor tick: micro-move near the anchor
|
|
144
|
+
ax += random.uniform(-0.35, 0.35) # the anchor itself drifts a little
|
|
145
|
+
ay += random.uniform(-0.35, 0.35)
|
|
146
|
+
ax = min(tx + 3, max(tx - 3, ax))
|
|
147
|
+
ay = min(ty + 3, max(ty - 3, ay))
|
|
148
|
+
page.mouse.move(ax + random.gauss(0, amp * 0.5),
|
|
149
|
+
ay + random.gauss(0, amp * 0.5))
|
|
150
|
+
page.mouse.up()
|
|
151
|
+
page._capium_mouse = (ax, ay)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def type_text(page, selector, text, preset="default"):
|
|
155
|
+
"""Click the field, then type with per-key jitter (occasional longer pauses)."""
|
|
156
|
+
c = _cfg(preset)
|
|
157
|
+
click(page, selector, preset)
|
|
158
|
+
for ch in text:
|
|
159
|
+
page.keyboard.type(ch)
|
|
160
|
+
d = _rand_ms(c["key_ms"])
|
|
161
|
+
if random.random() < 0.06: # occasional think-pause
|
|
162
|
+
d += random.uniform(0.15, 0.5)
|
|
163
|
+
time.sleep(d)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def scroll(page, dy, preset="default"):
|
|
167
|
+
"""Scroll `dy` pixels (positive = down) in eased increments, not one jump."""
|
|
168
|
+
c = _cfg(preset)
|
|
169
|
+
remaining = dy
|
|
170
|
+
direction = 1 if dy >= 0 else -1
|
|
171
|
+
while abs(remaining) > 1:
|
|
172
|
+
step = min(abs(remaining), random.uniform(*c["scroll_step"])) * direction
|
|
173
|
+
page.mouse.wheel(0, step)
|
|
174
|
+
remaining -= step
|
|
175
|
+
time.sleep(_rand_ms(c["scroll_ms"]))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def dwell(lo=0.4, hi=1.8):
|
|
179
|
+
"""Idle a human-plausible moment (reading/hesitating)."""
|
|
180
|
+
time.sleep(random.uniform(lo, hi))
|
|
@@ -15,7 +15,7 @@ _IOS_PROFILES = {profile["id"]: profile for profile in _IOS_CATALOG["profiles"]}
|
|
|
15
15
|
# No network request is sent. A secure origin exposes native UA Client Hints.
|
|
16
16
|
ENGINE_PROBE = r"""async expected => {
|
|
17
17
|
const match = navigator.userAgent.match(/Chrome\/(\d+)\.0\.0\.0 Mobile Safari\//);
|
|
18
|
-
if (!expected || navigator.platform !== 'Linux
|
|
18
|
+
if (!expected || navigator.platform !== 'Linux armv8l' || !match ||
|
|
19
19
|
!navigator.userAgent.includes('(Linux; Android 10; K)') ||
|
|
20
20
|
navigator.userAgent.includes('Version/4.0') || !navigator.userAgentData) return false;
|
|
21
21
|
const ch = await navigator.userAgentData.getHighEntropyValues([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: capiumbrowser
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Drop-in stealth browser SDK on top of Playwright (Capium Chromium).
|
|
5
5
|
Author: Capzy
|
|
6
6
|
License: Capzy capiumbrowser SDK License
|
|
@@ -408,7 +408,7 @@ and `launch_persistent_context` forward everything to `launch`.
|
|
|
408
408
|
| Parameter | Type | Default | Description |
|
|
409
409
|
|---|---|---|---|
|
|
410
410
|
| `proxy` | `str` \| `dict` \| `"env"`/`True` \| `None` | `None` | HTTP/HTTPS/SOCKS5 URL with inline creds, a `{"server","username","password"}` dict, `"env"`/`True` (reads `CAPIUM_PROXY`), or `None`/`"none"`/`""`. |
|
|
411
|
-
| `geoip` | `bool` \| `None` | `None` | Geo coherence, resolved inside the binary. **`None` (default) — OFF**:
|
|
411
|
+
| `geoip` | `bool` \| `None` | `None` | Geo coherence, resolved inside the binary. **`None` (default) — ON whenever a proxy is set, OFF otherwise**: an uncorrected host timezone under a proxied identity (UTC on a server) is a far stronger detection signal than the lookup's one-off launch latency. **`True`** — ON even proxyless (pins timezone/geo/WebRTC/`navigator.languages` to the host IP). **`False`** — explicit opt-out. No SDK-side probe. |
|
|
412
412
|
| `timezone` | `str` \| `None` | `None` | IANA tz (e.g. `"America/New_York"`) → `--timezone`. **Overrides** `geoip`. |
|
|
413
413
|
| `locale` | `str` \| `None` | `None` | BCP-47 (e.g. `"en-US"`) → `--lang` + `--accept-lang`. **Overrides** `geoip`. |
|
|
414
414
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"""Unit tests for the SDK geoip flag tri-state (capiumbrowser.browser._proxy_and_geo_args).
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Contract as of 1.3.1: geoip=None (the default) enables --geoip WHENEVER A PROXY IS SET and
|
|
4
|
+
stays off otherwise. An uncorrected host timezone under a proxied identity (UTC on a server
|
|
5
|
+
against a residential exit) is a far stronger detection signal than the lookup's one-off
|
|
6
|
+
launch latency, which is why the 2026-09 "default always off" contract was reversed.
|
|
7
|
+
Explicit False still opts out with --geoip=false (honored first by the binary).
|
|
5
8
|
"""
|
|
6
9
|
import asyncio
|
|
7
10
|
|
|
@@ -14,11 +17,12 @@ def _flags(spec, geoip):
|
|
|
14
17
|
return out
|
|
15
18
|
|
|
16
19
|
|
|
17
|
-
def
|
|
20
|
+
def test_default_none_enables_geoip_with_proxy():
|
|
18
21
|
out = _flags("http://u:p@h:1", geoip=None)
|
|
19
22
|
assert any(a.startswith("--proxy-server=") for a in out), "proxy flag expected"
|
|
20
|
-
assert
|
|
21
|
-
"a proxy
|
|
23
|
+
assert "--geoip" in out, \
|
|
24
|
+
"a proxy must enable geoip by default (exit-coherent timezone/geo/WebRTC)"
|
|
25
|
+
assert not any(a.startswith("--geoip=") for a in out)
|
|
22
26
|
|
|
23
27
|
|
|
24
28
|
def test_true_adds_geoip():
|
|
@@ -26,9 +30,15 @@ def test_true_adds_geoip():
|
|
|
26
30
|
assert "--geoip" in out
|
|
27
31
|
|
|
28
32
|
|
|
33
|
+
def test_true_without_proxy_adds_geoip():
|
|
34
|
+
out = _flags(None, geoip=True)
|
|
35
|
+
assert "--geoip" in out
|
|
36
|
+
|
|
37
|
+
|
|
29
38
|
def test_false_adds_explicit_optout():
|
|
30
39
|
out = _flags("http://u:p@h:1", geoip=False)
|
|
31
40
|
assert "--geoip=false" in out
|
|
41
|
+
assert "--geoip" not in out
|
|
32
42
|
|
|
33
43
|
|
|
34
44
|
def test_no_proxy_no_geoip_by_default():
|
|
@@ -42,5 +52,6 @@ def test_async_mirror_matches_sync():
|
|
|
42
52
|
geoip_on=geoip, display=None)
|
|
43
53
|
return out
|
|
44
54
|
assert "--geoip" in asyncio.run(_run("http://u:p@h:1", True))
|
|
45
|
-
assert
|
|
55
|
+
assert "--geoip" in asyncio.run(_run("http://u:p@h:1", None))
|
|
56
|
+
assert not any(a.startswith("--geoip") for a in asyncio.run(_run(None, None)))
|
|
46
57
|
assert "--geoip=false" in asyncio.run(_run(None, False))
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
capium.human.behavior -- realistic mouse / typing / scroll for Playwright pages.
|
|
3
|
-
|
|
4
|
-
Anti-bot systems increasingly score *behavior*: instant teleport-clicks, zero-jitter typing
|
|
5
|
-
and single-delta scrolls are bot tells. These helpers move the cursor along a bezier path with
|
|
6
|
-
variable speed, type with per-key jitter, and scroll in eased increments. Pure Playwright input
|
|
7
|
-
(page.mouse / page.keyboard) -- no CDP tricks, so it stays consistent with the stealth binary.
|
|
8
|
-
|
|
9
|
-
Presets tune the timing:
|
|
10
|
-
"default" -> natural human pace
|
|
11
|
-
"careful" -> slower, more deliberate (harder to flag, but slower runs)
|
|
12
|
-
"""
|
|
13
|
-
import math
|
|
14
|
-
import random
|
|
15
|
-
import time
|
|
16
|
-
|
|
17
|
-
PRESETS = {
|
|
18
|
-
"default": {"move_steps": (18, 34), "step_ms": (6, 16), "key_ms": (45, 130),
|
|
19
|
-
"click_pause_ms": (40, 140), "scroll_step": (90, 220), "scroll_ms": (30, 90)},
|
|
20
|
-
"careful": {"move_steps": (30, 55), "step_ms": (12, 28), "key_ms": (80, 220),
|
|
21
|
-
"click_pause_ms": (120, 320), "scroll_step": (50, 130), "scroll_ms": (60, 150)},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _cfg(preset):
|
|
26
|
-
return PRESETS.get(preset, PRESETS["default"])
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def _rand_ms(rng):
|
|
30
|
-
return random.uniform(rng[0], rng[1]) / 1000.0
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def _pos(page):
|
|
34
|
-
return getattr(page, "_capium_mouse", (random.randint(2, 60), random.randint(2, 60)))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _bezier(x0, y0, x1, y1, steps):
|
|
38
|
-
# two random control points -> a curved, non-linear path
|
|
39
|
-
cx1 = x0 + (x1 - x0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
40
|
-
cy1 = y0 + (y1 - y0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
41
|
-
cx2 = x0 + (x1 - x0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
42
|
-
cy2 = y0 + (y1 - y0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
43
|
-
pts = []
|
|
44
|
-
for i in range(1, steps + 1):
|
|
45
|
-
t = i / steps
|
|
46
|
-
mt = 1 - t
|
|
47
|
-
x = mt**3 * x0 + 3 * mt**2 * t * cx1 + 3 * mt * t**2 * cx2 + t**3 * x1
|
|
48
|
-
y = mt**3 * y0 + 3 * mt**2 * t * cy1 + 3 * mt * t**2 * cy2 + t**3 * y1
|
|
49
|
-
pts.append((x, y))
|
|
50
|
-
return pts
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def move(page, x, y, preset="default"):
|
|
54
|
-
"""Move the cursor to (x, y) along a human-like curved path."""
|
|
55
|
-
c = _cfg(preset)
|
|
56
|
-
x0, y0 = _pos(page)
|
|
57
|
-
steps = random.randint(*c["move_steps"])
|
|
58
|
-
for (px, py) in _bezier(x0, y0, x, y, steps):
|
|
59
|
-
page.mouse.move(px, py)
|
|
60
|
-
time.sleep(_rand_ms(c["step_ms"]))
|
|
61
|
-
page._capium_mouse = (x, y)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def click(page, selector, preset="default"):
|
|
65
|
-
"""Move to a random point inside `selector` and click with a natural pause."""
|
|
66
|
-
c = _cfg(preset)
|
|
67
|
-
el = page.wait_for_selector(selector, state="visible")
|
|
68
|
-
box = el.bounding_box()
|
|
69
|
-
tx = box["x"] + box["width"] * random.uniform(0.3, 0.7)
|
|
70
|
-
ty = box["y"] + box["height"] * random.uniform(0.3, 0.7)
|
|
71
|
-
move(page, tx, ty, preset)
|
|
72
|
-
time.sleep(_rand_ms(c["click_pause_ms"]))
|
|
73
|
-
page.mouse.down()
|
|
74
|
-
time.sleep(random.uniform(0.03, 0.09))
|
|
75
|
-
page.mouse.up()
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def type_text(page, selector, text, preset="default"):
|
|
79
|
-
"""Click the field, then type with per-key jitter (occasional longer pauses)."""
|
|
80
|
-
c = _cfg(preset)
|
|
81
|
-
click(page, selector, preset)
|
|
82
|
-
for ch in text:
|
|
83
|
-
page.keyboard.type(ch)
|
|
84
|
-
d = _rand_ms(c["key_ms"])
|
|
85
|
-
if random.random() < 0.06: # occasional think-pause
|
|
86
|
-
d += random.uniform(0.15, 0.5)
|
|
87
|
-
time.sleep(d)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def scroll(page, dy, preset="default"):
|
|
91
|
-
"""Scroll `dy` pixels (positive = down) in eased increments, not one jump."""
|
|
92
|
-
c = _cfg(preset)
|
|
93
|
-
remaining = dy
|
|
94
|
-
direction = 1 if dy >= 0 else -1
|
|
95
|
-
while abs(remaining) > 1:
|
|
96
|
-
step = min(abs(remaining), random.uniform(*c["scroll_step"])) * direction
|
|
97
|
-
page.mouse.wheel(0, step)
|
|
98
|
-
remaining -= step
|
|
99
|
-
time.sleep(_rand_ms(c["scroll_ms"]))
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def dwell(lo=0.4, hi=1.8):
|
|
103
|
-
"""Idle a human-plausible moment (reading/hesitating)."""
|
|
104
|
-
time.sleep(random.uniform(lo, hi))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|