diff --git a/run-offline/sasaaageyooo/Dockerfile b/run-offline/sasaaageyooo/Dockerfile new file mode 100644 index 0000000..6c13099 --- /dev/null +++ b/run-offline/sasaaageyooo/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.11-alpine + +RUN pip3 install websockets + +COPY server.py /srv/server.py + +ENTRYPOINT ["/usr/local/bin/python3", "/srv/server.py"] +#ENTRYPOINT /bin/python3 /srv/server.py diff --git a/run-offline/sasaaageyooo/docker-compose.yml b/run-offline/sasaaageyooo/docker-compose.yml new file mode 100644 index 0000000..611447f --- /dev/null +++ b/run-offline/sasaaageyooo/docker-compose.yml @@ -0,0 +1,29 @@ +services: + sasageyo-back: + build: . + container_name: sasageyo-back + networks: + - sasageyo-tie + nginx: + image: nginx:1.25.2-alpine-slim + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + - ./html:/var/www/html:ro + #hports: + # - 8080:8080 + labels: + - traefik.enable=true + - traefik.http.routers.sasaaageyooo.tls=false + - traefik.http.routers.sasaaageyooo.rule=Host(`sasaaageyooo.ctf.sch9.ru`) + - traefik.http.routers.sasaaageyooo.service=sasaaageyooo + - traefik.http.services.sasaaageyooo.loadbalancer.server.port=8080 + networks: + - traefik-proxy-net + - sasageyo-tie + +networks: + sasageyo-tie: + name: sasageyo-tie + traefik-proxy-net: + name: traefik-proxy-net + diff --git a/run-offline/sasaaageyooo/nginx.conf b/run-offline/sasaaageyooo/nginx.conf new file mode 100644 index 0000000..d51d100 --- /dev/null +++ b/run-offline/sasaaageyooo/nginx.conf @@ -0,0 +1,47 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; + + server{ + listen 8080; + location /train{ + proxy_pass http://sasageyo-back:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + } + location /get-flag{ + proxy_pass http://sasageyo-back:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + } + location /{ + root /var/www/html; + } + } +} + diff --git a/run-offline/sasaaageyooo/server.py b/run-offline/sasaaageyooo/server.py new file mode 100644 index 0000000..d79e153 --- /dev/null +++ b/run-offline/sasaaageyooo/server.py @@ -0,0 +1,69 @@ +import asyncio +#import time +import random as rnd +import websockets +import json + +flag='ctf{1_l0v3_4774ck_0n_7174n}' + +async def game(ws,path): + if('train' in path): + train=True + else: + train=False + if train: + state=[3,5,7] + else: + state=[rnd.randint(1,300) for i in range(300)] + + await ws.recv() + + await ws.send(json.dumps({'state':state})) + + while(state!=[0]*len(state)): + try: + data = json.loads(await ws.recv()) + index=data['index'] + value=data['value'] + if(state[index]