#!/bin/bash
rm -rf fofa 2>/dev/null
mkdir fofa
cd fofa

key='header="HKG" && server="cloudflare" && country="CN" && port="80" && domain=""'

if [ -n "$1" ];then
    key="$1"
fi

for d in $(seq 0 29)
do 
    dd="$(date -d "tomorrow -$d days" "+%Y-%m-%d")"
    key_date="$key && "'before="'"$dd"'"'
    for i in $(seq 1);do curl "https://fofa.info/result?qbase64=$(echo -n "$key_date" | base64 | tr -d '\n')&page=$i&size=10"
    done
done | grep -oE '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' | sort | uniq >>cfip.txt

curl -k -o cf.sh https://pan.1996999.xyz/router.sh
chmod +x cf.sh

./cf.sh -q -o

cp speedlog.txt ../fofa.txt

cd ..

rm -rf fofa
