Skip to content

Instantly share code, notes, and snippets.

@daehee
Created February 20, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daehee/cc93c02d3dfbbdd95c1ea01f68d1296d to your computer and use it in GitHub Desktop.
Save daehee/cc93c02d3dfbbdd95c1ea01f68d1296d to your computer and use it in GitHub Desktop.
strip out CDNs from list of IPs (cloudflare, akamai, incapsula, sucuri)
#!/bin/bash
# Call with domain name <e.g. tesla.com> as arg $1
scanned () {
cat $1 | sort -u | wc -l
}
## segregating cloudflare IP from non-cloudflare IP
iprange="173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/12 172.64.0.0/13 131.0.72.0/22"
for ip in `cat $1-ipz.txt`; do
grepcidr "$iprange" <(echo "$ip") >/dev/null && echo "[!] $ip is cloudflare" || echo "$ip" >> $1-ip4.txt
done
ipz=`scanned $1-ip4.txt`
ip_old=`scanned $1-ipz.txt`
echo "[+] $ipz non-cloudflare IPs has been collected out of $ip_old IPs!"
# rm $1-ipz.txt
sleep 5
incapsula="199.83.128.0/21 198.143.32.0/19 149.126.72.0/21 103.28.248.0/22 45.64.64.0/22 185.11.124.0/22 192.230.64.0/18 107.154.0.0/16 45.60.0.0/16 45.223.0.0/16"
for ip in `cat $1-ip4.txt`; do
grepcidr "$incapsula" <(echo "$ip") >/dev/null && echo "[!] $ip is Incapsula" || echo "$ip" >> $1-ip3.txt
done
ipz=`scanned $1-ip3.txt`
ip_old=`scanned $1-ip4.txt`
echo "[+] $ipz non-incapsula IPs has been collected out of $ip_old IPs!"
rm $1-ip4.txt
sleep 5
sucuri="185.93.228.0/24 185.93.229.0/24 185.93.230.0/24 185.93.231.0/24 192.124.249.0/24 192.161.0.0/24 192.88.134.0/24 192.88.135.0/24 193.19.224.0/24 193.19.225.0/24 66.248.200.0/24 66.248.201.0/24 66.248.202.0/24 66.248.203.0/24"
for ip in `cat $1-ip3.txt`; do
grepcidr "$sucuri" <(echo "$ip") >/dev/null && echo "[!] $ip is Sucuri" || echo "$ip" >> $1-ip2.txt
done
ipz=`scanned $1-ip2.txt`
ip_old=`scanned $1-ip3.txt`
echo "[+] $ipz non-sucuri IPs has been collected out of $ip_old IPs!"
rm $1-ip3.txt
sleep 5
akamai="104.101.221.0/24 184.51.125.0/24 184.51.154.0/24 184.51.157.0/24 184.51.33.0/24 2.16.36.0/24 2.16.37.0/24 2.22.226.0/24 2.22.227.0/24 2.22.60.0/24 23.15.12.0/24 23.15.13.0/24 23.209.105.0/24 23.62.225.0/24 23.74.29.0/24 23.79.224.0/24 23.79.225.0/24 23.79.226.0/24 23.79.227.0/24 23.79.229.0/24 23.79.230.0/24 23.79.231.0/24 23.79.232.0/24 23.79.233.0/24 23.79.235.0/24 23.79.237.0/24 23.79.238.0/24 23.79.239.0/24 63.208.195.0/24 72.246.0.0/24 72.246.1.0/24 72.246.116.0/24 72.246.199.0/24 72.246.2.0/24 72.247.150.0/24 72.247.151.0/24 72.247.216.0/24 72.247.44.0/24 72.247.45.0/24 80.67.64.0/24 80.67.65.0/24 80.67.70.0/24 80.67.73.0/24 88.221.208.0/24 88.221.209.0/24 96.6.114.0/24"
for ip in `cat $1-ip2.txt`; do
grepcidr "$akamai" <(echo "$ip") >/dev/null && echo "[!] $ip is Akamai" || echo "$ip" >> $1-ip.txt
done
ipz=`scanned $1-ip.txt`
ip_old=`scanned $1-ip2.txt`
echo "[+] $ipz non-akamai IPs has been collected out of $ip_old IPs!"
rm $1-ip2.txt
sleep 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment