Add README.md, {nc,telnet,pwn}-tasks

This commit is contained in:
2026-09-17 10:04:19 +03:00
parent 8ee59bdd9b
commit cd3441300c
18 changed files with 211 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
FROM alpine:3.20 AS build
RUN apk add --no-cache gcc musl-dev
WORKDIR /build
COPY vuln.c .
RUN gcc -o vuln vuln.c -fno-stack-protector -no-pie -static -w
FROM alpine:3.20
RUN apk add --no-cache socat su-exec
RUN adduser -D ctf
WORKDIR /app
COPY --from=build /build/vuln .
COPY docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh vuln
EXPOSE 1337
ENTRYPOINT ["./docker-entrypoint.sh"]
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
echo "${FLAG}" > /flag.txt
chmod 644 /flag.txt
unset FLAG
exec socat -T 30 TCP-LISTEN:1337,reuseaddr,fork EXEC:"su-exec ctf /app/vuln"
+31
View File
@@ -0,0 +1,31 @@
#include <fcntl.h>
#include <unistd.h>
#define FLAG_PATH "/flag.txt"
void win(void) {
char flag[128];
int fd = open(FLAG_PATH, O_RDONLY);
if (fd < 0) {
write(1, "No flag here, contact the admins!\n", 34);
_exit(1);
}
ssize_t n = read(fd, flag, sizeof(flag));
if (n > 0) {
write(1, flag, n);
}
_exit(0);
}
int main(void) {
char name[64];
write(1, "What's your name?\n", 18);
read(0, name, 0x100);
write(1, "Nice to meet you!\n", 18);
return 0;
}