コード例 #1
0
def getDomainStatus(domain):

    #key is linked to my Gmail account and will limit to
    # 10,000 lookups per day.
    api_key = 'ABQIAAAA_ZP3Gp39cTLiKArCd3K0GhQs0x-2rr_UO6hjtMF0uHW-GkhMSA'
    gsb = SafebrowsinglookupClient(api_key, 0, 0)
    return gsb.lookup(domain)
コード例 #2
0
def getDomainStatus(domain):
	
	#key is linked to my Gmail account and will limit to
	# 10,000 lookups per day. 
	api_key = 'ABQIAAAA_ZP3Gp39cTLiKArCd3K0GhQs0x-2rr_UO6hjtMF0uHW-GkhMSA'
	gsb = SafebrowsinglookupClient(api_key, 0, 0)
	return gsb.lookup(domain)
    def test_errors(self):
        client = SafebrowsinglookupClient("AAAAAAAAaaAAAaAAAaA0a0AaaAAAAAAa0AaAAAaAa0aaaAaAa0Aa0AaaaA")
        results = client.lookup(*["http://www.google.com/", "http://www.google.org/"])

        self.assertEquals(2, len(results))
        self.assertEquals("error", results["http://www.google.com/"])
        self.assertEquals("error", results["http://www.google.org/"])
    def test_errors(self):
        client = SafebrowsinglookupClient(
            'AAAAAAAAaaAAAaAAAaA0a0AaaAAAAAAa0AaAAAaAa0aaaAaAa0Aa0AaaaA')
        results = client.lookup(
            *['http://www.google.com/', 'http://www.google.org/'])

        self.assertEquals(2, len(results))
        self.assertEquals('error', results['http://www.google.com/'])
        self.assertEquals('error', results['http://www.google.org/'])
class SafebrowsinglookupClient_ParseTestCase(unittest.TestCase):
    def setUp(self):
        self.client = SafebrowsinglookupClient('insert_API_key_here')

    def test_errors(self):
        client = SafebrowsinglookupClient(
            'AAAAAAAAaaAAAaAAAaA0a0AaaAAAAAAa0AaAAAaAa0aaaAaAa0Aa0AaaaA')
        results = client.lookup(
            *['http://www.google.com/', 'http://www.google.org/'])

        self.assertEquals(2, len(results))
        self.assertEquals('error', results['http://www.google.com/'])
        self.assertEquals('error', results['http://www.google.org/'])

    def test_no_match(self):
        if self.client.key == 'insert_API_key_here':
            return

        results = self.client.lookup(
            *['http://www.google.com/', 'http://www.google.org/'])

        self.assertEquals(2, len(results))
        self.assertEquals('ok', results['http://www.google.com/'])
        self.assertEquals('ok', results['http://www.google.org/'])

    def test_match(self):
        if self.client.key == 'insert_API_key_here':
            return

        results = self.client.lookup('http://www.gumblar.cn/')

        self.assertEquals(1, len(results))
        self.assertEquals('malware', results['http://www.gumblar.cn/'])

    def test_match_many(self):
        if self.client.key == 'insert_API_key_here':
            return

        urls = []
        for i in range(1, 600):
            urls.append("http://www.gumblar.cn/" + str(i))

        results = self.client.lookup(*urls)

        self.assertEquals(len(urls), len(results))
        self.assertEquals('malware', results['http://www.gumblar.cn/1'])
        self.assertEquals('malware', results['http://www.gumblar.cn/500'])
        self.assertEquals('malware', results['http://www.gumblar.cn/599'])
class SafebrowsinglookupClient_ParseTestCase(unittest.TestCase):
    def setUp(self):
        self.client = SafebrowsinglookupClient("insert_API_key_here")

    def test_errors(self):
        client = SafebrowsinglookupClient("AAAAAAAAaaAAAaAAAaA0a0AaaAAAAAAa0AaAAAaAa0aaaAaAa0Aa0AaaaA")
        results = client.lookup(*["http://www.google.com/", "http://www.google.org/"])

        self.assertEquals(2, len(results))
        self.assertEquals("error", results["http://www.google.com/"])
        self.assertEquals("error", results["http://www.google.org/"])

    def test_no_match(self):
        if self.client.key == "insert_API_key_here":
            return

        results = self.client.lookup(*["http://www.google.com/", "http://www.google.org/"])

        self.assertEquals(2, len(results))
        self.assertEquals("ok", results["http://www.google.com/"])
        self.assertEquals("ok", results["http://www.google.org/"])

    def test_match(self):
        if self.client.key == "insert_API_key_here":
            return

        results = self.client.lookup("http://www.gumblar.cn/")

        self.assertEquals(1, len(results))
        self.assertEquals("malware", results["http://www.gumblar.cn/"])

    def test_match_many(self):
        if self.client.key == "insert_API_key_here":
            return

        urls = []
        for i in range(1, 600):
            urls.append("http://www.gumblar.cn/" + str(i))

        results = self.client.lookup(*urls)

        self.assertEquals(len(urls), len(results))
        self.assertEquals("malware", results["http://www.gumblar.cn/1"])
        self.assertEquals("malware", results["http://www.gumblar.cn/500"])
        self.assertEquals("malware", results["http://www.gumblar.cn/599"])
コード例 #7
0
def retrieveSafeBrowseringResutls():
    
    print("Connecting to SafebrowsinglookupClient...")
    
    #key = 'ABQIAAAAMW5c1P9_7qTcpx8drxoM8xQXc-3IJoTDvJwbFxcncj5ENdNsVw'
    key = 'AIzaSyAWHi27ImtGlIc2APppC4lGlU1N01fiE1c'
    client = SafebrowsinglookupClient(key)
    
    if(client):
        print("Connected successfully to SafebrowsinglookupClient!")
        print("Running lookup ...")
        
        results = client.lookup(*domains.keys());
        
        for url in results:
            if (results[url] != 'ok'):
                print url + ',' + results[url]
            if (results[url] == "malware" or results[url] ==  "phishing" or results[url] ==  "malware,phishing"):
                malwareDomains.append(url)
    
        print("Number of Malware Domains : " + str(len(malwareDomains)) + " Out of: " + str(len(domains))) 
 def setUp(self):
     self.client = SafebrowsinglookupClient('insert_API_key_here')
 def setUp(self):
     self.client = SafebrowsinglookupClient("insert_API_key_here")