Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions cuckoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ def add_file(self, file_path, tags, parent):
return obj.sha256

def api_query(self, api_method, api_uri, files=None, params=None):
if cfg.cuckoo.cuckoo_modified:
response = requests.post(api_uri, files=files, data=params,
proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert)
else:
auth_headers = {'Authorization': "Bearer {0}".format(cfg.cuckoo.auth_token)}
response = requests.post(api_uri, headers=auth_headers, files=files, data=params,
proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert)
if files:
try:
response = requests.post(api_uri, files=files, data=params,
proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert)
response

except requests.ConnectionError:
self.log('error', "Unable to connect to Cuckoo API at '{0}'.".format(api_uri))
Expand All @@ -79,9 +85,14 @@ def api_query(self, api_method, api_uri, files=None, params=None):
return

if not files and api_method == 'get':
if cfg.cuckoo.cuckoo_modified:
response = requests.get(api_uri, proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert)
else:
auth_headers = {'Authorization': "Bearer {0}".format(cfg.cuckoo.auth_token)}
response = requests.get(api_uri, headers=auth_headers, proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert)
# GET from API
try:
response = requests.get(api_uri, proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert)
response
except requests.ConnectionError:
self.log('error', "Unable to connect to Cuckoo API at '{0}'.".format(api_uri))
return
Expand Down