Closed hellow554 closed 2 years ago
thank you for the issue @hellow554 !
I can't find your GEF version anywhere in our git history, did you modify any files? for us to be able to help with this issue you have to use a clean, unmodified GEF version from dev
branch.
Also have you tried if the issue also exists with a rust binary for x86/x86_64? that would greatly improve our possibilities to understand the issue. Because unfortunately I don't have any stm32 lying around so I cant follow along :/
I took the latest ~dev~ master. Maybe vim added a newline?
x86(_64) works fine, for Linux and for windows.
I'm more than willing to help you and resolve this issue. Maybe using qemu will have the same effect, let me try that real quick
I took the latest dev. Maybe vim added a newline?
are you sure? on the latest dev
e.g. the version
command should return a SHA256
instead of SHA1
yeah, a working qemu setup would be great. looking at your code snippet I guess you took it from the Embedded Rust Book? If so I can try the qemu setup they describe there...
Here's the arm binary, the command line and another dump from gef:
qemu-system-arm -kernel fuzz.exe --machine stm32vldiscovery -S -s
Hope this helps!
hugsy/gef-extras#45 was just merged, you can either try again with the version on the dev
branch or wait for this weekend for the next relese that will include those changes. I think they should fix your issue:
@hugsy still no luck. Also I would like that this works out of the box without me running pi reset_architecture...
. Is that possible? :/
There are some things wrong in your screenshot, for example you need to use gef-remote
which is a wrapper that collects more info than gdb's target
command. Also you might want to retry by pulling the very latest commit (yesterday) in dev
However I'll take a further look at it after the next release is out.
Also I would like that this works out of the box without me running pi reset_architecture.... Is that possible? :/
It can be automatical if you add pi reset_architecture("ARM-M")
to your gdbinit after gef.py is sourced.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. You can reopen it by adding a comment to this issue.
This issue has been automatically closed because it has not had recent activity. If you are the owner of this issue, you can either re-open it and provide a more complete description; or create a new issue. Thank you for your contributions.
dev
branch?gdb -nx
Step 1: Describe your environment
version
in GEF.Step 2: Describe your problem
When I try to debug my application remotely I'm seeing a lot of
Command 'context' failed to execute proplery
messages. Directly after reset I see registers and the stack, but as soon as I run to main, I don't see them anymore:Steps to reproduce
cargo build
and afterwardsgdb-multiarch
to connect to your targetMinimalist test case
Traces
Trace
``` Breakpoint 4, l4::__cortex_m_rt_main_trampoline () at src/main.rs:10 10 #[entry] [ Legend: Modified register | Code | Heap | Stack | String ] ───────────────────────────────────────────────────────────────────────────────────── registers ──── ─────────────────────────────── Exception raised ─────────────────────────────── AttributeError: 'NoneType' object has no attribute 'sizeof' ───────────────────────────── Detailed stacktrace ────────────────────────────── ↳ File "/home/marcel/.gef.py", line 3710, in _ptr_width() → return uintptr_t.sizeof ↳ File "/home/marcel/.gef.py", line 3724, in is_32bit() → return _ptr_width() == 4 ↳ File "/home/marcel/.gef.py", line 3812, in get_memory_alignment() → if is_32bit(): ↳ File "/home/marcel/.gef.py", line 1888, in ptrsize() → return get_memory_alignment() ↳ File "/home/marcel/.gef.py", line 7516, in do_invoke() → memsize = current_arch.ptrsize ↳ File "/home/marcel/.gef.py", line 2980, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 2852, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 240, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 4616, in invoke() → bufferize(self.do_invoke)(argv) ─────────────────────────────────── Version ──────────────────────────────────── GEF: (Standalone) Blob Hash(/home/marcel/.gef.py): 612300df463844ee76d5dcf244053fb75b0c8b78 SHA1(/home/marcel/.gef.py): 470e64dd79a138efe82ee0b59616e04a43742d72 GDB: 11.1 GDB-Python: 3.9 Loaded commands: $, aliases, aliases add, aliases ls, aliases rm, aslr, assemble, canary, capstone-disassemble, checksec, context, dereference, edit-flags, elf-info, entry-break, format-string-helper, functions, gef-remote, got, heap, heap arenas, heap bins, heap bins fast, heap bins large, heap bins small, heap bins tcache, heap bins unsorted, heap chunk, heap chunks, heap set-arena, heap-analysis-helper, hexdump, hexdump byte, hexdump dword, hexdump qword, hexdump word, highlight, highlight add, highlight clear, highlight list, highlight remove, hijack-fd, ida-interact, is-syscall, ksymaddr, memory, memory list, memory reset, memory unwatch, memory watch, name-break, nop, patch, patch byte, patch dword, patch qword, patch string, patch word, pattern, pattern create, pattern search, pcustom, pcustom edit, pcustom list, pcustom show, pie, pie attach, pie breakpoint, pie delete, pie info, pie remote, pie run, print-format, process-search, process-status, registers, reset-cache, scan, search-pattern, set-permission, shellcode, shellcode get, shellcode search, stub, syscall-args, theme, trace-run, unicorn-emulate, version, vmmap, xfiles, xinfo, xor-memory, xor-memory display, xor-memory patch ───────────────────────────── Last 10 GDB commands ───────────────────────────── 250 c 251 version 252 version 253 si 254 break main 255 c 256 !cat src/main.rs 257 gef config gef.debug 1 258 break main 259 c ───────────────────────────── Runtime environment ────────────────────────────── * GDB: 11.1 * Python: 3.9.7 - final * OS: Linux - 5.10.60.1-microsoft-standard-WSL2 (x86_64) No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 21.10 Release: 21.10 Codename: impish ──────────────────────────────────────────────────────────────────────────────── ───────────────────────────────────────────────────────────────────────────────────────── stack ──── ─────────────────────────────── Exception raised ─────────────────────────────── AttributeError: 'NoneType' object has no attribute 'sizeof' ───────────────────────────── Detailed stacktrace ────────────────────────────── ↳ File "/home/marcel/.gef.py", line 3710, in _ptr_width() → return uintptr_t.sizeof ↳ File "/home/marcel/.gef.py", line 3724, in is_32bit() → return _ptr_width() == 4 ↳ File "/home/marcel/.gef.py", line 3182, in download_file() → if is_32bit(): ↳ File "/home/marcel/.gef.py", line 3197, in open_file() → lpath = download_file(path, use_cache) ↳ File "/home/marcel/.gef.py", line 3215, in get_process_maps_linux() → with open_file(proc_map_file, use_cache=False) as f: ↳ File "/home/marcel/.gef.py", line 3274, in get_process_maps() → return list(get_process_maps_linux(fpath)) ↳ File "/home/marcel/.gef.py", line 3357, in process_lookup_address() → for sect in get_process_maps(): ↳ File "/home/marcel/.gef.py", line 9466, in do_invoke() → if process_lookup_address(target_addr) is None: ↳ File "/home/marcel/.gef.py", line 2980, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 2852, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 240, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 4616, in invoke() → bufferize(self.do_invoke)(argv) ─────────────────────────────────── Version ──────────────────────────────────── GEF: (Standalone) Blob Hash(/home/marcel/.gef.py): 612300df463844ee76d5dcf244053fb75b0c8b78 SHA1(/home/marcel/.gef.py): 470e64dd79a138efe82ee0b59616e04a43742d72 GDB: 11.1 GDB-Python: 3.9 Loaded commands: $, aliases, aliases add, aliases ls, aliases rm, aslr, assemble, canary, capstone-disassemble, checksec, context, dereference, edit-flags, elf-info, entry-break, format-string-helper, functions, gef-remote, got, heap, heap arenas, heap bins, heap bins fast, heap bins large, heap bins small, heap bins tcache, heap bins unsorted, heap chunk, heap chunks, heap set-arena, heap-analysis-helper, hexdump, hexdump byte, hexdump dword, hexdump qword, hexdump word, highlight, highlight add, highlight clear, highlight list, highlight remove, hijack-fd, ida-interact, is-syscall, ksymaddr, memory, memory list, memory reset, memory unwatch, memory watch, name-break, nop, patch, patch byte, patch dword, patch qword, patch string, patch word, pattern, pattern create, pattern search, pcustom, pcustom edit, pcustom list, pcustom show, pie, pie attach, pie breakpoint, pie delete, pie info, pie remote, pie run, print-format, process-search, process-status, registers, reset-cache, scan, search-pattern, set-permission, shellcode, shellcode get, shellcode search, stub, syscall-args, theme, trace-run, unicorn-emulate, version, vmmap, xfiles, xinfo, xor-memory, xor-memory display, xor-memory patch ───────────────────────────── Last 10 GDB commands ───────────────────────────── 250 c 251 version 252 version 253 si 254 break main 255 c 256 !cat src/main.rs 257 gef config gef.debug 1 258 break main 259 c ───────────────────────────── Runtime environment ────────────────────────────── * GDB: 11.1 * Python: 3.9.7 - final * OS: Linux - 5.10.60.1-microsoft-standard-WSL2 (x86_64) No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 21.10 Release: 21.10 Codename: impish ──────────────────────────────────────────────────────────────────────────────── ─────────────────────────────── Exception raised ─────────────────────────────── TypeError: unsupported operand type(s) for &: 'NoneType' and 'int' ───────────────────────────── Detailed stacktrace ────────────────────────────── ↳ File "/home/marcel/.gef.py", line 2030, in is_thumb() → return is_alive() and get_register(self.flag_register) & (1 << 5) ↳ File "/home/marcel/.gef.py", line 2035, in pc() → if self.is_thumb(): ↳ File "/home/marcel/.gef.py", line 8493, in context_code() → pc = current_arch.pc ↳ File "/home/marcel/.gef.py", line 8355, in do_invoke() → display_pane_function() ↳ File "/home/marcel/.gef.py", line 2852, in wrapper() → return f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 244, in wrapper() → rv = f(*args, **kwargs) ↳ File "/home/marcel/.gef.py", line 4616, in invoke() → bufferize(self.do_invoke)(argv) ─────────────────────────────────── Version ──────────────────────────────────── GEF: (Standalone) Blob Hash(/home/marcel/.gef.py): 612300df463844ee76d5dcf244053fb75b0c8b78 SHA1(/home/marcel/.gef.py): 470e64dd79a138efe82ee0b59616e04a43742d72 GDB: 11.1 GDB-Python: 3.9 Loaded commands: $, aliases, aliases add, aliases ls, aliases rm, aslr, assemble, canary, capstone-disassemble, checksec, context, dereference, edit-flags, elf-info, entry-break, format-string-helper, functions, gef-remote, got, heap, heap arenas, heap bins, heap bins fast, heap bins large, heap bins small, heap bins tcache, heap bins unsorted, heap chunk, heap chunks, heap set-arena, heap-analysis-helper, hexdump, hexdump byte, hexdump dword, hexdump qword, hexdump word, highlight, highlight add, highlight clear, highlight list, highlight remove, hijack-fd, ida-interact, is-syscall, ksymaddr, memory, memory list, memory reset, memory unwatch, memory watch, name-break, nop, patch, patch byte, patch dword, patch qword, patch string, patch word, pattern, pattern create, pattern search, pcustom, pcustom edit, pcustom list, pcustom show, pie, pie attach, pie breakpoint, pie delete, pie info, pie remote, pie run, print-format, process-search, process-status, registers, reset-cache, scan, search-pattern, set-permission, shellcode, shellcode get, shellcode search, stub, syscall-args, theme, trace-run, unicorn-emulate, version, vmmap, xfiles, xinfo, xor-memory, xor-memory display, xor-memory patch ───────────────────────────── Last 10 GDB commands ───────────────────────────── 250 c 251 version 252 version 253 si 254 break main 255 c 256 !cat src/main.rs 257 gef config gef.debug 1 258 break main 259 c ───────────────────────────── Runtime environment ────────────────────────────── * GDB: 11.1 * Python: 3.9.7 - final * OS: Linux - 5.10.60.1-microsoft-standard-WSL2 (x86_64) No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 21.10 Release: 21.10 Codename: impish ──────────────────────────────────────────────────────────────────────────────── ```