Commit Graph

1586 Commits

Author SHA1 Message Date
Gulshan Singh caa22ce04e
Added command to list slabs (#1442) 2022-12-22 09:24:20 -08:00
Gulshan Singh 6a6107b4bf
Fix gdb-pt-dump exception when attaching to x86 QEMU (#1452)
Fixes https://github.com/pwndbg/pwndbg/issues/1404
2022-12-22 00:31:22 -08:00
Gulshan Singh 0083962780
Remove redundant struct.unpack formats (#1451) 2022-12-21 22:53:14 -08:00
Gulshan Singh 09d31c58b8
Add kbase command (#1450) 2022-12-21 22:41:16 -08:00
Gulshan Singh 2daf9faf62
Add x86_64ArchOps (#1449) 2022-12-21 18:51:19 -08:00
Gulshan Singh 22409202e7
Add kchecksec command (#1441)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-20 20:25:03 -08:00
Gulshan Singh 8b43ac297e
Use RawTextHelpFormatter for more commands (#1448)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-20 19:35:00 -08:00
Gulshan Singh d08c6af337
Start a env_parallel session to avoid argument too long errors (#1446)
Co-authored-by: Gulshan Singh <gsgx@google.com>
Fixes https://github.com/pwndbg/pwndbg/issues/1430
2022-12-20 13:37:51 -08:00
Gulshan Singh 7263d14adf
Move some event hooks to hooks.py (#1431)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-20 09:22:18 -08:00
Gulshan Singh 2971635c5a
Make it easier to remove cwatch expressions (#1421)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-19 23:43:49 -08:00
Gulshan Singh 0c0ab5f154
Add ArchOps (#1444)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-19 20:01:12 -08:00
Gulshan Singh fa8a033749
Fail tests if an error occurs (#1445)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-19 19:06:41 -08:00
Mohit Saxena 894f6e2103 Update tests.yml 2022-12-19 23:09:17 +01:00
Mohit Saxena 0b0b09c7f5 Update tests.yml 2022-12-19 23:09:17 +01:00
lebr0nli 1e32ff1fbb Reduce unnecessary `monitor` called if possible 2022-12-19 23:08:43 +01:00
lebr0nli 416bd4726c Update the comment about the bug caused by `monitor`
The GDB didn't freeze, but somehow showed an additional newline and failed to show the context because `pwndbg.gdblib.proc.thread_is_stopped` is False when running `gdb.prompt_hook`.
2022-12-19 23:08:43 +01:00
lebr0nli 86d096d544 Fix the bug when using gdbserver
If we execute the `monitor` command in `is_debug_probe()`, the GDB with normal GDBserver will stuck after first `continue`.

To avoid this, we check if `monitor help` showed that we are using GDBserver.
2022-12-19 23:08:43 +01:00
ytk2128 8ad2d649bb Fix ValueError of cyclic command 2022-12-19 23:06:10 +01:00
Gulshan Singh f49aa00f42
Allow running cpsr command on aarch64 (#1437)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 21:31:30 -08:00
Gulshan Singh 00f09a7831
Add OnlyWithKernelDebugSyms decorator (#1436)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 19:42:13 -08:00
lebr0nli af9ecf2203 Add developing guide for adding config 2022-12-12 10:29:18 +07:00
lebr0nli 2b1b6d567a Improve the docs of some configs
- Update the docs of the config: `kernel-vmmap`, `hexdump-group-use-big-endian`, `kernel_vmmap_via_pt`, and `resolve-heap-via-heuristic`

- Update the output of `get_show_string()` to display: ``See `help set <config>` for more information`` in the end of the output of `show <config>`
2022-12-12 10:29:18 +07:00
lebr0nli 2dc7cd168f Some enhancements to the heap heuristic
- Fix wrong output of `heap_config` command
- Implement auto mode for heap heuristic
  - In auto mode, pwndbg will try to resolve the heap using heuristics if debug symbols are missing
2022-12-12 10:29:18 +07:00
lebr0nli 0b394a440d Some improvements to configuration
- Modify `get_set_string()` to match GDB's builtin behaviour
- Make `gcc-compiler-path`'s and `cymbol-editor`'s `set_show_doc` first strings to lowercase
- Change `gcc-compiler-path` and `cymbol-editor` to `gdb.PARAM_OPTIONAL_FILENAME`
- Add resolve_heap_via_heuristic as a gdb.PARAM_ENUM config with options:
  - auto: pwndbg will try to use heuristics if debug symbols are missing
  - force: pwndbg will always try to use heuristics, even if debug symbols are available
  - never: pwndbg will never use heuristics to resolve the heap
- Move some hints to `resolve_heap_via_heuristic`'s `help_docstring`
2022-12-12 10:29:18 +07:00
Gulshan Singh d28f25c345
Add is_kaslr_enabled function (#1435)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 19:21:15 -08:00
Gulshan Singh 6f50b08767
Add commands to print kernel commandline and version (#1434)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 19:17:33 -08:00
Gulshan Singh a575fa7fab
Add kconfig command (#1425)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 19:02:54 -08:00
Gulshan Singh 800e6d5f23
Replace OnlyAmd64 decorator with more generic OnlyWithArch decorator (#1433)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 18:40:32 -08:00
Gulshan Singh 1bd4e4a482
Move some env_parallel code into the else branch (#1432)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-11 18:16:08 -08:00
Gulshan Singh 5e47e344a7
Fix gdb-pt-dump error when attaching to QEMU on aarch64 (#1429) 2022-12-11 01:11:59 -08:00
Gulshan Singh 3b482a6485
Add basic QEMU system testing scripts (#1428) 2022-12-11 00:14:58 -08:00
Gulshan Singh 5b32e6831c
Handle gdb-pt-dump permission error gracefully (#1426) 2022-12-11 00:14:14 -08:00
Gulshan Singh d52011877b
Add simple qemu-aarch64 test (#1423) 2022-12-10 15:30:52 -08:00
Disconnect3d 12488fbf1f
Bump gdb pt dump (#1205)
* bugreport command: use code listings

* improve bugreport text

* Update gdb-pt-dump version

* bump to ebdc245
2022-12-07 04:47:37 +01:00
Gulshan Singh 947024ee80
Deprecate kernel-vmmap-via-page-tables in favor of kernel-vmmap (#1415)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-05 18:02:39 +01:00
Gulshan Singh 02c97693f7
Add support for performance profiling (#1413)
Co-authored-by: Gulshan Singh <gsgx@google.com>
2022-12-05 17:49:00 +01:00
Testzero 94d1ebb9bd
Fix: support malloc_ptr of glibc<=2.23 (#1406)
* Fix: support malloc_ptr of glibc<=2.23

* Fix: support malloc_ptr of glibc<=2.23

Co-authored-by: T3stzer0 <testzerowz@gmail.com>
2022-12-04 18:26:19 +01:00
Disconnect3d f78e3250c7
Fix archlinux ci tests (#1411)
* Fix Arch CI: install missing netcat (#1400)

The arch linux test_command_procinfo was failing bcoz the netcat was not
installed on arch build. This commit fixes it by:
1) installing gnu-netcat for arch linux setup-dev.sh
2) asserting that nc is available in the test itself, to prevent similar
   regressions from happening on future/newer images

* Fix Arch CI: the load binary tests (#1400)

Before this commit we asserted whether the loaded binary in tests report
to find or not find debug symbols but this is irrelevant for the thing
we want to test there which is: pwndbg loading. What eventually cares is
whether Pwndbg got loaded and didn't raise an exception.

This commit fixes those tests so they should now work also on ArchLinux
CI and on all CI builds.

Additionally, it removes the `compile_binary` test utility function
which was redundant as we compile all test binaries via a makefile.

* fix lint

* cleanup tests/binaries/div_zero_binary
2022-12-03 17:10:08 +01:00
Disconnect3d 1c609eba15
Fix #1399: cymbol command on old GDB (#1409)
The cymbol command did not work on old GDB versions like 8.2 because
they require the ADDR argument to be passed into the `add-symbol-file`
command unlike newer GDB versions in which the argument is optional.

This can be seen below.

```
pwndbg> help add-symbol-file
Load symbols from FILE, assuming FILE has been dynamically loaded.
Usage: add-symbol-file FILE ADDR [-readnow | -readnever | -s SECT-NAME SECT-ADDR]...
ADDR is the starting address of the file's text.
Each '-s' argument provides a section name and address, and
should be specified if the data and bss segments are not contiguous
with the text.  SECT-NAME is a section name to be loaded at SECT-ADDR.
The '-readnow' option will cause GDB to read the entire symbol file
immediately.  This makes the command slower, but may make future operations
faster.
The '-readnever' option will prevent GDB from reading the symbol file's
symbolic debug information.
pwndbg> version
Gdb:      8.1.1
Python:   3.6.9 (default, Jun 29 2022, 11:45:57)  [GCC 8.4.0]
Pwndbg:   1.1.1 build: c5d8800
Capstone: 4.0.1024
Unicorn:  2.0.7
```

vs

```
pwndbg> help add-symbol-file
Load symbols from FILE, assuming FILE has been dynamically loaded.
Usage: add-symbol-file FILE [-readnow | -readnever] [-o OFF] [ADDR] [-s SECT-NAME SECT-ADDR]...
ADDR is the starting address of the file's text.
Each '-s' argument provides a section name and address, and
should be specified if the data and bss segments are not contiguous
with the text.  SECT-NAME is a section name to be loaded at SECT-ADDR.
OFF is an optional offset which is added to the default load addresses
of all sections for which no other address was specified.
The '-readnow' option will cause GDB to read the entire symbol file
immediately.  This makes the command slower, but may make future operations
faster.
The '-readnever' option will prevent GDB from reading the symbol file's
symbolic debug information.
pwndbg> version
Gdb:      12.1
Python:   3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
Pwndbg:   1.1.1 build: c5d8800
Capstone: 4.0.1024
Unicorn:  2.0.0
pwndbg>
```
2022-12-03 14:10:55 +01:00
Disconnect3d 275b9c9786
tests.sh: fix --pdb (set SERIAL when --pdb is set) (#1410)
When we optimized tests runs with gnu parallel execution, we broke the
--pdb flag. This commit fixes it and sets the SERIAL flag so that tests
are run one by one when --pdb is passed.
2022-12-03 14:05:54 +01:00
Disconnect3d c5d880020e
fix #1188: incorrect 32-bit syscall display on x64 (#1407)
* fix #1188: incorrect 32-bit syscall display on x64

* fix lint

* Update pwndbg/arguments.py
2022-12-03 12:42:37 +01:00
Disconnect3d d382fca97a
abi.py: don't recreate ABI dicts (#1408) 2022-12-03 12:41:46 +01:00
Albert Koczy 5b87775491
fix: Prevent pwndbg from trying to download ELF files from a remote embedded device. (#1402)
Added a heuristic to check whether we are debugging using a Blackmagic probe or a SEGGER J-link, if yes we don't download any elf files (this caused pwndbg to error out).
2022-11-30 16:27:33 +01:00
Albert Koczy 71baca5116
fix: fix crash when debugging ARMv7-M and set architecture mapping for ARM Cortex to thumb (#1401)
As per: https://developer.arm.com/documentation/ddi0403/d/Application-Level-Architecture/The-ARMv7-M-Instruction-Set/About-the-instruction-set/ARMv7-M-and-interworking-support?lang=en

"ARMv7-M only supports the Thumb instruction execution state"
2022-11-30 13:58:56 +01:00
CptGibbon 2d537b5751
Fix find_fake_fast command test (#1397)
Use a more reliable method for mapping one of the fake chunks such that its heap_info struct is guaranteed to be unmapped.
2022-11-30 06:52:55 +01:00
Gulshan Singh 5a0e229fc5
Disable IDA RPC by default (#1395)
If there is some other application using port 31337, you get an XML RPC error:
```
[!] Ida Pro xmlrpc error
Traceback (most recent call last):
  File "/home/gsgx/tools/pwndbg/pwndbg/ida.py", line 69, in init_ida_rpc_client
    _ida.here()
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1122, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1464, in __request
    response = self.__transport.request(
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1196, in single_request
    raise ProtocolError(
xmlrpc.client.ProtocolError: <ProtocolError for 127.0.0.1:31337/RPC2: 404 Not Found>
```

We should disable IDA by default, and any users that want it can just enable it in their config.
2022-11-28 05:34:29 +01:00
Gulshan Singh 44808f911a
Add CI badge (#1396) 2022-11-27 16:25:09 -08:00
Disconnect3d f01f932755
version.py: fix build_id after recent refactors (#1393)
* version.py: fix build_id after recent refactors

* fix lint
2022-11-27 17:11:04 +01:00
Alan Li 39ebd66539
Add `default-visualize-chunk-number` config and refactor some code related to config (#1388)
* Add a config for the `vis_heap_chunks` command

After this commit, we can use `set default-visualize-chunk-number <number>` to set the default value of the `count` argument of the `vis_heap_chunks` command.

* Add a test for `default-visualize-chunk-number`

* Refactor some code related to config

* Add `*`: https://github.com/pwndbg/pwndbg/pull/1315#discussion_r1002533684

* Use `set_show_doc` instead of `docstring`: https://github.com/pwndbg/pwndbg/pull/1315#discussion_r1002600089
2022-11-26 03:57:46 +01:00
Disconnect3d c6ab8dc671
Fix vmmap coredump test (#1391)
* fix shlint

* Fix crash when unable to get ehdr and fix vmmap coredump test

This commit fixes two issues and test them.

1. It changes the reads in `get_ehdr` to partial reads so that inability
   to read the `vmmap.start` address there will not crash Pwndbg with
`gdb.error` but instead we will simply return `None` as expected from
this function. This crash could happen on Debian 10 (GDB 8.2.1) and
Ubuntu 18.04 (not sure which GDB) when you did:
- gdb ./binary-that-crashes
- `run`
- `generate-core-file /tmp/core`
- `file` - to unload the binary
- `core-file /tmp/core` - to load the generated core

At this point I think we may have preserved the old vmmap info and use
it in `get_ehdr` maybe, which then crashed? I am not sure, but this fix
here works.

To test this behavior properly I also added the `unload_file`
parametrization to the
`test_command_vmmap_on_coredump_on_crash_simple_binary` test.

2. We fix the vmmap coredump test case when the `info proc mappings` returns nothing on core
   dumps on old GDBs. In such case we are missing the vmmap info about
the binary mapping, so now we properly remove it in the test.
2022-11-22 21:15:39 +01:00