lola530 / gfw_resist_tls_proxy

knock up GFW sni detection in tls client hello

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gfw_resist_tls_proxy

internet for everyone or no one

سلام گرم به همه دوستانی که برای حق اولیه و ابتدایی شهروندی ، برای دسترسی به اینترنت ، تلاش میکنند
سلام به هیدیفای،باشسیز،سگارو،آی آر سی اف ، پروژه امید،ثنایی،هگزا، یوتیوبرها و همه عزیزان دوست داشتنی

روش این پیج یک زخم عمیق بر پیکر GFW می گذارد که تا سالها سوزش آن در ماتحت فیلترچیان دنیا باقی خواهد ماند

خلاصه کار به فارسی:
روترهای gfw تلاش میکنند اما نمیتوانند همه packet های fragment را سرهم کنند زمانی که delay بین پکت ها باشد
چرا؟ چون کل ترافیک کشور ازشون عبور میکنه و براشون سخته و cache محدود دارند و باید سریع باشند
از طرفی gfw نمیتونه پکت های فرگمنت رو reject کنه چون اولا fragmet جزو اصول شبکه هست
ثانیا در خیلی از نت های ضعیف packet ها تکه میشوند
در صورت reject کردن نت بسیاری از گوشی های قدیمی و خطوط ضعیف مختل میشه
همچنین در مسیر روترهای پرسرعت fragmentation اتفاق می افته
و اینو gfw میدونه بنابراین سعی میکنه اسمبل کنه و اگر نتونه عبور میده
سرورها ولی موظف به سرهم کردن fragment ها هستند چون در پروتکل ip قید شده و سرشون به اندازه gfw شلوغ نیست
سرورهای کلودفلر به خوبی این کارو میکنن
باور کنید یا نکنید کار gfw ساختست
الان عمده ترافیک TLS هست و تنها با تحلیل SNI میتونه ترافیک TLS رو تفکیک کنه
و ما کار رو براش هزینه بر و پردازش بر میکنیم
یا باید کل cloudflare رو با همه سایت هاش ببنده و عملا نت جهانی رو قطع کنه
یا باید فرگمنت رو drop کنه که در هر صورت سیستم های خودشون هم دچار اختلال میشه
این سیستم تست شده و کار میکنه
و شما با domain فیلتر شده و با ip کثیف cloudflare میتوانید از gfw عبور کنید
با اندکی تنظیمات ، سرعت handshake اول هم بالا خواهد رفت
اینترنت برای همه یا برای هیچکس

goodbye SNI filtering & goodbye GFW mf'er



main Idea:

in TLS protocol (even latest v1.3) SNI transfered in plain-text
GFW find it and when SNI is not in whitelist reply with TCP-RST
so it filter cloudflare-ip , based on SNI , such that some popular sites
like plos.org is open , and all other sites closed , through that ip
so we need to hide SNI from GFW
we fragment TLS "client Hello" packet into chunks in a simple manner
we show that it pass the firewall
more importantly we show that GFW cant fix it because its nearly impossible
to cache TBs of data in high speed router , so they MUST give up or break the whole network



about SNI , ESNI & ECH (skip if you want)

leaking domain name (SNI) is the old famous bug of TLS protocol which is not fixed yet as of 2023
some attempt started few years ago , was trying to encrypt sni called ESNI which is deprecated today
cloudflare stop supporting esni in summer 2022
another way is Encrypted Client Hello (ECH) which is in draft version and not well-documented
i made much effort to use ECH but its too complex and still is in development
also its based on DNS-over-HTTPS which is already filtered by GFW

about GFW SNI filtering on cloudflare IPs (skip if you want)

cloudflare IPs are high traffic and 30% of web is behind them
so GFW cant simply block them by traffic volume
and all traffic is encrypted except client hello which leak server name (SNI)


so GFW extract sni from client hello and when SNI is in white list it pass

Alt text

if SNI in in blacklist , GFW send TCP-RST to terminate tcp socket

Alt text

about packet fragment (skip if you want)

we hide sni by fragmenting client hello packet into several chunk.
but GFW already know this and try to assemble those chunk to find SNI! LOL
but we add time delay between fragment. LOL
since cloudflare IPs have too much traffic , GFW cant wait too long. LOL
GFW high-speed cache is limited so it cant cache TBs of data looking for a tiny tcp fragment. LOL
so it forget those fragments after a second. LOL
its impossible to looking at huge traffic for a packet didnt know when or where it arrive. LOL
so it forced to Give up. LOL

how to run

  1. assume that you have v2ray config {websocket+tls+Cloudflare}
  2. setup pyprox listen_port and cloudflare_dirty_ip

  3. setup your v2ray client to forward to 127.0.0.1:listen_port

  4. on your local machine run
    python pyprox_tcp.py
  5. monitor traffic by wireshark or microsoft network monitor
  6. adjast fragment_size & fragment_sleep
    typical Client Hello packet is ~300 byte
    we split 300 into {77+77+77+69} and send each by delay of 0.3 second
    fragment_size=77 byte , fragment_sleep=0.3 sec -> moderate packet size with moderate delay -> work good
    another setup might be:
    fragment_size=77 byte , fragment_sleep=0.2 sec -> moderate packet size with moderate delay -> work nice
    fragment_size=17 byte , fragment_sleep=0.03 sec -> too small chunk with less delay -> work good
    too big chunk -> assembled by GFW -> TCP-RST recieved
    too small delay -> assembled by GFW -> TCP-RST recieved
  7. just surf the web using your filtered sni and a dirty cloudflare IP !

we are working on it to adjast parameters better

it might be slow at initiating tls handshake
but we make it better by setting up persistent TLS
stay tuned!

TO DO NEXT

  1. implement into v2ray clients or xray-core -> Client Hello Fragmentation option
  2. setup persistent TLS (thus one handshake is enough for everything)
  3. sending TCP packet in reverse time order
  4. your ideas are welcome

About

knock up GFW sni detection in tls client hello

License:GNU General Public License v3.0


Languages

Language:Python 100.0%