mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/generic-methodologies-and-resources/basic-forensic-meth
This commit is contained in:
parent
db29bcf964
commit
a3d34e4e3f
@ -37,6 +37,7 @@
|
||||
- [Mobile Phishing Malicious Apps](generic-methodologies-and-resources/phishing-methodology/mobile-phishing-malicious-apps.md)
|
||||
- [Phishing Files & Documents](generic-methodologies-and-resources/phishing-methodology/phishing-documents.md)
|
||||
- [Basic Forensic Methodology](generic-methodologies-and-resources/basic-forensic-methodology/README.md)
|
||||
- [Adaptixc2 Config Extraction And Ttps](generic-methodologies-and-resources/basic-forensic-methodology/adaptixc2-config-extraction-and-ttps.md)
|
||||
- [Baseline Monitoring](generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md)
|
||||
- [Anti-Forensic Techniques](generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md)
|
||||
- [Docker Forensics](generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md)
|
||||
@ -130,6 +131,7 @@
|
||||
- [Seccomp](linux-hardening/privilege-escalation/docker-security/seccomp.md)
|
||||
- [Weaponizing Distroless](linux-hardening/privilege-escalation/docker-security/weaponizing-distroless.md)
|
||||
- [Escaping from Jails](linux-hardening/privilege-escalation/escaping-from-limited-bash.md)
|
||||
- [Posix Cpu Timers Toctou Cve 2025 38352](linux-hardening/privilege-escalation/linux-kernel-exploitation/posix-cpu-timers-toctou-cve-2025-38352.md)
|
||||
- [euid, ruid, suid](linux-hardening/privilege-escalation/euid-ruid-suid.md)
|
||||
- [Interesting Groups - Linux Privesc](linux-hardening/privilege-escalation/interesting-groups-linux-pe/README.md)
|
||||
- [lxd/lxc Group - Privilege escalation](linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation.md)
|
||||
@ -771,7 +773,7 @@
|
||||
- [Stack Shellcode - arm64](binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md)
|
||||
- [Stack Pivoting - EBP2Ret - EBP chaining](binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md)
|
||||
- [Uninitialized Variables](binary-exploitation/stack-overflow/uninitialized-variables.md)
|
||||
- [ROP and JOP](binary-exploitation/rop-return-oriented-programing/README.md)
|
||||
- [ROP & JOP](binary-exploitation/rop-return-oriented-programing/README.md)
|
||||
- [BROP - Blind Return Oriented Programming](binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md)
|
||||
- [Ret2csu](binary-exploitation/rop-return-oriented-programing/ret2csu.md)
|
||||
- [Ret2dlresolve](binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md)
|
||||
@ -840,6 +842,7 @@
|
||||
- [WWW2Exec - GOT/PLT](binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md)
|
||||
- [WWW2Exec - \_\_malloc_hook & \_\_free_hook](binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md)
|
||||
- [Common Exploiting Problems](binary-exploitation/common-exploiting-problems.md)
|
||||
- [Linux kernel exploitation - toctou](binary-exploitation/linux-kernel-exploitation/posix-cpu-timers-toctou-cve-2025-38352.md)
|
||||
- [Windows Exploiting (Basic Guide - OSCP lvl)](binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md)
|
||||
- [iOS Exploiting](binary-exploitation/ios-exploiting/README.md)
|
||||
- [ios CVE-2020-27950-mach_msg_trailer_t](binary-exploitation/ios-exploiting/CVE-2020-27950-mach_msg_trailer_t.md)
|
||||
@ -937,6 +940,4 @@
|
||||
- [Stealing Sensitive Information Disclosure from a Web](todo/stealing-sensitive-information-disclosure-from-a-web.md)
|
||||
- [Post Exploitation](todo/post-exploitation.md)
|
||||
- [Investment Terms](todo/investment-terms.md)
|
||||
- [Cookies Policy](todo/cookies-policy.md)
|
||||
|
||||
- [Posix Cpu Timers Toctou Cve 2025 38352](linux-hardening/privilege-escalation/linux-kernel-exploitation/posix-cpu-timers-toctou-cve-2025-38352.md)
|
||||
- [Cookies Policy](todo/cookies-policy.md)
|
@ -0,0 +1,243 @@
|
||||
# AdaptixC2 Configuration Extraction and TTPs
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
AdaptixC2 è un framework modulare, open‑source post‑exploitation/C2 con beacon Windows x86/x64 (EXE/DLL/service EXE/raw shellcode) e supporto BOF. Questa pagina documenta:
|
||||
- Come la sua configurazione RC4‑packed è incorporata e come estrarla dai beacon
|
||||
- Indicatori di rete/profilo per listener HTTP/SMB/TCP
|
||||
- TTPs comuni di loader e persistence osservati nel mondo reale, con link alle pagine sulle tecniche Windows rilevanti
|
||||
|
||||
## Beacon profiles and fields
|
||||
|
||||
AdaptixC2 supporta tre tipi principali di beacon:
|
||||
- BEACON_HTTP: web C2 con servers/ports/SSL configurabili, method, URI, headers, user‑agent, e un nome di parametro personalizzato
|
||||
- BEACON_SMB: named‑pipe peer‑to‑peer C2 (intranet)
|
||||
- BEACON_TCP: socket diretti, opzionalmente con un marker prefisso per offuscare l'inizio del protocollo
|
||||
|
||||
Campi tipici del profilo osservati nelle configurazioni del beacon HTTP (dopo la decrittazione):
|
||||
- agent_type (u32)
|
||||
- use_ssl (bool)
|
||||
- servers_count (u32), servers (array of strings), ports (array of u32)
|
||||
- http_method, uri, parameter, user_agent, http_headers (length‑prefixed strings)
|
||||
- ans_pre_size (u32), ans_size (u32) – used to parse response sizes
|
||||
- kill_date (u32), working_time (u32)
|
||||
- sleep_delay (u32), jitter_delay (u32)
|
||||
- listener_type (u32)
|
||||
- download_chunk_size (u32)
|
||||
|
||||
Esempio di profilo HTTP predefinito (da una build del beacon):
|
||||
```json
|
||||
{
|
||||
"agent_type": 3192652105,
|
||||
"use_ssl": true,
|
||||
"servers_count": 1,
|
||||
"servers": ["172.16.196.1"],
|
||||
"ports": [4443],
|
||||
"http_method": "POST",
|
||||
"uri": "/uri.php",
|
||||
"parameter": "X-Beacon-Id",
|
||||
"user_agent": "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0",
|
||||
"http_headers": "\r\n",
|
||||
"ans_pre_size": 26,
|
||||
"ans_size": 47,
|
||||
"kill_date": 0,
|
||||
"working_time": 0,
|
||||
"sleep_delay": 2,
|
||||
"jitter_delay": 0,
|
||||
"listener_type": 0,
|
||||
"download_chunk_size": 102400
|
||||
}
|
||||
```
|
||||
Profilo HTTP malevolo osservato (attacco reale):
|
||||
```json
|
||||
{
|
||||
"agent_type": 3192652105,
|
||||
"use_ssl": true,
|
||||
"servers_count": 1,
|
||||
"servers": ["tech-system[.]online"],
|
||||
"ports": [443],
|
||||
"http_method": "POST",
|
||||
"uri": "/endpoint/api",
|
||||
"parameter": "X-App-Id",
|
||||
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.160 Safari/537.36",
|
||||
"http_headers": "\r\n",
|
||||
"ans_pre_size": 26,
|
||||
"ans_size": 47,
|
||||
"kill_date": 0,
|
||||
"working_time": 0,
|
||||
"sleep_delay": 4,
|
||||
"jitter_delay": 0,
|
||||
"listener_type": 0,
|
||||
"download_chunk_size": 102400
|
||||
}
|
||||
```
|
||||
## Impacchettamento della configurazione cifrata e percorso di caricamento
|
||||
|
||||
Quando l'operatore clicca Create nel builder, AdaptixC2 incorpora il profilo cifrato come tail blob nel beacon. Il formato è:
|
||||
- 4 byte: dimensione della configurazione (uint32, little-endian)
|
||||
- N byte: dati di configurazione cifrati con RC4
|
||||
- 16 byte: chiave RC4
|
||||
|
||||
Il beacon loader copia la chiave di 16 byte dalla fine e decifra in loco il blocco di N byte con RC4:
|
||||
```c
|
||||
ULONG profileSize = packer->Unpack32();
|
||||
this->encrypt_key = (PBYTE) MemAllocLocal(16);
|
||||
memcpy(this->encrypt_key, packer->data() + 4 + profileSize, 16);
|
||||
DecryptRC4(packer->data()+4, profileSize, this->encrypt_key, 16);
|
||||
```
|
||||
Implicazioni pratiche:
|
||||
- L'intera struttura spesso risiede nella sezione PE .rdata.
|
||||
- L'estrazione è deterministica: leggere la dimensione, leggere il ciphertext di quella dimensione, leggere la chiave di 16‑byte posta immediatamente dopo, quindi RC4‑decrypt.
|
||||
|
||||
## Flusso di estrazione della configurazione (difensori)
|
||||
|
||||
Implementare un extractor che emuli la beacon logic:
|
||||
1) Individuare il blob all'interno del PE (di solito .rdata). Un approccio pragmatico è scansionare .rdata alla ricerca di un layout plausibile [size|ciphertext|16‑byte key] e tentare RC4.
|
||||
2) Leggere i primi 4 bytes → size (uint32 LE).
|
||||
3) Leggere i successivi N=size bytes → ciphertext.
|
||||
4) Leggere gli ultimi 16 bytes → RC4 key.
|
||||
5) RC4‑decrypt il ciphertext. Quindi analizzare il profilo in chiaro come:
|
||||
- u32/boolean scalars come indicato sopra
|
||||
- length‑prefixed strings (u32 length seguito da bytes; può essere presente NUL terminale)
|
||||
- arrays: servers_count seguito da quel numero di coppie [string, u32 port]
|
||||
|
||||
Proof‑of‑concept Python minimale (standalone, senza dipendenze esterne) che funziona con un blob pre‑estratto:
|
||||
```python
|
||||
import struct
|
||||
from typing import List, Tuple
|
||||
|
||||
def rc4(key: bytes, data: bytes) -> bytes:
|
||||
S = list(range(256))
|
||||
j = 0
|
||||
for i in range(256):
|
||||
j = (j + S[i] + key[i % len(key)]) & 0xFF
|
||||
S[i], S[j] = S[j], S[i]
|
||||
i = j = 0
|
||||
out = bytearray()
|
||||
for b in data:
|
||||
i = (i + 1) & 0xFF
|
||||
j = (j + S[i]) & 0xFF
|
||||
S[i], S[j] = S[j], S[i]
|
||||
K = S[(S[i] + S[j]) & 0xFF]
|
||||
out.append(b ^ K)
|
||||
return bytes(out)
|
||||
|
||||
class P:
|
||||
def __init__(self, buf: bytes):
|
||||
self.b = buf; self.o = 0
|
||||
def u32(self) -> int:
|
||||
v = struct.unpack_from('<I', self.b, self.o)[0]; self.o += 4; return v
|
||||
def u8(self) -> int:
|
||||
v = self.b[self.o]; self.o += 1; return v
|
||||
def s(self) -> str:
|
||||
L = self.u32(); s = self.b[self.o:self.o+L]; self.o += L
|
||||
return s[:-1].decode('utf-8','replace') if L and s[-1] == 0 else s.decode('utf-8','replace')
|
||||
|
||||
def parse_http_cfg(plain: bytes) -> dict:
|
||||
p = P(plain)
|
||||
cfg = {}
|
||||
cfg['agent_type'] = p.u32()
|
||||
cfg['use_ssl'] = bool(p.u8())
|
||||
n = p.u32()
|
||||
cfg['servers'] = []
|
||||
cfg['ports'] = []
|
||||
for _ in range(n):
|
||||
cfg['servers'].append(p.s())
|
||||
cfg['ports'].append(p.u32())
|
||||
cfg['http_method'] = p.s()
|
||||
cfg['uri'] = p.s()
|
||||
cfg['parameter'] = p.s()
|
||||
cfg['user_agent'] = p.s()
|
||||
cfg['http_headers'] = p.s()
|
||||
cfg['ans_pre_size'] = p.u32()
|
||||
cfg['ans_size'] = p.u32() + cfg['ans_pre_size']
|
||||
cfg['kill_date'] = p.u32()
|
||||
cfg['working_time'] = p.u32()
|
||||
cfg['sleep_delay'] = p.u32()
|
||||
cfg['jitter_delay'] = p.u32()
|
||||
cfg['listener_type'] = 0
|
||||
cfg['download_chunk_size'] = 0x19000
|
||||
return cfg
|
||||
|
||||
# Usage (when you have [size|ciphertext|key] bytes):
|
||||
# blob = open('blob.bin','rb').read()
|
||||
# size = struct.unpack_from('<I', blob, 0)[0]
|
||||
# ct = blob[4:4+size]
|
||||
# key = blob[4+size:4+size+16]
|
||||
# pt = rc4(key, ct)
|
||||
# cfg = parse_http_cfg(pt)
|
||||
```
|
||||
Tips:
|
||||
- When automating, use a PE parser to read .rdata then apply a sliding window: for each offset o, try size = u32(.rdata[o:o+4]), ct = .rdata[o+4:o+4+size], candidate key = next 16 bytes; RC4‑decrypt and check that string fields decode as UTF‑8 and lengths are sane.
|
||||
- Parse SMB/TCP profiles by following the same length‑prefixed conventions.
|
||||
|
||||
## Fingerprinting di rete e hunting
|
||||
|
||||
HTTP
|
||||
- Common: POST to operator‑selected URIs (e.g., /uri.php, /endpoint/api)
|
||||
- Custom header parameter used for beacon ID (e.g., X‑Beacon‑Id, X‑App‑Id)
|
||||
- User‑agents mimicking Firefox 20 or contemporary Chrome builds
|
||||
- Polling cadence visible via sleep_delay/jitter_delay
|
||||
|
||||
SMB/TCP
|
||||
- SMB named‑pipe listeners for intranet C2 where web egress is constrained
|
||||
- TCP beacons may prepend a few bytes before traffic to obfuscate protocol start
|
||||
|
||||
## Loader and persistence TTPs seen in incidents
|
||||
|
||||
In‑memory PowerShell loaders
|
||||
- Download Base64/XOR payloads (Invoke‑RestMethod / WebClient)
|
||||
- Allocate unmanaged memory, copy shellcode, switch protection to 0x40 (PAGE_EXECUTE_READWRITE) via VirtualProtect
|
||||
- Execute via .NET dynamic invocation: Marshal.GetDelegateForFunctionPointer + delegate.Invoke()
|
||||
|
||||
Check these pages for in‑memory execution and AMSI/ETW considerations:
|
||||
|
||||
{{#ref}}
|
||||
../../windows-hardening/av-bypass.md
|
||||
{{#endref}}
|
||||
|
||||
Persistence mechanisms observed
|
||||
- Startup folder shortcut (.lnk) to re‑launch a loader at logon
|
||||
- Registry Run keys (HKCU/HKLM ...\CurrentVersion\Run), often with benign‑sounding names like "Updater" to start loader.ps1
|
||||
- DLL search‑order hijack by dropping msimg32.dll under %APPDATA%\Microsoft\Windows\Templates for susceptible processes
|
||||
|
||||
Technique deep‑dives and checks:
|
||||
|
||||
{{#ref}}
|
||||
../../windows-hardening/windows-local-privilege-escalation/privilege-escalation-with-autorun-binaries.md
|
||||
{{#endref}}
|
||||
|
||||
{{#ref}}
|
||||
../../windows-hardening/windows-local-privilege-escalation/dll-hijacking/README.md
|
||||
{{#endref}}
|
||||
|
||||
Hunting ideas
|
||||
- PowerShell spawning RW→RX transitions: VirtualProtect to PAGE_EXECUTE_READWRITE inside powershell.exe
|
||||
- Dynamic invocation patterns (GetDelegateForFunctionPointer)
|
||||
- Startup .lnk under user or common Startup folders
|
||||
- Suspicious Run keys (e.g., "Updater"), and loader names like update.ps1/loader.ps1
|
||||
- User‑writable DLL paths under %APPDATA%\Microsoft\Windows\Templates containing msimg32.dll
|
||||
|
||||
## Note sui campi OpSec
|
||||
|
||||
- KillDate: timestamp after which the agent self‑expires
|
||||
- WorkingTime: hours when the agent should be active to blend with business activity
|
||||
|
||||
These fields can be used for clustering and to explain observed quiet periods.
|
||||
|
||||
## YARA e indizi statici
|
||||
|
||||
Unit 42 published basic YARA for beacons (C/C++ and Go) and loader API‑hashing constants. Consider complementing with rules that look for the [size|ciphertext|16‑byte‑key] layout near PE .rdata end and the default HTTP profile strings.
|
||||
|
||||
## References
|
||||
|
||||
- [AdaptixC2: A New Open-Source Framework Leveraged in Real-World Attacks (Unit 42)](https://unit42.paloaltonetworks.com/adaptixc2-post-exploitation-framework/)
|
||||
- [AdaptixC2 GitHub](https://github.com/Adaptix-Framework/AdaptixC2)
|
||||
- [Adaptix Framework Docs](https://adaptix-framework.gitbook.io/adaptix-framework)
|
||||
- [Marshal.GetDelegateForFunctionPointer – Microsoft Docs](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.getdelegateforfunctionpointer)
|
||||
- [VirtualProtect – Microsoft Docs](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualprotect)
|
||||
- [Memory protection constants – Microsoft Docs](https://learn.microsoft.com/en-us/windows/win32/memory/memory-protection-constants)
|
||||
- [Invoke-RestMethod – PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod)
|
||||
- [MITRE ATT&CK T1547.001 – Registry Run Keys/Startup Folder](https://attack.mitre.org/techniques/T1547/001/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
@ -1,8 +1,8 @@
|
||||
# Analisi del malware
|
||||
# Malware Analysis
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Schede di riferimento Forensics
|
||||
## Forensics CheatSheets
|
||||
|
||||
[https://www.jaiminton.com/cheatsheet/DFIR/#](https://www.jaiminton.com/cheatsheet/DFIR/)
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
### Yara
|
||||
|
||||
#### Install
|
||||
#### Installazione
|
||||
```bash
|
||||
sudo apt-get install -y yara
|
||||
```
|
||||
@ -36,7 +36,7 @@ python malware_yara_rules.py
|
||||
yara -w malware_rules.yar image #Scan 1 file
|
||||
yara -w malware_rules.yar folder #Scan the whole folder
|
||||
```
|
||||
#### YaraGen: Controlla la presenza di malware e crea regole
|
||||
#### YaraGen: Verificare la presenza di malware e creare rules
|
||||
|
||||
Puoi usare lo strumento [**YaraGen**](https://github.com/Neo23x0/yarGen) per generare yara rules da un binary. Consulta questi tutorial: [**Part 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Part 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Part 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/)
|
||||
```bash
|
||||
@ -57,21 +57,21 @@ clamscan folderpath #Scan the whole folder
|
||||
```
|
||||
### [Capa](https://github.com/mandiant/capa)
|
||||
|
||||
**Capa** rileva potenzialmente **capacità** dannose negli eseguibili: PE, ELF, .NET. Quindi troverà cose come Att\&ck tactics, o capacità sospette come:
|
||||
**Capa** rileva potenziali **capabilities** dannose in eseguibili: PE, ELF, .NET. Quindi troverà cose come Att\&ck tactics, o capabilities sospette come:
|
||||
|
||||
- controllare l'errore OutputDebugString
|
||||
- eseguire come servizio
|
||||
- creare un processo
|
||||
- check for OutputDebugString error
|
||||
- run as a service
|
||||
- create process
|
||||
|
||||
Scaricalo dal [**Github repo**](https://github.com/mandiant/capa).
|
||||
|
||||
### IOCs
|
||||
|
||||
IOC significa Indicator Of Compromise. Un IOC è un insieme di **condizioni che identificano** del software potenzialmente indesiderato o confermato **malware**. Le Blue Teams usano questo tipo di definizione per **cercare questo tipo di file maligni** nei loro **sistemi** e **reti**.\
|
||||
Condividere queste definizioni è molto utile: quando il malware viene identificato in un computer e viene creato un IOC per quel malware, altre Blue Teams possono usarlo per identificare il malware più rapidamente.
|
||||
IOC significa Indicator Of Compromise. Un IOC è un insieme di **condizioni che identificano** alcuni software potenzialmente indesiderati o **malware** confermato. I Blue Teams usano questo tipo di definizione per **cercare questo tipo di file maligni** nei loro **systems** e **networks**.\
|
||||
Condividere queste definizioni è molto utile: quando un malware viene identificato in un computer e viene creato un IOC per quel malware, altri Blue Teams possono usarlo per identificare il malware più velocemente.
|
||||
|
||||
Uno strumento per creare o modificare gli IOC è [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\
|
||||
Puoi usare strumenti come [**Redline**](https://www.fireeye.com/services/freeware/redline.html) per **cercare IOCs definiti in un dispositivo**.
|
||||
Uno strumento per creare o modificare IOC è [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\
|
||||
Puoi usare strumenti come [**Redline**](https://www.fireeye.com/services/freeware/redline.html) per **cercare gli IOC definiti in un dispositivo**.
|
||||
|
||||
### Loki
|
||||
|
||||
@ -92,25 +92,25 @@ Compares process connection endpoints with C2 IOCs (new since version v.10)
|
||||
```
|
||||
### Linux Malware Detect
|
||||
|
||||
[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) è uno scanner di malware per Linux rilasciato sotto licenza GNU GPLv2, progettato per le minacce presenti negli ambienti hosting condivisi. Utilizza dati sulle minacce provenienti da network edge intrusion detection systems per estrarre il malware attivamente impiegato negli attacchi e genera firme per il rilevamento. Inoltre, i dati sulle minacce derivano anche dalle segnalazioni degli utenti tramite la funzionalità LMD checkout e dalle risorse della community del malware.
|
||||
[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) è uno scanner per malware per Linux rilasciato sotto la licenza GNU GPLv2, progettato per le minacce affrontate negli ambienti di hosting condiviso. Utilizza dati sulle minacce provenienti da network edge intrusion detection systems per estrarre malware attivamente utilizzati negli attacchi e genera signatures per il rilevamento. Inoltre, i dati sulle minacce sono anche ricavati dalle segnalazioni degli utenti tramite la LMD checkout feature e dalle risorse della community sul malware.
|
||||
|
||||
### rkhunter
|
||||
|
||||
Strumenti come [**rkhunter**](http://rkhunter.sourceforge.net) possono essere usati per controllare il filesystem alla ricerca di possibili **rootkits** e malware.
|
||||
Strumenti come [**rkhunter**](http://rkhunter.sourceforge.net) possono essere utilizzati per controllare il filesystem alla ricerca di possibili **rootkits** e malware.
|
||||
```bash
|
||||
sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--skip-keypress]
|
||||
```
|
||||
### FLOSS
|
||||
|
||||
[**FLOSS**](https://github.com/mandiant/flare-floss) è uno strumento che tenta di trovare obfuscated strings all'interno di executables usando diverse tecniche.
|
||||
[**FLOSS**](https://github.com/mandiant/flare-floss) è uno strumento che prova a trovare obfuscated strings all'interno degli eseguibili usando tecniche diverse.
|
||||
|
||||
### PEpper
|
||||
|
||||
[PEpper ](https://github.com/Th3Hurrican3/PEpper)controlla alcune informazioni di base nell'executable (binary data, entropy, URLs and IPs, some yara rules).
|
||||
[PEpper ](https://github.com/Th3Hurrican3/PEpper) controlla alcune informazioni di base all'interno dell'eseguibile (binary data, entropy, URLs and IPs, alcune yara rules).
|
||||
|
||||
### PEstudio
|
||||
|
||||
[PEstudio](https://www.winitor.com/download) è uno strumento che permette di ottenere informazioni sui Windows executables come imports, exports, headers, ma controlla anche virus total e individua potenziali Att\&ck techniques.
|
||||
[PEstudio](https://www.winitor.com/download) è uno strumento che permette di ottenere informazioni sugli eseguibili Windows come imports, exports, headers, ma controllerà anche VirusTotal e troverà potenziali tecniche Att\&ck.
|
||||
|
||||
### Detect It Easy(DiE)
|
||||
|
||||
@ -118,7 +118,7 @@ sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--sk
|
||||
|
||||
### NeoPI
|
||||
|
||||
[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)is a Python script che utilizza una varietà di **statistical methods** per rilevare contenuti **obfuscated** e **encrypted** all'interno di file di testo/script. Lo scopo di NeoPI è aiutare nella **detection of hidden web shell code**.
|
||||
[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI) è uno script Python che utilizza una varietà di **statistical methods** per rilevare contenuti **obfuscated** e **encrypted** all'interno di file di testo/script. Lo scopo previsto di NeoPI è aiutare nella **detection of hidden web shell code**.
|
||||
|
||||
### **php-malware-finder**
|
||||
|
||||
@ -126,7 +126,7 @@ sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--sk
|
||||
|
||||
### Apple Binary Signatures
|
||||
|
||||
Quando si analizza un **malware sample** dovresti sempre **check the signature** del binary, poiché il **developer** che lo ha firmato potrebbe essere già **related** con **malware.**
|
||||
Quando si controlla qualche **malware sample** dovresti sempre **check the signature** del binario poiché il **developer** che l'ha firmato potrebbe essere già **related** con **malware.**
|
||||
```bash
|
||||
#Get signer
|
||||
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"
|
||||
@ -137,25 +137,25 @@ codesign --verify --verbose /Applications/Safari.app
|
||||
#Check if the signature is valid
|
||||
spctl --assess --verbose /Applications/Safari.app
|
||||
```
|
||||
## Tecniche di rilevamento
|
||||
## Detection Techniques
|
||||
|
||||
### File Stacking
|
||||
|
||||
Se sai che una cartella contenente i **file** di un web server è stata **aggiornata l'ultima volta in una certa data**, **controlla** la **data** in cui tutti i **file** nel **web server** sono stati creati e modificati e, se qualche data è **sospetta**, analizza quel file.
|
||||
Se sai che una cartella contenente i **file** di un web server è stata **ultima modifica in una certa data**, **controlla** la **data** di creazione e modifica di tutti i **file** nel **web server** e se qualche data è **sospetta**, controlla quel file.
|
||||
|
||||
### Linee di base
|
||||
### Baselines
|
||||
|
||||
Se i file di una cartella **non avrebbero dovuto essere modificati**, puoi calcolare l'**hash** dei **file originali** della cartella e **confrontarlo** con quelli **correnti**. Qualsiasi modifica sarà **sospetta**.
|
||||
Se i file di una cartella **non dovrebbero essere stati modificati**, puoi calcolare l'**hash** dei **file originali** della cartella e **confrontarli** con quelli **attuali**. Qualsiasi modifica sarà **sospetta**.
|
||||
|
||||
### Analisi statistica
|
||||
### Statistical Analysis
|
||||
|
||||
Quando le informazioni sono salvate nei log puoi **controllare statistiche** come quante volte è stato accesso ciascun file del web server, poiché una web shell potrebbe essere uno dei file più accessi.
|
||||
Quando le informazioni sono salvate nei log puoi **controllare statistiche** come quante volte ogni file di un web server è stato richiesto, poiché una web shell potrebbe essere tra i più richiesti.
|
||||
|
||||
---
|
||||
|
||||
### Android in-app native telemetry (no root)
|
||||
|
||||
Su Android, puoi strumentare codice nativo all'interno del processo dell'app target precaricando una piccola libreria logger prima che le altre librerie JNI vengano inizializzate. Questo fornisce visibilità precoce sul comportamento nativo senza hook di sistema o root. Un approccio popolare è SoTap: inserire libsotap.so per l'ABI corretto nell'APK e iniettare una chiamata System.loadLibrary("sotap") in fase iniziale (ad es., static initializer o Application.onCreate), quindi raccogliere i log da percorsi interni/esterni o usare Logcat come fallback.
|
||||
Su Android puoi applicare strumentazione al codice nativo all'interno del processo dell'app target pre-caricando una piccola libreria di logging prima che le altre librerie JNI vengano inizializzate. Questo fornisce visibilità precoce sul comportamento nativo senza hook di sistema o root. Un approccio popolare è SoTap: inserire libsotap.so per l'ABI corretta nell'APK e iniettare una chiamata System.loadLibrary("sotap") precocemente (ad es. initializer statico o Application.onCreate), quindi raccogliere i log da percorsi interni/esterni o come fallback da Logcat.
|
||||
|
||||
See the Android native reversing page for setup details and log paths:
|
||||
|
||||
@ -165,13 +165,13 @@ See the Android native reversing page for setup details and log paths:
|
||||
|
||||
---
|
||||
|
||||
## Deobfuscazione del controllo di flusso dinamico (JMP/CALL RAX Dispatchers)
|
||||
## Deobfuscating Dynamic Control-Flow (JMP/CALL RAX Dispatchers)
|
||||
|
||||
Le famiglie di malware moderne abusano pesantemente dell'offuscamento del Control-Flow Graph (CFG): invece di un jump/call diretto calcolano la destinazione a runtime ed eseguono un `jmp rax` o `call rax`. Un piccolo *dispatcher* (tipicamente nove istruzioni) imposta il target finale a seconda dei flag della CPU `ZF`/`CF`, compromettendo completamente il recupero statico del CFG.
|
||||
Le famiglie di malware moderne fanno un largo abuso dell'obfuscazione del Control-Flow Graph (CFG): invece di un jump/call diretto calcolano la destinazione a runtime ed eseguono un `jmp rax` o `call rax`. Un piccolo *dispatcher* (tipicamente nove istruzioni) imposta la destinazione finale in base ai flag CPU `ZF`/`CF`, rompendo completamente il recupero statico del CFG.
|
||||
|
||||
La tecnica — mostrata dal loader SLOW#TEMPEST — può essere neutralizzata con un flusso di lavoro in tre passaggi che si basa solamente su IDAPython e sull'emulatore CPU Unicorn.
|
||||
La tecnica — mostrata dal loader SLOW#TEMPEST — può essere sconfitta con un workflow in tre passi che si basa solo su IDAPython e l'emulatore CPU Unicorn.
|
||||
|
||||
### 1. Individuare ogni indirect jump / call
|
||||
### 1. Individua ogni jump / call indiretto
|
||||
```python
|
||||
import idautils, idc
|
||||
|
||||
@ -195,7 +195,7 @@ size = jmp_ea + idc.get_item_size(jmp_ea) - start
|
||||
code = idc.get_bytes(start, size)
|
||||
open(f"{start:X}.bin", "wb").write(code)
|
||||
```
|
||||
### 3. Emulalo due volte con Unicorn
|
||||
### 3. Emularlo due volte con Unicorn
|
||||
```python
|
||||
from unicorn import *
|
||||
from unicorn.x86_const import *
|
||||
@ -211,9 +211,9 @@ mu.reg_write(UC_X86_REG_RAX, 0)
|
||||
mu.emu_start(BASE, BASE+len(code))
|
||||
return mu.reg_read(UC_X86_REG_RAX)
|
||||
```
|
||||
Esegui `run(code,0,0)` e `run(code,1,1)` per ottenere i target dei rami *false* e *true*.
|
||||
Esegui `run(code,0,0)` e `run(code,1,1)` per ottenere i target dei branch *false* e *true*.
|
||||
|
||||
### 4. Ripristinare tramite patch un jump / call diretto
|
||||
### 4. Ripristinare tramite patch un direct jump / call
|
||||
```python
|
||||
import struct, ida_bytes
|
||||
|
||||
@ -222,28 +222,37 @@ op = 0xE8 if is_call else 0xE9 # CALL rel32 or JMP rel32
|
||||
disp = target - (ea + 5) & 0xFFFFFFFF
|
||||
ida_bytes.patch_bytes(ea, bytes([op]) + struct.pack('<I', disp))
|
||||
```
|
||||
Dopo il patching, forza IDA a rianalizzare la funzione in modo che il CFG completo e l'output di Hex-Rays vengano ripristinati:
|
||||
Dopo il patching, forzare IDA a rianalizzare la funzione in modo che il CFG completo e l'output di Hex-Rays siano ripristinati:
|
||||
```python
|
||||
import ida_auto, idaapi
|
||||
idaapi.reanalyze_function(idc.get_func_attr(ea, idc.FUNCATTR_START))
|
||||
```
|
||||
### 5. Etichettare le chiamate API indirette
|
||||
|
||||
Una volta che la destinazione reale di ogni `call rax` è nota, puoi indicare a IDA quale sia in modo che i tipi dei parametri e i nomi delle variabili vengano recuperati automaticamente:
|
||||
Una volta nota la destinazione reale di ogni `call rax`, puoi indicare a IDA quale sia, in modo che i tipi dei parametri & i nomi delle variabili vengano recuperati automaticamente:
|
||||
```python
|
||||
idc.set_callee_name(call_ea, resolved_addr, 0) # IDA 8.3+
|
||||
```
|
||||
### Benefici pratici
|
||||
### Vantaggi pratici
|
||||
|
||||
* Ripristina il vero CFG → la decompilazione passa da *10* righe a migliaia.
|
||||
* Abilita string-cross-reference & xrefs, rendendo la ricostruzione del comportamento semplice.
|
||||
* Gli script sono riutilizzabili: inseriscili in qualsiasi loader protetto dallo stesso trick.
|
||||
* Ripristina il reale CFG → la decompilazione passa da *10* righe a migliaia.
|
||||
* Abilita string-cross-reference & xrefs, rendendo la ricostruzione del comportamento banale.
|
||||
* Gli script sono riutilizzabili: inseriscili in qualsiasi loader protetto dallo stesso trucco.
|
||||
|
||||
---
|
||||
|
||||
## AdaptixC2: Estrazione della configurazione e TTPs
|
||||
|
||||
Vedi la pagina dedicata:
|
||||
|
||||
{{#ref}}
|
||||
adaptixc2-config-extraction-and-ttps.md
|
||||
{{#endref}}
|
||||
|
||||
## Riferimenti
|
||||
|
||||
- [Unit42 – Evolving Tactics of SLOW#TEMPEST: A Deep Dive Into Advanced Malware Techniques](https://unit42.paloaltonetworks.com/slow-tempest-malware-obfuscation/)
|
||||
- SoTap: Lightweight in-app JNI (.so) behavior logger – [github.com/RezaArbabBot/SoTap](https://github.com/RezaArbabBot/SoTap)
|
||||
- [Unit42 – AdaptixC2: A New Open-Source Framework Leveraged in Real-World Attacks](https://unit42.paloaltonetworks.com/adaptixc2-post-exploitation-framework/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user