Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure: add support for decomp2dbg in ghidra #598

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

private-static-voidmain

No description provided.

@zardus
Copy link
Contributor

zardus commented Oct 17, 2024

As @robwaz mentioned on discord, we are now in the Nix Era. Ghidra actually exists here: https://github.com/pwncollege/dojo/blob/master/workspace/additional/additional.nix

I'm not sure how to add decomp2gdb to nix, but @ConnorNelson, @supercoolspy, or @spencerpogo might!

@ConnorNelson
Copy link
Member

Looks like nix already has some support in place for adding extensions to ghidra: https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/security/ghidra/with-extensions.nix#L18.

@supercoolspy
Copy link
Contributor

Introduces `gdb` wrapper with as `decomp2dbg`.
TODO left in `dbg-plugins` to fill Nix's sha256 checksum for this tag.
After vanilla gdb is working, we'll focus on extending to gef and pwndbg.
@private-static-voidmain
Copy link
Author

@ConnorNelson @supercoolspy please see latest changes. Do note the TODO in dbg-plugins.

@supercoolspy
Copy link
Contributor

Yeah, if you can test if it works and add the hash that looks good to me

@private-static-voidmain
Copy link
Author

private-static-voidmain commented Oct 25, 2024

How to test? I've followed "Local Deployment" and when I try to execute docker exec dojo dojo logs I'm greeted with:

$ docker exec dojo dojo logs
Oct 25 05:15:43 96a8374930d9 systemd[1]: Dependency failed for pwn.college.service - pwn.college docker compose service.
Oct 25 05:15:43 96a8374930d9 systemd[1]: pwn.college.service: Job pwn.college.service/start failed with result 'dependency'.

P.S. I don't know if it matters, but FYI the attempt above is from a WSL context.

@private-static-voidmain
Copy link
Author

Looks like it was a WSL thing, inside ubuntu VM it goes much further, I'll update.

@private-static-voidmain
Copy link
Author

Ok, so I've changed DOJO_WORKSPACE to full (to include additionals), rebuilt everything (also deleted ./dojo/data), and now when I try to start a challenge I get Docker failed. Where I can see those errors?

I've tried:

docker exec -it dojo /bin/bash
# inside the container
journalctl -u docker.service

I'm looking for the container build errors (specifically the workspace part of it), but the errors I get are not as informative as I would like:

Oct 25 20:29:25 2201fd059e24 dockerd[408]: time="2024-10-25T20:29:25.249467285Z" level=info msg="ignoring event" container=4a3f3bce3a56484d1>
Oct 25 20:29:25 2201fd059e24 dockerd[408]: time="2024-10-25T20:29:25.258558643Z" level=warning msg="failed to close stdin: NotFound: task 4a>
Oct 25 20:29:25 2201fd059e24 dockerd[408]: time="2024-10-25T20:29:25.389876728Z" level=error msg="Error setting up exec command in container>
Oct 25 20:29:30 2201fd059e24 dockerd[408]: time="2024-10-25T20:29:30.709399726Z" level=info msg="ignoring event" container=6707f10d4ce110836>
Oct 25 20:29:30 2201fd059e24 dockerd[408]: time="2024-10-25T20:29:30.718612883Z" level=warning msg="failed to close stdin: NotFound: task 67>
Oct 25 20:29:30 2201fd059e24 dockerd[408]: time="2024-10-25T20:29:30.841452708Z" level=error msg="Error setting up exec command in container>

49467285Z" level=info msg="ignoring event" container=4a3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec38 module=libcontainerd n>
58558643Z" level=warning msg="failed to close stdin: NotFound: task 4a3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec38 not fou>
89876728Z" level=error msg="Error setting up exec command in container 4a3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec38: con>
09399726Z" level=info msg="ignoring event" container=6707f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9 module=libcontainerd n>
18612883Z" level=warning msg="failed to close stdin: NotFound: task 6707f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9 not fou>
41452708Z" level=error msg="Error setting up exec command in container 6707f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9: con>
248418a4c7e403c22524dbafe6bae446839b0416d34ec38 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec38 not found: not found"
 4a3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec38: container 4a3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec3>
6bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
07f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9 not found: not found"
 6707f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9: container 6707f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f>
amespace=moby topic=/tasks/delete type="*events.TaskDelete"
nd: not found"
tainer 4a3f3bce3a56484d1248418a4c7e403c22524dbafe6bae446839b0416d34ec38 is not running" spanID=18e80f18ec974f02 traceID=94ed3ae27794d0b298c1>
amespace=moby topic=/tasks/delete type="*events.TaskDelete"
nd: not found"
tainer 6707f10d4ce1108366bd2280dab52d5063295c7e1a10953d5a7ffba3092369f9 is not running" spanID=b6b60a8c257f81b2 traceID=5cd5e97adacebf65b42c>

