-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathcompile-readflag.yaml
More file actions
55 lines (55 loc) · 1.44 KB
/
Copy pathcompile-readflag.yaml
File metadata and controls
55 lines (55 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: ds-readflag
labels:
app: build-readflag
spec:
selector:
matchLabels:
app: build-readflag
template:
metadata:
labels:
app: build-readflag
spec:
hostNetwork: false
restartPolicy: Always
containers:
- name: sleep
image: muslcc/x86_64:x86_64-linux-musl
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
volumeMounts:
- name: host-root
mountPath: /host
readOnly: false
lifecycle:
preStop:
exec:
command: ["rm", "-f", "/host/readflag"]
initContainers:
- name: build
image: muslcc/x86_64:x86_64-linux-musl
env:
- name: FLAG
value: "flag{test1234}"
command: ["/bin/sh", "-c"]
args:
- |
echo '#include <stdio.h>
int main(){puts("'"$FLAG"'");}' > readflag.c && \
gcc readflag.c -o /host/readflag -static -Os -s -Wl,--build-id=none -ffunction-sections -fdata-sections -Wl,--gc-sections && \
rm readflag.c && \
chmod 0111 /host/readflag
volumeMounts:
- name: host-root
mountPath: /host
securityContext:
runAsUser: 0
volumes:
- name: host-root
hostPath:
path: /etc
type: Directory
terminationGracePeriodSeconds: 30