Upload files to 'run-offline/sasaaageyooo'
This commit is contained in:
parent
4e7c16ab82
commit
30b5cd3c39
4 changed files with 153 additions and 0 deletions
8
run-offline/sasaaageyooo/Dockerfile
Normal file
8
run-offline/sasaaageyooo/Dockerfile
Normal file
|
@ -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
|
29
run-offline/sasaaageyooo/docker-compose.yml
Normal file
29
run-offline/sasaaageyooo/docker-compose.yml
Normal file
|
@ -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
|
||||||
|
|
47
run-offline/sasaaageyooo/nginx.conf
Normal file
47
run-offline/sasaaageyooo/nginx.conf
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
69
run-offline/sasaaageyooo/server.py
Normal file
69
run-offline/sasaaageyooo/server.py
Normal file
|
@ -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]<value or value<1):
|
||||||
|
0/0
|
||||||
|
state[index]-=value
|
||||||
|
except Exception as e:
|
||||||
|
await ws.send(json.dumps({'msg':'not valid request'}))
|
||||||
|
return
|
||||||
|
|
||||||
|
if(state==[0]*len(state)):
|
||||||
|
if(train):
|
||||||
|
await ws.send(json.dumps({'msg':'Вы победили. Теперь победите в финальной битве'}))
|
||||||
|
else:
|
||||||
|
await ws.send(json.dumps({'msg':flag}))
|
||||||
|
return
|
||||||
|
|
||||||
|
x=0
|
||||||
|
for i in state:
|
||||||
|
x^=i
|
||||||
|
mask=x
|
||||||
|
while(mask&(mask-1)):
|
||||||
|
mask=mask&(mask-1)
|
||||||
|
if(x==0):
|
||||||
|
for i in range(len(state)):
|
||||||
|
if(state[i]!=0):
|
||||||
|
index=i
|
||||||
|
value=rnd.randint(1,state[i])
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
for i in range(len(state)):
|
||||||
|
if(mask&state[i]):
|
||||||
|
index=i
|
||||||
|
value=state[i]-(state[i]^x)
|
||||||
|
state[index]-=value
|
||||||
|
await ws.send(json.dumps({'index':index,'value':value}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
start_server = websockets.serve(game, "0.0.0.0", 8000)
|
||||||
|
|
||||||
|
asyncio.get_event_loop().run_until_complete(start_server)
|
||||||
|
|
||||||
|
asyncio.get_event_loop().run_forever()
|
||||||
|
|
Loading…
Reference in a new issue