gef-extras
gef-extras copied to clipboard
arm chroot problem - [!] Command 'context' failed to execute properly, reason: attempted relative import with no known parent package
Bug Report
- [X] Is your bug specific to GEF (not GDB)? - Try to reproduce it running
gdb -nx - [X] Did you search through the documentation first?
- [X] Did you check issues (including the closed ones) - and the PR?
Step 1: Describe your environment
- Operating System / Distribution: Debian (+ arm7 alpine rootfs chroot for target)
- Architecture: amd64 or x86_64
- GEF version (including the Python library version) run
versionin GEF. GEF: (Standalone) Blob Hash(/home/mike/.gef-revisit-target-remote.py): 7363309ca813527fba7d73038dc43d4770417eed SHA256(/home/mike/.gef-revisit-target-remote.py): dcaa4fc5b8218d14124f9e391f972c8ebb05e534dc90ed9e51f22e905e50412c GDB: 13.1 GDB-Python: 3.11
Step 2: Describe your problem
Steps to reproduce
- breaking on certain syscalls? in an arm 32 bit chroot.
Minimalist test case
# enable qemu-user-static and binfmt like so: https://gist.github.com/gokart23/8ade2d431ead2de47340160301837cab
wget https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/armhf/alpine-minirootfs-3.21.3-armhf.tar.gz
tar xzf ./alpine-minirootfs-3.21.3-armhf.tar.gz
cp $(which qemu-arm-static) ./$(which qemu-arm-static
sudo chroot . $(which qemu-arm-static) -g 4444 /usr/bin/scanelf -v
<open another terminal in same dir>
gdb-multiarch -ex "set systroot ." -ex "file ./lib/libc.musl-armhf.so.1" -ex "target remote localhost:4444" -ex "b __uflow" -ex "c"
# or use gef-remote with appropriate params if on main
Observed Results
- context fails to print the gef-extras
─────────────────────────────────────────────────────────────────────────────────────────── threads ────
[#0] Id 1, stopped 0x3f7af94c in __uflow (), reason: BREAKPOINT
───────────────────────────────────────────────────────────────────────────────────────────── trace ────
[#0] 0x3f7af94c → __uflow()
[#1] 0x3f7b1f70 → getdelim()
────────────────────────────────────────────────────────────────────────── Glibc Function Arguments ────
[!] Command 'context' failed to execute properly, reason: attempted relative import with no known parent package
Expected results
- No errors when printing context
Traces
Can you run in debug mode and print the stacktrace ?
it might be helpful to mention I had to assist the installer script by emulating what it was supposed to do because Debian doesn't allow installing system packages
pi print(sys.path)
['/usr/share/gdb/python', '/usr/lib/python311.zip', '/usr/lib/python3.11', '/usr/lib/python3.11/lib-dynload', '/home/mike/.local/lib/python3.11/site-packages', '/home/mike/.local/lib/python3.11/site-packages/unicornafl-2.1.0-py3.11.egg', '/home/mike/.local/lib/python3.11/site-packages/unicorn-2.0.1.post1-py3.11-linux-x86_64.egg', '/usr/local/lib/python3.11/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.11/dist-packages']
─────────────────────────────── Exception raised ───────────────────────────────
ImportError: attempted relative import with no known parent package
───────────────────────────── Detailed stacktrace ──────────────────────────────
↳ File "/home/mike/.config/gef-extras/scripts/libc_function_args/__init__.py", line 48, in load_libc_args()
→ from .tables.generator import generate_all_json_files
↳ File "/home/mike/.config/gef-extras/scripts/libc_function_args/__init__.py", line 92, in pane_content()
→ GlibcFunctionArguments.load_libc_args()
↳ File "/home/mike/.gef-revisit-target-remote.py", line 7712, in do_invoke()
→ display_pane_function()
↳ File "/home/mike/.gef-revisit-target-remote.py", line 370, in wrapper()
→ return f(*args, **kwargs)
↳ File "/home/mike/.gef-revisit-target-remote.py", line 242, in wrapper()
→ rv = f(*args, **kwargs)
↳ File "/home/mike/.gef-revisit-target-remote.py", line 4753, in invoke()
→ bufferize(self.do_invoke)(argv)
─────────────────────────────────── Version ────────────────────────────────────