+int main (int argc, char **argv, char **envp, char **apple)
+{
+for (int i=0; apple[i]; i++)
+printf("%d: %s\n", i, apple[i])
+}
+```
+结果:
+```
+0: executable_path=./a
+1:
+2:
+3:
+4: ptr_munge=
+5: main_stack=
+6: executable_file=0x1a01000012,0x5105b6a
+7: dyld_file=0x1a01000012,0xfffffff0009834a
+8: executable_cdhash=757a1b08ab1a79c50a66610f3adbca86dfd3199b
+9: executable_boothash=f32448504e788a2c5935e372d22b7b18372aa5aa
+10: arm64e_abi=os
+11: th_port=
+```
+{% hint style="success" %}
+当这些值到达主函数时,敏感信息已经被删除,否则可能会导致数据泄漏。
+{% endhint %}
+
+在进入主函数之前,可以通过调试查看所有这些有趣的值:
+
+lldb ./apple
+
+(lldb) target create "./a"
+当前可执行文件设置为'/tmp/a' (arm64)。
+(lldb) process launch -s
+[..]
+
+(lldb) mem read $sp
+0x16fdff510: 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 ................
+0x16fdff520: d8 f6 df 6f 01 00 00 00 00 00 00 00 00 00 00 00 ...o............
+
+(lldb) x/55s 0x016fdff6d8
+[...]
+0x16fdffd6a: "TERM_PROGRAM=WarpTerminal"
+0x16fdffd84: "WARP_USE_SSH_WRAPPER=1"
+0x16fdffd9b: "WARP_IS_LOCAL_SHELL_SESSION=1"
+0x16fdffdb9: "SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk"
+0x16fdffe24: "NVM_DIR=/Users/carlospolop/.nvm"
+0x16fdffe44: "CONDA_CHANGEPS1=false"
+0x16fdffe5a: ""
+0x16fdffe5b: ""
+0x16fdffe5c: ""
+0x16fdffe5d: ""
+0x16fdffe5e: ""
+0x16fdffe5f: ""
+0x16fdffe60: "pfz=0xffeaf0000"
+0x16fdffe70: "stack_guard=0x8af2b510e6b800b5"
+0x16fdffe8f: "malloc_entropy=0xf2349fbdea53f1e4,0x3fd85d7dcf817101"
+0x16fdffec4: "ptr_munge=0x983e2eebd2f3e746"
+0x16fdffee1: "main_stack=0x16fe00000,0x7fc000,0x16be00000,0x4000000"
+0x16fdfff17: "executable_file=0x1a01000012,0x5105b6a"
+0x16fdfff3e: "dyld_file=0x1a01000012,0xfffffff0009834a"
+0x16fdfff67: "executable_cdhash=757a1b08ab1a79c50a66610f3adbca86dfd3199b"
+0x16fdfffa2: "executable_boothash=f32448504e788a2c5935e372d22b7b18372aa5aa"
+0x16fdfffdf: "arm64e_abi=os"
+0x16fdfffed: "th_port=0x103"
+0x16fdffffb: ""
+
+
+## dyld\_all\_image\_infos
+
+这是由dyld导出的一个结构,包含有关dyld状态的信息,可以在[**源代码**](https://opensource.apple.com/source/dyld/dyld-852.2/include/mach-o/dyld\_images.h.auto.html)中找到,包括版本、指向dyld\_image\_info数组的指针、指向dyld\_image\_notifier的指针、如果进程与共享缓存分离、是否调用了libSystem初始化程序、指向dyld自身Mach头文件的指针、指向dyld版本字符串的指针...
+
+## dyld环境变量
+
+### 调试dyld
+
+有助于了解dyld操作的有趣环境变量:
+
+* **DYLD\_PRINT\_LIBRARIES**
+
+检查加载的每个库:
+```
+DYLD_PRINT_LIBRARIES=1 ./apple
+dyld[19948]: <9F848759-9AB8-3BD2-96A1-C069DC1FFD43> /private/tmp/a
+dyld[19948]: /usr/lib/libSystem.B.dylib
+dyld[19948]: /usr/lib/system/libcache.dylib
+dyld[19948]: /usr/lib/system/libcommonCrypto.dylib
+dyld[19948]: /usr/lib/system/libcompiler_rt.dylib
+dyld[19948]: <65612C42-C5E4-3821-B71D-DDE620FB014C> /usr/lib/system/libcopyfile.dylib
+dyld[19948]: /usr/lib/system/libcorecrypto.dylib
+dyld[19948]: <8790BA20-19EC-3A36-8975-E34382D9747C> /usr/lib/system/libdispatch.dylib
+dyld[19948]: <4BB77515-DBA8-3EDF-9AF7-3C9EAE959EA6> /usr/lib/system/libdyld.dylib
+dyld[19948]: /usr/lib/system/libkeymgr.dylib
+dyld[19948]: <1A7038EC-EE49-35AE-8A3C-C311083795FB> /usr/lib/system/libmacho.dylib
+[...]
+```
+* **DYLD\_PRINT\_SEGMENTS**
+
+检查每个库是如何加载的:
+```
+DYLD_PRINT_SEGMENTS=1 ./apple
+dyld[21147]: re-using existing shared cache (/System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_arm64e):
+dyld[21147]: 0x181944000->0x1D5D4BFFF init=5, max=5 __TEXT
+dyld[21147]: 0x1D5D4C000->0x1D5EC3FFF init=1, max=3 __DATA_CONST
+dyld[21147]: 0x1D7EC4000->0x1D8E23FFF init=3, max=3 __DATA
+dyld[21147]: 0x1D8E24000->0x1DCEBFFFF init=3, max=3 __AUTH
+dyld[21147]: 0x1DCEC0000->0x1E22BFFFF init=1, max=3 __AUTH_CONST
+dyld[21147]: 0x1E42C0000->0x1E5457FFF init=1, max=1 __LINKEDIT
+dyld[21147]: 0x1E5458000->0x22D173FFF init=5, max=5 __TEXT
+dyld[21147]: 0x22D174000->0x22D9E3FFF init=1, max=3 __DATA_CONST
+dyld[21147]: 0x22F9E4000->0x230F87FFF init=3, max=3 __DATA
+dyld[21147]: 0x230F88000->0x234EC3FFF init=3, max=3 __AUTH
+dyld[21147]: 0x234EC4000->0x237573FFF init=1, max=3 __AUTH_CONST
+dyld[21147]: 0x239574000->0x270BE3FFF init=1, max=1 __LINKEDIT
+dyld[21147]: Kernel mapped /private/tmp/a
+dyld[21147]: __PAGEZERO (...) 0x000000904000->0x000101208000
+dyld[21147]: __TEXT (r.x) 0x000100904000->0x000100908000
+dyld[21147]: __DATA_CONST (rw.) 0x000100908000->0x00010090C000
+dyld[21147]: __LINKEDIT (r..) 0x00010090C000->0x000100910000
+dyld[21147]: Using mapping in dyld cache for /usr/lib/libSystem.B.dylib
+dyld[21147]: __TEXT (r.x) 0x00018E59D000->0x00018E59F000
+dyld[21147]: __DATA_CONST (rw.) 0x0001D5DFDB98->0x0001D5DFDBA8
+dyld[21147]: __AUTH_CONST (rw.) 0x0001DDE015A8->0x0001DDE01878
+dyld[21147]: __AUTH (rw.) 0x0001D9688650->0x0001D9688658
+dyld[21147]: __DATA (rw.) 0x0001D808AD60->0x0001D808AD68
+dyld[21147]: __LINKEDIT (r..) 0x000239574000->0x000270BE4000
+dyld[21147]: Using mapping in dyld cache for /usr/lib/system/libcache.dylib
+dyld[21147]: __TEXT (r.x) 0x00018E597000->0x00018E59D000
+dyld[21147]: __DATA_CONST (rw.) 0x0001D5DFDAF0->0x0001D5DFDB98
+dyld[21147]: __AUTH_CONST (rw.) 0x0001DDE014D0->0x0001DDE015A8
+dyld[21147]: __LINKEDIT (r..) 0x000239574000->0x000270BE4000
+[...]
+```
+* **DYLD\_PRINT\_INITIALIZERS**
+
+打印每个库初始化程序运行时的信息:
+```
+DYLD_PRINT_INITIALIZERS=1 ./apple
+dyld[21623]: running initializer 0x18e59e5c0 in /usr/lib/libSystem.B.dylib
+[...]
+```
+### 其他
+
+* `DYLD_BIND_AT_LAUNCH`: 惰性绑定将使用非惰性绑定解析
+* `DYLD_DISABLE_PREFETCH`: 禁用对 \_\_DATA 和 \_\_LINKEDIT 内容的预取
+* `DYLD_FORCE_FLAT_NAMESPACE`: 单级绑定
+* `DYLD_[FRAMEWORK/LIBRARY]_PATH | DYLD_FALLBACK_[FRAMEWORK/LIBRARY]_PATH | DYLD_VERSIONED_[FRAMEWORK/LIBRARY]_PATH`: 解析路径
+* `DYLD_INSERT_LIBRARIES`: 加载特定库
+* `DYLD_PRINT_TO_FILE`: 将 dyld 调试信息写入文件
+* `DYLD_PRINT_APIS`: 打印 libdyld API 调用
+* `DYLD_PRINT_APIS_APP`: 打印主程序调用的 libdyld API
+* `DYLD_PRINT_BINDINGS`: 绑定时打印符号
+* `DYLD_WEAK_BINDINGS`: 仅在绑定时打印弱符号
+* `DYLD_PRINT_CODE_SIGNATURES`: 打印代码签名注册操作
+* `DYLD_PRINT_DOFS`: 打印加载的 D-Trace 对象格式部分
+* `DYLD_PRINT_ENV`: 打印 dyld 可见的环境变量
+* `DYLD_PRINT_INTERPOSTING`: 打印 interposing 操作
+* `DYLD_PRINT_LIBRARIES`: 打印加载的库
+* `DYLD_PRINT_OPTS`: 打印加载选项
+* `DYLD_REBASING`: 打印符号重新定位操作
+* `DYLD_RPATHS`: 打印 @rpath 的扩展
+* `DYLD_PRINT_SEGMENTS`: 打印 Mach-O 段的映射
+* `DYLD_PRINT_STATISTICS`: 打印时间统计信息
+* `DYLD_PRINT_STATISTICS_DETAILS`: 打印详细的时间统计信息
+* `DYLD_PRINT_WARNINGS`: 打印警告消息
+* `DYLD_SHARED_CACHE_DIR`: 用于共享库缓存的路径
+* `DYLD_SHARED_REGION`: "use", "private", "avoid"
+* `DYLD_USE_CLOSURES`: 启用闭包
+
+可以通过类似以下方式找到更多内容:
+```bash
+strings /usr/lib/dyld | grep "^DYLD_" | sort -u
+```
+或者从[https://opensource.apple.com/tarballs/dyld/dyld-852.2.tar.gz](https://opensource.apple.com/tarballs/dyld/dyld-852.2.tar.gz)下载dyld项目,并在文件夹内运行:
+```bash
+find . -type f | xargs grep strcmp| grep key,\ \" | cut -d'"' -f2 | sort -u
+```
+## 参考资料
+
+* [**\*OS Internals, Volume I: User Mode. By Jonathan Levin**](https://www.amazon.com/MacOS-iOS-Internals-User-Mode/dp/099105556X)
+
+
+
+从零开始学习AWS黑客技术,成为专家 htARTE (HackTricks AWS Red Team Expert)!
+
+支持HackTricks的其他方式:
+
+* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
+* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
+* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
+* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**。**
+* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
+
+