Mas 10
Mas 10
com
0. Quote
“No thinking - that comes later. You must write your first draft with your heart. You rewrite with your
head. The first key to writing is... to write, not to think”
(William Forrester played by Sean Connery | “Finding Forrester” movie - 2000)
1. Introduction
Welcome to the tenth (and last) article of the Malware Analysis Series, where we are reviewing concepts,
techniques and practical steps used for analyzing ELF malware binaries. If readers have not read my
previous articles yet, all of them are available on the following links:
▪ ERS_02: https://exploitreversing.com/2024/01/03/exploiting-reversing-er-series-article-02/
▪ ERS_01: https://exploitreversing.com/2023/04/11/exploiting-reversing-er-series/
▪ MAS_9: https://exploitreversing.com/2025/01/08/malware-analysis-series-mas-article-09/
▪ MAS_8: https://exploitreversing.com/2024/08/07/malware-analysis-series-mas-article-08/
▪ MAS_7: https://exploitreversing.com/2023/01/05/malware-analysis-series-mas-article-7/
▪ MAS_6: https://exploitreversing.com/2022/11/24/malware-analysis-series-mas-article-6/
▪ MAS_5: https://exploitreversing.com/2022/09/14/malware-analysis-series-mas-article-5/
▪ MAS_4: https://exploitreversing.com/2022/05/12/malware-analysis-series-mas-article-4/
▪ MAS_3: https://exploitreversing.com/2022/05/05/malware-analysis-series-mas-article-3/
▪ MAS_2: https://exploitreversing.com/2022/02/03/malware-analysis-series-mas-article-2/
▪ MAS_1: https://exploitreversing.com/2021/12/03/malware-analysis-series-mas-article-1/
This article offers an introductory analysis of ELF binaries on Linux, and we will be moving slowly and
carefully to not getting in unnecessary details that, at first approach, do not contribute to building the
knowledge. The main goal of this article is to keep it short, simple, and informative, avoiding touching on
tons of details associated with ELF format, and only examining the most important aspects of the malware.
2. Acknowledgments
The year is 2025. Four years ago, I started drafting articles with the sole purpose of helping the hacking and
information security community, and as I could already imagine at that time, it would be challenging to
find time to continue producing content, and indeed this side effect has been confirmed over time.
1|Page
https://exploitreversing.com
As I have been using IDA Pro for a long time, I needed a license of my own, and that was when Ilfak
Guilfanov (@ilfak) and Hex-Rays SA (@HexRaysSA) decided to help me, and since then they have provided
continuous and decisive support to write this Malware Analysis Series (MAS), which is focused on malware
analysis, and the Exploiting Reversing series (ERs), which is my current and long-term series on internals,
vulnerability research and, eventually, exploitation in critical topics such as Windows, kernel drivers,
macOS, browser and hypervisors.
Time flies, and companies around the world have become more demanding in terms of technical skills, but
I still believe that one of the most effective ways to help these professionals is to write articles because
such content can offer a solid method to learn details that would be a bit more difficult in live conferences
or even other media. I still face serious time constraints to write, but I keep trying to do it because, in some
way, I know that these series have been important for people's careers.
Life may be short, but every moment is worth it. Enjoy the journey and keep exploiting it!
3. Lab Setup
This article and next ones I will be using the following lab configuration:
We need to establish a starting point to initiate our article analyzing malware threats for Linux and,
probably, one of the possible approaches is to search for samples and retrieve one of them to start our
work. As readers already know, Linux binaries are represented in ELF format, so we can use Malwoverview
tool to search such samples. One of the recommended sources to list and download samples is Malware
Bazaar, which readers could do by executing the following commands (I specified “-o 0” because I have
used a clear background for the terminal, but if you are using a dark background, so you should omit this
option):
Once you have downloaded the sample, you can retrieve reports from different services such as Virus
Total, Triage, InQuest, URL Haus, Alien Vault, Polyswarm, Hybrid Analysis and :
2|Page
https://exploitreversing.com
I will be using different tools to collect properties of our malicious binary, and I am going to focus on static
analysis. As usual, quite a few concepts and fundamentals will be provided to support and improve the
understanding of the topics exposed. I am going to use a simple example, whose hash is the following one:
▪ SHA256: f864922f947a6bb7d894245b53795b54b9378c0f7633c521240488e86f60c2c5
3|Page
https://exploitreversing.com
4|Page
https://exploitreversing.com
5|Page
https://exploitreversing.com
For now, we have not found anything really weird or that represents an issue, and the information shown
so far was already expected.
Thus, we can list the program header table by running the following command:
6|Page
https://exploitreversing.com
▪ This binary has 9 program headers, and readers can observe that each section is associated with
one segment, which contains runtime execution.
▪ The main program headers (check Figure 5) have the following description:
o PHDR: this header is a meta-segment, which contains the program header table and some
metadata.
o INTERP: this header an indication on the necessary system loader should be used to load
this binary into memory. In this case, it is /lib64/ld-linux-x86-64.so.2.
o LOAD: this headers provides information such as memory size, permission and alignment to
the loader about how to load the binary into the memory.
o DYNAMIC: this header provides information about the shared library dependencies and
relocations.
o NOTE: this header usually stores meta-information provided the vendor.
o GNU_PROPERTY: this header is usually generated by the linker, and it is used to locate
.note.gnu.property section.
o GNU_EH_FRAME: this header provides the memory address of the stack unwind tables,
which are used by exception handlers (throw or try/catch/finally).
o GNU_RELRO: this header, named as Relocation Read-Only, is used for exploit mitigations
such as -znow (full RELRO mitigation) or -zrelro (partial RELRO mitigation).
7|Page
https://exploitreversing.com
o GNU_STACK: this header, created by the linker, provides information whether stack is or
not executable. Thus, the key information presented by this header is the memory
protection used granted to the stack.
o NEEDED: it indicates main libraries dependencies, which are used by the dynamic linker to
load shared libraries when the program starts. In this case, the binary has a direct
dependency on three shared libraries.
o STRTAB: it holds a reference to the address of a string table, which contains strings used by
the dynamic linker, as expected.
o SYMTAB: it holds a reference to a symbol table, which contains information about symbols
such as functions (FUNC), global data variable (OBJECT), sections (SECTION), thread-local
data variable (TLS) and even symbols that do not have a specific type (NOTYPE).
Additionally, symbols can be shared with external programs and libraries (GLOBAL), not
accessible to other programs and libraries (LOCAL) and can even be used by function’s
implementation and overwritten in a later moment.
o STRSZ: it represents the size of the string table.
o SYMENT: it represents the size of the symbol table.
▪ There are many other dynamic sections, but they are not important for now.
▪ The symbol table referred to above can be checked by running the following command:
8|Page
https://exploitreversing.com
▪ To the list of sections presented above, a concise description of the main ones follows below::
10 | P a g e
https://exploitreversing.com
Through the output we found strings related command to be executed (esxclivm process kill --type=force)
and to encryption scripts, which tell us a bit about the malware/ransomware operation.
Repeating the same command, but for .data section, we have:
11 | P a g e
https://exploitreversing.com
12 | P a g e
https://exploitreversing.com
13 | P a g e
https://exploitreversing.com
The only note is that the ransomware is looking for VMware ESXi installations and kill any associated
process before executing any operation.
14 | P a g e
https://exploitreversing.com
Get a compact list of imported functions, the number of imports and also the number of the functions:
15 | P a g e
https://exploitreversing.com
16 | P a g e
https://exploitreversing.com
I am not going to proceed using Radare2, but certainly many readers might follow the analysis using it
because messages and instructions there are truly clear.
Check for libraries loaded dynamically at loading time:
17 | P a g e
https://exploitreversing.com
18 | P a g e
https://exploitreversing.com
19 | P a g e
https://exploitreversing.com
▪ Exploits can use GOT to find API functions’ addresses such as system, setuid, memcpy, strcpy and
many other ones. Eventually such an approach would only be feasible if GOT can be found in a
static location (predictable), which happens only with non-PIE programs.
▪ Readers could remember PIE (Position Independent Executable) programs can be loaded in any
address in the memory, which makes finding GOT harder. Obviously, it would not be a concern for
malicious binaries.
▪ There are exploits that replace entries in GOT with addresses pointing to a malicious function or
even a payload.
At the same way that we have seen on Windows operating system, malware threats have injected shared
libraries into processes to read and extract information, escalate privileges, hook and even establishing
persistence, and all of these mentioned attacks start by compromising the process structure (represented
by task_struct), which hold memory maps, opened file descriptors, scheduling information and so on, and
it is related through the slab allocator (and variants) to kmem_cache that caches kernel objects and related
information such as respective pointers and meta-information.
Finally, we have the main tool for any malware triage that is capa (from Mandiant), which one of last versions
can be downloaded from https://github.com/mandiant/capa/releases/tag/v8.0.1. Personally, I copy capa
binary to /usr/local/bin directory, but readers can adopt any approach to put it in a valid path. Executing
capa binary is direct, as shown below:
20 | P a g e
https://exploitreversing.com
21 | P a g e
https://exploitreversing.com
▪ checksec:
o git clone https://github.com/slimm609/checksec
o go build
6. Reversing
Open our sample on IDA Pro (my current version is 8.4 SP2). If we check for signatures (View → Open
Subviews → Signatures or SHIFT+F5), we will not see anything there. If you want, you can right-click on
the background and pick up Apply new signature to add signatures such as elf64, libc or even go_std_abi0
(if it was a Golang file), but in this case you will not have success and no function signature will be added,
unfortunately. Using the same approach, we can add Type Libraries (SHIFT+F11). There is already an added
Type Library (gnulnx_x64), and we do not have further useful libraries to include. Finally, and as usual, we
must decompile the whole binary by going to File → Produce File → Create C File, where the IDA will
suggest mas_10.bin.c as filename, and we can accept it.
22 | P a g e
https://exploitreversing.com
The disassembly of the main function (not start function) is shown below:
23 | P a g e
https://exploitreversing.com
24 | P a g e
https://exploitreversing.com
Some obvious and few observations that can be made about the code:
▪ As signsrch tool, Capa Explorer have also identified several functions involved with cryptography.
▪ AES and RC4 are the main symmetric algorithms used by this ransomware.
▪ Base64 encoding is also present, and it was expected according to what we have seen previously.
▪ For ransomware, operations such as reading, writing, moving, and deleting are completely usual.
However, the information offered by Capa Explorer is limited, and there are multiple parts of the code
involved with cryptography that, eventually, deserves some light on.
The sub_40E2AA routine performs Base64 encoding and decoding, and there are some indications such as
the explicit alphabet and constants. The piece of code below is the decoding part:
26 | P a g e
https://exploitreversing.com
27 | P a g e
https://exploitreversing.com
28 | P a g e
https://exploitreversing.com
29 | P a g e
https://exploitreversing.com
However, the sub_40C62D routine, which is called by sub_40C6E4 routine, shows the there is a generation
of a random value, which helps the sub_40C6E4 routine to produce a 32 bytes random value:
30 | P a g e
https://exploitreversing.com
The sub_40E7F5 routine sets the AES key for encryption (128, 192 and 256 bits), and the prototype and
respective arguments follow:
__int64 __fastcall sub_40E7F5(
int *a1,
unsigned __int8 *a2,
int a3)
{
31 | P a g e
https://exploitreversing.com
▪ A CRC32 hash of encrypted data is calculated and appended to the final encrypted data.
The piece of code putting all routines together is shown below:
32 | P a g e
https://exploitreversing.com
33 | P a g e
https://exploitreversing.com
The sub_40CF44 routine generates a JSON file, which probably contains information about the target
system:
7. Conclusion
In this article we have reviewed a few basic concepts of analyzing an ELF binary as also we perform a quick
and superficial analysis of a ransomware sample.
Finally, I have accomplished my promise in producing a ten-articles series! This was the last article of the
Malware Analysis Series (MAS), and I hope you have enjoyed reading all articles over the years. As you
already know, I moved to another area (vulnerability research) a bit more than a couple of years ago, and
now I really do something I have passion to do. Therefore, that is my advice. Follow your heart.
Just in case you want to stay connected:
▪ Twitter: @ale_sp_brazil
▪ Blog: https://exploitreversing.com
Keep learning, reversing, and exploiting everything, and I will see you next time!
Alexandre Borges
35 | P a g e