









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Eurecom
Cisco Systems, Inc.
Eurecom
Eurecom
Abstract—For the past two decades, the security community has been fighting malicious programs for Windows-based operat- ing systems. However, the recent surge in adoption of embedded devices and the IoT revolution are rapidly changing the malware landscape. Embedded devices are profoundly different than tradi- tional personal computers. In fact, while personal computers run predominantly on x86-flavored architectures, embedded systems rely on a variety of different architectures. In turn, this aspect causes a large number of these systems to run some variants of the Linux operating system, pushing malicious actors to give birth to “Linux malware.” To the best of our knowledge, there is currently no comprehen- sive study attempting to characterize, analyze, and understand Linux malware. The majority of resources on the topic are available as sparse reports often published as blog posts, while the few systematic studies focused on the analysis of specific families of malware (e.g., the Mirai botnet) mainly by looking at their network-level behavior, thus leaving the main challenges of analyzing Linux malware unaddressed. This work constitutes the first step towards filling this gap. After a systematic exploration of the challenges involved in the process, we present the design and implementation details of the first malware analysis pipeline specifically tailored for Linux malware. We then present the results of the first large- scale measurement study conducted on 10,548 malware samples (collected over a time frame of one year) documenting detailed statistics and insights that can help directing future work in the area.
I. INTRODUCTION The security community has been fighting malware for over two decades. However, despite the significant effort dedicated to this problem by both the academic and indus- try communities, the automated analysis and detection of malicious software remains an open problem. Historically, the vast majority of malware was designed to target almost exclusively personal computers running Microsoft’s Windows operating system, mainly because of its very large market share (currently estimated at 83% [1] for desktop computers). Therefore, the security community has also been focusing its effort on Windows-based malware—resulting in several hundreds of papers and a vast knowledge base on how to detect, analyze, and defend from different classes of malicious programs. However, the recent exponential growth in popularity of embedded devices is causing the malware landscape to rapidly change. Embedded devices have been in use in industrial environments for many years, but it is only recently that they started to permeate every aspect of our society, mainly (but not only) driven by the so-called “Internet of Things” (IoT) revolution. Companies producing these devices are in a con- stant race to increase their market share, thus focusing mainly
on a short time-to-market combined with innovative features to attract new users. Too often, this results in postponing (if not simply ignoring) any security and privacy concerns. With these premises, it does not come as a surprise that the vast majority of these newly interconnected devices are routinely found vulnerable to critical security issues, ranging from Internet-facing insecure logins (e.g., easy-to-guess hard- coded passwords, exposed telnet services, or accessible debug interfaces), to unsafe default configurations and unpatched software containing well-known security vulnerabilities. Embedded devices are profoundly different from traditional personal computers. For example, while personal computers run predominantly on x86 architectures, embedded devices are built upon a variety of other CPU architectures—and often on hardware with limited resources. To support these new systems, developers often adopt Unix-like operating systems, with different flavors of Linux quickly gaining popularity in this sector. Not surprisingly, the astonishing number of poorly secured devices that are now connected to the Internet has recently attracted the attention of malware authors. However, with the exception of few anecdotal proof-of-concept examples, the an- tivirus industry had largely ignored malicious Linux programs, and it is only by the end of 2014 that VirusTotal recognized this as a growing concern for the security community [2]. Academia was even slower to react to this change, and to date it has not given much attention to this emerging threat. In the meantime, available resources are often limited to blog posts (such as the excellent Malware Must Die [3]) that present the, often manually performed, analysis of specific samples. One of the few systematic works in this area is a recent study by Antonakakis et al. [4] that focuses on the network behavior of a specific malware family (the Mirai botnet). However, no comprehensive study has been conducted to characterize, analyze, and understand the characteristics of Linux-based malware.
This work aims at filling this gap by presenting the first large-scale empirical study conducted to characterize and un- derstand Linux-based malware (for both embedded devices and traditional personal computers). We first systematically enumerate the challenges that arise when collecting and ana- lyzing Linux samples. For example, we show how supporting malware analysis for “common” architectures such as x86 and ARM is often insufficient, and we explore several challenges including the analysis of statically linked binaries, the prepa- ration of a suitable execution environment, and the differential
analysis of samples run with different privileges. We also detail Linux-specific techniques that are used to implement different aspects traditionally associated with malicious software, such as anti-analysis tricks, packing and polymorphism, evasion, and attempts to gain persistence on the infected machine. These insights were uncovered thanks to an analysis pipeline we specifically designed to analyze Linux-based malware and the experiments we conducted with over 10K malicious samples. Our results show that Linux malware is already a multi-faced problem. While still not as complex as its Windows coun- terpart, we were able to identify many interesting behaviors— including the ability of certain samples to properly run in mul- tiple operating systems, the use of privilege escalation exploits, or the custom modification of the UPX packer adopted to protect their code. We also found that a considerable fraction of Linux malware interacts with other shell utilities and, despite the lack of available malware analysis sandboxes, that some samples already implement a wide range of VM-detections approaches. Finally, we also performed a differential analysis to study how the malware behavior changes when the same sample is executed with or without root privileges.
In summary, this paper brings the following contributions:
II. CHALLENGES The analysis of generic (and potentially malicious) Linux programs requires tackling a number of specific challenges. This section presents a systematic exploration of the main problems we encountered in our study.
A. Target Diversity
The first problem relates to the broad diversity of the possible target environments. The general belief is that the main challenge is about supporting different architectures (e.g., ARM or MIPS), but this is in fact only one aspect of a much more complex problem. Malware analysis systems for Windows, MacOS, or Android executables can rely on de- tailed information about the underlying execution environment. Linux-based malware can instead target a very diverse set of targets, such as Internet routers, printers, surveillance cameras, smart TVs, or medical devices. This greatly complicates their analysis. In fact, without the proper information about the target (unfortunately, program binaries do not specify where
they were supposed to run) it is very hard to properly configure the right execution environment. Computer Architectures. Linux is known to support tens of different architectures. This requires analysts to prepare different analysis sandboxes and port the different architecture- specific analysis components to support each of them. In a re- cent work covering the Mirai botnet [4], the authors supported three architectures: MIPS 32-bit, ARM 32-bit, and x86 32-bit. However, this covers a small fraction of the overall malware landscape for Linux. For instance, these three architectures together only cover about 32% of our dataset. Moreover, some families (such as ARM) are particularly challenging to support because of the large number of different CPU architectures they contain. Loaders and Libraries. The ELF file format allows a Linux program to specify an arbitrary loader, which is responsible to load and prepare the executable in memory. Unfortunately, a copy of the requested loader may not be present in the analysis environment, thus preventing the sample from starting its execution. Moreover, dynamically linked binaries expect their required libraries to be available in the target system: once again, it is enough for a single library to be missing to prevent the successful execution of the program. Contrary to what one would expect, in the context of this work these aspects affect a significant portion of our dataset. A common example are Linux programs that are dynamically linked with uClibc or musl, smaller and more performant alternatives to the traditional glibc. Not only does an analysis environment need to have these alternatives installed, but their corresponding loaders are also required. Operating System. This work focuses on Linux binaries. However, and quite unexpectedly, it can be challenging to discern ELF programs compiled for Linux from other ELF- compatible operating systems, such as FreeBSD or Android. The ELF headers include an “OS/ABI” field that, in principle, should specify which operating system is required for the program to run. In practice, this is rarely informative. For example, ELF binaries for both Linux and Android specify a generic “System V” OS/ABI. Moreover, current Linux kernels seem to ignore this field, and it is possible for a binary that specifies “FreeBSD” as its OS/ABI to be a valid Linux program, a trick that was abused by one of the malware sample we encountered in our experiments. Finally, while a binary compiled for FreeBSD can be properly loaded and executed under Linux, this is only the case for dynamically linked pro- grams. In fact, the syscalls numbers and arguments for Linux and FreeBSD do not generally match, and therefore statically linked programs usually crash when they encounter such a difference. These differences may also exist between different versions of the Linux kernel, and custom modifications are not too rare in the world of embedded devices. This has two important consequences for our work: On the one hand, it makes it hard to compile a dataset of Linux-based malware. On the other hand, this also results in the fact that even well- formed Linux binaries may not be guaranteed to run correctly
File & Metadata Analysis
AVClass
ELF Anomaly
File Recognition
Static Analysis
Packing Identification
Code Analysis
Dynamic Analysis
Emulation
Packer Analysis
Trace Analysis Sandbox Preparation
Fig. 1. Overview of our analysis pipeline.
between November 2016 and November 2017. Based on the content of the reports, we downloaded 200 candidate samples per day. Our selection criteria were designed to minimize non- Linux binaries and to select at least one sample for each family observed during the day. We also split our selection in two groups: 140 samples taken from those with more than five AV positive matches, and 60 samples with an AV score between one and five.
B. File & Metadata Analysis
The first phase of our analysis focuses on the file itself. Certain fields contained in the ELF file format are required at runtime by the operating system, and therefore need to provide reliable information about the architecture on which the application is supposed to run and the type of code (e.g., executable or shared object) contained in the file. We implemented our custom parser for the ELF format because the existing ones (as explained in Section V-A) were often unable to cope with malformed fields, unexpected values, or missing information. We use the data extracted from each file for two purposes. First, to filter out files that were not relevant for our analysis. For instance, shared libraries, core dumps, corrupted files, or executables designed for other operating systems (e.g., when a sample imported an Android library). Second, we use the information to identify any anomalous file structure that, while not preventing the sample to run, could still be used as anti- analysis routine and prevent existing tools to correctly process the file (see Section V-A for more details about our findings). Finally, as part of this first phase of our pipeline, we also extract from the VirusTotal reports the AV labels for each sample and fed them to the AVClass tool to obtain a normalized name for the malware family. AVClass, recently proposed by Sebasti´an et al. [5], implements a state-of-the-art technique to normalize, remove generic tokens, and detect aliases among a set of AV labels assigned to a malware sample. Therefore, whenever it is able to output a name, it means that there was a general consensus among different antivirus on the class (family) the malware belongs to.
C. Static Analysis
Our static analysis phase includes two tasks: binary code analysis and packing detection. The first task relied on a
number of custom IDA Pro scripts to extract several code metrics—including the number of functions, their size and cyclomatic complexity, their overall coverage (i.e., the fractions of the .text section and PT_LOAD segments covered by the recognized functions), the presence of overlapping instructions and other assembly tricks, the direct invocation of system calls, and the number of direct/indirect branch instructions. In this phase we also computed aggregated metrics, such as the distribution of opcodes, or a rolling entropy of the different code and data sections. This information is used for statistical purposes, but also integrated in other analysis components, for instance to identify anti-analysis behaviors or packed samples. The second task of the static analysis phase consists of combining the information extracted so far from the ELF headers and the binary code analysis to identify likely packed applications (see Section V-E for more details). Binaries that could be statically unpacked (e.g., in the common case of UPX) were processed at this stage and the result fed back to be statically analyzed again. Samples that we could not unpack statically were marked in the database for a subsequent more fine-grained dynamic attempt.
D. Dynamic Analysis We performed two types of dynamic analysis in our study: a five-minute execution inside an instrumented emulator, and a custom packing analysis and unpacking attempt. For the emulation, we implemented two types of dynamic sandboxes: a KVM-based virtualized sandbox with hardware support for x86 and x86-64 architectures, and a set of QEMU-based emulated sandboxes for ARM 32-bit little-endian, MIPS 32- bit big-endian, and PowerPC 32-bit. These five sandboxes were nested inside an outer VM dedicated to dispatch each sample depending on its architecture. Our system also main- tained several snapshots of all VMs, each corresponding to a different configurations to choose from (e.g., execution under user or root accounts and glibc or uClibc setup). All VMs were equipped with additional libraries, the list of which was collected during the static analysis phase, as well as popular loaders (such as the uClibc commonly used in embedded systems). For the instrumentation we relied on SystemTap [8] to implement kernel probes (kprobes) and user probes (uprobes).
While, according to its documentation, SystemTap should be supported on a variety of different architectures (such as x86, x86-64, ARM, aarch64, MIPS, and PowerPC), in practice we needed to patch its code to support ARM and MIPS with o32 ABI. Our patches include fixes on syscall numbers, CPU registers naming and offsets, and the routines required to extract the syscall arguments from the stack. We designed our SystemTap probes to collect every system call, along with its arguments and return value, and the instruction pointer from which the syscall was invoked. We also recompiled the glibc to add uprobes designed to collect, when possible, additional information on string and memory manipulation functions.
At the end of the execution, each sandbox returns a text file containing the full trace of system calls and userspace functions. This trace is then immediately parsed to identify useful feedback information for the sandbox. For example, this preliminary analysis can identify missing components (such as libraries and loaders) or detect if a sample tested its user per- missions or attempted to perform an action that failed because of insufficient permissions. In this case, our system would immediately repeat the execution of the sample, this time with root privileges. As explained in Section V-D, we later compare the two traces collected with different users as part of our differential analysis to identify how the sample behavior was affected by the privilege level. Finally, the preliminary trace analysis can also report to the analyst any error that prevented the sample to run in our system. As an example of these warnings, we encountered a number of ARM samples that crashed because of a four-byte misalignment between the physical and virtual address of their LOAD segments. These samples were probably designed to infect an ARM- based system whose kernel would memory map segments by considering their physical address, something that does not happen in common desktop Linux distributions. We extended our system with a component designed to identify these cases by looking at the ELF headers and fix the data alignment before passing them to the dynamic analysis stage.
To avoid hindering the execution and miss important code paths, we gave samples partial network access, while mon- itoring the traffic for signs of abuse. Although not an ideal solution, a similar approach has been previously adopted in other behavioral analysis experiments [4], [9] as it is the only way to observe the full behavior of a sample.
Our system also record PCAP files of the network traffic, due to space limitations we will not discuss their analysis as this is the only aspect of Linux-based malware that was already partially studied in previous works [4]. Finally, to dynamically unpack unknown UPX variants we developed a tool based on Unicorn [10]. The system emulates instructions on multiple architectures and behaves like a tiny kernel that exports the limited set of system calls used by UPX during unpacking (supporting a combination of different system call tables and system call ABIs). As we explain in Section V-E, this approach allowed us to automatically unpack all but three malware samples in our dataset.
TABLE I DISTRIBUTION OF THE 10,548 DOWNLOADED SAMPLES ACROSS ARCHITECTURES
Architecture Samples Percentage X86-64 3018 28.61% MIPS I 2120 20.10% PowerPC 1569 14.87% Motorola 68000 1216 11.53% Sparc 1170 11.09% Intel 80386 720 6.83% ARM 32-bit 555 5.26% Hitachi SH 130 1.23% AArch64 (ARM 64-bit) 47 0.45% others 3 0.03%
Our final dataset, after the filtering stage, consisted of 10, ELF executables, covering more than ten different architectures (see Table I for a breakdown of the collected samples). Note again how the distribution differs from other datasets collected only by using honeypots: x86, ARM 32-bit, and MIPS 32-bit covered 75% of the data used by Antonakakis et al. [4] on the Mirai botnet, but only account for 32% of our samples. We report detailed statistics about the distribution of samples in our dataset in Appendix. Here we just want to focus on their broad variety and on the large differences that exist among all features we extracted in our database. For example, our set of Linux-based malware vary considerably in size, from a minimum of 134 bytes (a simple backdoor) to a maximum of 14.8 megabytes (a botnet coded in Go). IDA Pro was able to recognize (in dynamically linked binaries) from a minimum of zero (in two samples) to a maximum of 5685 unique functions. Moreover, we extracted from the ELF header of dynamically linked malware the symbols imported from external libraries—which can give an idea of the most commonly used functionalities. Most samples import between 10 and 100 symbols. Interestingly, there are more than 10% of the samples that use malloc but never use free. And while socket is one of the most common functions (confirming the importance that interconnected devices have nowadays) less than 50% of the binaries requests file-based routines (such as fopen). Finally, entropy plays an important role to identify potential packers or encrypted binary blobs. The vast majority of the binaries in our dataset has entropy around six, a common value for compiled but not packed code. However, one sample had entropy of only 0.98, due to large blocks of null bytes inserted in the data segment.
A. Malware Families The AVClass tool was able to associate a family (108 in total) to 83% of the samples in our dataset. As expected, bot- nets, often dedicated to run DDoS attacks, dominate the Linux- based malware landscape—accounting for 69% of our samples spread over more than 25 families. One of the reasons for this prevalence is that attackers often harvest poorly protected IoT devices to join large remotely controlled botnets. This task is
of section entries) fields in the ELF header. We also found evidence of samples exploiting the ELF header file format to create overlapping segments header. For instance, three samples belonging to the Mumblehard family declared a single segment starting from the 44th^ byte of the ELF header itself and zeroed out any field unused at runtime. Table II summarizes the most common ELF manipulation tricks we observed in our dataset.
Impact on Userspace Tools. To measure the consequences of the previously discussed transformations, in Table III we report how popular tools (used to work with ELF files) react to unusual or malformed files. This includes readelf (part of GNU Binutils), pyelftools (a convenient Python library to parse and analyze ELF files), GDB (the de-facto standard debugger on Linux and many UNIX-like systems), and IDA Pro 7 (the latest version, at the time of writing, of the most popular commercial disassembler, decompiler, and reverse engineering tool). Our results show that all tools are able to properly process anomalous files, but unfortunately often result in errors when dealing with invalid fields. For example, readelf complained for the absence of a valid table on hundreds of sample, but was able to complete the parsing of the remaining fields in the ELF header. On the other side, pyelftools denies further analysis if the section header table is corrupted, while it can instead parse ELF files if the table is declared as empty. Because of this poor management of erroneous conditions, for our experiments we decided to write our own custom ELF parser, which was specifically designed to work in presence of unusual settings, inconsistencies, invalid values, or malformed header information. Despite its widespread use in the *nix world, GDB showed a severe lack of resilience in dealing with corrupted information coming from a malformed section header table. The presence of an invalid value results in GDB not being able to recognize the ELF binary and in its inability to start the program. Finally, IDA Pro 7 was the only tool we used in our analysis pipeline that was able to handle correctly the presence of any corrupted section information or other fields that would not affect the program execution.
B. Persistence
Persistence involves a configuration change of the infected system such that the malicious executable will be able to run regardless of possible reboot and power-off operations performed on the underlying machine. This, along with the ability to remain hidden, is one of the first objectives of malicious code. A broad and well-documented set of techniques exists for malware authors to achieve persistence on Microsoft Windows platforms. The vast majority of these techniques relies on the modification of Registry keys to run software at boot, when a user logs in, when certain events occurs, or to schedule particular services. Linux-based malware needs to rely on different strategies, which are so far more limited both in number and in nature. We group the techniques that we observed in our dataset in four categories, described next.
TABLE IV ELF BINARIES ADOPTING PERSISTENCE STRATEGIES
Path Samples w/o root w/ root /etc/rc.d/rc.local - 1393 /etc/rc.conf - 1236 /etc/init.d/ - 210 /etc/rcX.d/ - 212 /etc/rc.local - 11 systemd service - 2 ˜/.bashrc 19 8 ˜/.bash_profile 18 8 X desktop autostart 3 1 /etc/cron.hourly/ - 70 /etc/crontab - 70 /etc/cron.daily/ - 26 crontab utility 6 6 File replacement - 110 File infection 5 26 Total 1644 (21.10%)
Subsystems Initialization. This appears to be the most com- mon approach adopted by malware authors and takes advantage of the well known Linux init system. Table IV shows that more than 1000 samples attempted to modify the system rc script (executed at the end of each run-level). Instead, 210 samples added themselves under the /etc/init.d/ folder and then created soft-links to directories holding run-level configurations. Overall, we found 212 binaries displacing links from /etc/rc1.d to /etc.rc5.d, with 16 of them using the less common run-levels dedicated to machine halt and reboot operations. Note how malicious programs still largely rely on the System-V init system and only two samples in our dataset supported more recent initialization technologies (e.g., systemd). More important, this type of persistence only works if the running process has privileged permissions. If the user executing the ELF is not root or a user under privileged policies, it is usually impossible to modify services and initialization configurations. Time-based Execution. This technique is the second choice commonly used by malware and relies on the presence of cron, the time-based job scheduler for Unix systems. Malicious ELF files try to modify, with success when running under adequate higher privileges, cron configuration files to get scheduled ex- ecution at a fixed time interval. As for subsystem initialization, time-based persistence will not work if the malware is launched by unprivileged users unless the sample invokes the system utility crontab (a SUID program specifically designed to mod- ify configuration files stored under /var/spool/cron/). File Infection and Replacement. Another approach for mal- ware to maintain a foothold in the system is by replacing (or infecting) applications that already exist in the target. This includes both a traditional virus-like behavior (where the malware locates and infect other ELF files without a strategy) as well as more targeted approaches that subvert the original functionalities of specific system tools.
TABLE V ELF PROGRAMS RENAMING THE PROCESS
Process name Samples Percentage sshd 406 5.21% telnetd 33 0.42% cron 31 0.40% sh 14 0.18% busybox 11 0.14% other tools 22 0.28% empty 2034 26.11% other *^973 12.49% random 618 7.93% Total 4091 52.50%
Our dynamically analysis reports allow us to observe infec- tion and replacement of system and user files. Examples in this category are samples in the family EbolaChan, which inject their code at the beginning of the ls tool and append the origi- nal code after the malicious data. Another example are samples of the RST, Sickabs and Diesel families, which still use a 20 years old ELF infections techniques [13]. The first group limits the infection to other ELF files located in the current working directory, while the second adopts a system-wide infection that also targets binaries in the /bin/ folder. Interestingly, samples of this family were first observed in 2001, according to a Sophos report they were still widespread in 2008 [14], and our study shows that they are still surprisingly active today. A different approach is taken by samples in the Gates family, which fully replace system tools in /bin/ or /usr/bin/ folders (e.g., ps and netstat) after creating a backup copy of the original code in /usr/bin/dpkgd/.
User Files Alteration. As shown in the middle part of Table IV, very few samples modify configuration files in the user home directory such as shell configurations. Malware writers adopting this method can ensure persistence at user level, but other Linux users, beside the infected one, will not be affected by this persistence mechanism. While the most common, changes to the shell configuration are not the only form of per-user persistency. Few samples (such as those in the Handofthief family) that target desktop Linux installations, modified instead the .desktop startup files used by the windows manager. Table IV reports a summary of the amount of samples using each technique. Surprisingly, only 21% of our ELF files imple- mented at least one persistence strategy. However, samples that do try to be persistent often try multiple techniques in a row to reach their objective. As an example, in our experiments we noticed that user files alteration was a common fallback mechanism when the sample failed to achieve system-wide persistency.
C. Deception
Stealthy malware may try to hide their nature by assuming names that look genuine and innocuous at a first glance, with the objective of tricking the user to open an apparently benign
TABLE VI ELF SAMPLES GETTING PRIVILEGES ERRORS OR PROBING IDENTITIES
Motivation Samples Percentage EPERM error 986 12.65% EACCES error 716 9.19% Query user identity *^1609 20.65% Query group identity *^877 11.26% Total 2637 33.84%
TABLE VII BEHAVIORAL DIFFERENCES BETWEEN USER/ROOT ANALYSIS
Different behavior Samples Percentage Execute privileged shell command 579 21.96% Drop a file into a protected directory 426 16.15% Achieve system-wide persistence 259 9.82% Tamper with Sandbox 61 2.31% Delete a protected file 47 1.78% Run ptrace request on another process 10 0.38%
program, or avoid showing unusual names in the list of running processes. Overall, we noted that this behavior, already common on Windows operating systems, is also widespread on Linux- based malware. Table V shows that over 50% of the samples assumed different names once in memory, and also reports the top benign application that are impersonated. In total we counted more than 4K samples invoking the system call prctl with request PR_SET_NAME, or simply modifying the first command line argument of the program (the program name). Out of those, 11% adopted names taken from common utilities. For example, samples belonging to the Gafgyt family often disguise as sshd or telnetd. It is also interesting to discuss the difference between the two renaming techniques. The first (based on the prctl call) results in a different process name listed in /proc/
D. Required Privileges Our tests show that the distinction between administrator (root) and normal user is very important for Linux-based malware. First, malicious samples can perform different actions and show a different behavior when they are executed with super-user privileges. Second, especially when targeting low-
TABLE IX TOP TEN COMMON SHELL COMMANDS EXECUTED
Shell command Samples Percentage sh 400 5.13% sed 243 3.12% cp 223 2.86% rm 216 2.77% grep 214 2.75% ps 131 1.68% insmod 124 1.59% chmod 113 1.45% cat 93 1.19% iptables 84 1.08%
UPX unpacking tool. This includes a modification to the magic number (so that the file does not appear to be packed with UPX anymore), the modification of UPX strings, and the insertion of junk bytes (to break the UPX utility). However, all these samples share the same underlying packing structure and the same compression algorithm—showing that malware writers simply applied “cosmetic” variations to the open source UPX code.
Custom packers. Linux does not count on a large variety of publicly available packers and UPX is usually the main choice. However, we detected three samples (all belonging to the Mumblehard family) that implemented some form of custom packing, where a single unpacking routine is executed before transferring the control to the unpacked program [23]. In one case, the malware started a separate process running a perl interpreter and then used the main process to decrypt instructions and feed them into the interpreter.
F. Process Interaction
This section covers the techniques used by Linux malware to interact with child processes or other binaries already installed or running in the system.
Multiple Processes. 25% of our samples consists of a single process, 9% spawn a new process, 43% involves three pro- cesses in total (largely due to the “double-fork” pattern used to daemonize a program), while the remaining 23% created a higher number of separate processes (up to 1684). Among the samples that spawn multiple processes we find many popular botnets such as Gafgyt, Tsunami, Mirai, and XorDDos. For instance, Gafgyt creates a new process for every attempt to connect to its command and control (C&C) server. XorDDos, instead, creates parallel DDos attack processes.
Shell Commands. 13% of the samples we analyzed inside our sandbox executed at least one external shell command. In total, we registered the execution of 93 unique command- line tools—the most prevalent of which are summarized in Table IX. Commands such as sed, cp, and chmod are often executed to achieve persistence on the target system, while rm is used to unlink the sample itself or to delete the bash history file. Several malware families also try to kill previous infections of the same malware. Hijami, the counter-malware
TABLE X TOP TEN PROC FILE SYSTEM ACCESSES BY MALICIOUS SAMPLES
Path Samples Percentage /proc/net/route 3368 43.22% /proc/filesystems 649 8.33% /proc/stat 515 6.61% /proc/net/tcp 498 6.39% /proc/meminfo 354 4.54% /proc/net/dev 346 4.44% /proc/
to “vaccinate” Mirai, uses iptables to close and open network ports, while Mirai tries to close vulnerable ports already used to infect the system. Process Injection An attacker may want to inject new code into a running process to change its behavior, make the sample more difficult to debug, or to hook interesting functions in order to steal information. Our system monitors three different techniques a process can use to write to the memory of another program: 1) a ptrace syscall that requests the PTRACE_POKETEXT, PTRACE_POKEDATA, or PTRACE_POKEUSER functionali- ties; 2) a PTRACE_ATTACH request followed by read/write operations to /proc/<TARGET_PID>/mem; and 3) an in- vocation to the process_vm_writev system call. It is important to mention that the Linux kernel has been hardened against ptrace calls in 2010. Since then it is not possible to use ptrace on processes that are not direct descendant of the tracer process, unless the unprivileged user is granted the CAP_SYS_PTRACE capability. The same capabil- ity is required to execute the process_vm_writev call, a new system call introduced in 2012 with kernel 3.2 to directly transfer data between the address spaces of two processes. We found a sample performing injection by using the first technique mentioned above. It injects a dynamic li- brary in every active process that uses libc (but ex- cludes gnome-session, dbus and pulseaudio). In the injected payload the malware uses the libc function __libc_dlopen_mode to load dynamic objects at run- time. This function is similar to the well-known dlopen, which is less preferable because implemented in libdl, not already included in the libc. After the new code is mapped in memory, the malware issues ptrace requests to backup the registers values of the victim process, hijack the control flow to execute its malicious behavior, and restore the original execution context. G. Information Gathering Information gathering is an important step of malware execution as the collected information can be used to detect the presence of a sandbox, or to control the execution of the sample. Data stored on the system can also be exfiltrated to a remote location, as it often happens with programs controlled
TABLE XI TOP TEN SYSFS FILE SYSTEM ACCESSES BY MALICIOUS SAMPLES
Path Samples Percentage /sys/devices/system/cpu/online 338 4.34% /sys/devices/system/node/node0/meminfo 26 0.33% /sys/module/x tables/initstate 22 0.28% /sys/module/ip tables/initstate 22 0.28% /sys/class/dmi/id/sys vendor 18 0.23% /sys/class/dmi/id/product name 18 0.23% /sys/class/net/
TABLE XII TOP TEN ACCESSES ON /E T C/ BY MALICIOUS SAMPLES
Path Samples Percentage /etc/rc.d/rc.local 1393 17.88% /etc/rc.conf 1236 15.86% /etc/resolv.conf 641 8.23% /etc/nsswitch.conf 453 5.81% /etc/hosts 423 5.43% /etc/passwd 244 3.13% /etc/host.conf 201 2.58% /etc/rc.local 170 2.18% /etc/localtime 165 2.12% /etc/cron.deny 101 1.30%
by a C&C server. In this section we look at which portions of the file system are inspected by malware and discuss security- relevant paths analysts should monitor when inspecting new malware strains.
Proc and Sysfs File Systems. The proc and sysfs virtual file systems contain, respectively, runtime system informa- tion on processes, system and hardware configurations, and information on the kernel subsystems, hardware devices, and kernel drivers. We divide the type of information collected by malware samples in three macro categories: system con- figuration, processes information, and network configuration. The network category is the most common in our dataset with more than 3000 samples, as shown in Table X, which accessed /proc/net/route (system routing table) to get the list of active network interfaces with their relative configuration. Additional information is extracted from /proc/net/tcp (active TCP sockets) and /proc/net/dev (sent and re- ceived packets). Moreover, 111 samples in our dataset read /proc/net/arp to retrieve the system ARP table. For the sysfs counterpart, reported in Table XI, we found accesses to /sys/class/net/ to get the transmission queue length, a relevant information for DDoS attacks. The system configuration category is the second most com- mon, with hundreds of samples that extracted the amount of installed memory, the number of available CPU cores, and other CPU characteristics. The files used for sandbox detection and evasion also fall into this category (see Subsection V-H) as well as the lists of USB and PCI connected devices. This category also includes accesses to /proc/cmdline to
TABLE XIII ELF PROGRAMS SHOWING EVASIVE FEATURES
Type of evasion Samples Percentage Sandbox detection 19 0.24% Processes enumeration *^259 3.32% Anti-debugging 63 0.81% Anti-execution 3 0.04% Stalling code 0 -
TABLE XIV FILE SYSTEM PATHS LEADING TO SANDBOX DETECTION
Path Detected Environments # /sys/class/dmi/id/product name VMware/VirtualBox 18 /sys/class/dmi/id/sys vendor QEMU 18 /proc/cpuinfo CPU model/hypervisor flag 1 /proc/sysinfo KVM 1 /proc/scsi/scsi VMware/VirtualBox 1 /proc/vz and /proc/bc OpenVZ container 1 /proc/xen/capabilities XEN hypervisor 1 /proc/
retrieve the name of the running kernel image. Another common type of information gathering focuses on processes enumeration. This is used to prevent multiple executions of the same malware (e.g., by the Mirai family), or to identify other relevant programs running on the target machine. As reported in Table IX, we found 131 samples executing the shell command ps, used as a fast interface to get the list of running processes. For example, 67 samples of the BitcoinMiner family invoke ps and then try to kill other crypto-miner processes that may interfere with their malicious activity. Configuration Files. System configuration files are contained in the /etc/ folder. As reported in Table XII, configuration files required to achieve persistence are the ones accessed more often. Network-related configuration files also appear to be popular, with /etc/resolv.conf (the DNS resolver) or /etc/hosts (the mapping between hosts and IP addresses). Among the top entries we also find /etc/passwd (list of registered accounts). For instance, Flooder samples use it to check for the presence of a backdoor account on the system. If not found, they add a new user by directly writing to /etc/passwd and /etc/shadow.
H. Evasion The purpose of evasion is to hide the malicious behavior and remain undetected as long as possible. This typically requires the sample to detect the presence of analysis tools, or to distin- guish whether it is running within an analysis environment or on a real target device. We now present more details about the different evasion techniques, whose prevalence in our dataset is summarized in Table XIII. Sandbox Detection. Our string comparison instrumentation detected a number of programs that attempted to detect the presence of a sandbox by comparing different pieces of
different libraries, the distribution has a very long tail and it drops very steeply. For instance, the tenth most popular library is only used by 1% of the samples.
VI. INTRA-FAMILY VARIETY In the previous section we described several characteristics of Linux-based malware. For each of them, we presented the number of samples instead of the count of families that exhibited a given trait. This is because we noted that samples belonging to the same family often had very different charac- teristics, probably due to the availability of the source codes for several classes of Linux malware. As an example of this variety, we want to discuss the case of a popular malware family, Tsunami, for which we have 743 samples in our dataset. Those samples are compiled for nine different architectures, the most common being x86-64, and the rarest being Hitachi SuperH. In total, 86% of them are statically linked and 13% are stripped. Dynamically linked Tsunami samples rely on different loaders, and their entropy varies from 1.85 to 7.99. Out of the 19 samples with higher entropy, one is packed with vanilla UPX while the other 18 use modified versions of the same algorithm. This variability is not limited to static features. For instance, looking at our dynamic traces we noted the use of different persistence techniques with some samples only relying on user-level approached and other using run-level scripts or cron jobs for system-wide persistence. Concerning unprivileged and privileged execution, only 15% of the Tsunami samples we analyzed in our sandboxes tested the user privileges or got privileges-related errors. Differences arise even in terms of evasion: 17 samples contain code to evade the sandbox while all the others did not include evasive functionalities.
VII. RELATED WORK In the past two decades the security community has focused almost exclusively on fighting malware targeting Microsoft Windows. As a result, hundreds of papers have described techniques to analyze PE binaries [25]–[28], detecting ongoing threats [27], [29], [30], and preventing possible infection at- tempts [31]–[33] on Windows operating systems. The commu- nity also developed many analysis tools for dissecting threats related to the Windows environment, ranging from dynamic analysis solutions [34]–[37] to dissectors for file formats used as attack vectors [38]–[40]. With the exception of mobile malware, non-Windows ma- licious software did not receive the same level of atten- tion. While the hacking community developed—almost two decades ago—interesting techniques to implement malicious ELF files [13], [41]–[44], rootkits [45], [46], and tools to dissect them [47]–[49], none of them has seen vast adoption. In fact, the security industry has only recently started looking at ELF files—mainly driven by newsworthy cases like the Mirai botnet [50] and Shellshock [51]. Many blog posts and papers were published for the analysis and dissection of spe- cific families [52]–[57], but these investigations were mainly conducted by manual reverse engineering. Recent research by
Shazhad et al. [58] and by Bai et al. [59] extracts static features from ELF binaries to train a classifier for malware detection. Unfortunately, these works are not comprehensive, do not take into account different architectures, or are easily evaded by stripping a binary or by using packing. Researchers have also started to explore dynamic analysis for non-Windows malware only very recently. The few solu- tions that are available at the moment support a limited number of platforms or provide very limited analysis capabilities. For example, Limon [60] is an analysis sandbox based on strace (and thus easily detectable), and it only supports the analysis of x86-flavored binaries. Sysdig [61] and PayloadSecurity [62] are affected by similar issues and they also only work for x86 binaries. Detux [63], instead, supports four different architectures (i.e., x86, x86-64, ARM, and MIPS). However, it only performs a very basic analysis by running readelf and provides network dumps. Cuckoo sandbox [64] is another available tool that supports the analysis of Linux samples. However, the Cuckoo project only provides the external orches- tration analysis framework, while the preparation of the various sandbox images is left to the user. Last, in November 2017 VirusTotal announced the integration of the Tencent HABO sandbox solution, which reportedly is able to analyze also Linux-based malware [9]. Unfortunately, there is no public report on how the system works and it currently works only for x86 binaries. One of the first systematic studies of IoT malware was done by Pa et al. [65]. In their paper, they present a Telnet honeypot to measure the current attack trends as well as the first sandbox environment based on Qemu and OpenWRT called IoTBOX for analyzing IoT malware. They showed the issue of IoT devices exposing Telnet online and they collected few families actively targeting this service. Similarly, Antonakakis et al. [4] studied in detail a specific Linux malware family, the Mirai botnet. They measure systematically the evolution and growth of the botnet mainly from the network point of view. These works are invaluable to the community, but only look at limited aspects of the entire picture: the samples network behavior. We believe that our work can complement these efforts and provide a clearer overview of how Linux malware actually works. Moreover, the datasets used in these previous studies are not representative of the overall Linux malware, since they were collected via telnet-based honeypots.
VIII. CONCLUSIONS This paper presents the first comprehensive study of Linux- based malware. We document the design and implementation of the first analysis pipeline specifically tailored for Linux malware, and we discuss the results of the first large-scale em- pirical study on how Linux malware implements its malicious behavior. While the complexity of current Linux malware is not very high, we have identified a number of samples already adopting techniques borrowed from their Windows counter- parts. We believe these insights can be the foundation for more systematic future works in the area, which is, unfortunately, bound to have an ever-increasing importance.
[1] StatCounter, “Desktop Operating System Market Share Worldwide.” http://gs.statcounter.com/os-market-share/desktop/worldwide. [2] ZDnet, “Google’s VirusTotal puts Linux malware under the spotlight.” http://www.zdnet.com/article/ googles-virustotal-puts-linux-malware-under-the-spotlight/. [3] “Malware Must Die!.” http://blog.malwaremustdie.org/. [4] Antonakakis et al., “Understanding the Mirai Botnet,” in Proceedings of the USENIX Security Symposium, 2017. [5] M. Sebasti´an, R. Rivera, P. Kotzias, and J. Caballero, “AVclass: A Tool for Massive Malware Labeling,” in RAID, 2016. [6] “radare2, a portable reversing framework.” http://www.radare.org/. [7] D. Andriesse, A. Slowinska, and H. Bos, “Compiler-Agnostic Function Detection in Binaries,” in IEEE European Symposium on Security and Privacy, 2017. [8] “SystemTap.” https://sourceware.org/systemtap/. [9] “Malware analysis sandbox aggregation: Welcome Tencent HABO.” http: //blog.virustotal.com/2017/11/malware-analysis-sandbox-aggregation. html. [10] Nguyen Anh Quynh, “Unicorn Emulator.” https://github.com/ unicorn-engine/unicorn. [11] “Shodan, the world’s first search engine for Internet-connected devices.” https://www.shodan.io/. [12] Z. Durumeric, E. Wustrow, and A. Halderman, “ZMap: Fast Internet- wide Scanning and Its Security Applications,” in Proceedings of the USENIX Security Symposium, 2013. [13] Silvio Cesare, “Unix ELF parasites and virus.” http://vxer.org/lib/vsc01. html. [14] SophosLabs, “Botnets, a free tool and 6 years of Linux/Rst-B.” https://nakedsecurity.sophos.com/2008/02/13/ botnets-a-free-tool-and-6-years-of-linuxrst-b. [15] Team TESO, “Burneye ELF encryption program.” https: //packetstormsecurity.com/files/30648/burneye-1.0.1-src.tar.bz2.html. [16] elfmaster, “ELF Packer v0.3.” http://www.bitlackeys.org/projects/ elfpacker.tgz. [17] grugq and scut, “Armouring the ELF: Binary encryption on the UNIX platform.” http://phrack.org/issues/58/5.html. [18] R. Lyda and J. Hamrock, “Using entropy analysis to find encrypted and packed malware,” IEEE Security & Privacy, vol. 5, no. 2, 2007. [19] X. Ugarte-Pedrero, D. Balzarotti, I. Santos, and P. G. Bringas, “RAMBO: Run-time packer Analysis with Multiple Branch Observation,” July 2016. [20] S. Cesare and Y. Xiang, “Classification of malware using structured control flow,” in Proceedings of the Eighth Australasian Symposium on Parallel and Distributed Computing-Volume 107, pp. 61–70, Australian Computer Society, Inc., 2010. [21] R. Perdisci, A. Lanzi, and W. Lee, “Mcboost: Boosting scalability in malware collection and analysis using statistical classification of exe- cutables,” in Computer Security Applications Conference, 2008. ACSAC
[26] Ferrie, Peter and Peter, Szr, “Hunting for metamorphic.” http://vxer.org/ lib/apf39.html. [27] M. Christodorescu, S. Jha, S. A. Seshia, D. Song, and R. E. Bryant, “Semantics-aware malware detection,” in Proceedings of the 2005 IEEE Symposium on Security and Privacy, SP ’05, 2005. [28] C. Kruegel, W. Robertson, F. Valeur, and G. Vigna, “Static disassembly of obfuscated binaries,” [29] S. J. Stolfo, K. Wang, and W.-J. Li, “Fileprint analysis for malware detection,” ACM CCS WORM, 2005. [30] D. Dagon, X. Qin, G. Gu, W. Lee, J. Grizzard, J. Levine, and H. Owen, “Honeystat: Local worm detection using honeypots,” in RAID, vol. 4, pp. 39–58, Springer, 2004.
[31] P. Mell, K. Kent, and J. Nusbaum, Guide to malware incident prevention and handling. US Department of Commerce, Technology Administra- tion, National Institute of Standards and Technology, 2005. [32] D. Harley, U. E. Gattiker, and R. Slade, Viruses revealed. McGraw-Hill Professional, 2001. [33] M. E. Locasto, K. Wang, A. D. Keromytis, and S. J. Stolfo, “Flips: Hybrid adaptive intrusion prevention,” in RAID, pp. 82–101, Springer,
[34] “malwr.” https://www.malwr.com/. [35] “CWsandbox.” http://www.mwanalysis.org. [36] “Anubis.” https://anubis.iseclab.org. [37] “VirusTotal += Behavioural Information.” http://blog.virustotal.com/ 2012/07/virustotal-behavioural-information.html. [38] “oletools - python tools to analyze OLE and MS Office files.” https: //www.decalage.info/python/oletools. [39] “peepdf - PDF Analysis Tool.” http://eternal-todo.com/tools/ peepdf-pdf-analysis-tool. [40] “oledump-py.” https://blog.didierstevens.com/programs/oledump-py/. [41] Silvio Cesare, “Shared Library Redirection via ELF PLT Infection.” http: //www.phrack.org/issues/56/7.html#article. [42] Silvio Cesare, “Runtime kernel kmem patching.” https://github. com/BuddhaLabs/PacketStorm-Exploits/blob/master/9901-exploits/ runtime-kernel-kmem-patching.txt. [43] Z0mbie, “Injected Evil.” http://z0mbie.daemonlab.org/infelf.html. [44] Alexander Bartolich, “The ELF Virus Writing HOWTO.” http://www.linuxsecurity.com/resource files/documentation/ virus-writing-HOWTO/ html/index.html. [45] darkangel, “Mood-NT.” http://darkangel.antifork.org/codes/mood-nt.tgz. [46] sd and devik, “Linux on-the-fly kernel patching without LKM.” http: //phrack.org/issues/58/7.html. [47] Mayhem, “The Cerberus ELF Interface.” http://phrack.org/issues/61/8. html. [48] elfmaster, “ftrace.” https://github.com/elfmaster/ftrace. [49] elfmaster, “ECFS.” https://github.com/elfmaster/ecfs. [50] Nicky Woolf, “DDoS attack that disrupted internet was largest of its kind in history, experts say.” https://www.theguardian.com/technology/ 2016/oct/26/ddos-attack-dyn-mirai-botnet. [51] Dave Lee, “Shellshock: ’Deadly serious’ new vulnerability found.” http: //www.bbc.com/news/technology-29361794. [52] Cathal, Mullaney and Sayali, Kulkarni, “VB2014 paper: Linux- based Apache malware infections: biting the hand that serves us all.” https://www.virusbulletin.com/virusbulletin/2016/01/ paper-linux-based-apache-malware-infections-biting-hand-serves-us-all/. [53] MMD, “MMD-0062-2017 - Credential harvesting by SSH Direct TCP Forward attack via IoT botnet.” http://blog.malwaremustdie.org/2017/02/ mmd-0062-2017-ssh-direct-tcp-forward-attack.html. [54] MMD, “MMD-0030-2015 - New ELF malware on Shell- shock: the ChinaZ.” http://blog.malwaremustdie.org/2015/01/ mmd-0030-2015-new-elf-malware-on.html. [55] MMD, “MMD-0025-2014 - ITW Infection of ELF .IptabLex and .Ipta- bLes China DDoS bots malware.” http://blog.malwaremustdie.org/2014/ 06/mmd-0025-2014-itw-infection-of-elf.html. [56] A. Wang, R. Liang, X. Liu, Y. Zhang, K. Chen, and J. Li, An Inside Look at IoT Malware. [57] P. Celeda, R. Krejci, J. Vykopal, and M. Drasar, “Embedded malware- an analysis of the chuck norris botnet,” in Computer Network Defense (EC2ND), 2010 European Conference on, pp. 3–10, IEEE, 2010. [58] F. Shahzad and M. Farooq, “Elf-miner: Using structural knowledge and data mining methods to detect new (linux) malicious executables,” Knowledge and Information Systems, 2012. [59] J. Bai, Y. Yang, S. Mu, and Y. Ma, “Malware detection through mining symbol table of Linux executables,” Information Technology Journal,
[60] K. Monnappa, “Automating Linux Malware Analysis Using Limon Sandbox,” Black Hat Europe 2015, 2015. [61] “Sysdig.” https://www.sysdig.org/. [62] PayloadSecurity, “VxStream Sandbox Linux.” https://www. payload-security.com/products/linux. [63] “Multiplatform Linux Sandbox.” https://detux.org/. [64] “Cuckoo Sandbox 2.0 Release Candidate 1.” https://cuckoosandbox.org/ blog/cuckoo-sandbox-v2-rc1. [65] Y. P. Minn, S. Suzuki, K. Yoshioka, T. Matsumoto, and C. Rossow, “IoTPOT: Analysing the rise of IoT compromises,” in 9th USENIX