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
f592615a03
commit
90645289d5
@ -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 구성 추출 및 TTPs
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
AdaptixC2는 Windows x86/x64 beacons(EXE/DLL/service EXE/raw shellcode) 및 BOF를 지원하는 모듈식의 오픈소스 post‑exploitation/C2 프레임워크입니다. 이 페이지는 다음을 문서화합니다:
|
||||
- RC4‑packed configuration이 어떻게 포함되어 있는지와 beacon에서 이를 추출하는 방법
|
||||
- HTTP/SMB/TCP 리스너에 대한 네트워크/프로필 지표
|
||||
- 실제 사례에서 관찰된 일반적인 loader 및 persistence TTPs와 관련 Windows technique 페이지로의 링크
|
||||
|
||||
## Beacon 프로필 및 필드
|
||||
|
||||
AdaptixC2는 세 가지 주요 beacon 타입을 지원합니다:
|
||||
- BEACON_HTTP: 서버/포트/SSL, method, URI, headers, user‑agent 및 custom parameter name을 설정할 수 있는 web C2
|
||||
- BEACON_SMB: named‑pipe 기반의 peer‑to‑peer C2 (intranet)
|
||||
- BEACON_TCP: 직접 소켓 방식, 선택적으로 프로토콜 시작을 난독화하기 위한 선행 마커(prepended marker) 포함 가능
|
||||
|
||||
HTTP beacon 구성(복호화 후)에서 관찰되는 일반적인 프로필 필드:
|
||||
- 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 프로필 (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
|
||||
}
|
||||
```
|
||||
관찰된 악성 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
|
||||
}
|
||||
```
|
||||
## 암호화된 구성 패킹 및 로드 경로
|
||||
|
||||
운영자가 builder에서 Create를 클릭하면, AdaptixC2는 암호화된 프로파일을 beacon의 tail blob으로 임베드합니다. 형식은 다음과 같습니다:
|
||||
- 4 바이트: 구성 크기 (uint32, little‑endian)
|
||||
- N 바이트: RC4‑암호화된 구성 데이터
|
||||
- 16 바이트: RC4 키
|
||||
|
||||
beacon loader는 끝에서 16‑byte 키를 복사하고 N‑byte 블록을 제자리에서 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);
|
||||
```
|
||||
실무적 시사점:
|
||||
- 전체 구조는 종종 PE .rdata 섹션 내부에 위치합니다.
|
||||
- 추출은 결정적입니다: size를 읽고, 해당 크기의 ciphertext를 읽고, 바로 다음에 위치한 16‑byte 키를 읽은 다음, RC4‑decrypt합니다.
|
||||
|
||||
## 구성 추출 워크플로우 (방어자)
|
||||
|
||||
beacon logic을 모방하는 extractor를 작성하세요:
|
||||
1) PE 내부에서 blob을 찾습니다 (일반적으로 .rdata). 실용적인 방법은 .rdata를 스캔하여 합리적인 [size|ciphertext|16‑byte key] 레이아웃을 찾고 RC4를 시도하는 것입니다.
|
||||
2) 처음 4바이트를 읽습니다 → size (uint32 LE).
|
||||
3) 다음 N=size 바이트를 읽습니다 → ciphertext.
|
||||
4) 마지막 16바이트를 읽습니다 → RC4 key.
|
||||
5) ciphertext를 RC4‑decrypt한 뒤, 평문 프로파일을 다음과 같이 파싱합니다:
|
||||
- 위에 언급한 것처럼 u32/boolean scalars
|
||||
- 길이 접두형 문자열 (u32 length 다음에 바이트; 끝의 NUL이 있을 수 있음)
|
||||
- 배열: servers_count 다음에 그 수만큼의 [string, u32 port] 쌍이 옵니다
|
||||
|
||||
사전 추출된 blob에서 동작하는 최소한의 Python proof‑of‑concept(standalone, 외부 종속 없음):
|
||||
```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)
|
||||
```
|
||||
팁:
|
||||
- 자동화할 때, PE parser를 사용해 .rdata를 읽고 슬라이딩 윈도우를 적용하세요: 각 오프셋 o에 대해 size = u32(.rdata[o:o+4]), ct = .rdata[o+4:o+4+size], candidate key = next 16 bytes; RC4‑decrypt하고 문자열 필드가 UTF‑8로 디코딩되는지와 길이가 타당한지 확인합니다.
|
||||
- 동일한 length‑prefixed 규약을 따라 SMB/TCP 프로파일을 파싱하세요.
|
||||
|
||||
## 네트워크 지문화 및 헌팅
|
||||
|
||||
HTTP
|
||||
- 일반적: 운영자 선택 URIs로 POST(예: /uri.php, /endpoint/api)
|
||||
- beacon ID에 사용되는 커스텀 헤더 파라미터(예: X‑Beacon‑Id, X‑App‑Id)
|
||||
- Firefox 20 또는 당시의 Chrome 빌드를 흉내내는 User‑agents
|
||||
- sleep_delay/jitter_delay를 통해 보이는 폴링 주기
|
||||
|
||||
SMB/TCP
|
||||
- 웹 egress가 제한된 인트라넷 C2를 위한 SMB named‑pipe 리스너
|
||||
- TCP beacons는 프로토콜 시작을 은폐하기 위해 트래픽 앞에 몇 바이트를 붙일 수 있음
|
||||
|
||||
## 인시던트에서 관찰된 Loader 및 persistence TTPs
|
||||
|
||||
메모리 내 PowerShell 로더
|
||||
- Base64/XOR 페이로드 다운로드 (Invoke‑RestMethod / WebClient)
|
||||
- unmanaged memory 할당, shellcode 복사, VirtualProtect로 보호를 0x40 (PAGE_EXECUTE_READWRITE)으로 변경
|
||||
- .NET 동적 호출로 실행: Marshal.GetDelegateForFunctionPointer + delegate.Invoke()
|
||||
|
||||
메모리 내 실행 및 AMSI/ETW 관련 고려사항은 다음 페이지를 확인하세요:
|
||||
|
||||
{{#ref}}
|
||||
../../windows-hardening/av-bypass.md
|
||||
{{#endref}}
|
||||
|
||||
관찰된 지속성 메커니즘
|
||||
- 로그온 시 로더를 재실행하기 위한 Startup 폴더의 바로가기(.lnk)
|
||||
- Registry Run 키(HKCU/HKLM ...\CurrentVersion\Run), 종종 "Updater"처럼 무해하게 들리는 이름으로 loader.ps1을 시작
|
||||
- 취약한 프로세스를 대상으로 %APPDATA%\Microsoft\Windows\Templates 아래에 msimg32.dll을 둬서 발생하는 DLL search‑order hijack
|
||||
|
||||
기술 심층 분석 및 점검:
|
||||
|
||||
{{#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}}
|
||||
|
||||
헌팅 아이디어
|
||||
- PowerShell에서 발생하는 RW→RX 전환: powershell.exe 내부에서 VirtualProtect를 통해 PAGE_EXECUTE_READWRITE
|
||||
- 동적 호출 패턴 (GetDelegateForFunctionPointer)
|
||||
- 사용자 또는 공용 Startup 폴더의 Startup .lnk
|
||||
- 의심스러운 Run 키(예: "Updater") 및 update.ps1/loader.ps1 같은 로더 이름
|
||||
- msimg32.dll을 포함하는 %APPDATA%\Microsoft\Windows\Templates 아래의 사용자 쓰기 가능한 DLL 경로
|
||||
|
||||
## OpSec 필드에 대한 노트
|
||||
|
||||
- KillDate: 에이전트가 스스로 만료되는 시점 이후의 타임스탬프
|
||||
- WorkingTime: 에이전트가 비즈니스 활동에 섞이도록 활성화되어야 하는 시간대
|
||||
|
||||
이 필드들은 클러스터링에 사용하거나 관찰된 조용한 기간을 설명하는 데 활용할 수 있습니다.
|
||||
|
||||
## YARA 및 정적 단서
|
||||
|
||||
Unit 42는 beacons(C/C++ 및 Go)용 기본 YARA와 loader API‑hashing 상수를 공개했습니다. PE .rdata 끝 근처에서 [size|ciphertext|16‑byte‑key] 레이아웃과 기본 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}}
|
@ -24,21 +24,21 @@ sudo apt-get install -y yara
|
||||
```
|
||||
#### 규칙 준비
|
||||
|
||||
이 스크립트를 사용하여 github에서 모든 yara malware rules을 다운로드하고 병합하세요: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\
|
||||
_**rules**_ 디렉토리를 생성하고 실행하세요. 그러면 모든 yara rules for malware가 포함된 _**malware_rules.yar**_ 파일이 생성됩니다.
|
||||
이 스크립트를 사용하여 GitHub에서 모든 yara malware rules를 다운로드하고 병합하세요: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\
|
||||
_**rules**_ 디렉터리를 만들고 스크립트를 실행하세요. 그러면 malware용 모든 yara rules를 포함한 _**malware_rules.yar**_ 파일이 생성됩니다.
|
||||
```bash
|
||||
wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py
|
||||
mkdir rules
|
||||
python malware_yara_rules.py
|
||||
```
|
||||
#### 스캔
|
||||
#### Scan
|
||||
```bash
|
||||
yara -w malware_rules.yar image #Scan 1 file
|
||||
yara -w malware_rules.yar folder #Scan the whole folder
|
||||
```
|
||||
#### YaraGen: malware 검사 및 yara rules 생성
|
||||
#### YaraGen: malware 검사 및 규칙 생성
|
||||
|
||||
바이너리에서 yara rules를 생성하기 위해 [**YaraGen**](https://github.com/Neo23x0/yarGen) 도구를 사용할 수 있습니다. 다음 튜토리얼을 참조하세요: [**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를 생성할 수 있습니다. 다음 튜토리얼을 확인하세요: [**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
|
||||
python3 yarGen.py --update
|
||||
python3.exe yarGen.py --excludegood -m ../../mals/
|
||||
@ -59,24 +59,24 @@ clamscan folderpath #Scan the whole folder
|
||||
|
||||
**Capa**는 실행 파일(PE, ELF, .NET)에서 잠재적으로 악의적인 **기능**을 탐지합니다. 따라서 Att\&ck 전술이나 다음과 같은 의심스러운 기능들을 찾아냅니다:
|
||||
|
||||
- check for OutputDebugString error
|
||||
- run as a service
|
||||
- create process
|
||||
- OutputDebugString 오류 확인
|
||||
- 서비스로 실행
|
||||
- 프로세스 생성
|
||||
|
||||
설치는 [**Github repo**](https://github.com/mandiant/capa)에서 받으세요.
|
||||
다운로드는 [**Github repo**](https://github.com/mandiant/capa)에서 가능합니다.
|
||||
|
||||
### IOCs
|
||||
|
||||
IOC는 Indicator Of Compromise의 약자입니다. IOC는 일부 잠재적으로 원치 않는 소프트웨어나 확인된 **malware**를 식별하는 **조건들의 집합**입니다. Blue Teams는 이러한 정의를 사용해 자신들의 **시스템**과 **네트워크**에서 이러한 종류의 악성 파일을 **검색합니다**.\
|
||||
이 정의들을 공유하는 것은 매우 유용합니다. 한 컴퓨터에서 malware가 식별되어 해당 malware에 대한 IOC가 생성되면, 다른 Blue Teams가 이를 사용해 malware를 더 빠르게 식별할 수 있기 때문입니다.
|
||||
IOC는 Indicator Of Compromise의 약자입니다. IOC는 잠재적으로 원치 않는 소프트웨어나 확인된 **malware**를 식별하는 일련의 **조건**입니다. Blue Teams는 이러한 정의를 사용하여 자신들의 **시스템** 및 **네트워크**에서 이러한 악성 파일을 **검색**합니다.\
|
||||
이 정의들을 공유하는 것은 매우 유용합니다. 한 컴퓨터에서 malware가 식별되어 해당 malware에 대한 IOC가 만들어지면, 다른 Blue Teams가 이를 사용해 malware를 더 빠르게 식별할 수 있기 때문입니다.
|
||||
|
||||
IOC를 생성하거나 수정하는 도구는 [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\
|
||||
또한 [**Redline**](https://www.fireeye.com/services/freeware/redline.html)과 같은 도구를 사용해 **장치에서 정의된 IOCs를 검색**할 수 있습니다.
|
||||
A tool to create or modify IOCs is [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\
|
||||
You can use tools such as [**Redline**](https://www.fireeye.com/services/freeware/redline.html) to **search for defined IOCs in a device**.
|
||||
|
||||
### Loki
|
||||
|
||||
[**Loki**](https://github.com/Neo23x0/Loki) 는 Simple Indicators of Compromise를 위한 스캐너입니다.\
|
||||
탐지는 네 가지 탐지 방법에 기반합니다:
|
||||
[**Loki**](https://github.com/Neo23x0/Loki) is a scanner for Simple Indicators of Compromise.\
|
||||
Detection is based on four detection methods:
|
||||
```
|
||||
1. File Name IOC
|
||||
Regex match on full file path/name
|
||||
@ -92,7 +92,7 @@ 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/)는 GNU GPLv2 license 하에 배포되는 Linux용 malware scanner로, 공유 호스팅 환경에서 직면하는 위협을 중심으로 설계되었습니다. 네트워크 에지 intrusion detection systems로부터의 위협 데이터를 이용해 공격에 실제로 사용되는 malware를 추출하고 탐지용 signatures를 생성합니다. 또한 위협 데이터는 LMD checkout feature를 통한 사용자 제출과 malware community resources에서도 파생됩니다.
|
||||
[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) 는 GNU GPLv2 라이선스 하에 배포되는 Linux용 malware scanner로, 공유 호스팅 환경에서 직면하는 위협을 중심으로 설계되었습니다. 네트워크 에지 침입 탐지 시스템으로부터 얻은 위협 데이터를 사용해 실제 공격에 사용 중인 malware를 추출하고 탐지용 시그니처를 생성합니다. 또한 LMD의 checkout 기능을 통한 사용자 제출과 malware 커뮤니티 자원으로부터 위협 데이터가 추가로 수집됩니다.
|
||||
|
||||
### rkhunter
|
||||
|
||||
@ -102,31 +102,31 @@ sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--sk
|
||||
```
|
||||
### FLOSS
|
||||
|
||||
[**FLOSS**](https://github.com/mandiant/flare-floss)는 실행 파일 내의 난독화된 문자열을 다양한 기법으로 찾아내려고 시도하는 도구입니다.
|
||||
[**FLOSS**](https://github.com/mandiant/flare-floss) 는 다양한 기법을 사용해 executables 내부의 obfuscated strings를 찾아내는 도구입니다.
|
||||
|
||||
### PEpper
|
||||
|
||||
[PEpper ](https://github.com/Th3Hurrican3/PEpper)는 실행 파일 내부의 몇 가지 기본 항목(binary data, entropy, URLs and IPs, some yara rules)을 검사합니다.
|
||||
[PEpper ](https://github.com/Th3Hurrican3/PEpper)checks executable 내부의 기본 항목들(binary data, entropy, URLs and IPs, some yara rules)을 검사합니다.
|
||||
|
||||
### PEstudio
|
||||
|
||||
[PEstudio](https://www.winitor.com/download)는 Windows 실행 파일의 imports, exports, headers 등의 정보를 얻을 수 있게 해주는 도구이며, 또한 virus total을 확인하고 잠재적인 Att\&ck 기법을 찾아냅니다.
|
||||
[PEstudio](https://www.winitor.com/download) 는 imports, exports, headers 등의 Windows executables 정보를 제공하며, virus total을 확인하고 잠재적 Att\&ck techniques를 찾아냅니다.
|
||||
|
||||
### Detect It Easy(DiE)
|
||||
|
||||
[**DiE**](https://github.com/horsicq/Detect-It-Easy/)는 파일이 **암호화된**지 여부를 감지하고 **packers**도 찾아내는 도구입니다.
|
||||
[**DiE**](https://github.com/horsicq/Detect-It-Easy/) 는 파일이 **encrypted**인지 감지하고 **packers**를 찾아내는 도구입니다.
|
||||
|
||||
### NeoPI
|
||||
|
||||
[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)은 다양한 **통계적 방법**을 사용하여 텍스트/스크립트 파일 내의 **난독화된** 및 **암호화된** 콘텐츠를 탐지하는 Python 스크립트입니다. NeoPI의 의도된 목적은 숨겨진 **web shell 코드**의 **탐지**를 돕는 것입니다.
|
||||
[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)는 다양한 **statistical methods**를 사용해 text/script 파일 내의 **obfuscated** 및 **encrypted** 콘텐츠를 탐지하는 Python 스크립트입니다. NeoPI의 목적은 hidden web shell code의 **detection**을 돕는 것입니다.
|
||||
|
||||
### **php-malware-finder**
|
||||
|
||||
[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder)는 **난독화된**/**의심스러운 코드**와 malwares/webshells에서 자주 사용되는 **PHP** 함수들을 사용하는 파일들을 탐지하는 데 최선을 다합니다.
|
||||
[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) 는 **obfuscated**/**dodgy code**뿐만 아니라 종종 malwares/webshells에서 사용되는 PHP 함수들을 사용하는 파일들을 탐지하려 최선을 다합니다.
|
||||
|
||||
### Apple Binary Signatures
|
||||
|
||||
어떤 **malware sample**을 확인할 때는 바이너리의 **서명을 확인**해야 합니다. 서명한 **developer**가 이미 **malware**와 **관련되어** 있을 수 있기 때문입니다.
|
||||
When checking some **malware sample** you should always **check the signature** of the binary as the **developer** that signed it may be already **related** with **malware.**
|
||||
```bash
|
||||
#Get signer
|
||||
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"
|
||||
@ -141,23 +141,23 @@ spctl --assess --verbose /Applications/Safari.app
|
||||
|
||||
### File Stacking
|
||||
|
||||
If you know that some folder containing the **files** of a web server was **last updated on some date**. **Check** the **date** all the **files** in the **web server were created and modified** and if any date is **suspicious**, check that file.
|
||||
어떤 폴더가 웹 서버의 **파일**을 포함하고 있고 **마지막으로 업데이트된 날짜**가 알려져 있다면, 웹 서버의 모든 **파일**이 생성 및 수정된 **날짜**를 **확인**하고 어떤 날짜가 **수상한** 경우 해당 파일을 조사하세요.
|
||||
|
||||
### Baselines
|
||||
|
||||
If the **files** of a folder **shouldn't have been modified**, you can calculate the **hash** of the **original files** of the folder and **compare** them with the **current** ones. Anything modified will be **suspicious**.
|
||||
폴더의 파일들이 **수정되지 않아야 하는 경우**, 해당 폴더의 **원본 파일**의 **hash**를 계산하여 **현재** 파일들과 **비교**하세요. 변경된 항목은 **수상합니다**.
|
||||
|
||||
### Statistical Analysis
|
||||
|
||||
When the information is saved in **logs** you can **check statistics like how many times each file of a web server was accessed as a web shell might be one of the most**.
|
||||
정보가 로그에 저장되어 있으면, 웹 서버의 각 파일이 얼마나 자주 접근되었는지와 같은 **통계(예: web shell이 가장 많이 접근된 파일 중 하나일 수 있음)를 확인**할 수 있습니다.
|
||||
|
||||
---
|
||||
|
||||
### Android in-app native telemetry (no root)
|
||||
|
||||
Android에서는 다른 JNI 라이브러리들이 초기화되기 전에 작은 로거 라이브러리를 프리로딩하여 대상 앱 프로세스 내부의 native code를 계측할 수 있습니다. 이렇게 하면 시스템 전역 훅이나 root 없이도 native 동작을 조기에 관찰할 수 있습니다. 널리 쓰이는 접근법은 SoTap입니다: 적절한 ABI에 맞는 libsotap.so를 APK에 넣고 초기에 System.loadLibrary("sotap") 호출을 삽입(예: static initializer 또는 Application.onCreate)한 뒤, internal/external 경로나 Logcat을 통해 로그를 수집합니다.
|
||||
Android에서는, 타깃 앱 프로세스 내부의 네이티브 코드를 다른 JNI 라이브러리들이 초기화되기 전에 작은 로거 라이브러리를 프리로드하여 계측할 수 있습니다. 이렇게 하면 시스템 전역 훅이나 루트 없이도 네이티브 동작을 조기에 관찰할 수 있습니다. 널리 사용되는 접근법은 SoTap입니다: 올바른 ABI용 libsotap.so를 APK에 넣고 초기 시점(예: static initializer 또는 Application.onCreate)에 System.loadLibrary("sotap") 호출을 주입한 뒤, 내부/외부 경로나 Logcat으로 로그를 수집합니다.
|
||||
|
||||
See the Android native reversing page for setup details and log paths:
|
||||
설정 방법 및 로그 경로는 Android native reversing 페이지를 참조하세요:
|
||||
|
||||
{{#ref}}
|
||||
../../mobile-pentesting/android-app-pentesting/reversing-native-libraries.md
|
||||
@ -167,11 +167,11 @@ See the Android native reversing page for setup details and log paths:
|
||||
|
||||
## Deobfuscating Dynamic Control-Flow (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.
|
||||
최근 악성코드 계열은 Control-Flow Graph (CFG) 난독화를 광범위하게 남용합니다: 직접적인 jump/call 대신 실행 시 목적지를 계산하여 `jmp rax` 또는 `call rax`를 실행합니다. 작은 *dispatcher*(보통 9개 명령어)가 CPU의 `ZF`/`CF` 플래그에 따라 최종 타깃을 설정하며, 이는 정적 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.
|
||||
이 기법은 SLOW#TEMPEST 로더에서 보여졌으며, IDAPython과 Unicorn CPU emulator만으로 수행하는 세 단계 워크플로로 대응할 수 있습니다.
|
||||
|
||||
### 1. Locate every indirect jump / call
|
||||
### 1. 모든 간접 jump / call 위치 찾기
|
||||
```python
|
||||
import idautils, idc
|
||||
|
||||
@ -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)
|
||||
```
|
||||
`run(code,0,0)` 및 `run(code,1,1)`을 실행하여 *false* 및 *true* 분기 타겟을 얻습니다.
|
||||
`run(code,0,0)` 및 `run(code,1,1)`을 실행하여 *false* 및 *true* 브랜치 타깃을 얻으세요.
|
||||
|
||||
### 4. 직접적인 jump / call 복원
|
||||
### 4. 직접적인 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))
|
||||
```
|
||||
패치 후에는 전체 CFG와 Hex-Rays 출력이 복원되도록 IDA에 함수를 강제로 다시 분석시키세요:
|
||||
패치한 후 IDA에게 함수를 재분석하도록 강제하여 전체 CFG와 Hex-Rays 출력이 복원되도록 합니다:
|
||||
```python
|
||||
import ida_auto, idaapi
|
||||
idaapi.reanalyze_function(idc.get_func_attr(ea, idc.FUNCATTR_START))
|
||||
```
|
||||
### 5. 간접 API 호출에 레이블 지정
|
||||
### 5. 간접 API 호출에 라벨 지정
|
||||
|
||||
모든 `call rax`의 실제 목적지를 알게 되면 IDA에 그 정보를 알려 매개변수 타입 및 변수 이름이 자동으로 복구되도록 할 수 있습니다:
|
||||
모든 `call rax`의 실제 목적지가 확인되면 IDA에 이를 알려 파라미터 타입 및 변수 이름이 자동으로 복원되도록 할 수 있다:
|
||||
```python
|
||||
idc.set_callee_name(call_ea, resolved_addr, 0) # IDA 8.3+
|
||||
```
|
||||
### 실용적 이점
|
||||
|
||||
* 실제 CFG를 복원 → decompilation이 *10* 줄에서 수천 줄로 늘어납니다.
|
||||
* string-cross-reference & xrefs를 활성화하여 동작 재구성을 용이하게 합니다.
|
||||
* Scripts는 재사용 가능합니다: 동일한 기법으로 보호된 어떤 loader에도 넣어 사용할 수 있습니다.
|
||||
* 문자열 교차 참조 및 xrefs를 가능하게 하여 동작 재구성이 매우 쉬워집니다.
|
||||
* 스크립트는 재사용 가능: 동일한 트릭으로 보호된 어떤 loader에도 넣어 사용하세요.
|
||||
|
||||
---
|
||||
|
||||
## 참고자료
|
||||
## 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/)
|
||||
- SoTap: Lightweight in-app JNI (.so) behavior logger – [github.com/RezaArbabBot/SoTap](https://github.com/RezaArbabBot/SoTap)
|
||||
- SoTap: 경량 인앱 JNI (.so) 동작 로거 – [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