""" Fingerprint Profile Service - Manages predefined fingerprint profiles and configurations. """ import random from typing import List, Dict, Any, Optional, Tuple class FingerprintProfileService: """Service for managing fingerprint profiles and configurations.""" DESKTOP_PROFILES = [ { "name": "Windows Chrome User", "platform": "Win32", "hardware_concurrency": [4, 8, 16], "device_memory": [4, 8, 16], "screen_resolution": [(1920, 1080), (2560, 1440), (1366, 768)], "vendor": "Google Inc.", "renderer": ["ANGLE (Intel HD Graphics)", "ANGLE (NVIDIA GeForce GTX)", "ANGLE (AMD Radeon)"] }, { "name": "MacOS Safari User", "platform": "MacIntel", "hardware_concurrency": [4, 8, 12], "device_memory": [8, 16, 32], "screen_resolution": [(1440, 900), (2560, 1600), (5120, 2880)], "vendor": "Apple Inc.", "renderer": ["Apple M1", "Intel Iris", "AMD Radeon Pro"] } ] MOBILE_PROFILES = [ { "name": "Android Chrome", "platform": "Linux armv8l", "hardware_concurrency": [4, 6, 8], "device_memory": [3, 4, 6, 8], "screen_resolution": [(360, 740), (375, 812), (414, 896)], "vendor": "Google Inc.", "renderer": ["Adreno", "Mali", "PowerVR"] }, { "name": "iOS Safari", "platform": "iPhone", "hardware_concurrency": [2, 4, 6], "device_memory": [2, 3, 4], "screen_resolution": [(375, 667), (375, 812), (414, 896)], "vendor": "Apple Inc.", "renderer": ["Apple GPU"] } ] COMMON_FONTS = { "windows": [ "Arial", "Arial Black", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Times New Roman", "Trebuchet MS", "Verdana", "Webdings", "Wingdings", "Calibri", "Cambria", "Consolas", "Segoe UI", "Tahoma" ], "mac": [ "Arial", "Arial Black", "Comic Sans MS", "Courier New", "Georgia", "Helvetica", "Helvetica Neue", "Times New Roman", "Trebuchet MS", "Verdana", "American Typewriter", "Avenir", "Baskerville", "Big Caslon", "Futura", "Geneva", "Gill Sans" ], "linux": [ "Arial", "Courier New", "Times New Roman", "DejaVu Sans", "DejaVu Serif", "DejaVu Sans Mono", "Liberation Sans", "Liberation Serif", "Ubuntu", "Droid Sans", "Noto Sans" ] } AUDIO_CONTEXTS = { "default": { "base_latency": 0.01, "output_latency": 0.02, "sample_rate": 48000 }, "high_quality": { "base_latency": 0.005, "output_latency": 0.01, "sample_rate": 96000 }, "mobile": { "base_latency": 0.02, "output_latency": 0.04, "sample_rate": 44100 } } def get_profile(self, profile_type: Optional[str] = None) -> Dict[str, Any]: """Get a fingerprint profile based on type.""" if profile_type == "mobile": return random.choice(self.MOBILE_PROFILES) else: return random.choice(self.DESKTOP_PROFILES) def get_fonts_for_platform(self, platform: str) -> List[str]: """Get common fonts for a specific platform.""" if "Win" in platform: base_fonts = self.COMMON_FONTS["windows"] elif "Mac" in platform or "iPhone" in platform: base_fonts = self.COMMON_FONTS["mac"] else: base_fonts = self.COMMON_FONTS["linux"] # Randomly select 80-95% of fonts to add variation num_fonts = random.randint(int(len(base_fonts) * 0.8), int(len(base_fonts) * 0.95)) return random.sample(base_fonts, num_fonts) def get_audio_context(self, profile_type: str = "default") -> Dict[str, Any]: """Get audio context configuration.""" return self.AUDIO_CONTEXTS.get(profile_type, self.AUDIO_CONTEXTS["default"]) def get_user_agent_components(self, platform: str) -> Dict[str, str]: """Get user agent components for a platform.""" components = { "Win32": { "os": "Windows NT 10.0; Win64; x64", "browser": "Chrome/120.0.0.0", "engine": "AppleWebKit/537.36 (KHTML, like Gecko)" }, "MacIntel": { "os": "Macintosh; Intel Mac OS X 10_15_7", "browser": "Chrome/120.0.0.0", "engine": "AppleWebKit/537.36 (KHTML, like Gecko)" }, "Linux armv8l": { "os": "Linux; Android 13", "browser": "Chrome/120.0.0.0 Mobile", "engine": "AppleWebKit/537.36 (KHTML, like Gecko)" }, "iPhone": { "os": "iPhone; CPU iPhone OS 17_0 like Mac OS X", "browser": "Version/17.0 Mobile/15E148", "engine": "AppleWebKit/605.1.15 (KHTML, like Gecko)" } } return components.get(platform, components["Win32"]) def get_canvas_noise_config(self, profile_type: str = "default") -> Dict[str, Any]: """Get canvas noise configuration.""" configs = { "default": {"noise_level": 0.02, "algorithm": "gaussian"}, "aggressive": {"noise_level": 0.05, "algorithm": "perlin"}, "minimal": {"noise_level": 0.01, "algorithm": "uniform"} } return configs.get(profile_type, configs["default"]) def get_webrtc_config(self, platform: str) -> Dict[str, Any]: """Get WebRTC configuration for platform.""" if "mobile" in platform.lower() or "android" in platform.lower() or "iphone" in platform.lower(): return { "enabled": True, "ice_servers": ["stun:stun.l.google.com:19302"], "local_ip_mask": "192.168.1.x", "disable_webrtc": False } else: return { "enabled": True, "ice_servers": ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"], "local_ip_mask": "10.0.0.x", "disable_webrtc": False } def get_plugin_list(self, platform: str) -> List[Dict[str, str]]: """Get plugin list for platform.""" if "Win" in platform: return [ {"name": "Chrome PDF Plugin", "filename": "internal-pdf-viewer"}, {"name": "Chrome PDF Viewer", "filename": "mhjfbmdgcfjbbpaeojofohoefgiehjai"}, {"name": "Native Client", "filename": "internal-nacl-plugin"} ] elif "Mac" in platform: return [ {"name": "Chrome PDF Plugin", "filename": "internal-pdf-viewer"}, {"name": "Chrome PDF Viewer", "filename": "mhjfbmdgcfjbbpaeojofohoefgiehjai"} ] else: return []