Office ํ์ผ ๋ถ์
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์ถ๊ฐ ์ ๋ณด๋ https://trailofbits.github.io/ctf/forensics/๋ฅผ ํ์ธํ์ธ์. ์ด๊ฒ์ ์์ฝ์ ๋๋ค:
Microsoft๋ ์ฌ๋ฌ ์คํผ์ค ๋ฌธ์ ํฌ๋งท์ ๋ง๋ค์์ผ๋ฉฐ, ์ฃผ์ํ ๋ ๊ฐ์ง ์ ํ์ OLE formats(์: RTF, DOC, XLS, PPT)์ Office Open XML (OOXML) formats(์: DOCX, XLSX, PPTX)์ ๋๋ค. ์ด ํฌ๋งท๋ค์ ๋งคํฌ๋ก๋ฅผ ํฌํจํ ์ ์์ด ํผ์ฑ ๋ฐ ๋ฉ์จ์ด์ ํ์ ์ด ๋ฉ๋๋ค. OOXML ํ์ผ์ zip ์ปจํ ์ด๋ ๊ตฌ์กฐ๋ก ๋์ด ์์ด ์์ถ์ ํ์ด ํ์ผ/ํด๋ ๊ณ์ธต๊ณผ XML ํ์ผ ๋ด์ฉ์ ํ์ธํ ์ ์์ต๋๋ค.
OOXML ํ์ผ ๊ตฌ์กฐ๋ฅผ ํ์ํ๊ธฐ ์ํด ๋ฌธ์์ ์์ถ์ ํธ๋ ๋ช ๋ น๊ณผ ์ถ๋ ฅ ๊ตฌ์กฐ๊ฐ ์ ๊ณต๋ฉ๋๋ค. ์ด๋ฌํ ํ์ผ๋ค์ ๋ฐ์ดํฐ๋ฅผ ์จ๊ธฐ๋ ๊ธฐ๋ฒ๋ค์ด ๋ฌธ์ํ๋์ด ์์ผ๋ฉฐ, ์ด๋ CTF ์ฑ๋ฆฐ์ง ๋ด์์ ๋ฐ์ดํฐ ์๋ ๋ฐฉ๋ฒ์ ์ง์์ ์ธ ํ์ ์ ๋ณด์ฌ์ค๋๋ค.
๋ถ์์ ์ํด oletools์ OfficeDissector๋ OLE ๋ฐ OOXML ๋ฌธ์๋ฅผ ๊ฒ์ฌํ๊ธฐ ์ํ ํฌ๊ด์ ์ธ ํด์ ์ ์ ๊ณตํฉ๋๋ค. ์ด ๋๊ตฌ๋ค์ ์๋ฒ ๋๋ ๋งคํฌ๋ก๋ฅผ ์๋ณํ๊ณ ๋ถ์ํ๋ ๋ฐ ๋์์ ์ฃผ๋ฉฐ, ์๋ฒ ๋๋ ๋งคํฌ๋ก๋ ์ข ์ข ์ถ๊ฐ ์ ์ฑ ํ์ด๋ก๋๋ฅผ ๋ค์ด๋ก๋ํ๊ณ ์คํํ๋ ๋ฉ์จ์ด ์ ๋ฌ ๋ฒกํฐ๋ก ์ฌ์ฉ๋ฉ๋๋ค. VBA ๋งคํฌ๋ก์ ๋ถ์์ Microsoft Office ์์ด๋ Libre Office๋ฅผ ์ฌ์ฉํด ์ํํ ์ ์์ผ๋ฉฐ, Libre Office๋ ์ค๋จ์ (breakpoints)๊ณผ ์์น ๋ณ์(watch variables)๋ฅผ ์ฌ์ฉํ ๋๋ฒ๊น ์ ํ์ฉํฉ๋๋ค.
oletools์ ์ค์น ๋ฐ ์ฌ์ฉ์ ๊ฐ๋จํ๋ฉฐ, pip๋ก ์ค์นํ๋ ๋ช
๋ น๊ณผ ๋ฌธ์์์ ๋งคํฌ๋ก๋ฅผ ์ถ์ถํ๋ ๋ช
๋ น์ด ์ ๊ณต๋ฉ๋๋ค. ๋งคํฌ๋ก์ ์๋ ์คํ์ AutoOpen, AutoExec ๋๋ Document_Open ๊ฐ์ ํจ์๋ค์ ์ํด ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค.
sudo pip3 install -U oletools
olevba -c /path/to/document #Extract macros
OLE Compound File exploitation: Autodesk Revit RFA โ ECC recomputation and controlled gzip
Revit RFA models are stored as an OLE Compound File (aka CFBF). The serialized model is under storage/stream:
- Storage:
Global - Stream:
LatestโGlobal\Latest
Key layout of Global\Latest (observed on Revit 2025):
- ํค๋
- GZIP-compressed payload (์ค์ ์ง๋ ฌํ๋ ๊ฐ์ฒด ๊ทธ๋ํ)
- ์ ๋ก ํจ๋ฉ
- Error-Correcting Code (ECC) ํธ๋ ์ผ๋ฌ
Revit๋ ECC ํธ๋ ์ผ๋ฌ๋ฅผ ์ฌ์ฉํด ์คํธ๋ฆผ์ ์์ ๋ณํ์ ์๋ ๋ณต๊ตฌํ์ง๋ง, ECC์ ์ผ์นํ์ง ์๋ ์คํธ๋ฆผ์ ๊ฑฐ๋ถํฉ๋๋ค. ๋ฐ๋ผ์ ์์ถ๋ ๋ฐ์ดํธ๋ฅผ ๋จ์ํ ํธ์งํด๋ ๋ณ๊ฒฝ์ด ์ ์ง๋์ง ์์ต๋๋ค: ๋ณ๊ฒฝ์ด ๋๋๋ ค์ง๊ฑฐ๋ ํ์ผ์ด ๊ฑฐ๋ถ๋ฉ๋๋ค. ์ญ์ง๋ ฌํ๊ธฐ๊ฐ ๋ณด๋ ๋ด์ฉ์ ๋ฐ์ดํธ ๋จ์๋ก ์ ํํ ์ ์ดํ๋ ค๋ฉด ๋ค์์ ์ํํด์ผ ํฉ๋๋ค:
- Revit๊ณผ ํธํ๋๋ gzip ๊ตฌํ์ผ๋ก ๋ค์ ์์ถ(so the compressed bytes Revit produces/accepts match what it expects).
- ํจ๋ฉ๋ ์คํธ๋ฆผ์ ๋ํด ECC ํธ๋ ์ผ๋ฌ๋ฅผ ์ฌ๊ณ์ฐํ์ฌ Revit์ด ์๋ ๋ณต๊ตฌ ์์ด ์์ ๋ ์คํธ๋ฆผ์ ์๋ฝํ๋๋ก ํฉ๋๋ค.
Practical workflow for patching/fuzzing RFA contents:
- Expand the OLE compound document
# Expand RFA into a folder tree (storages โ folders, streams โ files)
CompoundFileTool /e model.rfa /o rfa_out
# rfa_out/Global/Latest is the serialized stream of interest
- gzip/ECC ๊ท์น์ ๋ฐ๋ผ Global\Latest ํธ์ง
Global/Latest๋ถํด: ํค๋๋ฅผ ์ ์งํ๊ณ , payload๋ฅผ gunzip์ผ๋ก ์์ถ ํด์ ํ ๋ค์ ๋ฐ์ดํธ๋ฅผ ๋ณํํ๊ณ Revit-compatible deflate parameters๋ฅผ ์ฌ์ฉํด ๋ค์ gzipํฉ๋๋ค.- zero-padding์ ๋ณด์กดํ๊ณ ECC ํธ๋ ์ผ๋ฌ๋ฅผ ์ฌ๊ณ์ฐํ์ฌ ์๋ก์ด ๋ฐ์ดํธ๊ฐ Revit์ ์ํด ๋ฐ์๋ค์ฌ์ง๋๋ก ํฉ๋๋ค.
- ๊ฒฐ์ ๋ก ์ ๋ฐ์ดํธ-๋จ์ ์ฌํ์ด ํ์ํ๋ฉด, Revitโs DLLs ์ฃผ์์ ์ต์ ๋ํผ๋ฅผ ๋ง๋ค์ด ๊ทธ gzip/gunzip ๊ฒฝ๋ก์ ECC ๊ณ์ฐ์ ํธ์ถํ๊ฑฐ๋(์ฐ๊ตฌ์์ ์์ฐ๋ ๊ฒ์ฒ๋ผ), ์ด๋ฌํ ์๋ฏธ๋ก ์ ๋ณต์ ํ๋ ์ฌ์ฉ ๊ฐ๋ฅํ ํฌํผ๋ฅผ ์ฌ์ฌ์ฉํ์ญ์์ค.
- OLE compound document ์ฌ๊ตฌ์ฑ
# Repack the folder tree back into an OLE file
CompoundFileTool /c rfa_out /o model_patched.rfa
์ฐธ๊ณ :
- CompoundFileTool๋ NTFS ์ด๋ฆ์์ ์ ํจํ์ง ์์ ๋ฌธ์๋ฅผ ์ด์ค์ผ์ดํ ์ฒ๋ฆฌํ์ฌ storages/streams๋ฅผ ํ์ผ ์์คํ
์ ๊ธฐ๋กํฉ๋๋ค; ์ถ๋ ฅ ํธ๋ฆฌ์์ ์ํ๋ ์คํธ๋ฆผ ๊ฒฝ๋ก๋ ์ ํํ
Global/Latest์ ๋๋ค. - cloud storage์์ RFA๋ฅผ ๊ฐ์ ธ์ค๋ ecosystem plugins๋ฅผ ํตํด ๋๊ท๋ชจ ๊ณต๊ฒฉ์ ์ ๋ฌํ ๋๋, ๋คํธ์ํฌ ์ฃผ์ ์ ์๋ํ๊ธฐ ์ ์ ํจ์นํ RFA๊ฐ ๋ก์ปฌ์์ Revit์ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฌ(์: gzip/ECC correct)๋ฅผ ๋จผ์ ํต๊ณผํ๋์ง ํ์ธํ์ธ์.
Exploitation insight (to guide what bytes to place in the gzip payload):
- The Revit deserializer reads a 16-bit class index and constructs an object. Certain types are nonโpolymorphic and lack vtables; abusing destructor handling yields a type confusion where the engine executes an indirect call through an attacker-controlled pointer.
- Picking
AString(class index0x1F) places an attacker-controlled heap pointer at object offset 0. During the destructor loop, Revit effectively executes:
rcx = [rbx] ; object pointer (e.g., AString*)
rax = [rcx] ; attacker-controlled pointer to AString buffer
call qword ptr [rax] ; one attacker-chosen gadget per object
- ์ฌ๋ฌ ๊ฐ์ ๊ทธ๋ฐ ๊ฐ์ฒด๋ฅผ ์ง๋ ฌํ๋ ๊ทธ๋ํ์ ๋ฐฐ์นํ์ฌ ๊ฐ destructor loop ๋ฐ๋ณต์ด ํ๋์ gadget(โweird machineโ)์ ์คํํ๋๋ก ํ๊ณ , stack pivot์ ์ ํ์ ์ธ x64 ROP chain์ผ๋ก ๊ตฌ์ฑํ๋ค.
See Windows x64 pivot/gadget building details here:
Stack Pivoting - EBP2Ret - EBP chaining
and general ROP guidance here:
๋๊ตฌ:
- CompoundFileTool (OSS) to expand/rebuild OLE compound files: https://github.com/thezdi/CompoundFileTool
- IDA Pro + WinDBG TTD for reverse/taint; disable page heap with TTD to keep traces compact.
- ๋ก์ปฌ ํ๋ก์(์: Fiddler)๋ ํ๋ฌ๊ทธ์ธ ํธ๋ํฝ์์ RFAs๋ฅผ ๊ต์ฒดํ์ฌ ๊ณต๊ธ๋ง ์ ๋ฌ์ ์๋ฎฌ๋ ์ด์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ค.
์ฐธ๊ณ ์๋ฃ
- Crafting a Full Exploit RCE from a Crash in Autodesk Revit RFA File Parsing (ZDI blog)
- CompoundFileTool (GitHub)
- OLE Compound File (CFBF) docs
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


