-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from CAPESandbox/misp
Create whoisxmlapi.py
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import logging | ||
|
||
import requests | ||
|
||
from lib.cuckoo.common.config import Config | ||
|
||
log = logging.getLogger() | ||
externalservices_cfg = Config("externalservices") | ||
apikey = externalservices_cfg.whoisxmlapi.apikey | ||
|
||
def whoisxmlapi_lookup(host): | ||
if not externalservices_cfg.whoisxmlapi.enabled or not apikey: | ||
return {} | ||
|
||
result = {} | ||
log.debug("Performing WHOIS Query for IP/Domain: %s", host) | ||
url = f"https://www.whoisxmlapi.com/whoisserver/WhoisService?apiKey={apikey}&domainName={host}&outputFormat=json" | ||
try: | ||
r = requests.get(url, verify=False) | ||
if r.ok: | ||
result = r.json() | ||
except Exception as e: | ||
log.error("whoismlapi.com exception: %s", str(e)) | ||
|
||
return result |