or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
D0cker
In this challenge, we connect to a server which spawns us a Docker container. On the filesystem, there is an
oracle.sock
with which we have to communicate and we have to find answers to its questions.Level 1
We connect to the oracle as the challenge suggests, by using
socat - UNIX-CONNECT:/oracle.sock
.Alternatively a
python3
script can be used (which is helpful later on) as there is Python 3 interpreter in the container.In the first level the oracle asks us about the cpu model used. We can find this in the
/proc/cpuinfo
file:Second level
In the second level, thhe oracle asks about our full container id:
This can be found as part of the
/proc/self/cgroup
file:Third level
Now, the oracle says it creates a
/secret
file inside of our container and wants us to read this value:If we fail to answer, we can read this file:
However, this file is re-created every time we get to level 3 and so we need to read it at the same time as we talk to the oracle.
I guess there are multiple ways to do this, but the easiest is probably to write a Python script to do so (and save it in
/tmp
withvim
, as it is also in the container).For this I have written the following code:
If we launch it, we get to level 4:
Level 4
Now, we have to answer with a path the
/secret
file is visible on the host. Interestingly, because of how overlayfs works, which is the filesystem used by Docker in this challenge, the host path is present in the/proc/mounts
file:The part that interests us is
upperdir
as this is the directory used for files in the overlayfs layer we change files in. So the/secret
path is eventually/var/lib/docker/overlay2/07bd747e7e08a4c28de6d20baa8236674f1a265d9640273447c23cd50f41150c/diff/secret
.We can extend our Python script with this:
Then, we will get:
Level 5
In level 5 we have to find out an id of another container. This can be given e.g. by running another container, but, the reality is that other container ids can be found in
/sys
(or sysfs) paths, due to cgroups debug configuration present in this kernel.Actually, I believe this is a bug and I reported it to Docker, but they did not fix it (yet?). More information can be found in this presentation: https://docs.google.com/presentation/d/1VpXqzPIPrfIPSIiua5ClNkjKAzM3uKlyAKUf0jBqoUI/
Level 6
In level 6, we are asked about the oracle container id. For this, one can find ALL container ids using the previous technique and then try each of them.
A full solver script and its output can be seen below:
Output:
And the flag is
justCTF{maaybe-Docker-will-finally-fix-this-after-this-task?}
.