File size: 2,462 Bytes
494c89b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Open fingerprint.com demo with a spoofed profile and keep it visible.

Usage:
  python scripts/test_fingerprint_com.py
  python scripts/test_fingerprint_com.py --duration 120 --url https://fingerprint.com/demo/
  python scripts/test_fingerprint_com.py --headless
"""

import argparse
import sys
import time
from DrissionPage import ChromiumPage, ChromiumOptions

# Make local modules importable
sys.path.insert(0, '.')

from spoofers.cdp_spoofer import CDPSpoofer
from spoofers.profile import generate_random_profile


def main() -> int:
    parser = argparse.ArgumentParser(description="Open fingerprint.com demo with spoofed profile")
    parser.add_argument('--duration', type=int, default=120, help='Seconds to keep the page open')
    parser.add_argument('--url', default='https://fingerprint.com/demo/', help='Target URL')
    parser.add_argument('--headless', action='store_true', help='Run in headless mode')
    args = parser.parse_args()

    profile = generate_random_profile()
    print("[PROFILE]")
    print(f"  User-Agent: {profile.user_agent[:80]}...")
    print(f"  Timezone: {profile.timezone} (offset: {profile.timezone_offset})")
    print(f"  Screen: {profile.screen_width}x{profile.screen_height}")
    print(f"  WebGL: {profile.webgl_renderer[:60]}...")
    print(f"  Locale: {profile.locale}")

    options = ChromiumOptions()
    options.set_argument('--no-first-run')
    options.set_argument('--no-default-browser-check')
    options.set_argument('--disable-dev-shm-usage')
    options.set_argument('--disable-infobars')
    options.set_argument('--lang=en-US')
    options.set_argument('--accept-lang=en-US,en')
    options.set_argument('--window-size=1920,1080')

    if args.headless:
        options.headless()
        options.set_argument('--disable-gpu')
        options.set_argument('--no-sandbox')

    print("[BROWSER] Starting...")
    page = ChromiumPage(options)

    print("[SPOOF] Applying pre-navigation spoofing...")
    spoofer = CDPSpoofer(profile)
    spoofer.apply_pre_navigation(page)

    print(f"[NAV] Opening {args.url}")
    page.get(args.url)

    # Keep page open for requested duration
    print(f"[WAIT] Holding for {args.duration}s...")
    for remaining in range(args.duration, 0, -1):
        print(f"  {remaining}s remaining", end='\r')
        time.sleep(1)
    print("\n[WAIT] Done.")

    page.quit()
    return 0


if __name__ == '__main__':
    raise SystemExit(main())