@private-static-voidmain
Copy link
Author

dojo compose logs ctfd shows:

ctfd  | ERROR [CTFd.plugins.dojo_plugin.api.v1.docker] ERROR: Docker failed for 1:
ctfd  | Traceback (most recent call last):
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/client.py", line 268, in _raise_for_status
ctfd  |     response.raise_for_status()
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
ctfd  |     raise HTTPError(http_error_msg, response=self)
ctfd  | requests.exceptions.HTTPError: 409 Client Error: Conflict for url: http+docker://localhost/v1.47/containers/a67bdbf895b36138cfde0a6c855800e30996d67265362a1e2dfc0e966039d668/exec
ctfd  | 
ctfd  | The above exception was the direct cause of the following exception:
ctfd  | 
ctfd  | Traceback (most recent call last):
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/api/v1/docker.py", line 323, in post
ctfd  |     start_challenge(user, dojo_challenge, practice, as_user=as_user)
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/api/v1/docker.py", line 246, in start_challenge
ctfd  |     insert_challenge(container, as_user, dojo_challenge)
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/api/v1/docker.py", line 187, in insert_challenge
ctfd  |     exec_run("/run/dojo/bin/mkdir -p /challenge", container=container)
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/utils/workspace.py", line 38, in exec_run
ctfd  |     exit_code, output = container.exec_run(cmd, user=workspace_user, **kwargs)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/models/containers.py", line 194, in exec_run
ctfd  |     resp = self.client.api.exec_create(
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/utils/decorators.py", line 19, in wrapped
ctfd  |     return f(self, resource_id, *args, **kwargs)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/exec_api.py", line 79, in exec_create
ctfd  |     return self._result(res, True)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/client.py", line 274, in _result
ctfd  |     self._raise_for_status(response)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/client.py", line 270, in _raise_for_status
ctfd  |     raise create_api_error_from_http_exception(e) from e
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/errors.py", line 39, in create_api_error_from_http_exception
ctfd  |     raise cls(e, response=response, explanation=explanation) from e
ctfd  | docker.errors.APIError: 409 Client Error for http+docker://localhost/v1.47/containers/a67bdbf895b36138cfde0a6c855800e30996d67265362a1e2dfc0e966039d668/exec: Conflict ("container a67bdbf895b36138cfde0a6c855800e30996d67265362a1e2dfc0e966039d668 is not running")
ctfd  | 
ctfd  | During handling of the above exception, another exception occurred:
ctfd  | 
ctfd  | Traceback (most recent call last):
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/client.py", line 268, in _raise_for_status
ctfd  |     response.raise_for_status()
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
ctfd  |     raise HTTPError(http_error_msg, response=self)
ctfd  | requests.exceptions.HTTPError: 409 Client Error: Conflict for url: http+docker://localhost/v1.47/containers/fe12ad2d86057afea607cdd53eb23e02c08474ff17e6b1b966dc5411aa3f93ec/exec
ctfd  | 
ctfd  | The above exception was the direct cause of the following exception:
ctfd  | 
ctfd  | Traceback (most recent call last):
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/api/v1/docker.py", line 327, in post
ctfd  |     start_challenge(user, dojo_challenge, practice, as_user=as_user)
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/api/v1/docker.py", line 246, in start_challenge
ctfd  |     insert_challenge(container, as_user, dojo_challenge)
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/api/v1/docker.py", line 187, in insert_challenge
ctfd  |     exec_run("/run/dojo/bin/mkdir -p /challenge", container=container)
ctfd  |   File "/opt/CTFd/CTFd/plugins/dojo_plugin/utils/workspace.py", line 38, in exec_run
ctfd  |     exit_code, output = container.exec_run(cmd, user=workspace_user, **kwargs)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/models/containers.py", line 194, in exec_run
ctfd  |     resp = self.client.api.exec_create(
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/utils/decorators.py", line 19, in wrapped
ctfd  |     return f(self, resource_id, *args, **kwargs)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/exec_api.py", line 79, in exec_create
ctfd  |     return self._result(res, True)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/client.py", line 274, in _result
ctfd  |     self._raise_for_status(response)
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/api/client.py", line 270, in _raise_for_status
ctfd  |     raise create_api_error_from_http_exception(e) from e
ctfd  |   File "/opt/venv/lib/python3.9/site-packages/docker/errors.py", line 39, in create_api_error_from_http_exception
ctfd  |     raise cls(e, response=response, explanation=explanation) from e
ctfd  | docker.errors.APIError: 409 Client Error for http+docker://localhost/v1.47/containers/fe12ad2d86057afea607cdd53eb23e02c08474ff17e6b1b966dc5411aa3f93ec/exec: Conflict ("container fe12ad2d86057afea607cdd53eb23e02c08474ff17e6b1b966dc5411aa3f93ec is not running")
ctfd  | INFO  [werkzeug] 172.17.0.1 - - [25/Oct/2024 21:24:37] "POST /pwncollege_api/v1/docker HTTP/1.1" 200 -

@private-static-voidmain
Copy link
Author

running docker exec dojo dojo compose up
I get:

...
workspace-builder  | warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
workspace-builder  | error:
workspace-builder  |        … while calling the 'derivationStrict' builtin
workspace-builder  |          at <nix/derivation-internal.nix>:9:12:
workspace-builder  |             8|
workspace-builder  |             9|   strict = derivationStrict drvAttrs;
workspace-builder  |              |            ^
workspace-builder  |            10|
workspace-builder  | 
workspace-builder  |        … while evaluating derivation 'dojo-workspace-full'
workspace-builder  |          whose name attribute is located at /nix/store/rfq6hpk4a4ki1q1856qpb846admnwq5d-source/pkgs/stdenv/generic/make-derivation.nix:333:7
workspace-builder  | 
workspace-builder  |        … while evaluating attribute 'passAsFile' of derivation 'dojo-workspace-full'
workspace-builder  |          at /nix/store/rfq6hpk4a4ki1q1856qpb846admnwq5d-source/pkgs/build-support/trivial-builders/default.nix:69:9:
workspace-builder  |            68|         inherit buildCommand name;
workspace-builder  |            69|         passAsFile = [ "buildCommand" ]
workspace-builder  |              |         ^
workspace-builder  |            70|           ++ (derivationArgs.passAsFile or [ ]);
workspace-builder  | 
workspace-builder  |        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
workspace-builder  | 
workspace-builder  |        error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "buildGhidraExtension" at /nix/store/gqsfkmrmm34pl7r8snyah3vgl9jb4d4v-source/additional/ghidra-extensions/decomp2dbg.nix:5'
nginx-proxy-acme   | 2024/10/25 21:39:39 Debounce minTimer fired
nginx-proxy-acme   | 2024/10/25 21:39:39 Contents of /app/letsencrypt_service_data did not change. Skipping notification '/app/signal_le_service'
workspace-builder  | warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
workspace-builder  | error:
workspace-builder  |        … while calling the 'derivationStrict' builtin
workspace-builder  |          at <nix/derivation-internal.nix>:9:12:
workspace-builder  |             8|
workspace-builder  |             9|   strict = derivationStrict drvAttrs;
workspace-builder  |              |            ^
workspace-builder  |            10|
workspace-builder  | 
workspace-builder  |        … while evaluating derivation 'dojo-workspace-full'
workspace-builder  |          whose name attribute is located at /nix/store/rfq6hpk4a4ki1q1856qpb846admnwq5d-source/pkgs/stdenv/generic/make-derivation.nix:333:7
workspace-builder  | 
workspace-builder  |        … while evaluating attribute 'passAsFile' of derivation 'dojo-workspace-full'
workspace-builder  |          at /nix/store/rfq6hpk4a4ki1q1856qpb846admnwq5d-source/pkgs/build-support/trivial-builders/default.nix:69:9:
workspace-builder  |            68|         inherit buildCommand name;
workspace-builder  |            69|         passAsFile = [ "buildCommand" ]
workspace-builder  |              |         ^
workspace-builder  |            70|           ++ (derivationArgs.passAsFile or [ ]);
workspace-builder  | 
workspace-builder  |        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
workspace-builder  | 
workspace-builder  |        error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "buildGhidraExtension" at /nix/store/gqsfkmrmm34pl7r8snyah3vgl9jb4d4v-source/additional/ghidra-extensions/decomp2dbg.nix:5'
workspace-builder  | realpath: /out/nix/var/nix/profiles/default/bin/python-dojo-suid: No such file or directory
workspace-builder  | realpath: /out/nix/var/nix/profiles/default/bin/python-suid: No such file or directory
workspace-builder  | realpath: /out/nix/var/nix/profiles/default/bin/bash-suid: No such file or directory
workspace-builder  | realpath: /out/nix/var/nix/profiles/default/bin/sh-suid: No such file or directory
workspace-builder  | realpath: /out/nix/var/nix/profiles/default/bin/sudo: No such file or directory
...

@ConnorNelson
Copy link
Member

As we discussed, ida was broken by a missing icon file on their main site. This has been resolved in #611.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants