<?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 Winson Low on Medium]]></title>
        <description><![CDATA[Stories by Winson Low on Medium]]></description>
        <link>https://medium.com/@WinsonLow?source=rss-5478f966fa5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AHTfLEgOH2P6nHky-weNMA.jpeg</url>
            <title>Stories by Winson Low on Medium</title>
            <link>https://medium.com/@WinsonLow?source=rss-5478f966fa5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:43:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@WinsonLow/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[Building a Automated Linux Sandbox for Malware Analysis]]></title>
            <link>https://medium.com/csit-tech-blog/building-a-automated-linux-sandbox-for-malware-analysis-6fb1fb6cb7c2?source=rss-5478f966fa5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fb1fb6cb7c2</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[sandbox]]></category>
            <dc:creator><![CDATA[Winson Low]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 06:10:47 GMT</pubDate>
            <atom:updated>2024-10-10T06:37:07.341Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building an Automated Linux Sandbox for Malware Analysis</h3><p>Co-authored by: <a href="https://medium.com/@theoleecj">@theoleecj</a></p><p>At Centre for Strategic Infocomm Technologies (CSIT), we perform Malware Analysis to enumerate the malware’s characteristics and capabilities, then develop detection rules for Incidence Response and Threat Hunting. Manual reverse engineering is typically a time-consuming, last-resort method for analysis. Therefore, we required an automated solution to quickly triage the samples, enabling us to identify known malware capabilities and focus our efforts on the unknown threats.</p><h3>Is Linux Immune to Malware?</h3><p>For many years, there was a widespread belief that Linux was less susceptible to malware. However, this is not true. While Linux is generally secure, it is still vulnerable to malware attacks. In fact, certain types of malware, such as DDoS botnets and ransomware, are prevalent on Linux systems. Common vulnerabilities exploited include unpatched software and system misconfiguration.</p><h3>Linux Malware on the rise?</h3><p>What many people are unaware of is that <a href="https://phoenixnap.com/kb/server-operating-system#ftoc-heading-2">Linux runs approximately 80% of Web servers</a>. Additionally, Linux runs most organizations’ database servers, file servers, and email servers. <strong>Linux basically runs the web</strong>. By unifying the IT stack, Linux makes network management more straightforward. So, if an attacker breaches a Linux environment, they can likely access an organization’s most critical systems and data.</p><p>An <a href="https://techjury.net/blog/list-of-linux-malware-and-threats/#is-linux-malware-on-the-rise">article published by TechJury in 2023</a> states that:</p><blockquote>Although the Linux platform makes up for just 1% of total operating space, it was still the target of over 1.9 million threats in 2022 (a YoY increase of almost 50%).</blockquote><p>As such, Linux malware is becoming increasingly prevalent. An increasing number of cyber criminals are targeting Linux servers and cloud infrastructure for ransomware campaigns, cryptojacking attacks, and other illicit activities. Many businesses remain vulnerable due to misconfigured or poorly managed Linux systems. Today, there is a growing need to analyse Linux malware to understand its capabilities.</p><h3>Analysing Linux Malware Dynamic Behaviour</h3><p>Dynamic analysis aids in understanding how malware interacts with the operating system during runtime. One of the tools utilised is strace, a <strong>diagnostic and debugging utility</strong> that traces executed syscalls. Analysing the syscalls being called provides insights into how the malware interacts with the system. For example, this approach will be demonstrated using a BPFDoor sample.</p><pre># Compiling and using strace to launch the sample<br>$ wget -O bpfdoor.c https://pastebin.com/raw/kmmJuuQP<br>$ gcc -o bpfdoor bpfdoor.c<br>$ chmod +x bpfdoor<br>$ sudo strace -o log -ff ./bpfdoor</pre><p>Utilising the `-ff` option enables the collection of syscalls for each individual process spawned during execution. By examining the process logs, it is possible to identify that the sample attempts to access the file `/var/run/haldrund.pid`.</p><blockquote>*<em>strace</em> output is condensed for demonstration purposes.</blockquote><pre>$ cat log.1805<br>execve(“./bpfdoor”, [“./bpfdoor”], 0x7ffc414e6318 /* 17 vars */) = 0<br>access(“/var/run/haldrund.pid”, R_OK) = -1 ENOENT (No such file or directory)<br>clone3({flags=CLONE_VM|CLONE_VFORK, exit_signal=SIGCHLD, stack=0x7f2d1761d000, stack_size=0x9000}, 88) = 1807<br>access(“/var/run/haldrund.pid”, R_OK) = 0</pre><p>The return value of the `clone3` system call (1807) represents a new process ID, a child process that is spawned from the initial execution.</p><pre>$ cat log.1807<br>execve(“/bin/sh”, [“sh”, “-c”, “/bin/rm -f /dev/shm/kdmtmpflush;/bin/cp /tmp/BPFDoor /dev/shm/kdmtmpflush &amp;&amp; /bin/chmod 755 /dev/shm/kdmtmpflush &amp;&amp; /dev/shm/kdmtmpflush — init &amp;&amp; /bin/rm -f /dev/shm/kdmtmpflush”], 0x7ffe50286468 /* 17 vars */) = 0</pre><p>This reveals that that the child process launches a few commands in sequence.</p><pre>/bin/rm -f /dev/shm/kdmtmpflush<br>/bin/cp ./bpfdoor /dev/shm/kdmtmpflush<br>/bin/chmod 755 /dev/shm/kdmtmpflush<br>/dev/shm/kdmtmpflush — init<br>/bin/rm -f /dev/shm/kdmtmpflush</pre><p>It can be observed that the sample copies itself to the /dev/shm/kdmtmpflush directory and modifies the necessary permissions to enable execution. At this stage, a high-level sense of the sample’s behaviour can be understood. Further in-depth analysis will not be continued, as the focus is on demonstrating how strace can facilitate dynamic analysis.</p><p>For those interested in additional details about the BPFDoor sample, further information is available here.</p><p><a href="https://www.elastic.co/security-labs/a-peek-behind-the-bpfdoor">A peek behind the BPFDoor - Elastic Security Labs</a></p><h4>Manual analysis — a tedious process?</h4><p>The troublesome part of performing dynamic analysis is setting up an isolated, controlled environment such as a virtual machine or sandbox, to observe the malware’s behaviour. It can be very time-consuming when dealing with a large volume of samples. Additionally, advanced malware strains can detect dynamic analysis environments, altering their behaviour or remain dormant, which reduces the effectiveness of this approach.</p><p>The full process of malware analysis can be difficult and time-consuming, something that can only be considered complete after one has a comprehensive understanding of a malware’s full capabilities. To do so, an analyst will have to spend a significant amount of time performing static and dynamic analysis on the malware.</p><h4>Automating Linux Malware Analysis via CAPEv2 Sandbox</h4><p>A sandbox can be used to perform automated malware analysis, allowing for initial examination and collection of data about the malware’s behaviour and potential impact. This initial triage can guide the analyst during the deeper analysis phase and helps expedite the process.</p><h4>Why use CAPEv2?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*jKnS5THh6tCdNsS561MDeQ.png" /><figcaption>Figure 1: CAPEv2 logo</figcaption></figure><p><a href="https://github.com/kevoreilly/CAPEv2/">CAPEv2</a> is an open-sourced automated malware analysis system. It’s used to automatically run and analyse files and collect comprehensive analysis results that outline what the malware does while running inside an isolated machine. It is modular in design, making it higher customizable, and new tools and modules can be easily added to suit our needs.</p><p>While most advancements and features are focused on Windows sandbox capabilities, CAPEv2 initially established some groundwork for analysing the execution of Linux samples using SystemTap. However, due to the continuous updates to the Linux kernel, compiling a compatible SystemTap binary became increasingly more challenging. Consequently, development for the Linux capability was discontinued. Nevertheless, the modular design of CAPEv2 offered a basis for creating a new Linux sandbox utilizing strace instead.</p><h4>Running the samples</h4><p>Similar to our approach with dynamic analysis, the samples are executed using strace to capture their log output. Once the sample has either completed its run or reached a timeout, the logs are collected by the CAPEv2 server for further processing. The results are then accessible on the CAPEv2 web frontend for behavioural analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueNZ5UQc4_mhJuZ3j0dmvw.png" /><figcaption>Figure 2: <em>Linux Behavioural Analysis Results</em></figcaption></figure><p>Though this process might sound straightforward, there were challenges encountered with ransomware samples. The strace log output would be corrupted or encrypted by the ransomware, requiring alternative methods to capture the logs to be sent to the CAPEv2 server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vK4xbaVSnEkoL-beUNyAUg.png" /><figcaption><em>Figure 3: Overview of sample analysis between CAPEv2 server and Linux VM</em></figcaption></figure><p>During the second step of the analysis, the sample was executed with a process that redirected the strace output stream directly to the CAPEv2 server instead of writing it to a log file. This circumvented the issue of the ransomware encryption.</p><h4>Signatures</h4><p>Signatures play a vital role in understanding and identifying malware in analyses. They provide context and help interpret findings, such as recognizing malicious software samples based on known patterns. As the Linux sandbox is a relatively new feature, the development of Linux-specific signatures is still in its early stages.</p><p>Currently, for Linux, CAPEv2 can only detect basic activities like new processes or file changes. Just as community-driven efforts have significantly contributed to signature development for Windows, similar advancements for Linux signatures is expected. With <a href="https://github.com/CAPESandbox/community">community support</a>, it is possible to enhance Linux malware analysis capabilities and further improve the CAPEv2 Linux sandbox.</p><h4>Limitations</h4><p>While strace is useful for tracing system calls in user-space programs, it doesn’t provide visibility into kernel-level activities.</p><p>Kernel-level malware can evade detection by bypassing or hooking system calls, directly manipulating kernel structures, or injecting code into the kernel. Advanced malware can also avoid detection by strace by changing its behaviour when it detects tracing tools or using anti-debugging techniques.</p><p>Given these limitations, there is a need for alternative solutions to effectively address the challenge of identifying and analysing kernel-level malware.</p><h3>eBPF Technology, Signatures &amp; Tracee</h3><p><a href="https://ebpf.io/what-is-ebpf/">eBPF</a> is a popular and powerful tool originally designed for network packet filtering, monitoring, and tracing in the Linux kernel. It allows for the execution of custom programs directly in the kernel, making it very flexible and efficient for legitimate uses. However, malicious actors can also exploit eBPF to <strong>create powerful kernel-level malware and evade detection</strong>.</p><p>Using eBPF technology, it is possible to trace and monitor kernel-level events. This capability allows for detailed insights into system and application behaviour that traditional tools like strace may not capture, enhancing overall threat detection capabilities.</p><h4>Tracee — using eBPF to detect malicious eBPF usage (and other malware behaviours)</h4><p>Tracee is an eBPF-based threat detection engine. It not only traces syscalls, but <strong>crucially, evaluates the syscalls against a curated list of signatures describing security events and malware-like behaviours</strong>.</p><p>The implications of this in assisting automated dynamic analysis are <strong>huge</strong>. It is the difference between poring over dozens of syscalls to figure out what a malware sample is doing, and simply running Tracee to get a bird’s eye view of common malware behaviours.</p><p>From their <a href="https://aquasecurity.github.io/tracee/latest/docs/events/builtin/signatures/">documentation</a>, some key signature-based detections are:</p><ul><li>Dynamic Code Loading</li><li>Fileless Execution</li><li>Hidden File Created</li><li>Syscall Table Hooking</li><li>kallsyms_lookup_name - it could be used in some rootkits, likely until recently… (it’s an <a href="https://github.com/xcellerator/linux_kernel_hacking/issues/3">interesting story</a>)</li><li><strong>Illegitimate Shell</strong> — detect instances where a web server program spawns a shell</li><li><strong>Kernel Module Loading</strong> — new kernel module loaded (possible kernel rookits)</li><li><strong>Loader Preload</strong> — identifies manipulation of LD_PRELOAD and LD_LIBRARY_PATH environment variables, or similar methods which can potentially be leveraged for code injection</li><li><strong>Process VM Write</strong> — detect potential code injection attacks using the process_vm_writev syscall</li><li><strong>Scheduled Task Modification</strong> — like cron</li><li><strong>Standard I/O Over Socket</strong> — potential remote shell</li><li>Many more…</li></ul><h4>Running Tracee</h4><p>While Tracee can simply be run as a Docker container without additional setup:</p><pre>docker run --name tracee -it --rm \<br>  --pid=host --cgroupns=host --privileged \<br>  -v /etc/os-release:/etc/os-release-host:ro \<br>  -v /var/run:/var/run:ro \<br>  aquasec/tracee:latest</pre><p>The default configuration appears to be optimised for detecting key security events across the entire system, rather than targeting a specific process. It is ideal for monitoring active systems, such as web servers, and notifying on-duty personnel of any suspicious activity.</p><p>For the use case of automated dynamic analysis, further configuration would be required. This can be done through Tracee policies.</p><h4>Configuring Tracee using Policies and Capture</h4><p>Tracee determines which syscalls and security event detections to output from specific processes based on a configurable <strong>policy</strong> for each run.</p><p>The following are key considerations for optimising the policy configuration to enhance automated analysis capture:</p><ul><li>Capturing all signature-based security events</li><li>Capturing all syscalls</li><li>Capturing all miscellaneous events (such as eBPF hooking by malware samples, like <a href="https://github.com/citronneur/pamspy">pamspy</a>)</li><li>Targeting specific processes (in minimise noise and false detections)</li></ul><h4>Tracee Scope</h4><p><a href="https://aquasecurity.github.io/tracee/latest/docs/policies/scopes/">Scopes</a> define what processes, containers or workloads should be traced.</p><p>To narrow the tracing range for Tracee, a copy of the Bourne shell, sh, is renamed to sh-shim. When executing malware samples with sh-shim, the executable=/sh-shim <a href="https://aquasecurity.github.io/tracee/latest/docs/policies/scopes/#executable-exec">scope</a> is applied to observe the behaviour of the detonated malware. Additionally, Tracee’s follow <a href="https://aquasecurity.github.io/tracee/latest/docs/policies/scopes/#follow">scope</a> is employed to monitor the child processes. This setup facilitates <strong>easy monitoring of the malware sample and all its child processes</strong>.</p><p>Here is a sample process tree to illustrate.</p><pre>strace /bin/sh-shim -c malware.elf<br> └── /bin/sh-shim -c malware.elf  &lt;-- Tracee starts monitoring from here<br>     └── malware.elf &lt;-- all child processes and their children are monitored<br>         ├── sh -s whoami<br>         │   └── whoami<br>         └── sh -c crontab -l | egrep -v &quot;^(#|$)&quot; | grep -e &quot;@reboot (/.Library/SystemServices/updateSystem)&quot;</pre><p>Which leads to a policy similar to:</p><pre>apiVersion: tracee.aquasec.com/v1beta1<br>kind: Policy<br>metadata:<br>  name: analysis-policy<br>  annotations:<br>    description: analysis-policy<br>spec:<br>  scope:<br>    - executable=/sh-shim<br>    - follow<br>  rules:<br>    # Signature-based events: https://github.com/aquasecurity/tracee/blob/main/examples/policies/signature_events.yaml<br>    - event: stdio_over_socket<br>    - event: k8s_api_connection<br>    - event: aslr_inspection<br>    - event: proc_mem_code_injection<br>    - event: docker_abuse   <br>    - event: scheduled_task_mod     <br>    - event: ld_preload     <br>    - event: cgroup_notify_on_release<br>    - event: default_loader_mod     <br>    - event: sudoers_modification   <br>    - event: sched_debug_recon      <br>    - event: system_request_key_mod <br>    - event: cgroup_release_agent   <br>    - event: rcd_modification       <br>    - event: core_pattern_modification<br>    - event: proc_kcore_read<br>    - event: proc_mem_access<br>    - event: hidden_file_created    <br>    - event: anti_debugging <br>    - event: ptrace_code_injection  <br>    - event: process_vm_write_inject<br>    - event: disk_mount     <br>    - event: dynamic_code_loading<br>    - event: fileless_execution     <br>    - event: illegitimate_shell     <br>    - event: kernel_module_loading  <br>    - event: k8s_cert_theft<br>    - event: syscall_hooking<br>    - event: dropped_executable<br>    - event: bpf_attach<br>    # ... the rest of the events are omitted for brevity. they are mostly syscalls.</pre><h4>Dealing with strace detection and Tracee</h4><p>If the malware uses anti-debugging methods to evade strace, the dynamic analysis can still continue without it by executing the malware only with sh-shim. While this reduces visibility into the immediate syscall outputs from strace, Tracee can still be used as an alternative for syscall tracing.</p><h4>Capturing Artifacts</h4><p>Tracee also has the powerful ability to <a href="https://aquasecurity.github.io/tracee/latest/docs/flags/capture.1/">capture artifacts</a> such as loaded BPF programs, kernel modules and memory regions that had write+execute (w+x) protection and then changed to execute (x) only (suspicious). These may be useful to the analyst.</p><h4>Streaming Output and Analysis UI</h4><p>Combining the policy and artifact-capturing configurations:</p><pre>sudo docker run --name tracee -d --rm \<br>  --pid=host --cgroupns=host --privileged \<br>  -v /etc/os-release:/etc/os-release-host:ro \<br>  -v /root/tracee-artifacts/:/tmp/tracee/out/host \<br>  -v /var/run:/var/run:ro \<br>  -v /root/modules/auxiliary/tracee:/policy \<br>  aquasec/tracee:latest --output json \<br>  --output option:parse-arguments,exec-env,exec-hash \<br>  --policy /policy/policy.yml \<br>  --cache cache-type=mem --cache mem-cache-size=1024 \<br>  --capture bpf --capture module \<br>  --capture write --capture mem</pre><p>This results in large amounts of JSON data to review. Below is a sample event that has been captured.</p><pre>{<br>  &quot;timestamp&quot;: 1718154078025472300,<br>  &quot;threadStartTime&quot;: 1718154077920012000,<br>  &quot;processorId&quot;: 1,<br>  &quot;processId&quot;: 2097,<br>  &quot;cgroupId&quot;: 3217,<br>  &quot;threadId&quot;: 2097,<br>  &quot;parentProcessId&quot;: 2095,<br>  &quot;hostProcessId&quot;: 2097,<br>  &quot;hostThreadId&quot;: 2097,<br>  &quot;hostParentProcessId&quot;: 2095,<br>  &quot;userId&quot;: 0,<br>  &quot;mountNamespace&quot;: 4026531841,<br>  &quot;pidNamespace&quot;: 4026531836,<br>  &quot;processName&quot;: &quot;pamspy.elf&quot;,<br>  &quot;executable&quot;: {<br>    &quot;path&quot;: &quot;&quot;<br>  },<br>  &quot;hostName&quot;: &quot;workstation&quot;,<br>  &quot;containerId&quot;: &quot;&quot;,<br>  &quot;container&quot;: {},<br>  &quot;kubernetes&quot;: {},<br>  &quot;eventId&quot;: &quot;777&quot;,<br>  &quot;eventName&quot;: &quot;security_bpf_prog&quot;,<br>  &quot;matchedPolicies&quot;: [<br>    &quot;analysis-policy&quot;<br>  ],<br>  &quot;argsNum&quot;: 5,<br>  &quot;returnValue&quot;: 0,<br>  &quot;syscall&quot;: &quot;bpf&quot;,<br>  &quot;stackAddresses&quot;: null,<br>  &quot;contextFlags&quot;: {<br>    &quot;containerStarted&quot;: false,<br>    &quot;isCompat&quot;: false<br>  },<br>  &quot;threadEntityId&quot;: 206392471,<br>  &quot;processEntityId&quot;: 206392471,<br>  &quot;parentEntityId&quot;: 3635788456,<br>  &quot;args&quot;: [<br>    {<br>      &quot;name&quot;: &quot;type&quot;,<br>      &quot;type&quot;: &quot;string&quot;,<br>      &quot;value&quot;: &quot;BPF_PROG_TYPE_SOCKET_FILTER&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;name&quot;,<br>      &quot;type&quot;: &quot;const char*&quot;,<br>      &quot;value&quot;: &quot;&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;helpers&quot;,<br>      &quot;type&quot;: &quot;const char**&quot;,<br>      &quot;value&quot;: null<br>    },<br>    {<br>      &quot;name&quot;: &quot;id&quot;,<br>      &quot;type&quot;: &quot;u32&quot;,<br>      &quot;value&quot;: 335<br>    },<br>    {<br>      &quot;name&quot;: &quot;load&quot;,<br>      &quot;type&quot;: &quot;bool&quot;,<br>      &quot;value&quot;: true<br>    }<br>  ]<br>}</pre><p>Many details such as the event name (security_bpf_prog, eBPF program loaded), process ID, process name (pamspy.elf), and much more can be seen. Several tens of thousands of events comprising a mix of security events and syscalls are generated.</p><p>Naturally, a considerable amount of post-processing is necessary for this data. Since the output is in JSON format and can be quite large in size, it can be highly compressed for more efficient storage and transfer.</p><p>To assist sandbox users and analysts, thousands of these events are rendered into a filtering UI with sensible defaults. For efficient filtering, <a href="https://datatables.net/">DataTables</a> is utilised. Some examples of this can be found below in the “Performance Evaluation” section.</p><p>Filtering and minimal processing for display were handled on the client side for several key reasons:</p><ol><li>As much raw data as possible is preserved from the initial Tracee run.</li><li>Future enhancements to the client-side processing and filtering can be applied to past analyses without the need for server-side re-processing.</li><li>End-user can configure and apply filters interactively without repetitively querying and consuming server resources.</li><li>The compression of JSON output ensures that only kilobytes of data are sent to the client, enhancing efficiency.</li></ol><h3>Linux Sandbox Performance Evaluation</h3><p>The diagram below outlines the complete process of executing a sample with Tracee integrated into the system and how the output is retrieved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*RSnp7feGRxfL-1eFtSYPKw.png" /><figcaption><em>Figure 4: Overview of Dynamic Analysis implementation</em></figcaption></figure><p>Before running the malware, the Tracee container is started via an auxiliary module integrated into CAPEv2. When the malware is executed, the container captures events, and the logs are collected by the CAPEv2 agent, which streams them to the CAPEv2 server. This process is similar to how the strace implementation functions.</p><p>After all is said and done, it is essential to evaluate how this enhances the functionality and performance of the Linux sandbox. The most effective way to assess this is by executing a range of real malware samples within the environment.</p><h3>Evaluation Methodology</h3><p>To evaluate the sandbox, three distinct malware samples (a password stealer, a backdoor and one rootkit) were selected from a diverse set of threats, each employing different capabilities and technologies. Thanks to MalwareBazaar and the authors for making these easily available.</p><h4>1. Open Source Credential Stealer “PamSpy”</h4><p>Pamspy was obtained and compiled from its official repository on GitHub.</p><p><a href="https://github.com/citronneur/pamspy">GitHub - citronneur/pamspy: Credentials Dumper for Linux using eBPF</a></p><blockquote><em>pamspy leverage eBPF technologies to achieve an equivalent work of 3snake.<br> It will track a particular userland function inside the PAM (Pluggable Authentication Modules) library, used by many critical applications to handle authentication like:<br> — </em>sudo<br> — sshd<br> — passwd<br> — gnome<br> — x11<br> — and many other …</blockquote><p>A PamSpy integration compiled into a larger malware would be particularly <a href="https://www.aquasec.com/blog/detecting-ebpf-malware-with-tracee/">challenging for analysis because of its use of eBPF</a>:</p><blockquote>Since Pamspy is using an eBPF program to steal secrets, traditional security controls that focus on the user-space may completely miss this malware.</blockquote><p>However, Tracee’s signatures effectively detect the eBPF abuse with ease. Below is the analysis tab for reference. Furthermore, Tracee also extracts the eBPF program for analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZRGYPNV47bT2szFNG3eGg.png" /><figcaption><em>Figure 5: Tracee results for PamSpy showing the PamSpy eBPF program being loaded and filtering interface</em></figcaption></figure><p>strace lets you get directly to the syscalls without wading through security events. Events of different categories are highlighted in different colours and filterable. Users can also search for specific API calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xVRD7IztLN8SiSO9QtXBzQ.png" /><figcaption><em>Figure 6: </em><em>strace results for PamSpy</em></figcaption></figure><h4>2. SysJoker Malware, 5e11432c30783b184dc2bf27aa1728b4</h4><p>A sample of the SysJoker Backdoor Trojan was obtained from MalwareBazaar.</p><p><a href="https://bazaar.abuse.ch/sample/bd0141e88a0d56b508bc52db4dab68a49b6027a486e4d9514ec0db006fe71eed/">Checking your browser</a></p><p>Using AttackIQ’s article, which describes the behavior of a SysJoker variant, as a reference point, the results and accuracy of the sandbox analysis can be assessed.</p><p><a href="https://www.attackiq.com/2022/08/02/malware-emulation-attack-graph-for-sysjokers-linux-variant/">Malware Emulation Attack Graph for SysJoker&#39;s Linux Variant</a></p><p>While there may be small differences in our samples, the general behaviours and TTPs ought to be similar since they are from the same malware family.</p><p>The article covers the following behaviours:</p><ol><li><strong>System Owner / User Discovery (T1033):</strong> Living off the land and executing native system commands to gain details about the account currently running the malware. SysJoker and two AttackIQ scenarios execute the id -u and whoami commands.</li><li><strong>Hide Artifacts: Hidden Files and Directories (T1564.001):</strong> Files and folders that begin with the . character are hidden by default from command line utilities like ls.</li><li><strong>Scheduled Task/Job: Cron (T1053.003):</strong> SysJoker uses the following command to establish persistence inside the running user’s crontab file:<br>crontab -l | egrep -v “^(#|$)” | grep -e “<a href="http://twitter.com/reboot">@reboot</a> (/.Library/SystemServices/updateSystem)”</li><li><strong>Command and Scripting Interpreter: Unix Shell ( T1059.004):</strong> The backdoor uses nohup to execute a copy of itself silently and redirect any output:<br>nohup ‘ /.Library/SystemServices/updateSystem’ &gt; /dev/null 2&gt;&amp;1</li></ol><p>Which can be observed in the Linux sandbox results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y97Gx3QpsWAQi7nlp4xgsw.png" /><figcaption><em>Figure 7: Tracee results for SysJoker showing the malware’s behaviour</em></figcaption></figure><p>From the screenshot, the results show that Tracee makes the large process tree, MITRE framework TTPs and security events easily visible, which can assist analysts in deciding where to look.</p><p>The strong correspondence between the behaviours covered in the article and our results suggests that our sandbox is fairly accurate. That said, more signatures and detections would be useful.</p><h4>3. Open Source Kernel Rootkit “Diamorphine”</h4><p>Diamorphine, a kernel module rootkit, was obtained and compiled from its official repository on GitHub.</p><p><a href="https://github.com/m0nad/Diamorphine">GitHub - m0nad/Diamorphine: LKM rootkit for Linux Kernels 2.6.x/3.x/4.x/5.x/6.x (x86/x86_64 and ARM64)</a></p><blockquote>Features<br> — When loaded, the module starts invisible;<br> — Hide/unhide any process by sending a signal 31;<br> — Sending a signal 63(to any pid) makes the module become (in)visible;<br> — Sending a signal 64(to any pid) makes the given user become root;<br> — Files or directories starting with the MAGIC_PREFIX become invisible;</blockquote><p>Particular attention was given to it due to its frequent <strong>use in larger malware campaigns</strong>, and given its availability on GitHub.</p><blockquote>The use of both libprocesshider and <strong>diamorphine is particularly common in cloud malware campaigns</strong> and was most recently exhibited by Migo, a Redis miner discovered by Cado Security Labs in <strong>February 2024</strong>.</blockquote><p><a href="https://www.cadosecurity.com/blog/spinning-yarn-a-new-linux-malware-campaign-targets-docker-apache-hadoop-redis-and-confluence">Spinning YARN - A New Linux Malware Campaign Targets Docker, Apache Hadoop, Redis and Confluence - Cado Security | Cloud Forensics &amp; Incident Response</a></p><p>The command kill -63 {any_pid} will make the Diamorphine module invisible. In order to investigate how the module does this, the newly developed Linux capability can be used.</p><p>To detonate it as a malware sample, a wrapper script is used:</p><pre>#!/bin/sh<br>insmod diamorphine.ko<br><br>sleep 3<br>lsmod &gt; diamorphine-invisible.txt<br>kill -63 0<br>lsmod &gt; diamorphine-visible.txt</pre><p>The analysis results are provided below for reference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yy0DCVKJ03YwEAcGBmXpvQ.png" /><figcaption><em>Figure 8: Tracee results for Diamorphine showing the </em><em>syscall_hooking detection</em></figcaption></figure><p>The Tracee analysis indicates that syscall hooking was utilised to accomplish process hiding and Diamorphine’s other behaviours.</p><h3>Conclusion</h3><p><strong>strace</strong>, a widely-adopted and industry-standard tool for tracing system calls, and <strong>Tracee</strong>, an eBPF-based detection tool equipped with numerous signatures for identifying suspicious behaviour, have been integrated into CAPEv2 to enhance its Linux sandbox capabilities.</p><p>Testing has demonstrated that these integrations significantly enhance CAPE’s functionality. strace allows for fast and visible filtering and searching of syscall categories, while Tracee identifies suspicious patterns and provides detailed information, including MITRE TTPs.</p><p>These enhancements are expected to benefit CAPEv2 users and malware analysts, equipping defenders with an edge in mitigating malware impacts. Furthermore, increased community efforts are anticipated to further advance Linux sandbox capabilities.</p><p>Future work on these capabilities will focus on stabilizing and increasing the success rate of malware sample detonation, as well as extending support to a broader range of sample types.</p><p>To learn more about CAPEv2 or Tracee, or if you have been inspired to contribute to their projects after reading this, please visit:</p><ul><li><a href="https://github.com/kevoreilly/CAPEv2">GitHub - kevoreilly/CAPEv2: Malware Configuration And Payload Extraction</a></li><li><a href="https://github.com/CAPESandbox/community">GitHub - CAPESandbox/community: Community modules for CAPE Sandbox</a></li><li><a href="https://github.com/aquasecurity/tracee">GitHub - aquasecurity/tracee: Linux Runtime Security and Forensics using eBPF</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fb1fb6cb7c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/csit-tech-blog/building-a-automated-linux-sandbox-for-malware-analysis-6fb1fb6cb7c2">Building a Automated Linux Sandbox for Malware Analysis</a> was originally published in <a href="https://medium.com/csit-tech-blog">CSIT tech blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>