getCFDomainFromList.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. WTFPL License
  4. Run `php -f getCFDomainFromList.php` and wait for result.
  5. This script will read INPUT_DOMAINS and add domain to OUTPUT_RESULT
  6. if the target is in Cloudflare domain lists.
  7. INPUT_DOMAINS is a list of domains. Do not list FQDN.
  8. */
  9. ignore_user_abort(true);
  10. set_time_limit(0);
  11. // INPUT_DOMAINS EOF = must LF
  12. define('INPUT_DOMAINS', 'example.mdn_basedom_list.txt');// _base_ domain list to scan
  13. define('DIR_CFDOMAINS', 'split/');// path to /split/ directory (Cloudflare Domains)
  14. define('OUTPUT_RESULT', 'example.mastodon_cf.txt');// result
  15. if (!file_exists(DIR_CFDOMAINS.'cloudflare_0.txt')){print 'Edit DIR_CFDOMAINS';exit;}
  16. if (!file_exists(INPUT_DOMAINS)){print 'INPUT_DOMAINS not found';exit;}
  17. $result=array();
  18. foreach(explode("\n",file_get_contents(INPUT_DOMAINS)) as $line){
  19. if (strlen($line)<4){continue;}
  20. $letter=substr($line,0,1);
  21. if (!preg_match("/^([a-z0-9]{1})$/",$letter)){continue;}
  22. print $letter.'='.$line."\n";
  23. if (in_array($line,explode("\n",file_get_contents(DIR_CFDOMAINS.'cloudflare_'.$letter.'.txt')))){$result[]=$line;}
  24. }
  25. print count($result)." found\n";
  26. file_put_contents(OUTPUT_RESULT,implode("\n",$result));
  27. print 'done';