arandomdev / DyldExtractor

Extract Binaries from Apple's Dyld Shared Cache
MIT License
404 stars 40 forks source link

DyldContext attempts to open .symbols file without checks. #45

Closed santalvarez closed 1 year ago

santalvarez commented 2 years ago

Hi, Im on macOS 12 (Monterey) and I am getting an error when trying to extract the cache.

FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/dyld/dyld_shared_cache_x86_64.symbols'

The file shown in the error does indeed not exist, does this mean DyldExtractor doesn't work in macOS 12?

arandomdev commented 2 years ago

DyldExtractor does not support x86_64 caches, but the error that is shown should have not happened. If possible, can you send me a file with the first 512 bytes of the main cache, /System/Library/dyld/dyld_shared_cache_x86_64. You can use the following command, dd count=1 if=INPUT_FILE of=OUTPUT_FILE.

santalvarez commented 2 years ago

Yeah, here you go dyld_shared_cache_x86_64.zip

arandomdev commented 2 years ago

Okay, I added a small check with 934b17d. As for x86_64 support, DyldExtractorC will support it, but development is going really slow unfortunately.

santalvarez commented 2 years ago

Nice, thank you. I tried it and I am getting this error for every lib, even in arm64e.

Processed: libsystem_info.dylib
----- libsystem_info.dylib -----
12:19:02:511 [  ERROR  ] dyldex_all:184 : 'NoneType' object has no attribute 'header'
Traceback (most recent call last):
  File "/usr/local/bin/dyldex_all", line 159, in _extractImage
    linkedit_optimizer.optimizeLinkedit(extractionCtx)
  File "/usr/local/lib/python3.9/site-packages/DyldExtractor/converter/linkedit_optimizer.py", line 600, in optimizeLinkedit
    optimizer.copyLocalSymbols(newLinkedit)
  File "/usr/local/lib/python3.9/site-packages/DyldExtractor/converter/linkedit_optimizer.py", line 270, in copyLocalSymbols
    if symbolsCache.header.localSymbolsOffset == 0:
AttributeError: 'NoneType' object has no attribute 'header'
--------------------
arandomdev commented 2 years ago

Hmm I probably should have done more testing, can you send me a download link for your cache files so I can look deeper into the issue?

torarnv commented 1 year ago

Also seeing this for an x86_64h cache

arandomdev commented 1 year ago

If possible can you send me your cache files? It would very helpful.

torarnv commented 1 year ago

Do you have an email I can reach you on?

arandomdev commented 1 year ago

Yep, haow6449@gmail.com

arandomdev commented 1 year ago

I added another check with 7a559b60a141323da11ce6d94e1ab1445b0d1a17 and that seems to fix this issue, but x86_64h still fails in ObjC Fixer.