Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Java implementation of Google's Safe Browsing Lookup API v3.1

License

Notifications You must be signed in to change notification settings

charlieIT/java-googlesafebrowsing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Safebrowsing API v3.1 for Java

[API V3 is currently deprecated -> refer to https://developers.google.com/safe-browsing/]

This project implements the Google Safe Browsing Lookup API v3.1 in Java.

###Features as of v1.0:

  • Check URL via GET method
  • Check multiple URLs via POST method
  • Check multiple URLs from local or remote file via POST method
  • Build a report in plain text or JSON format

###Simple usage:

        /*GET Request Example
        * using a know safe website
        */
        String apiKey = "<Your API KEY />";
        
        Lookup look = new Lookup(apiKey, "GET");
        
        LookupResult result = look.lookupURL("https://www.google.pt/");
        
        //Let's print the trusted status 
        System.out.println(result.isTrusted());
        
        //A known risky website taken from malc0de.com/database/
        LookupResult res = new Lookup(apiKey,"GET").lookupURL("wt8.52zsoft.com/hhbqxgq.exe");
        
        //Build a compact report in JSON format
        System.out.println(Utils.prettyJson(Utils.buildCompactReport(res)));
        
        /*
        * POST Request Examples
        * Websites taken from phishtank.com/ and malc0de.com/database/
        * Used only as an example :) 
        */
        
        //POST Request ex 1 - using an array of strings
        
        LookupResult post_res = 
                new Lookup(apiKey, "POST")
                        .lookupURL(
                                new String[]{"https://www.google.pt/",
                                    "wt8.52zsoft.com/hhbqxgq.exe",
                                    "http://www.win-install.info/dropbox/"});
        
        //Build a bigger threat report with a random term
        String report = new Utils().buildThreatReport(post_res, null);
        System.out.println(report);
        
        //POST Request ex 2 - using a remote file containing the urls to be checked
        LookupResult postRes = 
                new Lookup(apiKey, "POST")
                    .lookupURL("https://raw.githubusercontent.com/charlieIT/java-googlesafebrowsing/master/test_urls.txt");
        System.out.println(Utils.prettyJson(Utils.buildCompactReport(postRes)));

###Output:

        /*
        * Various options for output and output format
        * .isTrusted(), .getData(), .toString() 
        * .buildThreatReport() returns full text report along with ANSI colors and indentation
        * .buildCompactReport returns a valid JSON object
        *   using .prettyJSON() will indent the JSON output and make it visually pleasant
        */

###More usage 😄 usage

##Dependencies
- Apache Commons: commons-lang3-3.1
- JSON: json-20160212

##Attribution
This project is based of @kivibot work with [Java-SafeBrowsing](https://github.com/kivibot/Java-SafeBrowsing)

##Advisory
Advisory information provided by Google <br />
No page result is 100% certain, for more information visit:<br/> https://www.google.com/about/company/unwanted-software-policy.html<br/> http://code.google.com/apis/safebrowsing/safebrowsing_faq.html#whyAdvisory<br/>
http://www.antiphishing.org/<br/>
http://www.stopbadware.org/<br/>
https://developers.google.com/safe-browsing/lookup_guide<br/>

About

Java implementation of Google's Safe Browsing Lookup API v3.1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages