def run(self):
try:
if self.data_type == 'hash':
query_url = 'scan/'
query_data = self.getParam('data', None, 'Hash is missing')
elif self.data_type == 'file':
query_url = 'scan/'
hashes = self.getParam('attachment.hashes', None)
if hashes is None:
filepath = self.getParam('file', None, 'File is missing')
query_data = hashlib.sha256(open(filepath, 'r').read()).hexdigest()
else:
# find SHA256 hash
query_data = next(h for h in hashes if len(h) == 64)
elif self.data_type == 'filename':
query_url = 'search?query=filename:'
query_data = self.getParam('data', None, 'Filename is missing')
else:
self.notSupported()
url = str(self.basic_url) + str(query_url) + str(query_data)
error = True
while error:
r = requests.get(url, headers=self.headers, auth=HTTPBasicAuth(self.api_key, self.secret), verify=False)
if "error" in r.json().get('response') == "Exceeded maximum API requests per minute(5). Please try again later.":
time.sleep(60)
else:
error = False
self.report({'results': r.json()})
except ValueError as e:
self.unexpectedError(e)
HybridAnalysis_analyzer.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录