Guest User

Untitled

a guest
Sep 28th, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. To check if a domain is using cloudflare (perl code):
  2.  
  3. my $whoiscmd = "/usr/bin/whois";
  4. sub uses_cloudflare_dns
  5. {
  6. my $domain = shift;
  7. my $retval = system("$whoiscmd '$domain' |grep -i 'cloudflare' > /dev/null");
  8. return (($retval >> 8) == 0);
  9. }
  10.  
  11. To check blacklists:
  12.  
  13. my $score = 0;
  14. my $reason = "";
  15. my $hostcmd = "/usr/bin/host";
  16. sub check_blacklists
  17. {
  18. my $ip = shift;
  19. # Do a sorbs lookup (determine if it is a dynamic ip)
  20. my ($a, $b, $c, $d) = split('\.', $ip);
  21. my $ret = `$hostcmd $d.$c.$b.$a.dul.dnsbl.sorbs.net|grep 'has address'|head -n 1`;
  22. if ($ret =~ /has address ([0-9\.]+)/)
  23. {
  24. if ($reason ne "")
  25. {
  26. $reason .= ", ";
  27. }
  28. $reason .= "your outgoing mail server is listed in SORBS";
  29. $score += 100;
  30. if ($debug eq "true")
  31. {
  32. print "mail server $ip listed in sorbs: 100 added to score (total score=$score)\n";
  33. }
  34. }
  35.  
  36. # Do a spamhaus lookup
  37. $ret = `$hostcmd $d.$c.$b.$a.zen.spamhaus.org|grep 'has address'|head -n 1`;
  38. if ($ret =~ /has address ([0-9\.]+)/)
  39. {
  40. if ($reason ne "")
  41. {
  42. $reason .= ", ";
  43. }
  44. $reason .= "your outgoing mail server is listed in SPAMHAUS";
  45. $score += 100;
  46. if ($debug eq "true")
  47. {
  48. print "mail server listed in spamhaus: 100 added to score (total score=$score)\n";
  49. }
  50. }
  51.  
  52. # Do a barracuda lookup
  53. $ret = `$hostcmd $d.$c.$b.$a.b.barracudacentral.org|grep 'has address'|head -n 1`;
  54. if ($ret =~ /has address ([0-9\.]+)/)
  55. {
  56. if ($reason ne "")
  57. {
  58. $reason .= ", ";
  59. }
  60. $reason .= "your outgoing mail server is listed in Barracuda";
  61. $score += 100;
  62. if ($debug eq "true")
  63. {
  64. print "mail server listed in barracuda: 100 added to score (total score=$score)\n";
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment