One Article Review

Accueil - L'article:
Source AlienVault.webp AlienVault Blog
Identifiant 1165834
Date de publication 2019-06-20 13:00:00 (vue: 2019-06-20 21:00:21)
Titre Hunting for Linux library injection with Osquery
Texte When analyzing malware and adversary activity in Windows environments, DLL injection techniques are commonly used, and there are plenty of resources on how to detect these activities. When it comes to Linux, this is less commonly seen in the wild. I recently came across a great blog from TrustedSec that describes a few techniques and tools that can be used to do library injection in Linux. In this blog post, we are going to review some of those techniques and focus on how we can hunt for them using Osquery. LD_PRELOAD LD_PRELOAD is the easiest and most popular way to load a shared library in a process at startup. This environmental variable can be configured with a path to the shared library to be loaded before any other shared object. For most of the blog, we will be using the examples available in GitHub, listed here. Let’s use sample-target as the target process and sample-library as the shared library we will be injecting. We can utilize the ldd tool to inspect the shared libraries that are loaded into a process. If we execute the sample-target binary with ldd we can see that information. LD Preload to load a shared libary in a process at startup Linux-vdso.so.1, is a virtual dynamic shared object that the kernel automatically maps into the address space in every process. Depending on the architecture, it can have other names. Virtual dynamic shared object Libc.so.6 is one of the dynamic libraries that the sample-target requires to run, and ld-linux.so.2 is in charge of finding and loading the shared libraries. We can see how this is defined in the sample-target ELF file by using readelf. sample-target ELF file Now, let’s set the LD_PRELOAD environment variable to load our library by executing. export LD_PRELOAD=/home/ubuntu/linux-inject/sample-library.so; ldd /home/ubuntu/linux-inject/sample-target Ubuntu executing LD_PRELOAD We can see our sample-library being loaded now. We can also get more verbose information by setting the LD_DEBUG environment variable. export LD_DEBUG=files More verbose information on LD_PRELOAD A simple way to hunt for malicious LD_PRELOAD usage with Osquery is by querying the process_envs table and looking for processes with the LD_PRELOAD environment variable set. SELECT process_envs.pid as source_process_id, process_envs.key as environment_variable_key, process_envs.value as environment_variable_value, processes.name as source_process, processes.path as file_path, processes.cmdline as source_process_commandline, processes.cwd as current_working_directory, 'T1055' as event_attack_id, 'Process Injection' as event_attack_technique, 'Defense Evasion, Privilege Escalation' as event_attack_tactic FROM process_envs join processes USING (pid) WHERE key = 'LD_PRELOAD&
Envoyé Oui
Condensat /p> hunting injection library linux osquery
Tags
Stories
Notes
Move


L'article ne semble pas avoir été repris aprés sa publication.


L'article ne semble pas avoir été repris sur un précédent.
My email: