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
6d3a07943d
commit
3e9b33aedc
@ -37,6 +37,7 @@
|
|||||||
- [Mobile Phishing Malicious Apps](generic-methodologies-and-resources/phishing-methodology/mobile-phishing-malicious-apps.md)
|
- [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)
|
- [Phishing Files & Documents](generic-methodologies-and-resources/phishing-methodology/phishing-documents.md)
|
||||||
- [Basic Forensic Methodology](generic-methodologies-and-resources/basic-forensic-methodology/README.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)
|
- [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)
|
- [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)
|
- [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)
|
- [Seccomp](linux-hardening/privilege-escalation/docker-security/seccomp.md)
|
||||||
- [Weaponizing Distroless](linux-hardening/privilege-escalation/docker-security/weaponizing-distroless.md)
|
- [Weaponizing Distroless](linux-hardening/privilege-escalation/docker-security/weaponizing-distroless.md)
|
||||||
- [Escaping from Jails](linux-hardening/privilege-escalation/escaping-from-limited-bash.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)
|
- [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)
|
- [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)
|
- [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 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)
|
- [Stack Pivoting - EBP2Ret - EBP chaining](binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md)
|
||||||
- [Uninitialized Variables](binary-exploitation/stack-overflow/uninitialized-variables.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)
|
- [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)
|
- [Ret2csu](binary-exploitation/rop-return-oriented-programing/ret2csu.md)
|
||||||
- [Ret2dlresolve](binary-exploitation/rop-return-oriented-programing/ret2dlresolve.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 - 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)
|
- [WWW2Exec - \_\_malloc_hook & \_\_free_hook](binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md)
|
||||||
- [Common Exploiting Problems](binary-exploitation/common-exploiting-problems.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)
|
- [Windows Exploiting (Basic Guide - OSCP lvl)](binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md)
|
||||||
- [iOS Exploiting](binary-exploitation/ios-exploiting/README.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)
|
- [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)
|
- [Stealing Sensitive Information Disclosure from a Web](todo/stealing-sensitive-information-disclosure-from-a-web.md)
|
||||||
- [Post Exploitation](todo/post-exploitation.md)
|
- [Post Exploitation](todo/post-exploitation.md)
|
||||||
- [Investment Terms](todo/investment-terms.md)
|
- [Investment Terms](todo/investment-terms.md)
|
||||||
- [Cookies Policy](todo/cookies-policy.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)
|
|
@ -0,0 +1,243 @@
|
|||||||
|
# AdaptixC2 Εξαγωγή διαμόρφωσης και TTPs
|
||||||
|
|
||||||
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
|
Το AdaptixC2 είναι ένα modular, open‑source framework post‑exploitation/C2 με Windows x86/x64 beacons (EXE/DLL/service EXE/raw shellcode) και υποστήριξη BOF. Αυτή η σελίδα τεκμηριώνει:
|
||||||
|
- Πώς η RC4‑packed διαμόρφωσή του ενσωματώνεται και πώς να την εξαγάγετε από beacons
|
||||||
|
- Δείκτες δικτύου/προφίλ για HTTP/SMB/TCP listeners
|
||||||
|
- Κοινές TTPs για loader και persistence που παρατηρήθηκαν στο πεδίο, με links προς σχετικές σελίδες τεχνικών για Windows
|
||||||
|
|
||||||
|
## Beacon profiles and fields
|
||||||
|
|
||||||
|
Το AdaptixC2 υποστηρίζει τρεις κύριους τύπους beacon:
|
||||||
|
- BEACON_HTTP: web C2 με ρυθμιζόμενους servers/ports/SSL, method, URI, headers, user‑agent, και ένα custom parameter name
|
||||||
|
- BEACON_SMB: named‑pipe peer‑to‑peer C2 (intranet)
|
||||||
|
- BEACON_TCP: direct sockets, προαιρετικά με ένα prepended marker για να αποπροσανατολίσει την έναρξη του πρωτοκόλλου
|
||||||
|
|
||||||
|
Τυπικά πεδία προφίλ που παρατηρούνται σε HTTP beacon configs (μετά την αποκρυπτογράφηση):
|
||||||
|
- 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) – χρησιμοποιούνται για να αναλύσουν τα μεγέθη των αποκρίσεων
|
||||||
|
- kill_date (u32), working_time (u32)
|
||||||
|
- sleep_delay (u32), jitter_delay (u32)
|
||||||
|
- listener_type (u32)
|
||||||
|
- download_chunk_size (u32)
|
||||||
|
|
||||||
|
Παράδειγμα προεπιλεγμένου HTTP profile (από ένα beacon build):
|
||||||
|
```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
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Παρατηρήθηκε κακόβουλο προφίλ HTTP (πραγματική επίθεση):
|
||||||
|
```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
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Κρυπτογραφημένη συσκευασία διαμόρφωσης και διαδρομή φόρτωσης
|
||||||
|
|
||||||
|
Όταν ο χειριστής κάνει κλικ στο Create στον builder, το AdaptixC2 ενσωματώνει το κρυπτογραφημένο προφίλ ως tail blob στο beacon. Η μορφή είναι:
|
||||||
|
- 4 bytes: μέγεθος διαμόρφωσης (uint32, little‑endian)
|
||||||
|
- N bytes: RC4‑κρυπτογραφημένα δεδομένα διαμόρφωσης
|
||||||
|
- 16 bytes: RC4 κλειδί
|
||||||
|
|
||||||
|
Ο beacon loader αντιγράφει το 16‑byte κλειδί από το τέλος και RC4‑αποκρυπτογραφεί το μπλοκ των N‑byte επί τόπου:
|
||||||
|
```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);
|
||||||
|
```
|
||||||
|
Practical implications:
|
||||||
|
- Η ολόκληρη δομή συχνά βρίσκεται μέσα στο τμήμα .rdata του PE.
|
||||||
|
- Η εξαγωγή είναι ντετερμινιστική: read size, read ciphertext of that size, read the 16‑byte key placed immediately after, then RC4‑decrypt.
|
||||||
|
|
||||||
|
## Διαδικασία εξαγωγής διαμόρφωσης (αμυνόμενοι)
|
||||||
|
|
||||||
|
Γράψτε ένα εργαλείο εξαγωγής που μιμείται τη λογική του beacon:
|
||||||
|
1) Εντοπίστε το blob μέσα στο PE (συνήθως .rdata). Μια πρακτική προσέγγιση είναι να σαρώσετε το .rdata για μια πιθανή διάταξη [size|ciphertext|16‑byte key] και να δοκιμάσετε RC4.
|
||||||
|
2) Διαβάστε τα πρώτα 4 bytes → size (uint32 LE).
|
||||||
|
3) Διαβάστε τα επόμενα N=size bytes → ciphertext.
|
||||||
|
4) Διαβάστε τα τελικά 16 bytes → RC4 key.
|
||||||
|
5) RC4‑decrypt το ciphertext. Έπειτα αναλύστε το plain profile ως:
|
||||||
|
- u32/boolean scalars όπως αναφέρθηκαν παραπάνω
|
||||||
|
- length‑prefixed strings (u32 length followed by bytes; trailing NUL can be present)
|
||||||
|
- arrays: servers_count followed by that many [string, u32 port] pairs
|
||||||
|
|
||||||
|
Minimal Python proof‑of‑concept (standalone, χωρίς εξωτερικές εξαρτήσεις) που λειτουργεί με ένα προ‑εξαγόμενο blob:
|
||||||
|
```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:
|
||||||
|
- Κατά την αυτοματοποίηση, χρησιμοποιήστε έναν PE parser για να διαβάσετε το .rdata και στη συνέχεια εφαρμόστε ένα sliding window: για κάθε offset o, δοκιμάστε size = u32(.rdata[o:o+4]), ct = .rdata[o+4:o+4+size], candidate key = next 16 bytes; RC4‑decrypt και ελέγξτε ότι τα string fields αποκωδικοποιούνται ως UTF‑8 και ότι τα μήκη είναι λογικά.
|
||||||
|
- Αναλύστε SMB/TCP προφίλ ακολουθώντας τις ίδιες length‑prefixed συμβάσεις.
|
||||||
|
|
||||||
|
## Network fingerprinting and hunting
|
||||||
|
|
||||||
|
HTTP
|
||||||
|
- Συνηθισμένο: POST σε URIs επιλεγμένα από τον operator (π.χ., /uri.php, /endpoint/api)
|
||||||
|
- Προσαρμοσμένη παράμετρος header που χρησιμοποιείται για το beacon ID (π.χ., X‑Beacon‑Id, X‑App‑Id)
|
||||||
|
- User‑agents που μιμούνται το Firefox 20 ή σύγχρονες Chrome builds
|
||||||
|
- Ρυθμός polling ορατός μέσω sleep_delay/jitter_delay
|
||||||
|
|
||||||
|
SMB/TCP
|
||||||
|
- SMB named‑pipe listeners για intranet C2 όπου το web egress είναι περιορισμένο
|
||||||
|
- TCP beacons μπορεί να προθέτουν μερικά bytes πριν την κίνηση για να συγκαλύψουν την έναρξη του πρωτοκόλλου
|
||||||
|
|
||||||
|
## Loader and persistence TTPs seen in incidents
|
||||||
|
|
||||||
|
PowerShell loaders σε μνήμη (in‑memory)
|
||||||
|
- Κατεβάζουν payloads σε Base64/XOR (Invoke‑RestMethod / WebClient)
|
||||||
|
- Κάνουν allocate unmanaged memory, αντιγράφουν shellcode, αλλάζουν το protection σε 0x40 (PAGE_EXECUTE_READWRITE) μέσω VirtualProtect
|
||||||
|
- Εκτέλεση μέσω .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 (.lnk) για επανεκκίνηση του loader κατά το logon
|
||||||
|
- Registry Run keys (HKCU/HKLM ...\CurrentVersion\Run), συχνά με ονόματα που ακούγονται benign όπως "Updater" για να εκκινήσει το loader.ps1
|
||||||
|
- DLL search‑order hijack με τοποθέτηση msimg32.dll στο %APPDATA%\Microsoft\Windows\Templates για ευάλωτες διεργασίες
|
||||||
|
|
||||||
|
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 με μεταβάσεις RW→RX: VirtualProtect σε PAGE_EXECUTE_READWRITE μέσα σε powershell.exe
|
||||||
|
- Δυναμικά πρότυπα invocation (GetDelegateForFunctionPointer)
|
||||||
|
- Startup .lnk στον φάκελο Startup του χρήστη ή στους κοινόχρηστους φακέλους Startup
|
||||||
|
- Υποψιάζoμενα Run keys (π.χ., "Updater"), και ονόματα loader όπως update.ps1/loader.ps1
|
||||||
|
- Διαδρομές DLL εγγράψιμες από τον χρήστη κάτω από %APPDATA%\Microsoft\Windows\Templates που περιέχουν msimg32.dll
|
||||||
|
|
||||||
|
## Notes on OpSec fields
|
||||||
|
|
||||||
|
- KillDate: χρονική σφραγίδα μετά την οποία το agent αυτο‑λήγει
|
||||||
|
- WorkingTime: ώρες κατά τις οποίες ο agent θα πρέπει να είναι ενεργός για να συγχωνευτεί με την επιχειρησιακή δραστηριότητα
|
||||||
|
|
||||||
|
Αυτά τα πεδία μπορούν να χρησιμοποιηθούν για clustering και για να εξηγήσουν παρατηρούμενες ήσυχες περιόδους.
|
||||||
|
|
||||||
|
## YARA and static leads
|
||||||
|
|
||||||
|
Unit 42 δημοσίευσε βασικές YARA για beacons (C/C++ και Go) και constants για loader API‑hashing. Σκεφτείτε να συμπληρώσετε με κανόνες που αναζητούν τη διάταξη [size|ciphertext|16‑byte‑key] κοντά στο τέλος του PE .rdata και τις προεπιλεγμένες συμβολοσειρές προφίλ HTTP.
|
||||||
|
|
||||||
|
## 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 @@
|
|||||||
# Ανάλυση Κακόβουλου Λογισμικού
|
# Ανάλυση Malware
|
||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
## Cheatsheets Ψηφιακής Εγκληματολογίας
|
## CheatSheets Ψηφιακής Εγκληματολογίας
|
||||||
|
|
||||||
[https://www.jaiminton.com/cheatsheet/DFIR/#](https://www.jaiminton.com/cheatsheet/DFIR/)
|
[https://www.jaiminton.com/cheatsheet/DFIR/#](https://www.jaiminton.com/cheatsheet/DFIR/)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@
|
|||||||
- [Intezer](https://analyze.intezer.com)
|
- [Intezer](https://analyze.intezer.com)
|
||||||
- [Any.Run](https://any.run/)
|
- [Any.Run](https://any.run/)
|
||||||
|
|
||||||
## Offline Antivirus και Εργαλεία Ανίχνευσης
|
## Εργαλεία Antivirus και Ανίχνευσης (Offline)
|
||||||
|
|
||||||
### Yara
|
### Yara
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ sudo apt-get install -y yara
|
|||||||
```
|
```
|
||||||
#### Προετοιμασία κανόνων
|
#### Προετοιμασία κανόνων
|
||||||
|
|
||||||
Χρησιμοποιήστε αυτό το script για να κατεβάσετε και να συγχωνεύσετε όλους τους yara malware rules από github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\
|
Χρησιμοποιήστε αυτό το script για να κατεβάσετε και να συγχωνεύσετε όλους τους yara malware κανόνες από github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\
|
||||||
Δημιουργήστε τον φάκελο _**rules**_ και εκτελέστε το. Αυτό θα δημιουργήσει ένα αρχείο με όνομα _**malware_rules.yar**_ που περιέχει όλους τους yara rules για malware.
|
Δημιουργήστε τον φάκελο _**rules**_ και εκτελέστε το. Αυτό θα δημιουργήσει ένα αρχείο με όνομα _**malware_rules.yar**_ που περιέχει όλους τους yara κανόνες για malware.
|
||||||
```bash
|
```bash
|
||||||
wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py
|
wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py
|
||||||
mkdir rules
|
mkdir rules
|
||||||
@ -36,9 +36,9 @@ python malware_yara_rules.py
|
|||||||
yara -w malware_rules.yar image #Scan 1 file
|
yara -w malware_rules.yar image #Scan 1 file
|
||||||
yara -w malware_rules.yar folder #Scan the whole folder
|
yara -w malware_rules.yar folder #Scan the whole folder
|
||||||
```
|
```
|
||||||
#### YaraGen: Ελέγξτε για malware και δημιουργήστε κανόνες
|
#### YaraGen: Έλεγχος για malware και δημιουργία κανόνων
|
||||||
|
|
||||||
Μπορείτε να χρησιμοποιήσετε το εργαλείο [**YaraGen**](https://github.com/Neo23x0/yarGen) για να δημιουργήσετε yara rules από ένα δυαδικό αρχείο. Δείτε αυτούς τους οδηγούς: [**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/)
|
Μπορείτε να χρησιμοποιήσετε το εργαλείο [**YaraGen**](https://github.com/Neo23x0/yarGen) για να δημιουργήσετε yara rules από ένα binary. Δείτε αυτούς τους οδηγούς: [**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
|
```bash
|
||||||
python3 yarGen.py --update
|
python3 yarGen.py --update
|
||||||
python3.exe yarGen.py --excludegood -m ../../mals/
|
python3.exe yarGen.py --excludegood -m ../../mals/
|
||||||
@ -57,21 +57,21 @@ clamscan folderpath #Scan the whole folder
|
|||||||
```
|
```
|
||||||
### [Capa](https://github.com/mandiant/capa)
|
### [Capa](https://github.com/mandiant/capa)
|
||||||
|
|
||||||
**Capa** εντοπίζει πιθανώς κακόβουλες **capabilities** σε executables: PE, ELF, .NET. Έτσι θα βρει πράγματα όπως Att\&ck tactics, ή ύποπτες **capabilities** όπως:
|
**Capa** ανιχνεύει ενδεχομένως κακόβουλες **capabilities** σε εκτελέσιμα: PE, ELF, .NET. Έτσι θα βρει πράγματα όπως Att\&ck tactics, ή ύποπτες capabilities όπως:
|
||||||
|
|
||||||
- check for OutputDebugString error
|
- check for OutputDebugString error
|
||||||
- run as a service
|
- run as a service
|
||||||
- create process
|
- create process
|
||||||
|
|
||||||
Κατέβασέ το από το [**Github repo**](https://github.com/mandiant/capa).
|
Πάρε το από το [**Github repo**](https://github.com/mandiant/capa).
|
||||||
|
|
||||||
### IOCs
|
### IOCs
|
||||||
|
|
||||||
IOC σημαίνει Indicator Of Compromise. Ένα IOC είναι ένα σύνολο **κριτηρίων που προσδιορίζουν** κάποιο πιθανώς ανεπιθύμητο λογισμικό ή επιβεβαιωμένο **malware**. Οι Blue Teams χρησιμοποιούν αυτόν τον τύπο ορισμού για να **αναζητήσουν αυτό το είδος κακόβουλων αρχείων** στα **συστήματα** και τα **δίκτυά** τους.\
|
IOC σημαίνει Indicator Of Compromise. Ένας IOC είναι ένα σύνολο **συνθηκών που αναγνωρίζουν** κάποιο ενδεχομένως ανεπιθύμητο λογισμικό ή επιβεβαιωμένο **malware**. Οι Blue Teams χρησιμοποιούν αυτόν τον τύπο ορισμού για να **αναζητήσουν αυτό το είδος κακόβουλων αρχείων** στα **systems** και **networks** τους.\
|
||||||
Η κοινοποίηση αυτών των ορισμών είναι πολύ χρήσιμη, αφού όταν ένα malware εντοπιστεί σε έναν υπολογιστή και δημιουργηθεί ένα IOC για αυτό, άλλες Blue Teams μπορούν να το χρησιμοποιήσουν για να αναγνωρίσουν το malware πιο γρήγορα.
|
Η κοινή χρήση αυτών των ορισμών είναι πολύ χρήσιμη, καθώς όταν εντοπιστεί malware σε έναν υπολογιστή και δημιουργηθεί ένας IOC για αυτό, άλλοι Blue Teams μπορούν να τον χρησιμοποιήσουν για να εντοπίσουν το malware πιο γρήγορα.
|
||||||
|
|
||||||
Ένα εργαλείο για να δημιουργείς ή να τροποποιείς IOCs είναι [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\
|
Ένα εργαλείο για να δημιουργήσετε ή να τροποποιήσετε IOCs είναι το [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\
|
||||||
Μπορείς να χρησιμοποιήσεις εργαλεία όπως [**Redline**](https://www.fireeye.com/services/freeware/redline.html) για να **search for defined IOCs in a device**.
|
Μπορείτε να χρησιμοποιήσετε εργαλεία όπως το [**Redline**](https://www.fireeye.com/services/freeware/redline.html) για να **αναζητήσετε ορισμένους IOCs σε μια συσκευή**.
|
||||||
|
|
||||||
### Loki
|
### Loki
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ Compares process connection endpoints with C2 IOCs (new since version v.10)
|
|||||||
```
|
```
|
||||||
### Linux Malware Detect
|
### Linux Malware Detect
|
||||||
|
|
||||||
[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) είναι ένας malware scanner για Linux που κυκλοφορεί υπό την άδεια GNU GPLv2 και έχει σχεδιαστεί για τις απειλές που αντιμετωπίζονται σε κοινόχρηστα περιβάλλοντα φιλοξενίας. Χρησιμοποιεί δεδομένα απειλών από network edge intrusion detection systems για να εξάγει malware που χρησιμοποιείται ενεργά σε επιθέσεις και να δημιουργεί signatures για τον εντοπισμό. Επιπλέον, δεδομένα απειλών προέρχονται επίσης από υποβολές χρηστών μέσω του LMD checkout feature και από πόρους της malware κοινότητας.
|
[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) είναι ένας σαρωτής malware για Linux που κυκλοφορεί υπό την άδεια GNU GPLv2 και έχει σχεδιαστεί για τις απειλές που αντιμετωπίζονται σε κοινόχρηστα φιλοξενούμενα περιβάλλοντα. Χρησιμοποιεί δεδομένα απειλών από network edge intrusion detection systems για να εξάγει malware που χρησιμοποιείται ενεργά σε επιθέσεις και να δημιουργεί υπογραφές για εντοπισμό. Επιπλέον, δεδομένα απειλών προέρχονται επίσης από υποβολές χρηστών μέσω του LMD checkout feature και από malware community resources.
|
||||||
|
|
||||||
### rkhunter
|
### rkhunter
|
||||||
|
|
||||||
@ -102,31 +102,31 @@ sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--sk
|
|||||||
```
|
```
|
||||||
### FLOSS
|
### FLOSS
|
||||||
|
|
||||||
[**FLOSS**](https://github.com/mandiant/flare-floss) είναι ένα εργαλείο που θα προσπαθήσει να εντοπίσει obfuscated strings μέσα σε executables χρησιμοποιώντας διάφορες τεχνικές.
|
[**FLOSS**](https://github.com/mandiant/flare-floss) είναι ένα εργαλείο που θα προσπαθήσει να βρει obfuscated strings μέσα σε executables χρησιμοποιώντας διάφορες τεχνικές.
|
||||||
|
|
||||||
### PEpper
|
### PEpper
|
||||||
|
|
||||||
[PEpper ](https://github.com/Th3Hurrican3/PEpper) ελέγχει κάποια βασικά πράγματα μέσα στο executable (binary data, entropy, URLs and IPs, κάποια yara rules).
|
[PEpper ](https://github.com/Th3Hurrican3/PEpper)ελέγχει κάποια βασικά στοιχεία μέσα στο executable (binary data, entropy, URLs and IPs, μερικούς yara rules).
|
||||||
|
|
||||||
### PEstudio
|
### PEstudio
|
||||||
|
|
||||||
[PEstudio](https://www.winitor.com/download) είναι ένα εργαλείο που επιτρέπει την άντληση πληροφοριών για Windows executables όπως imports, exports, headers, αλλά επίσης θα ελέγξει virus total και θα εντοπίσει πιθανές Att\&ck τεχνικές.
|
[PEstudio](https://www.winitor.com/download) είναι ένα εργαλείο που επιτρέπει να λάβετε πληροφορίες για Windows executables όπως imports, exports, headers, αλλά επίσης θα ελέγξει το virus total και θα βρει πιθανές Att\&ck τεχνικές.
|
||||||
|
|
||||||
### Detect It Easy(DiE)
|
### Detect It Easy(DiE)
|
||||||
|
|
||||||
[**DiE**](https://github.com/horsicq/Detect-It-Easy/) είναι ένα εργαλείο για να ανιχνεύσει αν ένα αρχείο είναι **encrypted** και επίσης να βρει **packers**.
|
[**DiE**](https://github.com/horsicq/Detect-It-Easy/) είναι ένα εργαλείο για να εντοπίσει αν ένα αρχείο είναι **encrypted** και επίσης να βρει **packers**.
|
||||||
|
|
||||||
### NeoPI
|
### NeoPI
|
||||||
|
|
||||||
[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI) είναι ένα Python script που χρησιμοποιεί μια ποικιλία **statistical methods** για να ανιχνεύσει **obfuscated** και **encrypted** περιεχόμενο μέσα σε text/script αρχεία. Ο σκοπός του NeoPI είναι να βοηθήσει στην **detection of hidden web shell code**.
|
[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)είναι ένα Python script που χρησιμοποιεί μια σειρά από **statistical methods** για να εντοπίσει **obfuscated** και **encrypted** περιεχόμενο μέσα σε αρχεία κειμένου/script. Ο σκοπός του NeoPI είναι να βοηθήσει στην **detection of hidden web shell code**.
|
||||||
|
|
||||||
### **php-malware-finder**
|
### **php-malware-finder**
|
||||||
|
|
||||||
[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) κάνει ό,τι καλύτερο μπορεί για να εντοπίσει **obfuscated**/**dodgy code** καθώς και αρχεία που χρησιμοποιούν **PHP** functions που συχνά χρησιμοποιούνται σε **malwares**/webshells.
|
[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) κάνει το καλύτερο δυνατό για να εντοπίσει **obfuscated**/**dodgy code** καθώς και αρχεία που χρησιμοποιούν **PHP** functions που συχνά χρησιμοποιούνται σε **malwares**/webshells.
|
||||||
|
|
||||||
### Apple Binary Signatures
|
### Apple Binary Signatures
|
||||||
|
|
||||||
Όταν ελέγχετε κάποιο **malware sample** θα πρέπει πάντα να **check the signature** του binary, καθώς ο **developer** που το υπέγραψε μπορεί ήδη να είναι **related** με **malware.**
|
Όταν ελέγχετε κάποιο **malware sample**, θα πρέπει πάντα να **check the signature** του binary, καθώς ο **developer** που το υπέγραψε μπορεί να είναι ήδη **related** με **malware.**
|
||||||
```bash
|
```bash
|
||||||
#Get signer
|
#Get signer
|
||||||
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"
|
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"
|
||||||
@ -139,23 +139,23 @@ spctl --assess --verbose /Applications/Safari.app
|
|||||||
```
|
```
|
||||||
## Τεχνικές Ανίχνευσης
|
## Τεχνικές Ανίχνευσης
|
||||||
|
|
||||||
### File Stacking
|
### Στοίβα Αρχείων
|
||||||
|
|
||||||
Αν ξέρετε ότι κάποιος φάκελος που περιέχει τα **files** ενός web server ενημερώθηκε **τελευταία φορά σε κάποια ημερομηνία**, **ελέγξτε** την **ημερομηνία** δημιουργίας και τροποποίησης όλων των **files** στον **web server** και αν κάποια ημερομηνία είναι **ύποπτη**, ελέγξτε εκείνο το αρχείο.
|
Αν γνωρίζετε ότι κάποιος φάκελος που περιέχει τα **αρχεία** ενός web server ενημερώθηκε **τελευταία σε κάποια ημερομηνία**, **ελέγξτε** την **ημερομηνία δημιουργίας και τροποποίησης** όλων των **αρχείων** στον **web server** και αν κάποια ημερομηνία είναι **ύποπτη**, ελέγξτε εκείνο το αρχείο.
|
||||||
|
|
||||||
### Βάσεις Αναφοράς
|
### Βασικές Γραμμές
|
||||||
|
|
||||||
Αν τα αρχεία ενός φακέλου **δεν έπρεπε να έχουν τροποποιηθεί**, μπορείτε να υπολογίσετε το **hash** των **αρχικών αρχείων** του φακέλου και να τα **συγκρίνετε** με τα **τρέχοντα**. Οτιδήποτε τροποποιημένο θα είναι **ύποπτο**.
|
Αν τα αρχεία ενός φακέλου **δεν θα έπρεπε να έχουν τροποποιηθεί**, μπορείτε να υπολογίσετε το **hash** των **αρχικών αρχείων** του φακέλου και να τα **συγκρίνετε** με τα **τρέχοντα**. Οτιδήποτε τροποποιημένο θα είναι **ύποπτο**.
|
||||||
|
|
||||||
### Στατιστική Ανάλυση
|
### Στατιστική Ανάλυση
|
||||||
|
|
||||||
Όταν οι πληροφορίες αποθηκεύονται σε logs μπορείτε να **ελέγξετε στατιστικά** όπως πόσες φορές προσπελάστηκε κάθε αρχείο του web server, αφού ένα web shell μπορεί να είναι ένα από τα πιο προσπελασμένα.
|
Όταν οι πληροφορίες αποθηκεύονται σε logs μπορείτε να **ελέγξετε στατιστικά όπως πόσες φορές κάθε αρχείο ενός web server προσπελάστηκε καθώς ένα web shell μπορεί να είναι ένα από τα πιο**.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Android in-app native telemetry (no root)
|
### Android in-app native telemetry (no root)
|
||||||
|
|
||||||
Σε Android, μπορείτε να instrument το native code μέσα στη διαδικασία του target app προφορτώνοντας μια μικρή βιβλιοθήκη logger πριν αρχικοποιηθούν άλλες JNI libs. Αυτό δίνει πρώιμη ορατότητα στη native συμπεριφορά χωρίς system-wide hooks ή root. Μια δημοφιλής προσέγγιση είναι το SoTap: βάλτε libsotap.so για το σωστό ABI μέσα στο APK και εισάγετε μια κλήση System.loadLibrary("sotap") νωρίς (π.χ., static initializer ή Application.onCreate), στη συνέχεια συλλέξτε logs από εσωτερικές/εξωτερικές διαδρομές ή fallback σε Logcat.
|
On Android, you can instrument native code inside the target app process by preloading a tiny logger library before other JNI libs initialize. This gives early visibility into native behavior without system-wide hooks or root. A popular approach is SoTap: drop libsotap.so for the right ABI into the APK and inject a System.loadLibrary("sotap") call early (e.g., static initializer or Application.onCreate), then collect logs from internal/external paths or Logcat fallback.
|
||||||
|
|
||||||
See the Android native reversing page for setup details and log paths:
|
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:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Deobfuscating Dynamic Control-Flow (JMP/CALL RAX Dispatchers)
|
## Αποκρυπτογράφηση της δυναμικής ροής ελέγχου (JMP/CALL RAX Dispatchers)
|
||||||
|
|
||||||
Modern malware families heavily abuse Control-Flow Graph (CFG) obfuscation: instead of a direct jump/call they compute the destination at run-time and execute a `jmp rax` or `call rax`. A small *dispatcher* (typically nine instructions) sets the final target depending on the CPU `ZF`/`CF` flags, completely breaking static CFG recovery.
|
Σύγχρονες οικογένειες malware καταχρώνται έντονα τη θόλωση του Control-Flow Graph (CFG): αντί για έναν άμεσο jump/call, υπολογίζουν τον προορισμό κατά το runtime και εκτελούν `jmp rax` ή `call rax`. Ένας μικρός *dispatcher* (συνήθως εννέα εντολές) ορίζει τον τελικό στόχο ανάλογα με τα CPU `ZF`/`CF` flags, καταστρέφοντας εντελώς τη στατική ανάκτηση του CFG.
|
||||||
|
|
||||||
The technique – showcased by the SLOW#TEMPEST loader – can be defeated with a three-step workflow that only relies on IDAPython and the Unicorn CPU emulator.
|
Η τεχνική – showcased by the SLOW#TEMPEST loader – μπορεί να παρακαμφθεί με ένα τριών βημάτων workflow που βασίζεται μόνο σε IDAPython και τον Unicorn CPU emulator.
|
||||||
|
|
||||||
### 1. Εντοπίστε κάθε έμμεσο jump / call
|
### 1. Εντοπίστε κάθε indirect jump / call
|
||||||
```python
|
```python
|
||||||
import idautils, idc
|
import idautils, idc
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ mnem = idc.print_insn_mnem(ea)
|
|||||||
if mnem in ("jmp", "call") and idc.print_operand(ea, 0) == "rax":
|
if mnem in ("jmp", "call") and idc.print_operand(ea, 0) == "rax":
|
||||||
print(f"[+] Dispatcher found @ {ea:X}")
|
print(f"[+] Dispatcher found @ {ea:X}")
|
||||||
```
|
```
|
||||||
### 2. Εξαγάγετε το dispatcher byte-code
|
### 2. Εξαγωγή του byte-code του dispatcher
|
||||||
```python
|
```python
|
||||||
import idc
|
import idc
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ size = jmp_ea + idc.get_item_size(jmp_ea) - start
|
|||||||
code = idc.get_bytes(start, size)
|
code = idc.get_bytes(start, size)
|
||||||
open(f"{start:X}.bin", "wb").write(code)
|
open(f"{start:X}.bin", "wb").write(code)
|
||||||
```
|
```
|
||||||
### 3. Εξομοιώστε το δύο φορές με το Unicorn
|
### 3. Εξομοιώστε το δύο φορές με Unicorn
|
||||||
```python
|
```python
|
||||||
from unicorn import *
|
from unicorn import *
|
||||||
from unicorn.x86_const 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))
|
mu.emu_start(BASE, BASE+len(code))
|
||||||
return mu.reg_read(UC_X86_REG_RAX)
|
return mu.reg_read(UC_X86_REG_RAX)
|
||||||
```
|
```
|
||||||
Εκτελέστε `run(code,0,0)` και `run(code,1,1)` για να αποκτήσετε τους στόχους των κλάδων *false* και *true*.
|
Εκτελέστε `run(code,0,0)` και `run(code,1,1)` για να λάβετε τους *false* και *true* branch targets.
|
||||||
|
|
||||||
### 4. Επαναφορά με patch ενός άμεσου jump / call
|
### 4. Επαναφορά (patch back) άμεσου jump / call
|
||||||
```python
|
```python
|
||||||
import struct, ida_bytes
|
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
|
disp = target - (ea + 5) & 0xFFFFFFFF
|
||||||
ida_bytes.patch_bytes(ea, bytes([op]) + struct.pack('<I', disp))
|
ida_bytes.patch_bytes(ea, bytes([op]) + struct.pack('<I', disp))
|
||||||
```
|
```
|
||||||
Μετά το patching, αναγκάστε το IDA να αναλύσει ξανά τη συνάρτηση ώστε να αποκατασταθούν ο πλήρης CFG και η έξοδος του Hex-Rays:
|
Μετά το patch, αναγκάστε το IDA να αναλύσει ξανά τη συνάρτηση ώστε να αποκατασταθούν το πλήρες CFG και η έξοδος του Hex-Rays:
|
||||||
```python
|
```python
|
||||||
import ida_auto, idaapi
|
import ida_auto, idaapi
|
||||||
idaapi.reanalyze_function(idc.get_func_attr(ea, idc.FUNCATTR_START))
|
idaapi.reanalyze_function(idc.get_func_attr(ea, idc.FUNCATTR_START))
|
||||||
```
|
```
|
||||||
### 5. Επισήμανση έμμεσων κλήσεων API
|
### 5. Επισημάνετε έμμεσες κλήσεις API
|
||||||
|
|
||||||
Αφού γίνει γνωστός ο πραγματικός προορισμός κάθε `call rax`, μπορείτε να πείτε στην IDA τι είναι, ώστε οι τύποι παραμέτρων & τα ονόματα μεταβλητών να ανακτηθούν αυτόματα:
|
Μόλις γίνει γνωστός ο πραγματικός προορισμός κάθε `call rax`, μπορείτε να πείτε στο IDA τι είναι, ώστε οι τύποι παραμέτρων & τα ονόματα μεταβλητών να ανακτηθούν αυτόματα:
|
||||||
```python
|
```python
|
||||||
idc.set_callee_name(call_ea, resolved_addr, 0) # IDA 8.3+
|
idc.set_callee_name(call_ea, resolved_addr, 0) # IDA 8.3+
|
||||||
```
|
```
|
||||||
### Πρακτικά οφέλη
|
### Πρακτικά οφέλη
|
||||||
|
|
||||||
* Επαναφέρει το πραγματικό CFG → η decompilation αυξάνεται από *10* γραμμές σε χιλιάδες.
|
* Επαναφέρει το πραγματικό CFG → decompilation πηγαίνει από *10* γραμμές σε χιλιάδες.
|
||||||
* Ενεργοποιεί string-cross-reference & xrefs, καθιστώντας την ανακατασκευή της συμπεριφοράς πολύ απλή.
|
* Επιτρέπει string-cross-reference & xrefs, καθιστώντας την ανακατασκευή της συμπεριφοράς απλή.
|
||||||
* Τα Scripts είναι επαναχρησιμοποιήσιμα: τοποθετήστε τα σε οποιονδήποτε loader που προστατεύεται από το ίδιο κόλπο.
|
* Scripts είναι επαναχρησιμοποιήσιμα: τοποθετήστε τα σε οποιονδήποτε loader που προστατεύεται με το ίδιο trick.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## AdaptixC2: Εξαγωγή ρυθμίσεων και TTPs
|
||||||
|
|
||||||
|
Δείτε την αφιερωμένη σελίδα:
|
||||||
|
|
||||||
|
{{#ref}}
|
||||||
|
adaptixc2-config-extraction-and-ttps.md
|
||||||
|
{{#endref}}
|
||||||
|
|
||||||
## Αναφορές
|
## Αναφορές
|
||||||
|
|
||||||
- [Unit42 – Evolving Tactics of SLOW#TEMPEST: A Deep Dive Into Advanced Malware Techniques](https://unit42.paloaltonetworks.com/slow-tempest-malware-obfuscation/)
|
- [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)
|
- 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}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user