crypto: halloween

This commit is contained in:
agatha 2024-10-25 16:24:08 -04:00
parent 9e8502081c
commit 1fa848c01f
4 changed files with 37 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,15 @@
FROM python:3.11-alpine
RUN apk --update add socat \
&& adduser -D --home /app user \
&& pip3 install gostcrypto
COPY --chown=user . /app
RUN chmod 755 /app/entry.sh /app/chall.py
WORKDIR /app
EXPOSE ${LISTEN_PORT}
ENTRYPOINT ["/app/entry.sh"]

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
import gostcrypto
import os
with open("flag.txt", "rb") as f:
flag = f.read()
key, iv = os.urandom(32), os.urandom(8)
cipher = gostcrypto.gostcipher.new(
"kuznechik", key, gostcrypto.gostcipher.MODE_CTR, init_vect=iv
)
print(f"It's almost Halloween, time to get sp00{cipher.encrypt(flag).hex()}00ky 👻!")
while True:
print(cipher.encrypt(bytes.fromhex(input())).hex())

View File

@ -0,0 +1,6 @@
#! /bin/sh
while :
do
socat TCP-LISTEN:${LISTEN_PORT},forever,reuseaddr,fork EXEC:'/app/chall.py' 2>/dev/null
done