Skip to content
This repository was archived by the owner on Jun 24, 2026. It is now read-only.

Commit 5cfcdd9

Browse files
authored
Add flag 2 (#1)
* Now we're talking * Testing flags * Small fixes * FLAG2 working! Removed flag 3 * Flag 2 is working, let's try making the challenge archive * Remove comment from Cargo.toml * How did that go? * Weird
1 parent c04a068 commit 5cfcdd9

12 files changed

Lines changed: 426 additions & 115 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git/
2+
target/
3+
solution/
4+
*.md

.github/workflows/package.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'flag*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-22.04
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
20+
- name: Login to GHCR
21+
uses: docker/login-action@v4
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Extract metadata
28+
id: meta
29+
uses: docker/metadata-action@v6
30+
with:
31+
images: ghcr.io/${{ github.repository }}
32+
tags: |
33+
type=ref,event=tag
34+
type=raw,value=latest
35+
36+
- name: Build and push
37+
uses: docker/build-push-action@v7
38+
with:
39+
context: .
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}
43+
44+
release-assets:
45+
runs-on: ubuntu-22.04
46+
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v6
50+
51+
- name: Install Rust
52+
run: |
53+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
54+
| sh -s -- -y --default-toolchain none --profile minimal
55+
56+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
57+
58+
- name: Verify Rust version
59+
run: |
60+
rustc --version
61+
rustc --version | grep "1.79.0"
62+
63+
- name: Build challenge
64+
run: |
65+
cargo build --release
66+
67+
- name: Verify required files
68+
run: |
69+
test -f Dockerfile
70+
test -f libc.so.6
71+
test -f ld-linux-x86-64.so.2
72+
test -f rust-toolchain.toml
73+
test -f src/lib.rs
74+
test -f src/main.rs
75+
76+
- name: Verify binary
77+
run: |
78+
file target/release/nanolog
79+
80+
- name: Verify challenge starts with bundled libc
81+
run: |
82+
chmod +x target/release/nanolog
83+
chmod +x ld-linux-x86-64.so.2
84+
85+
timeout 3 \
86+
./ld-linux-x86-64.so.2 \
87+
--library-path . \
88+
./target/release/nanolog \
89+
|| true
90+
91+
- name: Create distribution archive
92+
run: |
93+
mkdir -p dist/src
94+
95+
cp Dockerfile dist/
96+
cp rust-toolchain.toml dist/
97+
98+
cp libc.so.6 dist/
99+
cp ld-linux-x86-64.so.2 dist/
100+
101+
cp target/release/nanolog dist/
102+
103+
cp src/lib.rs dist/src/
104+
cp src/main.rs dist/src/
105+
106+
tar -czf nanolog-${{ github.ref_name }}.tar.gz -C dist .
107+
108+
- name: Create release
109+
uses: softprops/action-gh-release@v3
110+
with:
111+
generate_release_notes: true
112+
body: |
113+
## Docker image
114+
115+
```
116+
docker pull ghcr.io/${{ github.repository }}:${{ github.ref_name }}
117+
```
118+
119+
## Run
120+
121+
```
122+
docker run --rm -p 1337:1337 \
123+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
124+
```
125+
126+
files: |
127+
nanolog-${{ github.ref_name }}.tar.gz

.github/workflows/rust.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@ name: Rust
33
on:
44
push:
55
branches: [ "main" ]
6+
paths:
7+
- "**/.github/workflows/release.yml"
8+
- "**/*.rs"
9+
- "**/Cargo.toml"
10+
- "**/Cargo.lock"
611
pull_request:
712
branches: [ "main" ]
13+
paths:
14+
- "**/.github/workflows/release.yml"
15+
- "**/*.rs"
16+
- "**/Cargo.toml"
17+
- "**/Cargo.lock"
18+
workflow_dispatch:
819

920
env:
1021
CARGO_TERM_COLOR: always

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
.env
3+
*.so*

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ edition = "2021"
77
heap-debug = []
88

99
[profile.release]
10-
opt-level = 0
10+
strip = "symbols"
11+
opt-level = 3
1112
debug = true
1213
lto = false
1314
codegen-units = 1

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
FROM ubuntu:22.04 AS build
22

33
RUN apt-get update && apt-get install -y \
4-
curl build-essential ca-certificates \
4+
curl build-essential ca-certificates \
55
&& rm -rf /var/lib/apt/lists/*
66

77
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
8-
| sh -s -- -y --default-toolchain none --profile minimal
8+
| sh -s -- -y --default-toolchain none --profile minimal
9+
910
ENV PATH="/root/.cargo/bin:${PATH}"
1011

12+
ARG FLAG2
13+
RUN printf '%s\n' "${FLAG2}" > /flag && chmod 444 /flag
14+
1115
COPY . /build/
1216
WORKDIR /build
17+
1318
RUN cargo build --release
1419

1520
FROM ubuntu:22.04
@@ -19,11 +24,14 @@ RUN apt-get update && apt-get install -y socat \
1924
&& useradd -m -s /bin/bash ctf
2025

2126
COPY --from=build /build/target/release/nanolog /challenge/nanolog
22-
RUN chmod 755 /challenge/nanolog
27+
COPY --from=build /flag /flag
28+
29+
RUN chmod 755 /challenge/nanolog \
30+
&& chown -R ctf:ctf /challenge
31+
32+
USER ctf
2333

2434
WORKDIR /challenge
2535
EXPOSE 1337
2636

27-
CMD ["socat", \
28-
"TCP-LISTEN:1337,reuseaddr,fork,nodelay", \
29-
"EXEC:/challenge/nanolog,nofork"]
37+
CMD ["socat", "TCP-LISTEN:1337,reuseaddr,fork,nodelay", "EXEC:/challenge/nanolog,nofork"]

compose.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
services:
22
nanolog:
3-
build: .
3+
build:
4+
context: .
5+
args:
6+
FLAG2: "DCI{N4n0L0g_L1bc_L34k_DC4svjxQ}"
47
restart: unless-stopped
58
ports:
69
- "1337:1337"
710
environment:
8-
- FLAG=DCI{N4n0L0g_Adm1n_Byp4ss_9a6295810c1b}
11+
- FLAG1=DCI{N4n0L0g_Adm1n_Byp4ss_b14b12bbcc2b}
912
# pid: host # Container escape vulnerability | Waiting on greenlight from infrastructure team
1013
read_only: true
1114
tmpfs:
12-
- /tmp
15+
- /tmp
1316
cap_drop:
14-
- ALL
17+
- ALL

libc.so.6

-2.12 MB
Binary file not shown.

0 commit comments

Comments
 (0)