From a7a9f4f448205d040e5f05fcc4bca8b8bd5270af Mon Sep 17 00:00:00 2001 From: connor-marchand Date: Fri, 21 Jul 2023 18:58:32 -0500 Subject: [PATCH] Fixed the outdated otx provider --- gau_python/providers/otx.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/gau_python/providers/otx.py b/gau_python/providers/otx.py index f02a5e3..186c22b 100644 --- a/gau_python/providers/otx.py +++ b/gau_python/providers/otx.py @@ -3,24 +3,29 @@ import requests -base_url = 'https://otx.alienvault.com/api/v1/indicators/hostname' +base_urls = ['https://otx.alienvault.com/api/v1/indicators/hostname', + 'https://otx.alienvault.com/api/v1/indicators/url', + 'https://otx.alienvault.com/api/v1/indicators/domain'] def get_urls_otx(domain): urls = [] - page = 1 try: - while True: - request_url = base_url + f'/{domain}/url_list?limit=100&page={str(page)}' - logging.info(f'GET {request_url}') - response = requests.get(url=request_url) - response_json = json.loads(response.text) + for base_url in base_urls: + page = 1 + while True: + request_url = base_url + f'/{domain}/url_list?limit=100&page={str(page)}' + logging.info(f'GET {request_url}') + response = requests.get(url=request_url) + response_json = json.loads(response.text) - for url_item in response_json["url_list"]: - urls.append(str(url_item["url"])) - if response_json['has_next']: - page += 1 - else: + if 'url_list' not in response_json: + for url_item in response_json["url_list"]: + urls.append(str(url_item["url"])) + if response_json['has_next']: + page += 1 + else: + break break except requests.exceptions.Timeout: