21 - Rootkits Flashcards

(35 cards)

1
Q

What is malware?

A

Any software intentionally designed to cause damage to a computer, server or computer network.

Malware does the damage after it is implanted or
introduced in some way into a target’s computer
- Can take the form of executable code, scripts, active content,
and other software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are explots?

A

Exploits are malicious programs that take advantage
of application software or OS vulnerabilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Do all exploits involve file-based malware?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Attacks through exploit kits.

A

The most common method to distribute exploits and exploit kits
is through webpages, but exploits can also arrive in emails.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are exploit kits?

A

Exploit kits are more comprehensive tools that contain a collection of exploits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a vulnerability?

A

A vulnerability is a mistake in software code that provides
an attacker with direct access to a system or network.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Common Vulnerabilities and Exposures (CVE)?

A

It is a program launched in 1999 by MITRE to identify and catalog
vulnerabilities in software or firmware into a free “dictionary” for
organizations to improve their security.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Vulnerability reporting in CVEs.

A

The dictionary’s main purpose is to standardize the way each known
vulnerability or exposure is identified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The Metasploit framework.

A

Metasploit Framework is a software platform for developing, testing, and executing exploits.

  • It can be used to create security testing tools and exploit modules and as a penetration testing system.

Can incorporate new exploits in the form of modules (plug-ins).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are rootkits?

A

The behavior of the operating system can be affected by the presence of rootkits.
- Enable access to a computer or areas of its software that is
not otherwise allowed (for example, to an unauthorized user).

Rootkits are a category of malware which has the ability to hide itself and cover up traces of activities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are rootkit goals?

A
  1. Enable future access to system by attacker
  2. Remove evidence of original attack and activity that
    led to rootkit installation
  3. Hide future attacker activity (files, net connections,
    processes) and prevent it from being logged
  4. Install tools to widen scope of penetration
  5. Secure system so other attackers can’t take control
    of system from original attacker
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Examples of rootkits.

A

Install a backdoor on the compromised system
Run a password logger on a compromised system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Rootkit tools: Backdoor programs.

A

Backdoor is an unauthorized way of gaining access to a
program, online service or an entire computer system
- Let attackers log in to the hacked system without using an exploit again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Rootkit tools: sniffers.

A

Packet sniffers
- Packet Sniffer is a program and/or device that monitor data
traveling over a network, TCP/IP or other network protocol
- Used to listen or to steal valuable information off a network; many
services such as “ftp” and “telnet” transfer their password in plain
text and it is easily capture by sniffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Rootkit tools: wipers.

A

Log-wiping utilities
- Log file are the lists actions that have occurred, e.g., in UNIX, wtmp
logs time and date user log in into the system
- Log file enable admins to monitor, review system performance and
detect any suspicious activities
- Deleting intrusion records helps prevent detection of the intrusion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Rootkit tools: Miscellaneous attacker tools.

A
  • DDOS program
  • IRC program
  • System patch: attacker may patch the system after successful attack; this will prevent other attacker to gain access into the system again
  • Password cracker
  • Vulnerability scanners
  • Hiding utilities: utilities to conceal the rootkit files on compromised system
17
Q

Rootkit stealth techniques.

A

File masquerading
Hooking
Direct Kernel Object Manipulation (DKOM)
Virtualization

18
Q
  1. File masquerading.
A

Aquele exemplo de criar uma diretoria .. falsa.
Replace system files (or directories) with malicious versions
that shared the same name and services as the original
- Or create files (or dirs) that resemble legitimate files (or dirs)

Installation concealment:
- Use spaces to make filenames look like expected dot files: “. “ and “.. “
- Use dot files, which aren’t in ls output
- Use a subdirectory of a busy system directory like /dev, /etc, /lib, or /usr/lib
- Use filenames that system might use
/dev/hdd (if no 4th IDE disk exists)
/usr/lib/libX.a (libX11 is real Sun X-Windows)
- Delete rootkit install directory once installation is complete

19
Q

Change system commands.

A

Command-level rootkits hide malware by changing system commands
- Based on principle: To suppress bad news, silence the messenger

Ou seja: se queres esconder que há malware, faz com que os comandos que denunciam o problema deixem de mostrar a verdade - “silencia” esses comandos. É exactamente isso que fazem command-level rootkits: alteram/substituem/enganam comandos para que deixem de reportar processos, portas, ficheiros, módulos, etc.

20
Q
  1. Hooking.
A

The next step in evolution of rootkits was to redirect system
calls to malicious code, a technique known as hooking.

Hooking is when a given pointer to a given resource or
service is redirected to a different object.

E.g., instead of replacing the file containing the “ls” command, a
system call can be redirected to a custom “dir” command in
memory space that filters out the malicious files and folders.

Basically, hooking achieves the same effect as file
masquerading, but is more difficult to detect
- Don’t require changing executable files
- Integrity checkers ineffective when validating executable files

21
Q

Where can hooking be performed?

A

Hooking can be performed at several layers in the
operating system, primarily libraries and kernel.

22
Q

Library-level hooking.

A

Instead of replacing system utilities, rootkits can hide their
existence by making changes at the next level down in the
system architecture: the system run-time library

A good example is redirecting the open() and stat() calls
- The purpose of these modifications is to fool file-integrity-checking
software that examines executable file contents and attributes
- By redirecting the open() and stat() calls to the original file, the
rootkit makes it appear as if the file is still intact
- However, execve() executes the subverted file

Fluxo técnico (passo a passo, explicado)

Programas em userland normalmente chamam open() e stat() para ler ficheiros ou ver atributos.

Essas funções fazem parte da biblioteca de tempo de execução (por ex. libc).

Antes de chegar ao kernel, a chamada passa por essa biblioteca.

Hook em nível de biblioteca (ex.: LD_PRELOAD) substitui as funções open()/stat() por versões maliciosas.

Quando um programa chama open(), chama as versões hookadas.

As versões hookadas podem devolver o conteúdo/atributos antigos (ou fabricados) — o programa vê “tudo bem”.

execve() também tem uma função wrapper em libc, mas no fim é uma syscall que pede ao kernel para carregar e executar o ficheiro que está no disco.

O kernel lê o inode e os blocos do disco diretamente e carrega o binário real para memória.

Se o ficheiro em disco foi substituído por um binário malicioso, o kernel vai carregar essa versão maliciosa e executá-la — mesmo que as funções open()/stat() em userland estejam a devolver uma “versão limpa”.

Conclusão: Hookar open()/stat() engana verificadores e programas que ficam em userland. Mas execução real (quando o kernel carrega o binário) usa o conteúdo real em disco, portanto o malware pode ser executado apesar do “checker” ter visto uma versão limpa.

Observação: rootkits mais avançados também podem hookar a nível do kernel para enganar tudo — aí é muito mais complicado.

Ideia geral (passo a passo)

O hook substitui a rota normal: quando um programa pede open()/stat() etc., o pedido passa para a função hookada em vez da função original.

O hook guarda/tem acesso à função original: antes de substituir, o autor do hook guarda uma referência para a função original (ou sabe como chamá-la).

O hook decide o que fazer:

pode chamar a função original (delegar) e devolver o resultado ao programa — geralmente depois de filtrar ou modificar esse resultado;

ou pode não chamar a original e devolver uma resposta fabricada (falsa).

Resultado: o programa recebe a resposta do hook (que pode ser idêntica ao original ou alterada), sem saber que houve interferência.

1) Como o hook decide o que mostrar (resumo)

O hook intercepta chamadas (por ex. open, stat, read). Antes de substituir o funcionamento normal, o autor do hook normalmente tem um modo de aceder ao comportamento original. Quando chega uma chamada, o hook inspeciona o contexto da chamada e escolhe uma das duas opções:

Devolver a versão limpa (fabricada ou antiga) — se o hook decidir que o chamador é uma ferramenta de verificação, um administrador, ou algo que não deve ver o ficheiro real.

Devolver a versão real/maliciosa — se for um processo que deve executar o malware (ex.: o próprio serviço que o atacante quer controlar).

Em suma: o hook faz uma checagem rápida do chamador e escolhe qual resposta devolver.

2) Que factores o hook usa para decidir (coisas que ele olha)

Normalmente o hook verifica coisas simples do processo que faz a chamada. Exemplos típicos (coisas que podes entender facilmente):

Nome do processo (argv[0]) — se for sha256sum, tripwire, rpm, etc., devolve o limpo.

PID / PPID / UID — se o processo tiver UID inesperado ou for filho de um processo suspeito, pode devolver o real.

Caminho do executável (/proc/<pid>/exe) — se vier de /usr/bin/ vs de /tmp/ o comportamento muda.</pid>

Variáveis de ambiente (ex.: se LD_PRELOAD existe, ou se tem variáveis de debugging).

Se a chamada vem de um terminal interativo vs de um serviço/background.

Sequência de chamadas (por ex., se depois de open() vem um execve() no mesmo processo, o hook pode diferenciar).

Assinatura do leitor — alguns hooks mantêm uma lista de “ferramentas conhecidas” e as tratam de forma especial.

Resumindo: o hook olha quem pediu e decide — é por isso que um checker normal nunca vê a versão verdadeira se o hook o identificar.

3) Como isto engana os checkers (o porquê prático)

Um checker típico faz stat()/open()/read() para calcular um hash ou verificar metadados.

Se todas essas funções foram substituídas por hooks que devolvem os valores “bons”, o checker nunca lê o ficheiro real em disco — só lê a versão que o hook lhe forneceu.

Ou seja: o checker pensa que está tudo ok porque está a ler a mentira que o hook lhe deu.

Por isso é que os checkers userland sozinhos não provam que o sistema está limpo — eles usam as mesmas APIs que o hook controla.

23
Q

Kernel-level hooking.

A

Just like user-level rootkits, kernel-level rootkits are
installed after a system’s security has been breached.

Kernel-level rootkits compromise the kernel
- Kernel runs in supervisor processor mode
- Thus, the rootkit gains complete control over the machine

Advantage: stealth, e.g.,
- Runtime integrity checkers cannot see rootkit changes
- All programs in the system can be affected by the rootkit
- Open backdoors/sniff network without running processes

24
Q

Methods to inject rootkit code into a kernel.

A
  1. Loading kernel module into a running kernel
  2. Injecting code into the memory of a running kernel that
    has no support for module loading
  3. Injecting code into the kernel file or a kernel module file
25
Early kernel rootkit architecture.
Based on system-call interposition: Early kernel rootkits subvert syscalls close to the process-kernel boundary.
26
Rootkit interposition code.
To prevent access to a hidden file, process, and so on, rootkits redirect specific system calls to wrapper code. O que é "interposition code" (em 1 frase) É código que intercepta chamadas ao SO (syscalls) ou funções da biblioteca (e.g. readdir, getdents, open, stat) e inspeciona/filtra os resultados para ocultar ficheiros, processos, sockets, etc. — em vez de devolveres o resultado verdadeiro, devolve-se uma versão modificada sem as coisas que queremos esconder. Como funciona, de forma geral Um programa pede uma lista (ex.: readdir("/proc") ou getdents() para listar diretórios; netstat usa netlink/syscalls para listar sockets). A chamada é redirecionada para um wrapper (a função hookada). O wrapper chama a implementação original (ou lê do disco), recebe a lista e depois filtra entradas que correspondem a ficheiros/processos/sockets que o rootkit quer ocultar. O wrapper devolve ao chamador a lista filtrada — o processo de inspeção nunca vê as entradas ocultas.
27
Routine patching.
Modify the code of a system routine to cause the execution path to jump to malicious code which is resident either in memory or on disk. Modern Windows-based rootkits may embed a JMP instruction within the system binary to redirect the execution path - This can be performed against the system binaries stored in the OS file system, or even against executing code loaded in memory Detection: - If the modification was performed on the file system, this can be easily detected by file integrity monitoring systems - Run-time modification can be detected by applications such as Kernel Path Protection, which is provided by the 64-bit versions of Windows
28
Filter drivers.
São drivers em kernel que se intercalam na pilha de I/O do Windows para ver, modificar ou bloquear pedidos de I/O (IRP — I/O Request Packets). Foram desenhados para permitir funcionalidades legítimas (antivírus, sistemas de ficheiros, filtros de teclado), mas também podem ser usados por rootkits para interceptar e manipular tráfego/outputs. Como rootkits abusam disto Inserem um driver próprio na pilha (ou substituem entradas) para interceptar IRPs e esconder ficheiros/processos/portas das ferramentas de segurança. Podem filtrar respostas a chamadas de listagem (ex.: esconder nomes em IRP_MJ_DIRECTORY_CONTROL) ou alterar dados lidos (ex.: devolver conteúdo limpo). Podem também capturar teclas (keyboard filters) ou duplicar/traficar pacotes de rede (NDIS filters). Técnicas usadas: hooks de rotinas do driver, patching in-memory, instalação de driver novo com um nome semelhante a um legit. The Windows driver stack architecture was designed in a layered manner. This feature enables rootkit authors to inject their malicious code to interrupt the flow of I/O Request Packets and perform activities such as keystroke logging or filtering the results that are returned to anti-malware applications. Rootkit authors can perform hooking of drivers, patch driver routines, or even create an entirely new driver and insert it into a driver stack.
29
Potential hooking locations in Windows.
There are several different locations along the way that can be hooked to perform malicious activities. These locations include: - Userland hooks in the Import Address Tables (IAT) - The Interrupt Descriptor Table (IDT) - The System Service Dispatch Table (SSDT) - Device drivers via I/O Request Packets
30
3. Direct Kernel Object Manipulation (DKOM).
The third generation of rootkits used technique known as Direct Kernel Object Manipulation (DKOM). DKOM can manipulate kernel data structures to hide processes, change privileges, etc.
31
4. Virtualization-based.
Leverage virtualization techniques to hide their presence “under” the native operating system. Example: Using the SVM hardware-virtualization instruction to install itself as a resident malicious hypervisor running in the computer.
32
Approaches to detecting file masquerading.
1. If a rootkit listens for connections, the network port will be visible to an external network port scanner 2. Some tools can reveal the names of all directory entries, including hidden or deleted files 3. Corrupted versions of ps and similar hide malware processes, but these can still be found using, e.g., the /proc file system 4. Deleted login/logout records in the wtmp file leave behind holes that can be detected using an appropriate tool 5. Ifconfig might report that a network interface is not in sniffer mode, but we can query the kernel for the interface status 6. CRC checksums reported by compromised cksum, can be detected using MD5 or SHA1 7. When examining a low-level copy of the file system on a trusted machine, all hidden files and modifications will be visible
33
Detection of kernel-level hooking.
- Kernel rootkits may be exposed because they introduce little inconsistencies into a system - Some may show up externally, in the results from system calls that manipulate processes, files, kernel modules, etc. - Others show up only internally, in the contents of kernel data structures - E.g., hidden objects occupy some storage even though the storage does not appear in kernel symbol tables
34
Inconsistencies that may reveal kernel rootkits.
Output of tools that bypass the file system can reveal information that is hidden by compromised FS code - E.g., TSK Unexpected behavior of some system calls - E.g., when the Adore rootkit is installed, setuid() – change process privileges – will report success for some parameter value even though the user does not have sufficient privileges Inconsistencies in the results from process-manipulating system calls and from the /proc file system - E.g., in reporting a process as “not found” Modifications to kernel tables, such as system call table or the virtual FS table Modifications to kernel tables or kernel code may be detected using a kernel module that samples critical data structures periodically
35
Example of kernel toolkit detector tool.
Findrootkit can produce modification reports. Changes to (a) the file system operations table, and (b) the system- call jump table