CTF
[드림핵] phphreg
채영채영
2023. 9. 20. 13:42
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$input_name = $_POST["input1"] ? $_POST["input1"] : "";
$input_pw = $_POST["input2"] ? $_POST["input2"] : "";
// pw filtering
if (preg_match("/[a-zA-Z]/", $input_pw)) {
echo "alphabet in the pw :(";
}
else{
$name = preg_replace("/nyang/i", "", $input_name);
$pw = preg_replace("/\d*\@\d{2,3}(31)+[^0-8]\!/", "d4y0r50ng", $input_pw);
if ($name === "dnyang0310" && $pw === "d4y0r50ng+1+13") {
step2.php에서 name이랑 pw가 필터링 된다.
name의 dnyang사이에 nyang을 넣어주고, pw부분에서 "/\d*\@\d{2,3}(31)+[^0-8]\!/"이 문자열 "d4y0r50ng"로 치환되므로 pw는 정규표현식을 통해 치환시킨다
1. \d*: 0개 이상의 숫자를 의미
2. \@: "@" 문자를 의미
3. \d{2,3}: 2개 또는 3개의 숫자를 의미
4. (31)+: 31이 1회 이상 반복을 의미
5. [^0-8]: 0과 8 사이의 숫자를 제외한 문자를 의미
6. \!: "!" 문자를 의미
else if (preg_match("/flag/i", $cmd)) {
echo "<pre>Error!</pre>";
}
else{
echo "<pre>--Output--\n";
system($cmd);
echo "</pre>";
}
command에도 필터링이 있다.
cat ../dream/flag.txt 를 cat ../dream/f*.txt로 우회한다