Crypto in Malware / Reverse Engineering
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์ด ํ์ ์น์ ์ ๋ฐ์ด๋๋ฆฌ ๋ด๋ถ์์ crypto/compression์ด ๋ณด์ผ ๋ ์ด๋ฅผ ๋น ๋ฅด๊ฒ ์ธ์ํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค.
Identifying cryptographic / compression algorithms
Technique-first heuristics
- ํ์ดํธํ ๋ฃจํ์์ ๋ง์ shifts/rotates, XORs, ๋ฐ 32-bit arithmetic.
.data์ ์๋ lookup tables (S-boxes) ๋๋ ๋ฐํ์์ ์์ฑ๋๋ ํ ์ด๋ธ.0x100๋ฐ๋ณต ๋ฃจํ๊ฐ ๋ฐ๋ณต๋๋ ๊ฒฝ์ฐ RC4๋ฅผ ์์ํ ์ ์์.
Windows crypto/compression APIs
CryptDeriveKey / CryptCreateHash
์ด ํจ์๋ค์ด ์ฌ์ฉ๋๋ฉด ๋ ๋ฒ์งธ ๋งค๊ฐ๋ณ์๋ ALG_ID์
๋๋ค:
.png)
ํ ์ด๋ธ: https://learn.microsoft.com/en-us/windows/win32/seccrypto/alg-id
RtlCompressBuffer / RtlDecompressBuffer
์ข ์ข ๋ด์ฅ Windows ์์ถ(LZNT1, XPRESS ๋ฑ)์ ๋ํ๋ ๋๋ค.
Constants & tables
๋๋๋ก ์์(๋๋ ํ ์ด๋ธ์ ์ฒซ dword)๋ฅผ ์จ๋ผ์ธ์์ ๊ฒ์ํ์ฌ hash/cipher๋ฅผ ์ง๋ฌธํํ ์ ์์ต๋๋ค.
.png)
AES tables ์์:
.png)
RC4 recognition notes
RC4๋ ๋ณดํต ๋ค์์ผ๋ก ์ธ์๋ฉ๋๋ค:
- 256 ๋ฐ๋ณต์ ๋ ๋ฃจํ (init + KSA)
- ๊ทธ ๋ค์
% 256์ ์ฌ์ฉํ๊ณ keystream์ ๋ฐ์ดํฐ์ XORํ๋ PRGA ๋ฃจํ
Unpacking binaries
Technique
Packers๋ ๋ฐ์ด๋๋ฆฌ๋ฅผ ๋ณํํ์ฌ static analysis๊ฐ ์ค๋๋๊ฒ ๋ง๋ญ๋๋ค (junk code, encrypted sections, runtime unpacking). ๋ชฉํ๋ ๋ค์ ์๊ฐ์ ํฌ์ฐฉํ๋ ๊ฒ์ ๋๋ค:
- ๋ฉ๋ชจ๋ฆฌ์ ์ค์ ์ฝ๋๋ฅผ ํ ๋น/๋ณตํธํํ๋ค
- ์ด๋ฅผ executable๋ก ํ์ํ๋ค
- ๊ทธ ์ฝ๋๋ก ์ ํํ๋ค
Identifying packed binaries
- ๋ฌธ์์ด์ด ๊ฑฐ์ ์๊ฑฐ๋(๋๋ packer ๋ฌธ์์ด๋ง ์์)
- ๋ง์ ๋ฌธ์์ด์ xrefs๊ฐ ์์ (commercial packers)
- packer-ID ๋๊ตฌ ์ฌ์ฉ:
- PEiD
- Exeinfo PE
Basic recommendations
- ๋ถ์์ ์๋์์๋ถํฐ ์๋ก ์์ํ์ธ์; unpackers๋ ์ข ์ข ๋ฆ๊ฒ ์ ํํฉ๋๋ค.
JMP/CALL regํจํด์ด๋ ์คํ ํธ๋ฆญ(push addr; retn)์ ์ฐพ์๋ณด์ธ์.VirtualAlloc/VirtualProtect์ ๋ธ๋ ์ดํฌํฌ์ธํธ๋ฅผ ๊ฑธ๊ณ RWX ์์ญ์ ์ถ์ ํ์ธ์.- ์ ํ ์ดํ ๊ฐ์์ค๋ฌ์ด ๋ฌธ์์ด ํญ์ฆ์ unpacked code์ ๋๋ฌํ์์ ๋ํ๋ด๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค.
- ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋คํํ๊ณ PE-bear ๊ฐ์ ๋๊ตฌ๋ก ํค๋๋ฅผ ์์ ํ์ธ์.
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


