Skip to content

aminhashemi1994/cf-scanner-with-sni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Cloudflare TLS Reliability Scanner

A Bash-based tool to discover Cloudflare edge IPs with open port 443 and evaluate their TLS handshake reliability against a specific SNI.

This script is useful in environments where:

  • Direct outbound access is restricted
  • Only ports 80/443 are allowed
  • Traffic must be proxied through Cloudflare IPs
  • Stable and repeatable TLS connectivity is critical (e.g. ProxyPass, reverse proxies, tunneling)

✨ Features

  • Scans official Cloudflare IP ranges using masscan
  • Filters IPs with port 443 open
  • Performs an initial TLS gate check (fast reject of bad IPs)
  • Runs multiple TLS handshake attempts to measure reliability
  • Categorizes IPs as GOOD / NORMAL / BAD
  • Saves reliable IPs into a reusable file (good_ips)

πŸ“¦ Requirements

  • Linux
  • bash
  • masscan
  • openssl
  • timeout (usually from coreutils)
  • sudo privileges (required by masscan)

Install masscan (example):

sudo apt install masscan

βš™οΈ Configuration

Edit the variables at the top of the script:

OUT="ips.txt"                 # masscan output file
SNI="your.example.com"        # Server Name Indication (IMPORTANT)
ATTEMPTS=10                    # Total TLS handshake attempts per IP
TIMEOUT=2                      # Timeout per handshake (seconds)

⚠️ SNI must match a valid hostname served behind Cloudflare, otherwise TLS checks will fail.


πŸš€ Usage

chmod +x scan.sh
./scan.sh

The script will:

  1. Scan Cloudflare IP ranges on port 443
  2. Perform an initial TLS handshake test
  3. Run reliability checks on passing IPs
  4. Output results to the console
  5. Save GOOD IPs into good_ips

πŸ“Š Result Classification

Status Condition
GOOD 4–5 successful TLS handshakes
NORMAL 2–3 successful TLS handshakes
BAD Less than 2 successful handshakes

Only GOOD IPs are written to good_ips.


πŸ“ Output Files

  • ips.txt β€” raw masscan output
  • good_ips β€” Cloudflare IPs with stable TLS connectivity

πŸ” Why This Exists

In restricted or filtered networks, not all Cloudflare IPs behave equally. Some edges:

  • Drop TLS handshakes
  • Reset connections
  • Are unstable over time

This tool helps you select only reliable Cloudflare IPs for:

  • Reverse proxies
  • ProxyPass setups
  • Tunnels
  • Whitelisted outbound access

⚠️ Notes

  • Scanning large IP ranges may trigger IDS/IPS systems
  • Adjust --max-rate if you experience packet loss
  • Cloudflare IP ranges may change over time

πŸ“œ License

MIT License


🀝 Contributing

PRs and improvements are welcome:

  • Better TLS validation
  • IPv6 support
  • Parallel TLS checks
  • JSON / CSV output

Happy scanning ☁️

About

this script will check clean cloudflare ips and will check you domain that can be able to handshake with that ip.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages