Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# 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

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**

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
// healthcheck.php

header("Content-Type: application/json");

$status = [
"status" => "up",
"timestamp" => time(),
"php_version" => phpversion()
];

http_response_code(200);
echo json_encode($status);