The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Google blacklist check script

Discussion in 'Security' started by Josh26, Aug 13, 2013.

  1. Josh26

    Josh26 Member

    Joined:
    May 17, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Hey guys,

    I ran this script up recently and found it, despite being small and simple, incredibly helpful. It iterates through all your domains, and lets you know if any of them are marked as phishing or malware websites. I'm piping its output to an email every night so its alerts are proactive. Knowing who's been hacked and blacklisted before a client does is immensely helpful.

    You will need to sign up for your own Google API key and insert it where shown. Otherwise, just save this content as a .pl file and chmod 700 it. Watch our for line wrapping if you paste from this site - that "get" request should be one line.

    Code:
    #!/usr/bin/perl -w
    
    use strict;
    
    use LWP::Simple;
    
    my $apikey = 'KEY HERE';
    
    open FH, "/etc/userdomains" || die "Failed to open file";
    while(my $domain = <FH>)
    {
            $domain = (split(':', $domain))[0];
            next if ($domain =~ /\*/);
    
            #Google Safebrowse Lookup
            my $content = get("https://sb-ssl.google.com/safebrowsing/api/lookup?client=api&apikey=$apikey&appver=1.0&pver=3.0&url=http%3A%2F%2F$domain%2F");
            die "Couldn't get Google lookup!" unless defined $content;
            next if ($content eq '');
            print "Google had this to say about $domain: $content\n";
    }
    
    close FH;
     
    #1 Josh26, Aug 13, 2013
    Last edited by a moderator: Aug 14, 2013
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    667
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I edited your original post to include code tags around the actual code. This should help users that decide to use this script when they copy and paste the contents.

    Thank you.
     
  3. Josh26

    Josh26 Member

    Joined:
    May 17, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Thanks Michael - yes it's certainly more readable now.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,468
    Likes Received:
    196
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  5. Josh26

    Josh26 Member

    Joined:
    May 17, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    I used the public API documented at that URL - it's my own Perl code.
     
  6. rlshosting

    rlshosting Well-Known Member

    Joined:
    Apr 23, 2009
    Messages:
    170
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    United States
    cPanel Access Level:
    Root Administrator
    Great Job. Thanks.
     
Loading...

Share This Page