Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
# sni_override_simple.py # Mitmproxy addon: Перехватывает SNI от клиента и подменяет его # для исходящего соединения, если он есть в карте. from mitmproxy import ctx, tls import traceback # ---------------- CONFIG ---------------- SNI_MAP = { "api.glebins.ru": "new-sni.target.example", "glebins.ru": "fake.glebins.ru", # "scontent-hel3-1.cdninstagram.com": "scontent-hel3-1.aaaaaaaaaaaa.com", # "static.cdninstagram.com": "bbbbbbbbbbb.com", "cdn": "nqw", "instagram": "a", "fb": "pl", "facebook.com": "b.com", "youtube": "google", "yt": "nt", "googlevideo": "google" # q4flrnel } # https://scontent-hel3-1.cdninstagram.com # ---------------------------------------- class SniOverride: def __init__(self): # Приводим все ключи в SNI_MAP к нижнему регистру при загрузке self.sni_map_lower = {k.lower(): v for k, v in SNI_MAP.items()} ctx.log.info(f"SniOverride loaded. Mappings: {self.sni_map_lower}") def tls_clienthello(self, data: tls.ClientHelloData): try: client_sni = data.client_hello.sni if not client_sni: ctx.log.debug(f"[tls_clienthello] Клиент не отправил SNI.") return client_sni_lower = client_sni.lower() ctx.log.info(f"[tls_clienthello] Перехвачен SNI клиента: '{client_sni}'") i = 0 for sni_to_change, target_sni in self.sni_map_lower.items(): if sni_to_change in client_sni_lower: if target_sni != "*": sni_to_take = client_sni_lower if i == 0 else data.context.server.sni data.context.server.sni = sni_to_take.replace(sni_to_change, target_sni) i += 1 if i == 3: break if client_sni != data.context.server.sni and data.context.server.sni != None: with open("my_file.txt", "a") as file: file.write(f"[tls_clienthello] client SNI: '{client_sni}' -> SNI for server '{data.context.server.sni}'\n") ctx.log.warn(f"[tls_clienthello] ПОДМЕНА: SNI клиента '{client_sni}' -> SNI для сервера '{data.context.server.sni}'") else: ctx.log.info(f"[tls_clienthello] SNI клиента '{client_sni}' не в карте. Пропускаем.") except Exception as e: ctx.log.error(f"[tls_clienthello] Ошибка: {e}\n{traceback.format_exc()}") addons = [SniOverride()]
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)