28 KiB
macOS Gatekeeper / Quarantine / XProtect
âïž HackTricks Cloud âïž -ðŠ Twitter ðŠ - ðïž Twitch ðïž - ð¥ Youtube ð¥
- ãµã€ããŒã»ãã¥ãªãã£äŒæ¥ã§åããŠããŸããïŒ HackTricksã§äŒç€Ÿã宣äŒãããã§ããïŒãŸãã¯ãPEASSã®ææ°ããŒãžã§ã³ã«ã¢ã¯ã»ã¹ããããHackTricksãPDFã§ããŠã³ããŒããããã§ããïŒSUBSCRIPTION PLANSããã§ãã¯ããŠãã ããïŒ
- The PEASS FamilyãèŠã€ããŠãã ãããç¬å çãªNFTã®ã³ã¬ã¯ã·ã§ã³ã§ãã
- å ¬åŒã®PEASSïŒHackTricks swagãæã«å ¥ããŸãããã
- ð¬ Discordã°ã«ãŒããŸãã¯telegramã°ã«ãŒãã«åå ããããTwitterã§ðŠ@carlospolopmããã©ããŒããŠãã ããã
- ãããã³ã°ã®ããªãã¯ãå ±æããã«ã¯ãPRã hacktricks repo ãš hacktricks-cloud repo ã«æåºããŠãã ããã
- .
Gatekeeper
GatekeeperïŒã²ãŒãããŒããŒïŒã¯ãMacãªãã¬ãŒãã£ã³ã°ã·ã¹ãã åãã«éçºãããã»ãã¥ãªãã£æ©èœã§ããŠãŒã¶ãŒãã·ã¹ãã äžã§ä¿¡é Œã§ãããœãããŠã§ã¢ã®ã¿ãå®è¡ããããšãä¿èšŒããããã«èšèšãããŠããŸããããã¯ããŠãŒã¶ãŒãApp Store以å€ã®ãœãŒã¹ããããŠã³ããŒãããŠéãããšãããœãããŠã§ã¢ïŒã¢ããªããã©ã°ã€ã³ãã€ã³ã¹ããŒã©ãŒããã±ãŒãžãªã©ïŒãæ€èšŒããããšã«ãã£ãŠæ©èœããŸãã
Gatekeeperã®äž»èŠãªã¡ã«ããºã ã¯ãæ€èšŒããã»ã¹ã«ãããŸããããŠã³ããŒããããœãããŠã§ã¢ãèªèãããéçºè ã«ãã£ãŠçœ²åãããŠãããã©ããããã§ãã¯ãããœãããŠã§ã¢ã®ä¿¡é Œæ§ã確èªããŸããããã«ããœãããŠã§ã¢ãAppleã«ãã£ãŠå ¬èšŒãããŠãããã©ããã確èªããæ¢ç¥ã®æªæã®ããã³ã³ãã³ããå«ãŸããŠããªãããšãããã³å ¬èšŒåŸã«æ¹ãããããŠããªãããšã確èªããŸãã
ããã«ãGatekeeperã¯ããŠãŒã¶ãŒãããŠã³ããŒããããœãããŠã§ã¢ã®ååã®å®è¡ãæ¿èªãããããŠãŒã¶ãŒã«ããã³ããã衚瀺ããããšã§ããŠãŒã¶ãŒã®å¶åŸ¡ãšã»ãã¥ãªãã£ã匷åããŸãããã®ä¿è·æ©èœã«ããããŠãŒã¶ãŒã¯ç¡å®³ãªããŒã¿ãã¡ã€ã«ãšééããŠå®è¡ããå¯èœæ§ã®ããæœåšçã«æ害ãªå®è¡å¯èœã³ãŒãã誀ã£ãŠå®è¡ããããšãé²ãããšãã§ããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®çœ²å
ã¢ããªã±ãŒã·ã§ã³ã®çœ²åã¯ãAppleã®ã»ãã¥ãªãã£ã€ã³ãã©ã¹ãã©ã¯ãã£ã®éèŠãªèŠçŽ ã§ããããã¯ããœãããŠã§ã¢ã®äœæè ïŒéçºè ïŒã®èº«å ã確èªããã³ãŒããæåŸã«çœ²åãããŠããæ¹ãããããŠããªãããšãä¿èšŒããããã«äœ¿çšãããŸãã
以äžã¯ããã®åäœæ¹æ³ã§ãã
- ã¢ããªã±ãŒã·ã§ã³ã®çœ²å: éçºè ãã¢ããªã±ãŒã·ã§ã³ãé åžããæºåãã§ããããéçºè ãç§å¯éµã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ã«çœ²åããŸãããã®ç§å¯éµã¯ãéçºè ãApple Developer Programã«ç»é²ããéã«Appleããçºè¡ããã蚌ææžãšé¢é£ä»ããããŠããŸãã眲åããã»ã¹ã§ã¯ãã¢ããªã®ãã¹ãŠã®éšåã®æå·ããã·ã¥ãäœæãããã®ããã·ã¥ãéçºè ã®ç§å¯éµã§æå·åããŸãã
- ã¢ããªã±ãŒã·ã§ã³ã®é åž: 眲åãããã¢ããªã±ãŒã·ã§ã³ã¯ãéçºè ã®èšŒææžãšå ±ã«ãŠãŒã¶ãŒã«é åžãããŸãããã®èšŒææžã«ã¯ã察å¿ããå ¬ééµãå«ãŸããŠããŸãã
- ã¢ããªã±ãŒã·ã§ã³ã®æ€èšŒ: ãŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ãããŠã³ããŒãããŠå®è¡ããããšãããšãMacãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã¯éçºè ã®èšŒææžããå ¬ééµã䜿çšããŠããã·ã¥ã埩å·åããŸãããã®åŸãã¢ããªã±ãŒã·ã§ã³ã®çŸåšã®ç¶æ ã«åºã¥ããŠããã·ã¥ãåèšç®ããããã埩å·åãããããã·ã¥ãšæ¯èŒããŸããäžèŽããå Žåãéçºè ã眲åããåŸã«ã¢ããªã±ãŒã·ã§ã³ãå€æŽãããŠããªãããšãæå³ããã·ã¹ãã ã¯ã¢ããªã±ãŒã·ã§ã³ã®å®è¡ãèš±å¯ããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®çœ²åã¯ãAppleã®Gatekeeperãã¯ãããžãŒã®éèŠãªéšåã§ãããŠãŒã¶ãŒãã€ã³ã¿ãŒãããããããŠã³ããŒãããã¢ããªã±ãŒã·ã§ã³ãéãããšãããšãGatekeeperã¯ã¢ããªã±ãŒã·ã§ã³ã®çœ²åãæ€èšŒããŸããAppleããæ¢ç¥ã®éçºè ã«çºè¡ããã蚌ææžã§çœ²åãããŠãããã³ãŒããæ¹ãããããŠããªãå ŽåãGatekeeperã¯ã¢ããªã±ãŒã·ã§ã³ã®å®è¡ãèš±å¯ããŸãããã以å€ã®å ŽåãGatekeeperã¯ã¢ããªã±ãŒã·ã§ã³ããããã¯ãããŠãŒã¶ãŒã«èŠåã衚瀺ããŸãã
macOS Catalina以éãGatekeeperã¯ã¢ããªã±ãŒã·ã§ã³ãAppleã«ãã£ãŠå ¬èšŒãããŠãããã©ããããã§ãã¯ããŸããå ¬èšŒããã»ã¹ã§ã¯ãã¢ããªã±ãŒã·ã§ã³ãæ¢ç¥ã®ã»ãã¥ãªãã£ã®åé¡ãæªæã®ããã³ãŒããå«ãã§ããªããã©ããããã§ãã¯ãããããã®ãã§ãã¯ã«åæ Œããå ŽåãAppleã¯Gatekeeperãæ€èšŒã§ããã¢ããªã±ãŒã·ã§ã³ã«ãã±ãããè¿œå ããŸãã
眲åã®ç¢ºèª
ãã«ãŠã§ã¢ãµã³ãã«ããã§ãã¯ããéã«ã¯ãåžžã«ãã€ããªã®çœ²åã確èªããå¿ èŠããããŸãã眲åããéçºè ãæ¢ã«ãã«ãŠã§ã¢ãšé¢é£ããŠããå¯èœæ§ãããããã§ãã
# Get signer
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"
# Check if the appâs contents have been modified
codesign --verify --verbose /Applications/Safari.app
# Get entitlements from the binary
codesign -d --entitlements :- /System/Applications/Automator.app # Check the TCC perms
# Check if the signature is valid
spctl --assess --verbose /Applications/Safari.app
# Sign a binary
codesign -s <cert-name-keychain> toolsdemo
NotarizationïŒå ¬èšŒïŒ
Appleã®å ¬èšŒããã»ã¹ã¯ããŠãŒã¶ãŒãæœåšçã«æ害ãªãœãããŠã§ã¢ããä¿è·ããããã®è¿œå ã®å®å šçãšããŠæ©èœããŸããããã¯ãéçºè ãèªåã®ã¢ããªã±ãŒã·ã§ã³ãAppleã®å ¬èšŒãµãŒãã¹ã«æåºããããšãå«ã¿ãŸãããã®ãµãŒãã¹ã¯ãApp Reviewãšã¯ç°ãªããã®ã§ãããæåºããããœãããŠã§ã¢ãæªæã®ããã³ã³ãã³ããã³ãŒã眲åã®æœåšçãªåé¡ããæ€æ»ããèªååã·ã¹ãã ã§ãã
ãœãããŠã§ã¢ããã®æ€æ»ãééããæžå¿µäºé ããªãå Žåãå ¬èšŒãµãŒãã¹ã¯å ¬èšŒãã±ãããçæããŸãããã®åŸãéçºè ã¯ãã®ãã±ããããœãããŠã§ã¢ã«æ·»ä»ããå¿ èŠããããŸãããã®ããã»ã¹ã¯ãã¹ããŒããªã³ã°ããšåŒã°ããŸããããã«ãå ¬èšŒãã±ããã¯ãªã³ã©ã€ã³ã§å ¬éãããGatekeeperïŒAppleã®ã»ãã¥ãªãã£ãã¯ãããžãŒïŒãã¢ã¯ã»ã¹ã§ããããã«ãªããŸãã
ãŠãŒã¶ãŒããœãããŠã§ã¢ãåããŠã€ã³ã¹ããŒã«ãŸãã¯å®è¡ããéãå®è¡å¯èœãã¡ã€ã«ã«ã¹ããŒãã«ãããŠãããããªã³ã©ã€ã³ã§èŠã€ãããã«ããããããå ¬èšŒãã±ããã®ååšã¯Gatekeeperã«ãœãããŠã§ã¢ãAppleã«ãã£ãŠå ¬èšŒãããããšãéç¥ããŸãããã®çµæãGatekeeperã¯ååèµ·åãã€ã¢ãã°ã«èª¬æçãªã¡ãã»ãŒãžã衚瀺ãããœãããŠã§ã¢ãAppleã«ãã£ãŠæªæã®ããã³ã³ãã³ãã®ãã§ãã¯ãåããããšã瀺ããŸãããã®ããã»ã¹ã«ããããŠãŒã¶ãŒã¯èªåã®ã·ã¹ãã ã«ã€ã³ã¹ããŒã«ãŸãã¯å®è¡ãããœãããŠã§ã¢ã®ã»ãã¥ãªãã£ã«å¯Ÿããä¿¡é Œæ§ãåäžããŸãã
GateKeeperã®åæ
GateKeeperã¯ãä¿¡é ŒãããŠããªãã¢ããªã±ãŒã·ã§ã³ã®å®è¡ãé²æ¢ããããã®è€æ°ã®ã»ãã¥ãªãã£ã³ã³ããŒãã³ãã§ããããŸããã®äžéšã§ããããŸãã
GateKeeperã®ç¶æ ã¯ã次ã®ã³ãã³ãã§ç¢ºèªããããšãã§ããŸãïŒ
# Check the status
spctl --status
{% hint style="danger" %} GateKeeperã®çœ²åãã§ãã¯ã¯ãQuarantineå±æ§ãæã€ãã¡ã€ã«ã«ã®ã¿å®è¡ãããŸãããã¹ãŠã®ãã¡ã€ã«ã«å¯ŸããŠå®è¡ãããããã§ã¯ãããŸããã {% endhint %}
GateKeeperã¯ãèšå®ãšçœ²åã«åºã¥ããŠãã€ããªãå®è¡å¯èœãã©ããããã§ãã¯ããŸãã
ãã®èšå®ãä¿æããããŒã¿ããŒã¹ã¯ã**/var/db/SystemPolicy
**ã«ãããŸãã次ã®ã³ãã³ããrootãšããŠå®è¡ããŠããã®ããŒã¿ããŒã¹ã確èªã§ããŸãã
# Open database
sqlite3 /var/db/SystemPolicy
# Get allowed rules
SELECT requirement,allow,disabled,label from authority where label != 'GKE' and disabled=0;
requirement|allow|disabled|label
anchor apple generic and certificate 1[subject.CN] = "Apple Software Update Certification Authority"|1|0|Apple Installer
anchor apple|1|0|Apple System
anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9] exists|1|0|Mac App Store
anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and (certificate leaf[field.1.2.840.113635.100.6.1.14] or certificate leaf[field.1.2.840.113635.100.6.1.13]) and notarized|1|0|Notarized Developer ID
[...]
æåã®ã«ãŒã«ããApp Storeãã§çµããã2çªç®ã®ã«ãŒã«ããDeveloper IDãã§çµãã£ãŠããããšã«æ³šç®ããåã®ã€ã¡ãŒãžã§ã¯App Storeãšèå¥ãããéçºè
ããã®ã¢ããªã®å®è¡ãæå¹ã«ãªã£ãŠããããšãããããŸãã
ãã®èšå®ãApp Storeã«å€æŽãããšããNotarized Developer IDãã®ã«ãŒã«ãæ¶ããŸãã
ãŸããGKEã¿ã€ãã®ã«ãŒã«ã¯æ°åãããŸãã
SELECT requirement,allow,disabled,label from authority where label = 'GKE' limit 5;
cdhash H"b40281d347dc574ae0850682f0fd1173aa2d0a39"|1|0|GKE
cdhash H"5fd63f5342ac0c7c0774ebcbecaf8787367c480f"|1|0|GKE
cdhash H"4317047eefac8125ce4d44cab0eb7b1dff29d19a"|1|0|GKE
cdhash H"0a71962e7a32f0c2b41ddb1fb8403f3420e1d861"|1|0|GKE
cdhash H"8d0d90ff23c3071211646c4c9c607cdb601cb18f"|1|0|GKE
ãããã¯ã/var/db/SystemPolicyConfiguration/gke.bundle/Contents/Resources/gke.auth
ã/var/db/gke.bundle/Contents/Resources/gk.db
ãããã³**/var/db/gkopaque.bundle/Contents/Resources/gkopaque.db
**ããååŸãããããã·ã¥ã§ãã
spctl
ã®ãªãã·ã§ã³--master-disable
ãš--global-disable
ã¯ããããã®çœ²åãã§ãã¯ãå®å
šã«ç¡å¹åããŸãã
# Disable GateKeeper
spctl --global-disable
spctl --master-disable
# Enable it
spctl --global-enable
spctl --master-enable
å®å šã«æå¹ã«ããããšãæ°ãããªãã·ã§ã³ã衚瀺ãããŸãïŒ
GateKeeperã«ãã£ãŠã¢ããªãèš±å¯ããããã©ããã確èªããããšãã§ããŸãã
spctl --assess -v /Applications/App.app
GateKeeperã«æ°ããã«ãŒã«ãè¿œå ããŠãç¹å®ã®ã¢ããªã®å®è¡ãèš±å¯ããããšãå¯èœã§ãã以äžã®ã³ãã³ãã䜿çšããŸã:
spctl --add --label "Approved" /path/to/app
ãã®ã³ãã³ãã¯ãæå®ãããã¹ã«ããã¢ããªã"Approved"ãšããã©ãã«ã§GateKeeperã«è¿œå ããŸããããã«ãããã¢ããªã¯å®è¡å¯èœãšãªããŸãã
# Check if allowed - nop
spctl --assess -v /Applications/App.app
/Applications/App.app: rejected
source=no usable signature
# Add a label and allow this label in GateKeeper
sudo spctl --add --label "whitelist" /Applications/App.app
sudo spctl --enable --label "whitelist"
# Check again - yep
spctl --assess -v /Applications/App.app
/Applications/App.app: accepted
ãã¡ã€ã«ã®éé¢
ã¢ããªã±ãŒã·ã§ã³ããã¡ã€ã«ãããŠã³ããŒãããéãmacOSã®ç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ïŒãŠã§ããã©ãŠã¶ãã¡ãŒã«ã¯ã©ã€ã¢ã³ããªã©ïŒã¯ãããŠã³ããŒãããããã¡ã€ã«ã«äžè¬çã«ç¥ãããŠãããéé¢ãã©ã°ããšåŒã°ããæ¡åŒµãã¡ã€ã«å±æ§ãä»å ããŸãããã®å±æ§ã¯ããã¡ã€ã«ãä¿¡é ŒãããŠããªããœãŒã¹ïŒã€ã³ã¿ãŒãããïŒããæ¥ãŠãããæœåšçãªãªã¹ã¯ãæã£ãŠããå¯èœæ§ãããããšã瀺ãã»ãã¥ãªãã£å¯ŸçãšããŠæ©èœããŸãããã ãããã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ããã®å±æ§ãä»å ããããã§ã¯ãããŸãããããšãã°ãäžè¬çãªBitTorrentã¯ã©ã€ã¢ã³ããœãããŠã§ã¢ã¯éåžžããã®ããã»ã¹ããã€ãã¹ããŸãã
éé¢ãã©ã°ãååšããå ŽåããŠãŒã¶ãŒããã¡ã€ã«ãå®è¡ããããšãããšãmacOSã®Gatekeeperã»ãã¥ãªãã£æ©èœã«éç¥ãããŸãã
éé¢ãã©ã°ãååšããªãå ŽåïŒäžéšã®BitTorrentã¯ã©ã€ã¢ã³ããä»ããŠããŠã³ããŒãããããã¡ã€ã«ãªã©ïŒãGatekeeperã®ãã§ãã¯ã¯å®è¡ãããªãå ŽåããããŸãããããã£ãŠãå®å šæ§ã®äœããŸãã¯äžæãªãœãŒã¹ããããŠã³ããŒãããããã¡ã€ã«ãéãéã«ã¯æ³šæãå¿ èŠã§ãã
{% hint style="info" %} ã³ãŒã眲åã®åŠ¥åœæ§ããã§ãã¯ããããšã¯ãã³ãŒããšãã®ãã³ãã«ããããªãœãŒã¹ã®æå·ããã·ã¥ãçæãããªã©ããªãœãŒã¹ãå€ãæ¶è²»ããããã»ã¹ã§ããããã«ã蚌ææžã®åŠ¥åœæ§ããã§ãã¯ããã«ã¯ãçºè¡åŸã«åãæ¶ãããŠããªãããAppleã®ãµãŒããŒã«ãªã³ã©ã€ã³ã§ç¢ºèªããå¿ èŠããããŸãããããã®çç±ãããå®å šãªã³ãŒã眲åãšå ¬èšŒãã§ãã¯ã¯ãã¢ããªãèµ·åãããã³ã«å®è¡ããã®ã¯çŸå®çã§ã¯ãããŸããã
ãããã£ãŠããããã®ãã§ãã¯ã¯éé¢å±æ§ãæã€ã¢ããªãå®è¡ãããšãã«ã®ã¿å®è¡ãããŸãã {% endhint %}
{% hint style="warning" %} ãã®å±æ§ã¯ããã¡ã€ã«ãäœæ/ããŠã³ããŒãããã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠèšå®ããå¿ èŠããããŸãã
ãã ãããµã³ãããã¯ã¹åããããã¡ã€ã«ã¯ãäœæããããã¹ãŠã®ãã¡ã€ã«ã«ãã®å±æ§ãèšå®ãããŸãããŸãããµã³ãããã¯ã¹åãããŠããªãã¢ããªã¯ãèªåèªèº«ã§èšå®ããããInfo.plistã«LSFileQuarantineEnabledããŒãæå®ããããšã§ãã·ã¹ãã ãäœæããããã¡ã€ã«ã«com.apple.quarantine
ã®æ¡åŒµå±æ§ãèšå®ããŸãã
{% endhint %}
次ã®ã³ãã³ãã§ããã®ç¶æ ã確èªããæå¹/ç¡å¹ã«ããããšãã§ããŸãïŒã«ãŒãæš©éãå¿ èŠã§ãïŒ:
spctl --status
assessments enabled
spctl --enable
spctl --disable
#You can also allow nee identifies to execute code using the binary "spctl"
次ã®ã³ãã³ãã䜿çšããŠããã¡ã€ã«ã«æ¡åŒµå±æ§ããããã©ããã確èªããããšãã§ããŸã:
xattr -p com.apple.quarantine <file>
ãã®ã³ãã³ãã¯ãæå®ãã <file>
ã«æ¡åŒµå±æ§ com.apple.quarantine
ãããå Žåããã®å€ã衚瀺ããŸãã
xattr file.png
com.apple.macl
com.apple.quarantine
次ã«ãæ¡åŒµå±æ§ã®å€ã確èªãã次ã®ã³ãã³ãã§ã¯ã©ã¬ã³ãã£ã³å±æ§ãæžã蟌ãã ã¢ããªãç¹å®ããŸãã
xattr -l portada.png
com.apple.macl:
00000000 03 00 53 DA 55 1B AE 4C 4E 88 9D CA B7 5C 50 F3 |..S.U..LN.....P.|
00000010 16 94 03 00 27 63 64 97 98 FB 4F 02 84 F3 D0 DB |....'cd...O.....|
00000020 89 53 C3 FC 03 00 27 63 64 97 98 FB 4F 02 84 F3 |.S....'cd...O...|
00000030 D0 DB 89 53 C3 FC 00 00 00 00 00 00 00 00 00 00 |...S............|
00000040 00 00 00 00 00 00 00 00 |........|
00000048
com.apple.quarantine: 00C1;607842eb;Brave;F643CD5F-6071-46AB-83AB-390BA944DEC5
# 00c1 -- It has been allowed to eexcute this file
# 607842eb -- Timestamp
# Brave -- App
# F643CD5F-6071-46AB-83AB-390BA944DEC5 -- UID assigned to the file downloaded
ãããŠã次ã®ã³ãã³ãã§ãã®å±æ§ãåé€ããŸãïŒ
xattr -d com.apple.quarantine portada.png
#You can also remove this attribute from every file with
find . -iname '*' -print0 | xargs -0 xattr -d com.apple.quarantine
次ã®ã³ãã³ãã§ãéé¢ããããã¡ã€ã«ããã¹ãŠæ€çŽ¢ããŸãïŒ
{% code overflow="wrap" %}
find / -exec ls -ld {} \; 2>/dev/null | grep -E "[x\-]@ " | awk '{printf $9; printf "\n"}' | xargs -I {} xattr -lv {} | grep "com.apple.quarantine"
{% endcode %}
Quarantine information is also stored in a central database managed by LaunchServices in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2
.
XProtect
XProtectã¯ãmacOSã«çµã¿èŸŒãŸããã¢ã³ããã«ãŠã§ã¢æ©èœã§ããXProtectã¯ãã¢ããªã±ãŒã·ã§ã³ãåããŠèµ·åããããå€æŽãããéã«ãæ¢ç¥ã®ãã«ãŠã§ã¢ãšå±éºãªãã¡ã€ã«ã¿ã€ãã®ããŒã¿ããŒã¹ãšç §åããŸããSafariãMailããŸãã¯Messagesãªã©ã®ç¹å®ã®ã¢ããªãä»ããŠãã¡ã€ã«ãããŠã³ããŒããããšãXProtectã¯èªåçã«ãã¡ã€ã«ãã¹ãã£ã³ããŸããããŒã¿ããŒã¹å ã®æ¢ç¥ã®ãã«ãŠã§ã¢ãšäžèŽããå ŽåãXProtectã¯ãã¡ã€ã«ã®å®è¡ãé²æ¢ããè åšãèŠåããŸãã
XProtectããŒã¿ããŒã¹ã¯ãAppleã«ãã£ãŠå®æçã«æŽæ°ããããããã®æŽæ°ã¯èªåçã«Macã«ããŠã³ããŒãããã³ã€ã³ã¹ããŒã«ãããŸããããã«ãããXProtectã¯åžžã«ææ°ã®æ¢ç¥ã®è åšãšåæãããŸãã
ãã ããXProtectã¯å®å šãªã¢ã³ããŠã€ã«ã¹ãœãªã¥ãŒã·ã§ã³ã§ã¯ãããŸãããXProtectã¯ç¹å®ã®æ¢ç¥ã®è åšã®ãªã¹ãã®ã¿ããã§ãã¯ããã»ãšãã©ã®ã¢ã³ããŠã€ã«ã¹ãœãããŠã§ã¢ã®ããã«ãªã³ã¢ã¯ã»ã¹ã¹ãã£ã³ãå®è¡ããŸããã
ææ°ã®XProtectã®æŽæ°ã«é¢ããæ å ±ãååŸããã«ã¯ã次ã®ã³ãã³ããå®è¡ããŸãïŒ
{% code overflow="wrap" %}
system_profiler SPInstallHistoryDataType 2>/dev/null | grep -A 4 "XProtectPlistConfigData" | tail -n 5
{% endcode %}
XProtectã¯ã/Library/Apple/System/Library/CoreServices/XProtect.bundleãšããSIPã§ä¿è·ãããå Žæã«ããããã³ãã«å ã«ã¯XProtectã䜿çšããæ å ±ãå«ãŸããŠããŸãïŒ
XProtect.bundle/Contents/Resources/LegacyEntitlementAllowlist.plist
ïŒãããã®cdhashãæã€ã³ãŒããã¬ã¬ã·ãŒæš©éã䜿çšã§ããããã«ããŸããXProtect.bundle/Contents/Resources/XProtect.meta.plist
ïŒBundleIDãšTeamIDãŸãã¯æå°ããŒãžã§ã³ã瀺ãããšã§ãããŒããçŠæ¢ãããŠãããã©ã°ã€ã³ãšæ¡åŒµæ©èœã®ãªã¹ãã§ããXProtect.bundle/Contents/Resources/XProtect.yara
ïŒãã«ãŠã§ã¢ãæ€åºããããã®Yaraã«ãŒã«ã§ããXProtect.bundle/Contents/Resources/gk.db
ïŒãããã¯ãããã¢ããªã±ãŒã·ã§ã³ãšTeamIDã®ããã·ã¥ãæã€SQLite3ããŒã¿ããŒã¹ã§ãã
XProtectã«é¢é£ããå¥ã®ã¢ããªã±ãŒã·ã§ã³ã§ãã**/Library/Apple/System/Library/CoreServices/XProtect.app
**ããããŸãããããã¯Gatekeeperããã»ã¹ãšã¯é¢ä¿ãããŸããã
Gatekeeperã®åé¿æ¹æ³
Gatekeeperããã€ãã¹ããæ¹æ³ïŒãŠãŒã¶ãŒã«äœããããŠã³ããŒããããGatekeeperããããèš±å¯ããªãã¯ãã®ãšãã«å®è¡ãããæ¹æ³ïŒã¯ãmacOSã®è匱æ§ãšèŠãªãããŸãããããã¯ãéå»ã«Gatekeeperããã€ãã¹ããããã«äœ¿çšãããããã€ãã®æè¡ã«å²ãåœãŠãããCVEã§ãïŒ
CVE-2021-1810
Archive Utilityã«ãã£ãŠæœåºããããšã886æå以äžã®ãã¹ãæã€ãã¡ã€ã«ã¯ãcom.apple.quarantineã®æ¡åŒµå±æ§ãç¶æ¿ã§ãããããã«ããGatekeeperããã€ãã¹ããããšãå¯èœã«ãªããŸãã
詳现ã«ã€ããŠã¯ãå ã®ã¬ããŒããåç §ããŠãã ããã
CVE-2021-30990
Automatorã§ã¢ããªã±ãŒã·ã§ã³ãäœæããããšãå®è¡ããããã®æ
å ±ã¯application.app/Contents/document.wflow
ã«ãããå®è¡å¯èœãã¡ã€ã«ã«ã¯ãããŸãããå®è¡å¯èœãã¡ã€ã«ã¯ãAutomator Application StubãšåŒã°ããæ±çšã®Automatorãã€ããªã§ãã
ãããã£ãŠãapplication.app/Contents/MacOS/Automator\ Application\ Stub
ãã·ã³ããªãã¯ãªã³ã¯ã§å¥ã®Automator Application Stubã«æå®ããããšã§ãdocument.wflow
ïŒã¹ã¯ãªããïŒå
ã®å
容ãå®è¡ããå®éã®å®è¡å¯èœãã¡ã€ã«ã«ã¯quarantine xattrããªããããGatekeeperãããªã¬ãŒããã«å®è¡ããããšãã§ããŸãã
äŸãšããŠæåŸ
ãããå ŽæïŒ/System/Library/CoreServices/Automator\ Application\ Stub.app/Contents/MacOS/Automator\ Application\ Stub
詳现ã«ã€ããŠã¯ãå ã®ã¬ããŒããåç §ããŠãã ããã
CVE-2022-22616
ãã®ãã€ãã¹ã§ã¯ãzipãã¡ã€ã«ãäœæãããapplication.app
ã§ã¯ãªãapplication.app/Contents
ããå§çž®ãéå§ãããŸããããããã£ãŠãquarantineå±æ§ã¯**application.app/Contents
å
ã®ãã¹ãŠã®ãã¡ã€ã«ã«é©çšãããŸããããGatekeeperããã§ãã¯ããŠããã®ã¯application.app
ã§ãããapplication.app
ãããªã¬ãŒããããšãã«ã¯quarantineå±æ§ãååšããªãã£ããããGatekeeperããã€ãã¹**ãããŸããã
zip -r test.app/Contents test.zip
詳现ãªæ å ±ã«ã€ããŠã¯ãå ã®ã¬ããŒããåç §ããŠãã ããã
CVE-2022-32910
ã³ã³ããŒãã³ãã¯ç°ãªããã®ã®ããã®è匱æ§ã®æªçšã¯åã®ãã®ãšéåžžã«äŒŒãŠããŸãããã®å Žåãapplication.app/Contents
ããApple ArchiveãçæããArchive Utility ã«ãã£ãŠå±éãããéã« application.app
ã«ã¯æ€ç«å±æ§ãä»äžãããªãããã«ããŸãã
aa archive -d test.app/Contents -o test.app.aar
詳现ãªæ å ±ã«ã€ããŠã¯ãå ã®ã¬ããŒããåç §ããŠãã ããã
CVE-2022-42821
ACL **writeextattr
**ã¯ããã¡ã€ã«ã®å±æ§ã®æžã蟌ã¿ã誰ã«ãå¶éããããã«äœ¿çšã§ããŸãã
touch /tmp/no-attr
chmod +a "everyone deny writeextattr" /tmp/no-attr
xattr -w attrname vale /tmp/no-attr
xattr: [Errno 13] Permission denied: '/tmp/no-attr'
ããã«ãAppleDoubleãã¡ã€ã«åœ¢åŒã¯ããã®ACEãå«ããã¡ã€ã«ãã³ããŒããŸãã
ãœãŒã¹ã³ãŒãã§ã¯ãxattrãšããŠä¿åãããŠããACLããã¹ãè¡šçŸã§ãã**com.apple.acl.text
**ããå±éããããã¡ã€ã«ã®ACLãšããŠèšå®ãããããšãããããŸãããããã£ãŠãä»ã®xattrã®æžã蟌ã¿ãé²æ¢ããACLãæã€zipãã¡ã€ã«ã«ã¢ããªã±ãŒã·ã§ã³ãå§çž®ããå Žåãquarantine xattrã¯ã¢ããªã±ãŒã·ã§ã³ã«èšå®ãããŸããã§ããã
chmod +a "everyone deny write,writeattr,writeextattr" /tmp/test
ditto -c -k test test.zip
python3 -m http.server
# Download the zip from the browser and decompress it, the file shuold be without a wuarantine xattr
詳现ã«ã€ããŠã¯ãå ã®ã¬ããŒããåç §ããŠãã ããã
CVE-2023-27943
Google Chromeã¯ãããã€ãã®macOSã®å éšçãªåé¡ã®ããã«ãããŠã³ããŒãããããã¡ã€ã«ã«éé¢å±æ§ãèšå®ããŠããŸããã§ããã
CVE-2023-27951
AppleDoubleãã¡ã€ã«åœ¢åŒã¯ããã¡ã€ã«ã®å±æ§ã._
ã§å§ãŸãå¥ã®ãã¡ã€ã«ã«ä¿åããããã«ããmacOSãã·ã³éã§ãã¡ã€ã«ã®å±æ§ãã³ããŒããã®ã«åœ¹ç«ã¡ãŸããããããAppleDoubleãã¡ã€ã«ãå±éããåŸã._
ã§å§ãŸããã¡ã€ã«ã«ã¯éé¢å±æ§ãèšå®ãããŠããªãããšãããããŸããã
{% code overflow="wrap" %}
mkdir test
echo a > test/a
echo b > test/b
echo ._a > test/._a
aa archive -d test/ -o test.aar
# If you downloaded the resulting test.aar and decompress it, the file test/._a won't have a quarantitne attribute
{% endcode %}
ã²ãŒãããŒããŒããã€ãã¹ããããšãã§ããããã«ãªããŸãããã¯ã€ãã¯ã¿ã€ã ã®ã¢ããªã±ãŒã·ã§ã³ãäœæããããã«ãAppleDoubleåèŠåïŒ._
ã§å§ãŸãïŒã䜿çšããŠDMGãã¡ã€ã«ã¢ããªã±ãŒã·ã§ã³ãäœæããã¯ã€ãã¯ã¿ã€ã ã®ã¢ããªã±ãŒã·ã§ã³ãšããŠè¡šç€ºããããã¡ã€ã«ãäœæããŸããããã®é ããã¡ã€ã«ã«ã¯ã¯ã€ãã¯ã¿ã€ã ã®å±æ§ãèšå®ãããŠããŸãããDMGãã¡ã€ã«ãå®è¡ããããšãã¯ã€ãã¯ã¿ã€ã ã®å±æ§ããªããããã²ãŒãããŒããŒããã€ãã¹ããŸãã
# Create an app bundle with the backdoor an call it app.app
echo "[+] creating disk image with app"
hdiutil create -srcfolder app.app app.dmg
echo "[+] creating directory and files"
mkdir
mkdir -p s/app
cp app.dmg s/app/._app.dmg
ln -s ._app.dmg s/app/app.dmg
echo "[+] compressing files"
aa archive -d s/ -o app.aar
âïž HackTricks Cloud âïž -ðŠ Twitter ðŠ - ðïž Twitch ðïž - ð¥ Youtube ð¥
- ãµã€ããŒã»ãã¥ãªãã£äŒæ¥ã§åããŠããŸããïŒ HackTricksã§äŒç€Ÿã宣äŒãããã§ããïŒãŸãã¯ãææ°ããŒãžã§ã³ã®PEASSã«ã¢ã¯ã»ã¹ããããHackTricksãPDFã§ããŠã³ããŒããããã§ããïŒSUBSCRIPTION PLANSããã§ãã¯ããŠãã ããïŒ
- The PEASS FamilyãèŠã€ããŠãã ãããç¬å çãªNFTã®ã³ã¬ã¯ã·ã§ã³ã§ãã
- å ¬åŒã®PEASSïŒHackTricksã®ã°ããºãæã«å ¥ããŸãããã
- ð¬ Discordã°ã«ãŒããŸãã¯telegramã°ã«ãŒãã«åå ããããTwitterã§ãã©ããŒããŠãã ããðŠ@carlospolopm.
- ãããã³ã°ã®ããªãã¯ãå ±æããã«ã¯ãPRã hacktricks repo ãš hacktricks-cloud repo ã«æåºããŠãã ããã