Skip to content

Commit

Permalink
Adds Quad9 plugin (closes Te-k#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-k committed Dec 7, 2019
1 parent 78f0959 commit bf2c784
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ opencage Forward/Reverse geocoding using OpenCage Geocoder API
otx Requests information from AlienVault OTX
permacc Request Perma.cc information through the API
pgp Search for information in PGP key servers
pt Requests Passive Total database
quad9 Check if a domain is blocked by Quad9
robtex Search in Robtex API (https://www.robtex.com/api/)
safebrowsing Check if the given domain is in Google safe Browsing list
save Save a webpage in cache platforms
Expand Down
40 changes: 40 additions & 0 deletions harpoon/commands/quad9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /usr/bin/env python
import sys
import json
import requests
from harpoon.commands.base import Command


class CommandQuad9(Command):
"""
# Quad9
Check if a domain is blocked by Quad9 https://quad9.net/
`harpoon quad9 DOMAIN`
"""
name = "quad9"
description = "Check if a domain is blocked by Quad9"

def add_arguments(self, parser):
parser.add_argument('DOMAIN', help='Domain to be checked')
parser.add_argument('--type', '-t', default='A', help='DNS Type')
parser.add_argument('--verbose', '-v', action='store_true', help='Display results')
self.parser = parser

def run(self, conf, args, plugins):
params = {
'name': args.DOMAIN,
'type': args.type,
'ct': 'application/dns-json',
}
r = requests.get("https://dns.quad9.net:5053/dns-query", params=params)
if r.status_code != 200:
print('Problem querying quad9 :(')
sys.exit(1)
if r.json()['Status'] == 3:
print("{} - BLOCKED".format(args.DOMAIN))
else:
print("{} - NOT BLOCKED".format(args.DOMAIN))
if args.verbose:
print(json.dumps(r.json(), indent=4))

0 comments on commit bf2c784

Please sign in to comment.