diff --git a/chapters/web-application-security/exotic-attacks/activities/pro-replacer/README.md b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/README.md index 90a644a8..97c2b46e 100644 --- a/chapters/web-application-security/exotic-attacks/activities/pro-replacer/README.md +++ b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/README.md @@ -1,4 +1,12 @@ -# Name: Web: Exotic Attacks: Pro Replacer +# Name: Web: Exotic Attacks: +# Pro Replacer + +## Description + +Get the flag from [pro-replacer](https://141.85.224.105:8001/pro-replacer) +You can do it! + +Score: 25 ## Vulnerability @@ -6,10 +14,7 @@ Use of `preg_replace()` function in PHP 5.5 that leads to command injection. ## Exploit -The server executes the `preg_replace()` function with unsanitized parameters from the user. - -If you use the `/e` modifier at the end of the regex, the next of the command will be treated as PHP code. -In this way you can execute shell commands. +Solution in ./sol/solution.sh. **Payload 1** diff --git a/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/Makefile b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/Makefile index 6acd4235..9afafe56 100644 --- a/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/Makefile +++ b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/Makefile @@ -1,13 +1,19 @@ +NAME := sss-web-08_pro-replacer +EXTERNAL_PORT := 8001 +INTERNAL_PORT := 80 +FLAG := $(shell cat ../flag) + + run: build - docker run -d -p 8001:80 --name sss-web-08_pro-replacer sss-web-08_pro-replacer + docker run -d -p $(EXTERNAL_PORT):$(INTERNAL_PORT) --name $(Name) $(NAME) build: - docker build -f Dockerfile -t sss-web-08_pro-replacer .. + docker build --build-arg FLAG=$(FLAG) -f Dockerfile -t $(NAME) .. stop: - docker stop sss-web-08_pro-replacer + docker stop $(NAME) clean: stop - docker rm sss-web-08_pro-replacer + docker rm $(NAME) .PHONY: build run stop clean diff --git a/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/values.yaml b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/values.yaml new file mode 100644 index 00000000..099b609e --- /dev/null +++ b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/deploy/values.yaml @@ -0,0 +1,24 @@ +namespace: web-basics + +challenge: + name: pro-replacer + category: web-basics + +image: + repository: ghcr.io/open-education-hub/web-security/web-basics/pro-replacer + tag: latest + pullPolicy: Always + +containerPort: 80 + +service: + type: NodePort + port: 80 + nodePort: 8001 + +healthCheck: + enabled: true + path: "/healthcheck.php" + initialDelaySeconds: 5 + periodSeconds: 15 + diff --git a/chapters/web-application-security/exotic-attacks/activities/pro-replacer/src/healthcheck.php b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/src/healthcheck.php new file mode 100644 index 00000000..e041079c --- /dev/null +++ b/chapters/web-application-security/exotic-attacks/activities/pro-replacer/src/healthcheck.php @@ -0,0 +1,13 @@ + "up", + "timestamp" => time(), + "php_version" => phpversion() +]; + +http_response_code(200); +echo json_encode($status);