import socket
import ssl
from typing import Optional
class SecureNetworkInspector:
"""
Demonstrates TLS certificate pinning checks and direct socket connections
to illustrate how anti-cheat clients validate network integrity.
"""
def __init__(self, target_host: str, target_port: int = 443):
self.target_host = target_host
self.target_port = target_port
def verify_direct_connection(self) -> bool:
"""
Simulates direct TLS handshake verification.
If an unauthorized local proxy interrupts the handshake, certificate validation fails.
"""
context = ssl.create_default_context()
context.check_hostname = True
context.verify_mode = ssl.CERT_REQUIRED
try:
with socket.create_connection((self.target_host, self.target_port), timeout=5) as sock:
with context.wrap_socket(sock, server_hostname=self.target_host) as ssock:
cert = ssock.getpeercert()
print(f"[Network Core] SSL/TLS El Sıkışması Başarılı. Sunucu: {self.target_host}")
print(f"[Network Core] Sertifika Sağlayıcısı (Issuer): {cert.get('issuer')}")
return True
except ssl.SSLError as ssl_err:
print(f"[!] TLS/SSL Hatası (Proxy/Interception Algılandı): {ssl_err}")
return False
except Exception as e:
print(f"[!] Bağlantı Hatası: {e}")
return False
if __name__ == "__main__":
# Standard connection validation
inspector = SecureNetworkInspector("auth.riotgames.com")
inspector.verify_direct_connection()