<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>ha0td4</title><description>OwO</description><link>https://ha0td4.github.io/</link><language>en</language><item><title>Behavior-Centric Malware Analysis Through Multi-Stage Processing and ATT&amp;CK Correlation</title><link>https://ha0td4.github.io/posts/projects/apiseqtracer/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/projects/apiseqtracer/</guid><pubDate>Sun, 28 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In this project, malware analysis system is built on a three-layer architecture designed to move beyond basic detection into deep behavioral interpretation and MITRE ATT&amp;amp;CK mapping. Each layer operates independently but remains tightly integrated, enabling the pipeline to progress from raw execution signals to high-level threat intelligence. This structure allows not only classification of malicious samples, but also the extraction of behavioral insights that support investigation, threat hunting, and automated TTP (Tactics, Techniques, Procedures) identification.
&lt;img src=&quot;https://hackmd.io/_uploads/SkESTaXVbx.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Dataset&lt;/h1&gt;
&lt;p&gt;To evaluate the system, we aggregated malware execution traces from multiple publicly available sources. Data was collected from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/datasets/comments/exhy38/malware_and_benign_windows_pe_cuckoo_reports/&quot;&gt;r/datasets – Malware &amp;amp; Benign PE Cuckoo Reports&lt;/a&gt;: Provides Cuckoo sandbox execution logs for both malware and benign Windows binaries.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ocslab.hksecurity.net/apimds-dataset&quot;&gt;APIMDS&lt;/a&gt;: A labeled malware dataset containing monitored API call sequences across various families.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/mpasco/MalbehavD-V1&quot;&gt;MalbehavD-V1&lt;/a&gt;: Focused on behavior-driven samples with process execution details suitable for dynamic analysis.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All samples were executed inside a controlled sandbox environment to extract API call sequences for downstream processing. The final dataset contains multiple malware families alongside benign executables, forming a diverse testbed for behavior-based threat analysis.&lt;/p&gt;
&lt;p&gt;The label distribution is shown in the chart below:
&lt;img src=&quot;/assets/images/posts/apiseqtracer/01.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As illustrated in the pie chart, Trojan samples dominate the dataset, followed by Miscellaneous, Adware, and Benign classes. This imbalance reflects common trends in real-world malware distributions and highlights the importance of balanced evaluation strategies.&lt;/p&gt;
&lt;h1&gt;Layer 1 – Malware Detection&lt;/h1&gt;
&lt;p&gt;Execution traces are first collected through a sandbox environment, where each sample is analyzed and its API call sequence is recorded. These API calls are transformed into a fixed-length feature vector of 1143 dimensions, with each dimension representing the frequency of a corresponding API within the global API set. An ensemble model combining Random Forest and XGBoost is used to classify the sample as malicious or benign. In addition to classification probability, this layer produces an explainability report using SHAP values, highlighting the APIs that contributed most to the model decision. The detection component therefore acts as the primary filtering stage, providing a reliable base for deeper behavioral analysis in subsequent layers.&lt;/p&gt;
&lt;h1&gt;Layer 2 – Behavioral Analysis&lt;/h1&gt;
&lt;p&gt;While Layer 1 focuses on classification, the second layer aims to capture and interpret behavioral patterns. The raw API sequence is first processed using a Log2-based noise reduction technique to eliminate redundant consecutive calls. The cleaned sequence is then segmented using a sliding-window approach to generate API gadgets—continuous execution fragments representing localized behaviors. Each gadget is encoded using CodeBERT to generate semantic embeddings, offering a richer contextual understanding compared to traditional discrete representations.&lt;/p&gt;
&lt;p&gt;These embeddings are clustered using HDBSCAN, and clusters with valid labels (cluster_id ≠ -1) are retained as behaviorally meaningful groups with potential malicious indicators. In parallel, a bag-of-APIs model using TF-IDF is applied, and Sequential Pattern Mining with PrefixSpan combined with Discriminative Scoring is used to extract API patterns that distinguish malware families. This layer produces two critical outputs: suspicious gadget clusters with maliciousness likelihood, and characteristic sequential API patterns representing family-specific behaviors. Both serve as essential input for semantic interpretation and MITRE mapping.&lt;/p&gt;
&lt;h1&gt;Layer 3 – MITRE ATT&amp;amp;CK Mapping&lt;/h1&gt;
&lt;p&gt;The final layer bridges behavioral signals with threat intelligence by translating them into ATT&amp;amp;CK-aligned interpretations. A Large Language Model (LLM Interpreter) is first used to convert API gadgets into natural-language behavioral descriptions—such as network communication, system manipulation, file operations, or registry modification. These descriptions are then processed by an Analysis Agent operating under a Retrieval-Augmented Generation (RAG) framework. The agent queries a MITRE knowledge base containing tactic-technique mappings, malware behavior references, and API-to-TTP correlation data.&lt;/p&gt;
&lt;p&gt;Using semantic matching between system-generated behavior descriptions and retrieved MITRE knowledge, the system infers relevant attack techniques and tactics. The final output is an automatically generated report summarizing detected TTPs, reasoning context, and originating gadget evidence. As a result, the system evolves from simple malware detection into a comprehensive analytical engine that supports digital forensics, active attack monitoring, and strategic defense decision-making.&lt;/p&gt;
&lt;h1&gt;Additional&lt;/h1&gt;
&lt;p&gt;You can explore the most APISeqTracer source code on GitLab: &lt;a href=&quot;https://gitlab.com/ha0td4/apiseqtracer&quot;&gt;https://gitlab.com/ha0td4/apiseqtracer&lt;/a&gt;.&lt;/p&gt;
</content:encoded></item><item><title>Preventing Nmap OS Fingerprinting Using Snort Rules</title><link>https://ha0td4.github.io/posts/labs/snort-prevent-nmap-os-fingerprinting/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/labs/snort-prevent-nmap-os-fingerprinting/</guid><pubDate>Mon, 21 Apr 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When it comes to network security, one of the first things an attacker usually does is try to figure out what operating system you&apos;re running. Tools like Nmap make this super easy with OS fingerprinting — it sends a bunch of weirdly crafted packets to your machine, and based on how your system responds, it can make a pretty good guess about your OS.
In this post, I’ll show you how I used Snort in inline mode to block those sneaky Nmap probes. I captured some traffic, broke down how Nmap does its thing, and wrote a bunch of Snort rules to stop it in its tracks. It’s a hands-on walkthrough — perfect if you’re experimenting with intrusion detection systems or just want to level up your blue team skills.&lt;/p&gt;
&lt;p&gt;Before we dive in, it’s helpful to have some basic knowledge of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How Snort rules work — especially how to match on packet content, headers, flags, and sizes. &lt;a href=&quot;https://docs.snort.org/start/rules&quot;&gt;https://docs.snort.org/start/rules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;How Nmap OS fingerprinting works — the kinds of probes it sends (TCP, UDP, ICMP) and what it&apos;s looking for in the responses. &lt;a href=&quot;https://nmap.org/book/osdetect-methods.html&quot;&gt;https://nmap.org/book/osdetect-methods.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Network topology&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/01.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In this setup, &lt;code&gt;x = 4&lt;/code&gt; and Snort is running in &lt;code&gt;inline mode&lt;/code&gt; to actively drop suspicious traffic.&lt;/p&gt;
&lt;h1&gt;Before Adding Detection Rules&lt;/h1&gt;
&lt;p&gt;The attacker begins by scanning the victim’s open ports using Nmap. Meanwhile, the victim captures packets using &lt;code&gt;tcpdump&lt;/code&gt; for analysis:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/02.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Packet Analysis and Rule Writing&lt;/h1&gt;
&lt;p&gt;According to the official Nmap documentation, OS fingerprinting works by sending 16 specially crafted TCP, UDP, and ICMP probes to analyze dozens of characteristics from the response packets.&lt;/p&gt;
&lt;h2&gt;UDP (U1 Probe)&lt;/h2&gt;
&lt;p&gt;The U1 packet wasn&apos;t captured directly, but we were able to analyze the ICMP error response generated by it:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/03.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
Cross-referencing with Nmap&apos;s documented behavior confirms this packet matches the U1 probe:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/04.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
Snort rule to drop U1 packets:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drop udp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: U1 detected&quot;; content:&quot;|43 43 43 43 43 43 43 43|&quot;; sid:1000015; rev:1;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Result:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/05.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
=&amp;gt; Successfully blocked the U1 probe, reducing the confidence of Nmap’s OS detection.&lt;/p&gt;
&lt;h2&gt;Sequence generation (SEQ, OPS, WIN, and T1)&lt;/h2&gt;
&lt;p&gt;These TCP packets are tricky to detect due to Snort 2&apos;s limited TCP header inspection capabilities. However, they can still be identified using distinct &lt;code&gt;TCP flags&lt;/code&gt; and &lt;code&gt;window size values&lt;/code&gt;:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/06.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/07.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
Rules:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: SEQ/OPS/WIN/T1 #1 detected&quot;; flags:S; window:1; sid:1000001; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: SEQ/OPS/WIN/T1 #2 detected&quot;; flags:S; window:63; sid:1000002; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: SEQ/OPS/WIN/T1 #3#4 detected&quot;; flags:S; window:4; sid:1000003; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: SEQ/OPS/WIN/T1 #5 detected&quot;; flags:S; window:16; sid:1000004; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: SEQ/OPS/WIN/T1 #6 detected&quot;; flags:S; window:512; sid:1000005; rev:1;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;ICMP echo (IE):&lt;/h2&gt;
&lt;p&gt;These echo probes can also be detected by analyzing their size and other fields:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/08.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/09.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
Rules:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drop icmp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: IE-1 detected&quot;; dsize:120; icode:9; icmp_seq:295; tos:0; sid:1000006; rev:1;)

