0cyn / ktool

pip install k2l | Mach-O + Obj-C analysis TUI / CLI kit and library. Zero compiled deps, runs anywhere with a python interpreter.
MIT License
484 stars 24 forks source link

Load Command LOAD_COMMAND.LOAD_UPWARD_DYLIB doesn't have a mapped struct type #34

Closed LeoNatan closed 2 years ago

LeoNatan commented 2 years ago

Hello, when attempting to dump headers for a shared library extracted from the dyld cache (using keith/dyld-shared-cache-extractor), the following error comes up:

➜  ~ ktool dump --headers --out ~/Desktop/test/headers /Users/lnatan/Desktop/test/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 
ERROR - ktool.dyld:L#83:ImageHeader:from_image() - 
ERROR - ktool.dyld:L#84:ImageHeader:from_image() - Load Command LOAD_COMMAND.LOAD_UPWARD_DYLIB doesn't have a mapped struct type
ERROR - ktool.dyld:L#85:ImageHeader:from_image() - *Please* file an issue on the github @ https://github.com/cxnder/ktool
ERROR - ktool.dyld:L#86:ImageHeader:from_image() - 
ERROR - ktool.dyld:L#87:ImageHeader:from_image() - Run with the -f flag before the subcommand to try and force loading anyways
ERROR - ktool.dyld:L#88:ImageHeader:from_image() - 
Traceback (most recent call last):
  File "/opt/homebrew/bin/ktool", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/ktool_script.py", line 376, in main
    args.func(args)
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/ktool_script.py", line 898, in dump
    image = ktool.load_image(fp, args.slice_index, use_mmaped_io=MMAP_ENABLED)
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/ktool.py", line 84, in load_image
    return Dyld.load(macho_slice, load_symtab=load_symtab, load_imports=load_imports, load_exports=load_exports)
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/dyld.py", line 292, in load
    image = Image(macho_slice)
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/dyld.py", line 139, in __init__
    self.macho_header: ImageHeader = ImageHeader.from_image(macho_slice=macho_slice)
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/dyld.py", line 89, in from_image
    raise ex
  File "/opt/homebrew/lib/python3.9/site-packages/ktool/dyld.py", line 74, in from_image
    load_cmd = Struct.create_with_bytes(LOAD_COMMAND_MAP[LOAD_COMMAND(cmd)], cmd_raw)
KeyError: <LOAD_COMMAND.LOAD_UPWARD_DYLIB: 2147483683>

Running with the -f flag doesn't help.

Thanks

LeoNatan commented 2 years ago

Thanks!

0cyn commented 2 years ago

Fix shipped in 1.1.0