I am attempting to leverage the attack python client via anaconda 4.6.14 on Windows. I was able to get the module installed but when I attempt to import it (from attackcti import attack_client), I receive an error.
I'm sitting behind a corporate proxy and assuming that is the issue. I've configured the proxy settings in the .condarc file as well as set the HTTP_PROXY and HTTPS_PROXY environment variables.
Is it possible to leverage the attack python client behind a proxy? Any assistance you can provide would be greatly appreciated. The error message is as follows:
---------------------------------------------------------------------------
TimeoutError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connection.py in _new_conn(self)
159 conn = connection.create_connection(
--> 160 (self._dns_host, self.port), self.timeout, **extra_kw)
161
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
79 if err is not None:
---> 80 raise err
81
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
69 sock.bind(source_address)
---> 70 sock.connect(sa)
71 return sock
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
602 body=body, headers=headers,
--> 603 chunked=chunked)
604
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
343 try:
--> 344 self._validate_conn(conn)
345 except (SocketTimeout, BaseSSLError) as e:
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connectionpool.py in _validate_conn(self, conn)
842 if not getattr(conn, 'sock', None): # AppEngine might not have `.sock`
--> 843 conn.connect()
844
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connection.py in connect(self)
315 # Add certificate verification
--> 316 conn = self._new_conn()
317 hostname = self.host
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connection.py in _new_conn(self)
168 raise NewConnectionError(
--> 169 self, "Failed to establish a new connection: %s" % e)
170
NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x0000000008756320>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
448 retries=self.max_retries,
--> 449 timeout=timeout
450 )
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
640 retries = retries.increment(method, url, error=e, _pool=self,
--> 641 _stacktrace=sys.exc_info()[2])
642 retries.sleep()
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
398 if new_retry.is_exhausted():
--> 399 raise MaxRetryError(_pool, url, error or ResponseError(cause))
400
MaxRetryError: HTTPSConnectionPool(host='cti-taxii.mitre.org', port=443): Max retries exceeded with url: /stix/collections/95ecc380-afe9-11e4-9b6c-751b66dd541e/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000000008756320>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
<ipython-input-2-8ab5632e9f1f> in <module>
----> 1 from attackcti import attack_client
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\attackcti\__init__.py in <module>
1 #!/usr/bin/env python
2
----> 3 from .attack_api import attack_client
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\attackcti\attack_api.py in <module>
20 MOBILE_ATTCK = "2f669986-b40b-4423-b720-4396ca6a462b"
21
---> 22 class attack_client(object):
23 ENTERPRISE_COLLECTION = Collection(ATTCK_STIX_COLLECTIONS + ENTERPRISE_ATTCK + "/")
24 PRE_COLLECTION = Collection(ATTCK_STIX_COLLECTIONS + PRE_ATTCK + "/")
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\attackcti\attack_api.py in attack_client()
25 MOBILE_COLLECTION = Collection(ATTCK_STIX_COLLECTIONS + MOBILE_ATTCK + "/")
26
---> 27 TC_ENTERPRISE_SOURCE = TAXIICollectionSource(ENTERPRISE_COLLECTION)
28 TC_PRE_SOURCE = TAXIICollectionSource(PRE_COLLECTION)
29 TC_MOBILE_SOURCE = TAXIICollectionSource(MOBILE_COLLECTION)
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\stix2\datastore\taxii.py in __init__(self, collection, allow_custom)
153
154 try:
--> 155 if collection.can_read:
156 self.collection = collection
157 else:
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\taxii2client\__init__.py in can_read(self)
410 @property
411 def can_read(self):
--> 412 self._ensure_loaded()
413 return self._can_read
414
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\taxii2client\__init__.py in _ensure_loaded(self)
478 def _ensure_loaded(self):
479 if not self._loaded:
--> 480 self.refresh()
481
482 def _verify_can_read(self):
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\taxii2client\__init__.py in refresh(self, accept)
493 """Update Collection information"""
494 response = self.__raw = self._conn.get(self.url,
--> 495 headers={"Accept": accept})
496 self._populate_fields(**response)
497 self._loaded = True
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\taxii2client\__init__.py in get(self, url, headers, params)
937 accept = merged_headers["Accept"]
938
--> 939 resp = self.session.get(url, headers=merged_headers, params=params)
940
941 resp.raise_for_status()
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\requests\sessions.py in get(self, url, **kwargs)
544
545 kwargs.setdefault('allow_redirects', True)
--> 546 return self.request('GET', url, **kwargs)
547
548 def options(self, url, **kwargs):
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
531 }
532 send_kwargs.update(settings)
--> 533 resp = self.send(prep, **send_kwargs)
534
535 return resp
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
644
645 # Send the request
--> 646 r = adapter.send(request, **kwargs)
647
648 # Total elapsed time of the request (approximately)
~\AppData\Local\Continuum\anaconda3\envs\attack\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
514 raise SSLError(e, request=request)
515
--> 516 raise ConnectionError(e, request=request)
517
518 except ClosedPoolError as e:
ConnectionError: HTTPSConnectionPool(host='cti-taxii.mitre.org', port=443): Max retries exceeded with url: /stix/collections/95ecc380-afe9-11e4-9b6c-751b66dd541e/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000000008756320>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))