Skip to content

Commit

Permalink
Merge branch 'safebrowsing_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismyrobot committed Oct 5, 2017
2 parents 7e976e3 + 19d0ac8 commit 850cf96
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dnstwister/api/checks/safebrowsing.py
Expand Up @@ -4,7 +4,7 @@
import requests


API_URL = 'https://www.google.com/safebrowsing/diagnostic'
API_URL = 'https://www.google.com/transparencyreport/api/v3/safebrowsing/status'


def get_report(domain):
Expand All @@ -15,17 +15,22 @@ def get_report(domain):
Returns a count of matches.
"""
data = {
'output': 'jsonp',
'site': domain
}

result = requests.get(API_URL, params=data)

json_result = json.loads(re.search(r'({.*})', result.text).groups()[0])
result_array = re.search(
r'(\["sb.ssr".*\])',
result.text,
flags=re.MULTILINE).groups()[0]

status = json_result['website']['malwareListStatus']
payload = r'{{"result": {}}}'.format(
result_array
)

if status == 'unlisted':
# TODO: Work out detailed meaning of these values.
if json.loads(payload)['result'][2:-1] == [0, 0, 0, 0, 0, 0]:
return 0

return 1

0 comments on commit 850cf96

Please sign in to comment.