drop icmp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: IE-2 detected&quot;; dsize:150; icode:0; icmp_seq=296; tos:4; sid:1000007; rev:1;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;TCP explicit congestion notification (ECN)&lt;/h2&gt;
&lt;p&gt;This probe uses unusual TCP flags (SCE) and a very small window size.
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/10.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/11.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
Rule:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: ECN detected&quot;; flags:SCE; window:3; ack:0; sid:1000008; rev:1;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;TCP (T2–T7)&lt;/h2&gt;
&lt;p&gt;Similar to SEQ probes, these can be detected through their unique flags and window fields:
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/12.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/13.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;
Rules:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: T2 detected&quot;; flags:0; window:128; sid:1000009; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: T3 detected&quot;; flags:SFUP; window:256; sid:1000010; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: T4 detected&quot;; flags:A; window:1024; sid:1000011; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: T5 detected&quot;; flags:S; window:31337; sid:1000012; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: T6 detected&quot;; flags:A; window:32768; sid:1000013; rev:1;)

drop tcp any any -&amp;gt; any any (msg:&quot;Nmap OS fingerprinting: T7 detected&quot;; flags:FUP; window:65535; sid:1000014; rev:1;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Final Results After Rule Deployment&lt;/h1&gt;
&lt;p&gt;The combined set of Snort rules effectively blocks all OS fingerprinting probes from Nmap while still allowing legitimate traffic through. Although false positives (FP) or false negatives (FN) could theoretically occur, in this controlled lab environment no such cases were observed. Nmap probes typically contain highly unusual characteristics—such as uncommon flag combinations (e.g., NULL, FIN+URG+PSH) and suspicious window sizes (e.g., 1, 4, 16, 128, etc.)—which makes them easier to detect and filter.
&lt;img src=&quot;/assets/images/posts/snort-prevent-nmap-os-fingerprinting/14.png&quot; alt=&quot;snort-prevent-nmap-os-fingerprinting&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;By analyzing how Nmap performs OS fingerprinting and crafting specific Snort rules to block its probes, we can effectively reduce the chances of our systems being accurately profiled. While this setup isn’t bulletproof — attackers can still try different evasion techniques — it definitely raises the bar and makes scanning much more difficult.&lt;/p&gt;
&lt;p&gt;Of course, like with any IDS rules, there&apos;s always the potential for false positives or false negatives. In my lab environment, everything worked smoothly, but in a real-world network, you’ll want to monitor the logs and fine-tune the rules as needed.&lt;/p&gt;
&lt;p&gt;This was a fun little exercise in both packet analysis and rule writing. Hopefully, it gives you some ideas on how to harden your own network or experiment more with Snort. If you’ve got other tips, tricks, or improvements, feel free to share — always happy to learn more from the community!&lt;/p&gt;
&lt;p&gt;Stay safe and keep packet sniffing 🔍💻&lt;/p&gt;
</content:encoded></item><item><title>A Deep Dive into Fileless Malware Detection</title><link>https://ha0td4.github.io/posts/research/study-argus/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/research/study-argus/</guid><pubDate>Wed, 12 Mar 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;!-- markdownlint-disable MD013 --&amp;gt;&lt;/p&gt;
&lt;p&gt;Traditional antivirus solutions struggle against a new breed of cyber threats: &lt;strong&gt;Fileless malware&lt;/strong&gt;, which operates entirely in system memory, leaving no trace on disk. These attacks bypass conventional detection methods, making them one of the most dangerous challenges in cybersecurity today.
Facing this challenge, &lt;strong&gt;Argus&lt;/strong&gt;, an advanced early-stage fileless malware detection system leveraging deep learning and the MITRE ATT&amp;amp;CK framework to identify threats before they escalate. By analyzing memory snapshots in real time, Argus can detect malicious activity in its pre-operational phase, preventing devastating data breaches.
The proposed Argus system for early-stage fileless malware detection consists of two key architectural components: the &lt;code&gt;Feature Explainer&lt;/code&gt; and the &lt;code&gt;Early-Stage Detector&lt;/code&gt;. Its operational workflow involves these two phases working in tandem.&lt;/p&gt;
&lt;h1&gt;1. Feature Explainer&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/posts/study-argus/01.png&quot; alt=&quot;Feature Explainer&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Monitoring for Suspicious Processes&lt;/strong&gt;: Argus continuously monitors the system in real-time for suspicious processes using &lt;code&gt;Windows Management Instrumentation (WMI)&lt;/code&gt;. It looks for unusual process names, high resource usage, and unusual network activity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Queueing Suspicious Processes&lt;/strong&gt;: When a suspicious process is identified, its Process ID (PID) is appended to a queue for further analysis.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Capturing Memory Snapshots&lt;/strong&gt;: A suspicious process PID is dequeued and Argus automatically invokes the ProcDump command-line utility to capture a memory snapshot of the process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Extracting Key Features&lt;/strong&gt;: Custom plugins developed using Volatility documentation are used to extract key features from the acquired memory snapshot. These raw features include:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Parent-Child Process Relationships&lt;/strong&gt;: Detecting abnormal relationships such as a script executed by an unexpected parent process via mshta.exe.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tracing Execution Paths&lt;/strong&gt;: Identifying deviations from standard execution paths, like &lt;code&gt;c:\Windows\syswow64\dllhost.exe&lt;/code&gt; being used for malicious activity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Monitoring Sensitive Registry Keys&lt;/strong&gt;: Detecting unauthorized modifications to registry keys for persistence or evasion.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Identifying Code Injection Attempts&lt;/strong&gt;: Recognizing attempts to inject malicious code into legitimate processes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recognizing Signs of Process Hollowing&lt;/strong&gt;: Identifying processes that appear legitimate but are executing malicious code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Suspicious Network Activity&lt;/strong&gt;: Detecting anomalous network connections initiated by a process, potentially indicating communication with C2 servers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/posts/study-argus/02.png&quot; alt=&quot;regex patterns&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Generating Explained Features&lt;/strong&gt;: The extracted key features are then fed into a fine-tuned Llama model (feature explainer model) to generate explained features corresponding to those key features. This model is fine-tuned on a Feature explanation dataset created from behavioral reports, as shown below:
&lt;img src=&quot;/assets/images/posts/study-argus/03.png&quot; alt=&quot;image&quot; /&gt;
Here is a structure of Llama feature explainer model:
&lt;img src=&quot;/assets/images/posts/study-argus/04.png&quot; alt=&quot;image&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;2. Early-Stage Detector&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/posts/study-argus/05.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;MITRE-attack-dataset&lt;/strong&gt;: This component utilizes a MITRE-attack-dataset, which is prepared from the MITRE ATT&amp;amp;CK enterprise matrix. This dataset contains information on adversary tactics and techniques based on real-world observations.
&lt;img src=&quot;/assets/images/posts/study-argus/06.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Correlation and Detection&lt;/strong&gt;: The generated explained features from the &lt;a href=&quot;#1-Feature-Explainer&quot;&gt;Feature Explainer&lt;/a&gt; are correlated with the MITRE-attack-dataset.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fine-tuned BERT Model with MLP&lt;/strong&gt;: An early-stage detector is a fine-tuned BERT (Bidirectional Encoder Representations from Transformers) model combined with an MLP (Multilayer Perceptron), is used to identify fileless malware attacks at an early stage. The BERT model is fine-tuned on the MITRE-attack-dataset.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;3. Operational Workflow&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Argus continuously monitors the system for suspicious processes using WMI.&lt;/li&gt;
&lt;li&gt;When a suspicious process is found, its PID is added to a queue.&lt;/li&gt;
&lt;li&gt;Argus dequeues a PID and uses ProcDump to capture a memory snapshot.&lt;/li&gt;
&lt;li&gt;Custom plugins extract key features from the memory snapshot.&lt;/li&gt;
&lt;li&gt;The extracted features are fed to the fine-tuned Llama model to generate explained features.&lt;/li&gt;
&lt;li&gt;These explained features are then correlated with the MITRE ATT&amp;amp;CK framework using a fine-tuned BERT model with an MLP to detect fileless malware at an early stage.&lt;/li&gt;
&lt;li&gt;Argus can then identify the active stage of the fileless malware attack based on the correlation with the MITRE ATT&amp;amp;CK tactics.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Argus aims to detect fileless malware before its operational stage to prevent potential damage and data breaches. The experimental results showed that Argus could successfully identify fileless malware samples in both the pre-operational and operational phases.&lt;/p&gt;
&lt;h1&gt;4. Experimental Result&lt;/h1&gt;
&lt;h2&gt;4.1. Argus performance on benchmark dataset&lt;/h2&gt;
&lt;p&gt;The performance of Argus evaluated across various APT threat groups. Notably, Argus did not detect any threats at the initial stage since it relies on memory analysis, which occurs after the malware has achieved initial access. Finally, Argus detected 2978 samples (out of total 5026 samples) at the pre-operation stage, 1889 samples at the subsequent stages, and 59 samples failed to detect. These results indicate that Argus is most effective in detecting fileless malware at the &lt;em&gt;pre-operation stage&lt;/em&gt;.
&lt;img src=&quot;/assets/images/posts/study-argus/07.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;4.2. Argus performance comparison with existing SOTA&lt;/h2&gt;
&lt;p&gt;Argus demonstrated robust performance by identifying 2978 fileless malware samples at the Pre-operational stage and 1378 samples at the Operational stage. The results demonstrate Argus efficiency in detecting fileless malware attacks at an early stage and outperform existing state-of-the-art methods with an impressive detection accuracy of 96.84%.
&lt;img src=&quot;/assets/images/posts/study-argus/08.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;4.3. Computational performance comparison&lt;/h2&gt;
&lt;p&gt;The performance evaluation is conducted by selecting 1000 random processes of each different size. The analysis is focused on determining the average time taken by feature generation and early-stage detection for each memory dump. In conclusion, Argus outperforms existing SOTA, which takes 11.252s to analyse smaller processes and 136.343s to analyse larger processes.
&lt;img src=&quot;/assets/images/posts/study-argus/09.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;5. Reference&lt;/h1&gt;
&lt;p&gt;Kara, I. (2023). Fileless malware threats: Recent advances, analysis approach through memory forensics and research challenges. Expert Systems with Applications, 214, 119133.&lt;/p&gt;
</content:encoded></item><item><title>Process Injection</title><link>https://ha0td4.github.io/posts/research/process-injection/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/research/process-injection/</guid><pubDate>Sat, 01 Mar 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;!-- markdownlint-disable MD013 --&amp;gt;&lt;/p&gt;
&lt;h1&gt;Process Injection&lt;/h1&gt;
&lt;p&gt;Tactics: &lt;a href=&quot;https://attack.mitre.org/tactics/TA0005/&quot;&gt;Defense Evasion&lt;/a&gt;, &lt;a href=&quot;https://attack.mitre.org/tactics/TA0004/&quot;&gt;Privilege Escalation&lt;/a&gt;
Technique: &lt;a href=&quot;https://attack.mitre.org/techniques/T1055/&quot;&gt;Process Injection&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Process injection is one of the most common techniques used to dynamically bypass antivirus engines. Many antivirus vendors and software developers rely on so-called process injection or code injection to inspect processes running on the system. Using process injection, attacker can &lt;em&gt;inject malicious code into the address space of a legitimate process&lt;/em&gt; within the operating system, thereby avoiding detection by dynamic antivirus engines.&lt;/p&gt;
&lt;h2&gt;Base knowledge&lt;/h2&gt;
&lt;p&gt;Before we understand what process injection is, we need to know about the concept of the process address space, process-injection steps and Windows API.&lt;/p&gt;
&lt;h3&gt;Process Address Space&lt;/h3&gt;
&lt;p&gt;A process address space is a space that is allocated to each process in the operating system based on the amount of memory the computer has. Each process that is allocated memory space will be given a set of memory address spaces. Each memory address space has a different purpose, depending on the programmer&apos;s code, on the executable format used (such as the PE format), and on the operating system, which actually takes care of loading the process and its attributes, mapping allocated virtual addresses to physical addresses, and more. The following diagram shows a sample layout of a typical process address space:
&lt;img src=&quot;/assets/images/posts/process-injection/01.png&quot; alt=&quot;Process Address Space&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Process-injection steps&lt;/h3&gt;
&lt;p&gt;The goal of process injection is to inject a piece of code into the process memory address space of another process, give this memory address space execution permissions, and then execute the injected code. This applies not merely to injecting a piece of shellcode but also to injecting a DLL, or even a full executable (EXE) file.
To achieve this goal, the following general steps are required:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Identify a target process in which to inject the code.&lt;/li&gt;
&lt;li&gt;Receive a handle for the targeted process to access its process address space.&lt;/li&gt;
&lt;li&gt;Allocate a virtual memory address space where the code will be injected and
executed, and assign an execution flag if needed.&lt;/li&gt;
&lt;li&gt;Perform code injection into the allocated memory address space of the targeted
process.&lt;/li&gt;
&lt;li&gt;Finally, execute the injected code.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The following diagram depicts this entire process in a simplified form:
&lt;img src=&quot;/assets/images/posts/process-injection/02.png&quot; alt=&quot;Process-injection steps&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we have this high-level perspective into how process injection or code injection is performed, let&apos;s turn to an explanation of Windows API functions.&lt;/p&gt;
&lt;h3&gt;Windows API&lt;/h3&gt;
&lt;p&gt;The Windows API is Microsoft&apos;s core set of APIs, allowing developers to create code that interacts with underlying, prewritten functionality provided by the Windows operating system.
Windows API functions are user-mode functions that are fully documented on Microsoft&apos;s site at msdn.microsoft.com. However, most Windows API functions actually invoke Native APIs to do the work.
For instance, when a Windows API function such as &lt;code&gt;CreateFile()&lt;/code&gt; is called, depending on the parameter provided by the developer, Windows will then transfer execution to one of two Native API routines: &lt;code&gt;ZwCreateFile&lt;/code&gt; or &lt;code&gt;NtCreateFile&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Sub-technique of Process Injection&lt;/h2&gt;
&lt;p&gt;There are many sub techniques of process injection, but we&apos;ll explore some of these in this blog.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://attack.mitre.org/techniques/T1055/001/&quot;&gt;Classic DLL Injection&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This technique forces the loading of a malicious DLL into a remote process by using these six basic Windows API functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OpenProcess&lt;/strong&gt;: Using this function and providing the target process ID as one of its parameters, the injector process receives a handle to the remote process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;VirtualAllocEx&lt;/strong&gt;: Using this function, the injector process allocates a memory buffer that will eventually contain a path of the loaded DLL within the target process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WriteProcessMemory&lt;/strong&gt;: This function performs the actual injection, inserting the malicious payload into the target process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CreateRemoteThread&lt;/strong&gt;: This function creates a thread within the remote process, and finally executes the LoadLibrary() function that will load our DLL.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LoadLibrary/GetProcAddress&lt;/strong&gt;: These functions return an address of the DLL loaded into the process. Considering that kernel32.dll is mapped to the same address for all Windows processes, these functions can be used to obtain the address of the API to be loaded in the remote process.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After performing these six functions, the malicious DLL file runs within the operating system inside the address space of the target victim process.
Example in IDA Pro:
&lt;img src=&quot;/assets/images/posts/process-injection/03.png&quot; alt=&quot;Classic DLL Injection&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://attack.mitre.org/techniques/T1055/012/&quot;&gt;Process Hollowing&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This injection technique lets us create a legitimate process within the operating system in a &lt;code&gt;SUSPENDED&lt;/code&gt; state, hollow out the memory content of the legitimate process, and replace it with malicious content followed by the matched base address of the hollowed section.
Here are the API function calls used to perform the process-hollowing injection technique:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CreateProcess&lt;/strong&gt;: This function creates a legitimate operating system process (such as notepad.exe) in a suspended state with a &lt;code&gt;dwCreationFlags&lt;/code&gt; parameter.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ZwUnmapViewOfSection/NtUnmapViewOfSection&lt;/strong&gt;: Those Native API functions perform an unmap for  he entire memory space of a specific section of a process. At this stage, the legitimate system process has a hollowed section, allowing the malicious process to write its malicious content into this hollowed section.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;VirtualAllocEx&lt;/strong&gt;: Before writing malicious content, this function allows us to allocate new memory space.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WriteProcessMemory&lt;/strong&gt;: As we saw before with classic DLL injection, this function actually writes the malicious content into the process memory.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SetThreadContext and ResumeThread&lt;/strong&gt;: These functions return the context to the thread and return the process to its running state, meaning the process will start to execute.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An example about malware using process hollowing in IDA Pro:
&lt;img src=&quot;/assets/images/posts/process-injection/04.png&quot; alt=&quot;Process Hollowing-1&quot; /&gt;
&lt;img src=&quot;/assets/images/posts/process-injection/05.png&quot; alt=&quot;Process Hollowing-2&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://attack.mitre.org/techniques/T1055/013/&quot;&gt;Process Doppelgänging&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This fascinating process-injection technique is mostly used to bypass antivirus engines and can be used to evade some memory forensics tools and techniques.
Process doppelgänging makes use of the following Windows API and Native API functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CreateFileTransacted&lt;/strong&gt;: This function creates or opens a file, file stream, or directory based on Microsoft&apos;s NTFS-TxF feature. This is used to open a legitimate process such as notepad.exe.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WriteFile&lt;/strong&gt;: This function writes data to the destined injected file.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NtCreateSection&lt;/strong&gt;: This function creates a new section and loads the malicious file into the newly created target process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RollbackTransaction&lt;/strong&gt;: This function ultimately prevents the altered executable (such as notepad.exe) from being saved on the disk.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NtCreateProcessEx, RtlCreateProcessParametersEx, VirtualAllocEx, WriteProcessMemory, NtCreateThreadEx, NtResumeThread&lt;/strong&gt;: All of these functions are used to initiate and run the altered process so that it can perform its intended malicious activity.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An example about PE file using process doppelgänging:
&lt;img src=&quot;/assets/images/posts/process-injection/06.png&quot; alt=&quot;Process Doppelgänging-1&quot; /&gt;
&lt;img src=&quot;/assets/images/posts/process-injection/07.png&quot; alt=&quot;Process Doppelgänging-2&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Process Herpaderping&lt;/h3&gt;
&lt;p&gt;The Process Herpaderping technique bypasses security products by obscuring the intentions of the process, making it difficult for security tools to detect and prevent the malicious activity. It use the following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CreateProcess&lt;/strong&gt;: Creates a new process in a suspended state.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NtCreateSection&lt;/strong&gt;: Creates a section object to share memory between processes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NtMapViewOfSection&lt;/strong&gt;: Maps a view of the section into the address space of the target process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WriteProcessMemory&lt;/strong&gt;: Writes the executable code into the mapped section of the target process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SetThreadContext&lt;/strong&gt;: Sets the context of the main thread of the target process to point to the entry point of the malicious code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ResumeThread&lt;/strong&gt;: Resumes the main thread of the target process, causing it to execute the malicious code.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/posts/process-injection/08.png&quot; alt=&quot;Process Herpaderping&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Comparison&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Process Hollowing&lt;/strong&gt;
Process Hollowing involves modifying the mapped section before execution begins, which abstractly this looks like: &lt;code&gt;map -&amp;gt; modify section -&amp;gt; execute&lt;/code&gt;. This workflow results in the intended execution flow of the Hollowed process diverging into unintended code. Doppelganging might be considered a form of Hollowing. However, Hollowing is closer to injection in that Hollowing usually involves an explicit write to the already mapped code. This differs from Herpaderping where there are no modified sections.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Process Doppelganging&lt;/strong&gt;
Process Doppelganging is closer to Herpaderping. Doppelganging abuses transacted file operations and generally involves these steps: &lt;code&gt;transact -&amp;gt; write -&amp;gt; map -&amp;gt; rollback -&amp;gt; execute&lt;/code&gt;. In this workflow, the OS will create the image section and account for transactions, so the cached image section ends up being what you wrote to the transaction. The OS has patched this technique. Well, they patched the crash it caused. Maybe they consider this a &quot;legal&quot; use of a transaction. Thankfully, Windows Defender does catch the Doppelganging technique. Doppelganging differs from Herpaderping in that Herpaderping does not rely on transacted file operations. And Defender doesn&apos;t catch Herpaderping.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Process Herpaderping&lt;/strong&gt;
The registered kernel callback is invoked when the initial thread is inserted, not when the process object is created. Because of this, an actor can create and map a process, modify the content of the file, then create the initial thread. A product that does inspection at the creation callback would see the modified content. Additionally, some products use an on-write scanning approach which consists of monitoring for file writes. An actor using a &lt;code&gt;write -&amp;gt; map -&amp;gt; modify -&amp;gt; execute -&amp;gt; close&lt;/code&gt; workflow will subvert on-write scanning that solely relies on inspection at IRP_MJ_CLEANUP.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Technique&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hollowing&lt;/td&gt;
&lt;td&gt;&lt;code&gt;map -&amp;gt; modify section -&amp;gt; execute&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Doppelganging&lt;/td&gt;
&lt;td&gt;&lt;code&gt;transact -&amp;gt; write -&amp;gt; map -&amp;gt; rollback -&amp;gt; execute&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Herpaderping&lt;/td&gt;
&lt;td&gt;&lt;code&gt;write -&amp;gt; map -&amp;gt; modify -&amp;gt; execute -&amp;gt; close&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Other techniques&lt;/h2&gt;
&lt;p&gt;You can explore more techniques from: &lt;a href=&quot;https://www.exploit-db.com/docs/47983&quot;&gt;https://www.exploit-db.com/docs/47983&lt;/a&gt;
&lt;img src=&quot;/assets/images/posts/process-injection/09.png&quot; alt=&quot;Other techniques&quot; /&gt;&lt;/p&gt;
</content:encoded></item><item><title>Transformation-based Evasion Strategy</title><link>https://ha0td4.github.io/posts/research/malware-evasion-technique/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/research/malware-evasion-technique/</guid><pubDate>Wed, 12 Feb 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;!-- markdownlint-disable MD013 --&amp;gt;&lt;/p&gt;
&lt;p&gt;Malware developers have continuously evolved their techniques to bypass antivirus systems. Their evasion strategies primarily fall into three categories: &lt;strong&gt;Transformation-based, Concealment-based, and Attack-based [^1]&lt;/strong&gt;, as illustrated in the image below:
&lt;img src=&quot;/assets/images/posts/malware-evasion-technique/01.png&quot; alt=&quot;Transformation-based Evasion Strategy&quot; /&gt;
To effectively counter these evasion strategies, it is crucial to understand how they work. For example, some malware variants insert excessive &lt;code&gt;NOP&lt;/code&gt; instructions to increase their file size, helping them bypass size-based detection thresholds used by antivirus scanners.&lt;/p&gt;
&lt;h1&gt;Transformation-based stategy&lt;/h1&gt;
&lt;p&gt;The transformation-based strategy involves modifying the structural and behavioral characteristics of malware to evade detection. This can be achieved by altering either the static structure or the dynamic behavior of malware during runtime. Static modifications help avoid signature-based detection, while dynamic changes help evade behavior-based analysis.&lt;/p&gt;
&lt;p&gt;Examples of transformation-based evasion techniques include:&lt;/p&gt;
&lt;h2&gt;Packers&lt;/h2&gt;
&lt;p&gt;Packers use encryption and compression techniques to modify the original executable, making it harder to analyze. Some packers utilize virtual machine-based execution, where they alter the program’s opcode to run within a custom virtual environment, further complicating detection.
For this demonstration, I used UPX [^2], a widely used tool among malware developers for packing binary files [^3] (as noted in a 2012 survey).
To illustrate, I selected a single malware sample and created multiple packed variants. The original SHA-256 hash of the sample is:
&lt;code&gt;e56e4f523e0a013820d3201995073401df92402b60a1d94a105f99381e7d3499&lt;/code&gt;.
This sample has been analyzed on VirusTotal &lt;a href=&quot;https://www.virustotal.com/gui/file/e56e4f523e0a013820d3201995073401df92402b60a1d94a105f99381e7d3499&quot;&gt;(Here)&lt;/a&gt; and flagged as malware by 44 different antivirus engines:
&lt;img src=&quot;/assets/images/posts/malware-evasion-technique/02.png&quot; alt=&quot;image&quot; /&gt;
However, after using UPX, only 10 antivirus engines successfully detected it:
&lt;img src=&quot;/assets/images/posts/malware-evasion-technique/03.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Code Obfuscation&lt;/h2&gt;
&lt;p&gt;Code obfuscation modifies the structure and control flow of a program to make analysis more difficult while preserving functionality. Common techniques include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Garbage code insertion: Injecting redundant instructions that do not affect program execution.&lt;/li&gt;
&lt;li&gt;Register substitution: Replacing register names to confuse disassemblers.&lt;/li&gt;
&lt;li&gt;Control flow obfuscation: Modifying execution paths to make analysis harder.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this test, I used the free version of Obfuscator Executive [^4] to obfuscate the sample. The results are shown below:
&lt;img src=&quot;/assets/images/posts/malware-evasion-technique/04.png&quot; alt=&quot;image&quot; /&gt;
Obfuscator Executive works by obscuring critical components within executables and binary files, such as class names, functions, subroutines, objects, variables, constants, and UI elements. It replaces meaningful identifiers with indistinguishable placeholders, making it harder for attackers to understand and reverse engineer your software.
Before obscuring:
&lt;img src=&quot;/assets/images/posts/malware-evasion-technique/05.png&quot; alt=&quot;image&quot; /&gt;
After obscuring:
&lt;img src=&quot;/assets/images/posts/malware-evasion-technique/06.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Metamorphism&lt;/h2&gt;
&lt;p&gt;Metamorphic malware undergoes extensive transformations, rewriting its own code to generate unique variants while maintaining its malicious behavior. For instance, the Frankenstein framework [^5] assembles malware by combining code fragments from legitimate software, making it resistant to signature-based detection.&lt;/p&gt;
&lt;h2&gt;Behavioral Obfuscation&lt;/h2&gt;
&lt;p&gt;Behavioral obfuscation techniques manipulate execution patterns to avoid detection. These include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Multi-threaded execution: Splitting malicious operations across multiple threads.&lt;/li&gt;
&lt;li&gt;API obfuscation: Masking API calls to evade detection.&lt;/li&gt;
&lt;li&gt;Process injection: Running malicious code inside legitimate processes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A notable example is the Shadow Attack [^6], which creates multiple processes to perform malicious tasks while evading system call-based detection methods.&lt;/p&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;As malware continues to evolve, security researchers must stay updated on evasion techniques to improve detection mechanisms. Transformation-based evasion alters malware’s structure, concealment-based evasion hides malicious behavior, and attack-based evasion directly targets security solutions or uses adversarial techniques to deceive them. Understanding these methods is essential for developing robust countermeasures against modern malware threats.&lt;/p&gt;
&lt;p&gt;[^1]: Jiaxuan Geng, Junfeng Wang, Zhiyang Fang, Yingjie Zhou, Di Wu, and Wenhan Ge. 2024. A survey of strategy-driven evasion methods for PE malware: Transformation, concealment, and attack. Comput. Secur. 137, C (Feb 2024). &lt;a href=&quot;https://doi.org/10.1016/j.cose.2023.103595&quot;&gt;https://doi.org/10.1016/j.cose.2023.103595&lt;/a&gt;
[^2]: Upx. (n.d.). GitHub - upx/upx: UPX - the Ultimate Packer for eXecutables. GitHub. Retrieved March 1, 2025, from &lt;a href=&quot;https://github.com/upx/upx&quot;&gt;https://github.com/upx/upx&lt;/a&gt;
[^3]:  Branco, R.R., Barbosa, G.N., &amp;amp; Drimel, P. (2012). Scientific but Not Academical Overview of Malware Anti-Debugging , Anti-Disassembly and Anti-VM Technologies.
[^4]: Executive, O. (2024, December 1). Obfuscator Executive – secure EXE and binary files. (C) Obfuscator Executive 2025. Retrieved March 1, 2025, from &lt;a href=&quot;https://obfuscator-executive.com/&quot;&gt;https://obfuscator-executive.com/&lt;/a&gt;
[^5]: Mohan, V., &amp;amp; Hamlen, K. W. (2012). Frankenstein: Stitching Malware from Benign Binaries. WOOT, 12, 77-84.
[^6]: Ma, W., Duan, P., Liu, S., Gu, G., &amp;amp; Liu, J. C. (2012). Shadow attacks: automatically evading system-call-behavior based malware detection. Journal in Computer Virology, 8, 1-13.&lt;/p&gt;
</content:encoded></item><item><title>DMLDroid: Deep Multimodal Fusion Framework for Android Malware Detection with Resilience to Code Obfuscation and Adversarial Perturbations</title><link>https://ha0td4.github.io/posts/projects/dmldroid/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/projects/dmldroid/</guid><pubDate>Tue, 28 Jan 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Android malware poses a significant threat to mobile security, with attackers constantly evolving their techniques to evade detection. Traditional single-modality approaches often struggle to capture the diverse characteristics of malicious applications.&lt;/p&gt;
&lt;p&gt;Below is an explanation of a multimodal approach for detecting Android malware using Deep Learning (DL). The framework utilizes feature fusion across three individual branches: Deep Neural Networks (DNN), Convolutional Neural Networks (CNN), and Bidirectional Encoder Representations from Transformers (BERT). Each branch processes different aspects of APK (Android Package Kit) files, and the outputs are combined in to improve predictive accuracy.&lt;/p&gt;
&lt;h1&gt;Overview the framework&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/posts/DMLDroid/01.png&quot; alt=&quot;DMLDroid framework&quot; /&gt;&lt;/p&gt;
&lt;p&gt;My research multimodal framework integrates complementary features extracted from Android APK files using three separate branches:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DNN Branch: Extracts and analyzes tabular features such as permissions, intents, and other metadata from AndroidManifest files.&lt;/li&gt;
&lt;li&gt;CNN Branch: Processes APK DEX files by converting them into RGB images to capture structural patterns.&lt;/li&gt;
&lt;li&gt;BERT Branch: Analyzes API call sequences generated from the APK&apos;s call graphs using a pre-trained BERT model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each branch outputs a 128-dimensional feature vector and a logit prediction vector that are fused for final malware prediction.&lt;/p&gt;
&lt;h1&gt;Branch-Specific Processing&lt;/h1&gt;
&lt;h2&gt;1. DNN Branch: Tabular Feature Analysis&lt;/h2&gt;
&lt;p&gt;The DNN branch processes tabular data extracted from the AndroidManifest.xml file, which is retireved by Apktool, including permissions, intents, services, and other metadata. These features are crucial for understanding the behavior and capabilities of an Android application.
The input of this branch is a 1D vector of size 400, representing the tabular features.
A DNN with fully connected layers is used to analyze the tabular data. The network learns to identify patterns and relationships in the metadata that may indicate malicious behavior.&lt;/p&gt;
&lt;h2&gt;2. CNN Branch: Image-Based Bytecode Analysis&lt;/h2&gt;
&lt;p&gt;The CNN branch focuses on the DEX (Dalvik Executable) files within the APK, which is extracted by decompressor like 7-zip, tar. These files contain the bytecode of the application, which is converted into RGB images. This transformation allows the CNN to analyze structural patterns in the bytecode that may be indicative of malware.
The input is a 3-channel RGB image with dimensions (3, 64, 64), where 3 represents the color channels and 64x64 is the spatial resolution of the image.
A CNN is employed to extract spatial features from the bytecode images. The CNN uses convolutional layers to detect local patterns and hierarchical structures in the image data.&lt;/p&gt;
&lt;h2&gt;3. BERT Branch: API Call Sequence Analysis&lt;/h2&gt;
&lt;p&gt;The BERT branch processes sequences of API calls generated from the APK&apos;s call graphs (which is extracted using Androguard). These sequences represent the dynamic behavior of the application and provide insights into how the app interacts with the Android system.
The input consists of two components: input_ids (tokenized API call sequences) and attention_mask (to handle variable sequence lengths). These are standard inputs for transformer-based models like BERT.
A pre-trained DistilBERT model is fine-tuned on the API call sequences. DistilBERT is a lightweight version of BERT that retains much of its performance while being more computationally efficient. The model learns to understand the semantic relationships between API calls and their potential malicious intent.&lt;/p&gt;
&lt;h2&gt;Summary of each branches&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Branch&lt;/th&gt;
&lt;th&gt;Input data&lt;/th&gt;
&lt;th&gt;Input shape&lt;/th&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Extractor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DNN&lt;/strong&gt; - Tabular Feature Analysis&lt;/td&gt;
&lt;td&gt;Tabular data of permissions, actions, services&lt;/td&gt;
&lt;td&gt;(400,)&lt;/td&gt;
&lt;td&gt;A deep neural network with fully connected layers&lt;/td&gt;
&lt;td&gt;Apktool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CNN&lt;/strong&gt; - Image-Based Bytecode Analysis&lt;/td&gt;
&lt;td&gt;Bytecode extracted from the DEX file, converted into RGB image&lt;/td&gt;
&lt;td&gt;(3, 64, 64)&lt;/td&gt;
&lt;td&gt;A convolutional neural network extracts spatial patterns&lt;/td&gt;
&lt;td&gt;Decompressor (7-zip, tar, ...)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;BERT&lt;/strong&gt; - API Call Sequence Analysis&lt;/td&gt;
&lt;td&gt;API call graphs are converted into sequences of API calls&lt;/td&gt;
&lt;td&gt;(input_ids, attention_mask)&lt;/td&gt;
&lt;td&gt;A pre-trained DistilBERT model fine-tuned on API call sequences&lt;/td&gt;
&lt;td&gt;Androguard&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h1&gt;Feature Fusion&lt;/h1&gt;
&lt;p&gt;The outputs from the three branches (each 128-dimensional on last hidden layer, or 1-dimesional on logit layer) are fused to create a comprehensive representation of the APK file. The fusion process combines features from all modalities to improve prediction performance.
There are many fusion strategy, but mainly I&apos;ve done it on intermediately fusion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Concatenation of the three feature vectors (DNN, CNN, and BERT outputs).&lt;/li&gt;
&lt;li&gt;Attention mechanisms to emphasize critical features.&lt;/li&gt;
&lt;li&gt;Gated-fusion mechianism to utilize various information seamlessly for auto-adjusting prediction on each models.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Experimental Results&lt;/h1&gt;
&lt;p&gt;Below is a comparison table of the models. While binary classification only cares whether the application is malicious or not, multi-class classification gives a deeper insight into the family of malware.&lt;/p&gt;
&lt;h2&gt;Environment&lt;/h2&gt;
&lt;p&gt;My models were trained on Kaggle, with CPU Intel(R) Xeon(R) CPU @ 2.20GHz, 13 GB RAM, GPU Tesla P100-PCIE-16GB; Python 3.9, PyTorch 1.9.&lt;/p&gt;
&lt;h2&gt;Classification Report&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Acc.&lt;/th&gt;
&lt;th&gt;Rec.&lt;/th&gt;
&lt;th&gt;Pre.&lt;/th&gt;
&lt;th&gt;F1&lt;/th&gt;
&lt;th&gt;Training time (mins)&lt;/th&gt;
&lt;th&gt;Testing time (mins)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DNN&lt;/td&gt;
&lt;td&gt;96.88&lt;/td&gt;
&lt;td&gt;95.97&lt;/td&gt;
&lt;td&gt;95.56&lt;/td&gt;
&lt;td&gt;95.77&lt;/td&gt;
&lt;td&gt;0.62&lt;/td&gt;
&lt;td&gt;0.10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CNN&lt;/td&gt;
&lt;td&gt;95.15&lt;/td&gt;
&lt;td&gt;93.90&lt;/td&gt;
&lt;td&gt;93.01&lt;/td&gt;
&lt;td&gt;93.44&lt;/td&gt;
&lt;td&gt;1.55&lt;/td&gt;
&lt;td&gt;0.21&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BERT&lt;/td&gt;
&lt;td&gt;87.18&lt;/td&gt;
&lt;td&gt;80.75&lt;/td&gt;
&lt;td&gt;83.18&lt;/td&gt;
&lt;td&gt;81.85&lt;/td&gt;
&lt;td&gt;181.62&lt;/td&gt;
&lt;td&gt;35.89&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multimodal (concatenation)&lt;/td&gt;
&lt;td&gt;97.72&lt;/td&gt;
&lt;td&gt;96.81&lt;/td&gt;
&lt;td&gt;96.97&lt;/td&gt;
&lt;td&gt;96.89&lt;/td&gt;
&lt;td&gt;179.60&lt;/td&gt;
&lt;td&gt;34.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multimodal (attention)&lt;/td&gt;
&lt;td&gt;97.70&lt;/td&gt;
&lt;td&gt;95.89&lt;/td&gt;
&lt;td&gt;97.80&lt;/td&gt;
&lt;td&gt;96.80&lt;/td&gt;
&lt;td&gt;181.66&lt;/td&gt;
&lt;td&gt;35.03&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multimodal (gated-fusion)&lt;/td&gt;
&lt;td&gt;97.44&lt;/td&gt;
&lt;td&gt;96.71&lt;/td&gt;
&lt;td&gt;96.34&lt;/td&gt;
&lt;td&gt;96.52&lt;/td&gt;
&lt;td&gt;180.89&lt;/td&gt;
&lt;td&gt;34.76&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;ul&gt;
&lt;li&gt;DNN performs well with all high evaluation metrics. It is also the fastest in terms of training (0.62 mins) and testing (0.10 mins).&lt;/li&gt;
&lt;li&gt;CNN has slightly lower performance compared to DNN, with accuracy and F1 scores around 95%. It is slower than DNN but still relatively efficient.&lt;/li&gt;
&lt;li&gt;BERT underperforms compared to DNN and CNN, with all evaluation metrics around 80-90%. It is significantly slower in both training (181.62 mins) and testing (35.89 mins), likely due to its complex architecture and large number of parameters.&lt;/li&gt;
&lt;li&gt;All multimodal methods (concatenation, attention, and gated fusion) outperform single-modality models (DNN, CNN, BERT) in all of evaluation metrics (all above 97%).&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;We explored a multimodal approach for detecting Android malware using deep learning feature fusion. By integrating three distinct branches—DNN, CNN, and BERT—we were able to leverage complementary features extracted from Android APK files.&lt;/p&gt;
&lt;p&gt;For those interested in experimenting with the framework, the Kaggle notebook &lt;a href=&quot;https://www.kaggle.com/code/haotienducanh/andmalmultimodal&quot;&gt;AndMalMultimodal&lt;/a&gt; provides a practical starting point. Feel free to explore, modify, and build upon this work to advance the field of Android malware detection.&lt;/p&gt;
</content:encoded></item><item><title>Frida</title><link>https://ha0td4.github.io/posts/notes/frida/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/notes/frida/</guid><pubDate>Tue, 03 Dec 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;My notes for using Frida&lt;/p&gt;
&lt;h1&gt;Android&lt;/h1&gt;
&lt;p&gt;Write script to a .js file. Usage:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;frida -U com.example.app -l script.js
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Common information&lt;/h2&gt;
&lt;h3&gt;Check Java available&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;console.log(Java.available)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Check Android Version&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;console.log(Java.androidVersion)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;List classes&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;Java.perform(() =&amp;gt; {
  console.log(&quot;List classes in package com.example.app&quot;);
  Java.enumerateLoadedClasses({
    onMatch: function(className) {
      if (className.startsWith(&quot;com.example.app&quot;)) {
        console.log(className); 
      }
    },
    onComplete: function() {
      console.log(&quot;Done&quot;); 
    }
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or, this version return a list:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Java.perform(function () {
  const classes = Java.enumerateLoadedClassesSync();
  console.log(&quot;Num of classes: &quot;, classes.length);
  // console.log(&quot;Loaded classes: &quot;, classes);
  // classes.forEach(function (cls) {
  //   if (cls.includes(&quot;com.example.app&quot;))
  //     console.log(cls);
  // });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;List methods of classes&lt;/h2&gt;
&lt;p&gt;Replace &lt;strong&gt;__class__&lt;/strong&gt; and &lt;strong&gt;__method__&lt;/strong&gt;, with globs permitted.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Java.perform(() =&amp;gt; {
  const groups = Java.enumerateMethods(&apos;*__class__*!__method__*&apos;)
  console.log(JSON.stringify(groups, null, 2));
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Call method&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;Java.perform(() =&amp;gt; {
  const targetedClass = Java.use(&quot;com.example.app&quot;);
  const instance = targetedClass.$new();
  const method = instance.__targetMethod__(var1, var2);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nested call method&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Java.perform(() =&amp;gt; {
  const Activity = Java.use(&apos;android.app.Activity&apos;);
  const Exception = Java.use(&apos;java.lang.Exception&apos;);
  Activity.__targetMethod__.implementation = function () {
    throw Exception.$new(&apos;Oh noes!&apos;);
  };
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Overwrite method&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;Java.perform(() =&amp;gt; {
  const targetedClass = Java.use(&quot;com.example.app&quot;);
  const instance = targetedClass.$new();
  console.log(&quot;Instance: &quot;, instance);
  instance.__firstTargetMethod__.implementation = function () {
    console.log(&quot;__firstTargetMethod__() called&quot;);
    // Do something here
  }

  instance.__secondTargetMethod__.implementation = function () {
    console.log(&quot;__secondTargetMethod__() called&quot;);
    // Also do something with this one
  }
});
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>ICTF - Forensics writeups</title><link>https://ha0td4.github.io/posts/forensics-ctf/</link><guid isPermaLink="true">https://ha0td4.github.io/posts/forensics-ctf/</guid><pubDate>Sun, 01 Dec 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Two forensics CTF challenges I&apos;ve done&lt;/p&gt;
&lt;h1&gt;10/31/2024: &lt;a href=&quot;https://imaginaryctf.org/ArchivedChallenges/58&quot;&gt;the-registrar&lt;/a&gt;&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;by lolmenow
&lt;strong&gt;Description&lt;/strong&gt;: Just carved this memory dump from the scarecrow&apos;s PC! Apparently he told me that his programs on &lt;strong&gt;startup&lt;/strong&gt; was acting weird while trying to &lt;em&gt;register&lt;/em&gt; his new &lt;strong&gt;software&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Following the clue, I try to find the hive file storing registry:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/01.png&quot; alt=&quot;image&quot; /&gt;
Then dump this file at offset &lt;code&gt;0xb183c10b83e0&lt;/code&gt;:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/02.png&quot; alt=&quot;image&quot; /&gt;
Open this .dat file using &lt;a href=&quot;https://ericzimmerman.github.io/#!index.md&quot;&gt;Registry Explorer&lt;/a&gt;, startup programs is registered at &lt;code&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]&lt;/code&gt;, go there and get the base32 string:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/03.png&quot; alt=&quot;image&quot; /&gt;
Decode this base32 string and reverse to get the flag:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/04.png&quot; alt=&quot;image&quot; /&gt;
Flag: &lt;code&gt;ictf{tH3_rEg1STry_i5_T0O_c0OL_foR_YOu!}&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;10/31/2024: &lt;a href=&quot;https://imaginaryctf.org/ArchivedChallenges/58&quot;&gt;the-partraditionalist&lt;/a&gt;&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;by lolmenow
&lt;strong&gt;Description&lt;/strong&gt;: The Forensics department over at ictf needs help recovering the flag from this image disk file!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The challenge give me a file, lets check it:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/05.png&quot; alt=&quot;image&quot; /&gt;
Check some first line, I notice this image disk file has been corrupted:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/06.png&quot; alt=&quot;image&quot; /&gt;
So I use &lt;strong&gt;testdisk&lt;/strong&gt; tool to explore it (I run under sudo mode). Select &lt;code&gt;partition table type = None&lt;/code&gt;
Result should be like this when use select &lt;code&gt;[ Analyse ]&lt;/code&gt;:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/07.png&quot; alt=&quot;image&quot; /&gt;
After exploring for a time, I found there are 3 files in &lt;strong&gt;Software&lt;/strong&gt; partition:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/08.png&quot; alt=&quot;image&quot; /&gt;
Select all files and copy it to another location.
Check these files, I know it use GPG to encrypt message:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/09.png&quot; alt=&quot;image&quot; /&gt;
Importing this private key to decrypt message and get the flag:
&lt;img src=&quot;/assets/images/posts/forensics-ctf/10.png&quot; alt=&quot;image&quot; /&gt;
Flag: &lt;code&gt;ictf{SH0Uld_i_aDd_my_L1NkeDiN_t0_tHE_6pg_Em4!L??}&lt;/code&gt;&lt;/p&gt;
</content:encoded></item></channel></rss>