From 0dcec5404102785d1e53a2cf319275911b0452c8 Mon Sep 17 00:00:00 2001 From: acd62081 Date: Sun, 20 Dec 2020 21:07:38 -0500 Subject: [PATCH 1/3] Updated API query Updated submit and get queries to be compatible with newer versions of Cuckoo --- cuckoo.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cuckoo.py b/cuckoo.py index 1955c6c..fa37fda 100644 --- a/cuckoo.py +++ b/cuckoo.py @@ -61,11 +61,18 @@ def add_file(self, file_path, tags, parent): db.add(obj=obj, tags=tags, parent_sha=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)) @@ -79,9 +86,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 = 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 @@ -131,7 +143,9 @@ def run(self): api_status['data']['tasks']['total'] ] else: + api_status = self.api_query('get', status_url).json() cuckoo_version = api_status['version'] + self.log('item', "Version: {0}".format(cuckoo_version)) machines = '{0}/{1}'.format(api_status['machines']['available'], api_status['machines']['total'] ) From b6a8ef27091045c7a7bc10b7df5487b53231d977 Mon Sep 17 00:00:00 2001 From: acd62081 Date: Sun, 20 Dec 2020 21:29:41 -0500 Subject: [PATCH 2/3] Updated API query Updated submit and get queries to be compatible with newer versions of Cuckoo --- cuckoo.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cuckoo.py b/cuckoo.py index fa37fda..bf3bab6 100644 --- a/cuckoo.py +++ b/cuckoo.py @@ -61,7 +61,6 @@ def add_file(self, file_path, tags, parent): db.add(obj=obj, tags=tags, parent_sha=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, @@ -69,7 +68,7 @@ def api_query(self, api_method, api_uri, files=None, params=None): 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) + proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert) if files: try: response @@ -143,9 +142,7 @@ def run(self): api_status['data']['tasks']['total'] ] else: - api_status = self.api_query('get', status_url).json() cuckoo_version = api_status['version'] - self.log('item', "Version: {0}".format(cuckoo_version)) machines = '{0}/{1}'.format(api_status['machines']['available'], api_status['machines']['total'] ) From 21d81db979c9d2ada6ae7ea8410cc5eae04ba213 Mon Sep 17 00:00:00 2001 From: acd62081 Date: Fri, 25 Dec 2020 18:34:07 -0500 Subject: [PATCH 3/3] Removed typo Allows status check and submission of files to new versions of cuckoo or cuckoo_modifed --- cuckoo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuckoo.py b/cuckoo.py index bf3bab6..ea9fc9b 100644 --- a/cuckoo.py +++ b/cuckoo.py @@ -86,7 +86,7 @@ def api_query(self, api_method, api_uri, files=None, params=None): if not files and api_method == 'get': if cfg.cuckoo.cuckoo_modified: - response = response = requests.get(api_uri, proxies=cfg.cuckoo.proxies, verify=cfg.cuckoo.verify, cert=cfg.cuckoo.cert) + 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)