Fix VT [!] Error: Virustotal probably now is blocking our requests
This commit is contained in:
parent
d4b50ac813
commit
0a77a784c8
32
sublist3r.py
32
sublist3r.py
|
|
@ -682,8 +682,10 @@ class DNSdumpster(enumratorBaseThreaded):
|
|||
class Virustotal(enumratorBaseThreaded):
|
||||
def __init__(self, domain, subdomains=None, q=None, silent=False, verbose=True):
|
||||
subdomains = subdomains or []
|
||||
base_url = 'https://www.virustotal.com/ui/domains/{domain}/subdomains'
|
||||
# base_url = 'https://www.virustotal.com/ui/domains/{domain}/subdomains'
|
||||
base_url = 'https://www.virustotal.com/api/v3/domains/{domain}/subdomains'
|
||||
self.engine_name = "Virustotal"
|
||||
self.apikey = os.getenv('VT_APIKEY', None)
|
||||
self.q = q
|
||||
super(Virustotal, self).__init__(base_url, self.engine_name, domain, subdomains, q=q, silent=silent, verbose=verbose)
|
||||
self.url = self.base_url.format(domain=self.domain)
|
||||
|
|
@ -692,6 +694,7 @@ class Virustotal(enumratorBaseThreaded):
|
|||
# the main send_req need to be rewritten
|
||||
def send_req(self, url):
|
||||
try:
|
||||
self.headers.update({'X-ApiKey': self.apikey})
|
||||
resp = self.session.get(url, headers=self.headers, timeout=self.timeout)
|
||||
except Exception as e:
|
||||
self.print_(e)
|
||||
|
|
@ -701,21 +704,20 @@ class Virustotal(enumratorBaseThreaded):
|
|||
|
||||
# once the send_req is rewritten we don't need to call this function, the stock one should be ok
|
||||
def enumerate(self):
|
||||
while self.url != '':
|
||||
resp = self.send_req(self.url)
|
||||
try:
|
||||
if self.apikey:
|
||||
while self.url != '':
|
||||
resp = self.send_req(self.url)
|
||||
resp = json.loads(resp)
|
||||
except Exception:
|
||||
self.print_(R + "[!] Error: Virustotal returns 'int' values" + W)
|
||||
break
|
||||
if 'error' in resp:
|
||||
self.print_(R + "[!] Error: Virustotal probably now is blocking our requests" + W)
|
||||
break
|
||||
if 'links' in resp and 'next' in resp['links']:
|
||||
self.url = resp['links']['next']
|
||||
else:
|
||||
self.url = ''
|
||||
self.extract_domains(resp)
|
||||
if 'error' in resp:
|
||||
self.print_(R + "[!] Error: Virustotal probably now is blocking our requests" + W)
|
||||
break
|
||||
if 'links' in resp and 'next' in resp['links']:
|
||||
self.url = resp['links']['next']
|
||||
else:
|
||||
self.url = ''
|
||||
self.extract_domains(resp)
|
||||
else:
|
||||
self.print_(R + "[!] Error: VirusTotal API key environment variable not found. Skipping" + W)
|
||||
return self.subdomains
|
||||
|
||||
def extract_domains(self, resp):
|
||||
|
|
|
|||
Loading…
Reference in New Issue