offsecginger / ctfd-docker-challenges Goto Github PK
View Code? Open in Web Editor NEWDocker Challenge creation for CTFd. Allows per team/user containers!
License: GNU General Public License v3.0
Docker Challenge creation for CTFd. Allows per team/user containers!
License: GNU General Public License v3.0
If you try to reset the CTFd it will crash and report "500 Internal Server Error".
If you try to delete a docker challenge it won't delete the challenge but silenty report the following error to the logs.
I think if you try to reset CTFd it will also try to delete the remaining challenges and call the same function.
CTFd throws the following error in both cases:
172.23.0.1 - - [24/Jun/2021:10:55:31 +0000] "DELETE /api/v1/challenges/3 HTTP/1.0" 500 37 "http://127.0.0.1/admin/challenges" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
ERROR [CTFd] Exception on /api/v1/challenges/5 [DELETE]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 170, in execute
result = self._query(query)
File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 328, in _query
conn.query(q)
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
result.read()
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 1075, in read
first_packet = self.connection._read_packet()
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
packet.check_error()
File "/usr/local/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/lib/python3.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`ctfd`.`docker_challenge`, CONSTRAINT `docker_challenge_ibfk_1` FOREIGN KEY (`id`) REFERENCES `challenges` (`id`))')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.7/site-packages/flask_restx/api.py", line 375, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_restx/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/opt/CTFd/CTFd/utils/decorators/__init__.py", line 133, in admins_only_wrapper
return f(*args, **kwargs)
File "/opt/CTFd/CTFd/api/v1/challenges.py", line 541, in delete
chal_class.delete(challenge)
File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 489, in delete
Challenges.query.filter_by(id=challenge.id).delete()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3872, in delete
delete_op.exec_()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1697, in exec_
self._do_exec()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1928, in _do_exec
self._execute_stmt(delete_stmt)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1702, in _execute_stmt
self.result = self.query._execute_crud(stmt, self.mapper)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3514, in _execute_crud
return conn.execute(stmt, self._params)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1020, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1324, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1518, in _handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from_=e
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 170, in execute
result = self._query(query)
File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 328, in _query
conn.query(q)
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
result.read()
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 1075, in read
first_packet = self.connection._read_packet()
File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
packet.check_error()
File "/usr/local/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/lib/python3.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`ctfd`.`docker_challenge`, CONSTRAINT `docker_challenge_ibfk_1` FOREIGN KEY (`id`) REFERENCES `challenges` (`id`))')
[SQL: DELETE FROM challenges WHERE challenges.id = %(id_1)s]
[parameters: {'id_1': 5}]
(Background on this error at: http://sqlalche.me/e/gkpj)
So it seems like there is something referenced which shouldn't be referenced or something is not properly deleted in the function delete(challenge)
inside the ChallengeType definition in the class DockerChallengeType(BaseChallenge)
.
I keep getting the above message anytime I try to start any of my containers. For context, I am using the Admin account, teams are disabled (so everyone including myself is just an individual), and the plugin has successful communications with the dockerd process on the backend. I got this message even the first time I started the test container challenge, so I don't think it actually has to do with waiting 5 minutes
Hey, I am trying to use this plugin but i am stuck loading repositories.
I am running the docker daemon with sudo dockerd --tls=false -H=127.0.0.1:2376
. When trying to access the images by the browser everything seems to work as it should.
I am not able to figure out what is going wrong for me here. This are the messages I receive when entering the address into the admin panel:
ctfd_1 | urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=2376): Max retries exceeded with url: /images/json?all=1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6dac494a90>: Failed to establish a new connection: [Errno 111] Connection refused')) ctfd_1 | ctfd_1 | During handling of the above exception, another exception occurred: ctfd_1 | ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 226, in do_request ctfd_1 | r = requests.get(url=f"%s{url}" % URL_TEMPLATE, headers=headers) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 76, in get ctfd_1 | return request('get', url, params=params, **kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request ctfd_1 | return session.request(method=method, url=url, **kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request ctfd_1 | resp = self.send(prep, **send_kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send ctfd_1 | r = adapter.send(request, **kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send ctfd_1 | raise ConnectionError(e, request=request) ctfd_1 | requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=2376): Max retries exceeded with url: /images/json?all=1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6dac494a90>: Failed to establish a new connection: [Errno 111] Connection refused')) ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 143, in docker_config ctfd_1 | repos = get_repositories(docker) ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 260, in get_repositories ctfd_1 | for i in r.json(): ctfd_1 | AttributeError: 'list' object has no attribute 'json' ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 107, in docker_config ctfd_1 | ca_cert = request.files['ca_cert'].stream.read() ctfd_1 | File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 442, in __getitem__ ctfd_1 | raise exceptions.BadRequestKeyError(key) ctfd_1 | werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 112, in docker_config ctfd_1 | client_cert = request.files['client_cert'].stream.read() ctfd_1 | File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 442, in __getitem__ ctfd_1 | raise exceptions.BadRequestKeyError(key) ctfd_1 | werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 117, in docker_config ctfd_1 | client_key = request.files['client_key'].stream.read() ctfd_1 | File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 442, in __getitem__ ctfd_1 | raise exceptions.BadRequestKeyError(key) ctfd_1 | werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 135, in docker_config ctfd_1 | b.repositories = ','.join(request.form.to_dict(flat=False)['repositories']) ctfd_1 | KeyError: 'repositories' ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn ctfd_1 | (self._dns_host, self.port), self.timeout, **extra_kw ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection ctfd_1 | raise err ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection ctfd_1 | sock.connect(sa) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/gevent/_socket3.py", line 407, in connect ctfd_1 | raise error(err, strerror(err)) ctfd_1 | ConnectionRefusedError: [Errno 111] Connection refused ctfd_1 | ctfd_1 | During handling of the above exception, another exception occurred: ctfd_1 | ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen ctfd_1 | chunked=chunked, ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request ctfd_1 | conn.request(method, url, **httplib_request_kw) ctfd_1 | File "/usr/local/lib/python3.7/http/client.py", line 1281, in request ctfd_1 | self._send_request(method, url, body, headers, encode_chunked) ctfd_1 | File "/usr/local/lib/python3.7/http/client.py", line 1327, in _send_request ctfd_1 | self.endheaders(body, encode_chunked=encode_chunked) ctfd_1 | File "/usr/local/lib/python3.7/http/client.py", line 1276, in endheaders ctfd_1 | self._send_output(message_body, encode_chunked=encode_chunked) ctfd_1 | File "/usr/local/lib/python3.7/http/client.py", line 1036, in _send_output ctfd_1 | self.send(msg) ctfd_1 | File "/usr/local/lib/python3.7/http/client.py", line 976, in send ctfd_1 | self.connect() ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect ctfd_1 | conn = self._new_conn() ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn ctfd_1 | self, "Failed to establish a new connection: %s" % e ctfd_1 | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f6dac490790>: Failed to establish a new connection: [Errno 111] Connection refused ctfd_1 | ctfd_1 | During handling of the above exception, another exception occurred: ctfd_1 | ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send ctfd_1 | timeout=timeout ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 727, in urlopen ctfd_1 | method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] ctfd_1 | File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 446, in increment ctfd_1 | raise MaxRetryError(_pool, url, error or ResponseError(cause)) ctfd_1 | urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=2376): Max retries exceeded with url: /images/json?all=1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6dac490790>: Failed to establish a new connection: [Errno 111] Connection refused')) ctfd_1 | ctfd_1 | During handling of the above exception, another exception occurred: ctfd_1 | ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 226, in do_request ctfd_1 | r = requests.get(url=f"%s{url}" % URL_TEMPLATE, headers=headers) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 76, in get ctfd_1 | return request('get', url, params=params, **kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request ctfd_1 | return session.request(method=method, url=url, **kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request ctfd_1 | resp = self.send(prep, **send_kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send ctfd_1 | r = adapter.send(request, **kwargs) ctfd_1 | File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send ctfd_1 | raise ConnectionError(e, request=request) ctfd_1 | requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=2376): Max retries exceeded with url: /images/json?all=1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6dac490790>: Failed to establish a new connection: [Errno 111] Connection refused')) ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 143, in docker_config ctfd_1 | repos = get_repositories(docker) ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 260, in get_repositories ctfd_1 | for i in r.json(): ctfd_1 | AttributeError: 'list' object has no attribute 'json' ctfd_1 | Traceback (most recent call last): ctfd_1 | File "/opt/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 107, in docker_config ctfd_1 | ca_cert = request.files['ca_cert'].stream.read() ctfd_1 | File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 442, in __getitem__ ctfd_1 | raise exceptions.BadRequestKeyError(key) ctfd_1 | None ctfd_1 | None ctfd_1 | None ctfd_1 | None ctfd_1 | None ctfd_1 | None ctfd_1 | 172.21.0.1 - - [21/Aug/2021:11:42:50 +0000] "POST /admin/docker_config HTTP/1.1" 200 8007 "http://localhost:8000/admin/docker_config" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
Could you help me please? Has it something to do with "AttributeError: 'list' object has no attribute 'json'"?
Hello, i am back :D and i manage to make the plugin work halfway :/
If i don't use TLS then i can get the docker repos
But the instances could not be create when the challenge start.
This error show in the log
Now if i decided to use TLS i could not get the repos
But from the command line i can get to it
Can you make the plugin to work with no TLS please ?
Hi.
Great plugin, I wish it was included by default, but I encountered problem while setting up TLS access. After uploading the ca.pem
, client-cert.pem
and client-key.pem
files I get an Internal Server Error
.
I found the following in the log file of the ctfd_ctfd_1
container:
I know for sure that TLS is working on the server (vm with CTF boxes I try to connect to) and client machine (vm with CTFd installed) and that these are the right certificate files as I get a list of images when i run the following command:
docker --tls --tlscacert=ca.pem --tlscert=client-cert.pem --tlskey=client-key.pem -H=10.10.23.5:2376 images
I have followed the docker protect access guide and I have some images on the server I am trying to connect to. Also, I used docker-compose to setup the CTFd environment if it matters. Do you maybe know how I could fix this? Thanks.
Hello! So, i'm trying to use your pluggin to host a ctf powered by docker. The only problem is that when i go to docker_config there the following error :
Traceback (most recent call last):
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 639, in error_router
return original_handler(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 639, in error_router
return original_handler(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ketherz/logiciel/CTFd/CTFd/utils/decorators/__init__.py", line 133, in admins_only_wrapper
return f(*args, **kwargs)
File "/home/ketherz/logiciel/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 137, in docker_config
return render_template("docker_config.html", config=dconfig, form=form, repos=selected_repos)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/home/ketherz/.local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/home/ketherz/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/ketherz/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/home/ketherz/logiciel/CTFd/CTFd/plugins/docker_challenges/templates/docker_config.html", line 1, in top-level template code
{% extends 'admin/base.html' %}
File "/home/ketherz/logiciel/CTFd/CTFd/themes/admin/templates/base.html", line 124, in top-level template code
{% block content %}
File "/home/ketherz/logiciel/CTFd/CTFd/plugins/docker_challenges/templates/docker_config.html", line 63, in block "content"
{% if key in repos %}
TypeError: argument of type 'NoneType' is not iterable
I think it's because of a problem in the database resulting in the variable selected_repos getting equal to none. I can get it to work by bypassing the repos = selected_repos variable but it lead to 2 other error.
1 - When i start a docker challenge, the container is not created .
2 - When i try to erase the challenge the database is locked.
It make me think that the database is the problem here so i would like to know if there is extra step to do with the database to set-up the plugin ? Or if i do something wrong ? The problem does not appear if there is 0 images in the docker naturally and images are detected in the docker challenge creator even with the error above. But starting a challenge with the website will lead to that kind of error.
Traceback (most recent call last):
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 638, in error_router
return original_handler(f)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 636, in error_router
return self.handle_error(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 638, in error_router
return original_handler(f)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 636, in error_router
return self.handle_error(e)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/api.py", line 375, in wrapper
resp = resource(*args, **kwargs)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/home/ketherz/.local/lib/python3.8/site-packages/flask_restx/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/home/ketherz/logiciel/CTFd/CTFd/utils/decorators/__init__.py", line 87, in authed_only_wrapper
return f(*args, **kwargs)
File "/home/ketherz/logiciel/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 589, in get
portsbl = get_unavailable_ports(docker)
File "/home/ketherz/logiciel/CTFd/CTFd/plugins/docker_challenges/__init__.py", line 255, in get_unavailable_ports
r = requests.get(url="%s/containers/json?all=1" % URL_TEMPLATE, cert=CERT, verify=ca_file.name)
UnboundLocalError: local variable 'CERT' referenced before assignment
I will continue to search a solution for those errors and will mark the solution if i find one. If anyone has an idea let me know too! Same if you need precision. Thanks ! (I use the python debug version of ctfd)
Hello, here are my environment settings:
OS: Ubuntu 20.04
Running CTFd using python 3.8 and python3 server.py
and flask run
CTFd: 3.2.1
After following the installation docs on CTFd for 3.2.1 (the version the docs here says it is compatible with breaks any /admin/* page i.e. /admin/statistics
, I also cannot visit any /admin/docker_status
or /admin/docker_config
route for the plugin, the error given by CTFd is the following: *AttributeError: 'list' object has no attribute 'get' please see the log below:
INFO [werkzeug] 127.0.0.1 - - [23/Oct/2021 20:34:53] "GET /admin HTTP/1.1" 302 -
INFO [werkzeug] 127.0.0.1 - - [23/Oct/2021 20:34:53] "GET /admin/statistics HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask_restx/api.py", line 639, in error_router
return original_handler(e)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask_restx/api.py", line 639, in error_router
return original_handler(e)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/cmnatic/CTFd/CTFd/utils/decorators/__init__.py", line 133, in admins_only_wrapper
return f(*args, **kwargs)
File "/home/cmnatic/CTFd/CTFd/admin/statistics.py", line 75, in statistics
return render_template(
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/home/cmnatic/.local/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/home/cmnatic/.local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/home/cmnatic/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/cmnatic/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/home/cmnatic/CTFd/CTFd/themes/admin/templates/statistics.html", line 1, in top-level template code
{% extends "admin/base.html" %}
File "/home/cmnatic/CTFd/CTFd/themes/admin/templates/base.html", line 74, in top-level template code
{% set plugins = get_configurable_plugins() %}
File "/home/cmnatic/.local/lib/python3.8/site-packages/jinja2/sandbox.py", line 462, in call
return __context.call(__obj, *args, **kwargs)
File "/home/cmnatic/CTFd/CTFd/utils/plugins/__init__.py", line 58, in get_configurable_plugins
name=plugin_json_data.get("name"),
Running CTFd without /home/cmnatic/CTFd/CTFd/plugins/docker_challenges
works absolutely fine.
I can't figure out where I've gone wrong with this. Could you perhaps suggest anything? Or even a version of CTFd and the plugin where this is known to work please?
Thanks so much!
CMNatic
Even when providing the correct certs, when the plugin attempts to connect to Docker over TLS, it errors out and states that it was not provided a cert.
The exact error from the Docker daemon logs is: TLS: client didn't provide a certificate
.
I'm trying to setup the plugin with a CTFd instance I have installed on a remote VPS, I have tried different hosts and each of the fails to render the repos, the debug logs shows that connection was refused when access the hostname:port.
my docker.service conf.
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:4444
I'm trying to use the docker0 interface hostname
root@debian: ip a | grep docker0
5: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
I have also tried different hostnames like localhost, 0.0.0.0 and remote IP and all has failed (I'm a bit clueless when it comes to DevOps sadly)
Latest commit merged a PR that has verify=false
in requests
as parameter. This was because I did not manage to find out how to properly verify self-signed certificates. Installing them to /etc/ssl/certs
did not help (thought it would be checked with the host-installed certs).
As there is still some work to do and because this can be a security concern, I raised this issue. The connection is still encrypted, but not secure against MITM.
Before the PR there was verify=ca_file.name
in the requests parameters. But, at least for me, that did not work. The certificate was not verified and no connection was possible.
would be cool If we could incorporate dynamic scoring into this, I have been messing around trying to inherit the class but can't seem to get it working so thought I would request this feature.
Thanks.
I've been trying to get the plugin to connect to my server's port 2376 using HTTPS for a few days now, but I keep getting the error from the picture below. I know that the Docker service I have running (on the same machine BTW) is working because I can use "docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H=ballisticctf.org:2376 version" and it will output the version. I have tried every IP address and I still get the same issues. The CTFd instance we have running is containerized, if that makes any difference
The challenge description for these Docker challenges is not properly rendered.
The entire description is just printed raw, it does not format any of the markdown or HTML that may be included in the challenge description.
Once a team has started a docker instance, trying to start another instance for a different container but for the same team, it gives the error "You can only revert a container once per 5 minutes", just like when you are trying to revert an active container when less than 5 minutes have passed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.