Commit Graph

1586 Commits

Author SHA1 Message Date
Ido Frankenthal 52d729f574
Fix: Undefined info command: "win" (#1775)
* Return no cmd window size when info win is not avaiable

* Update pwndbg/ui.py

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-07-04 13:56:40 +02:00
Disconnect3d 0db1eeadca
Remove ArchLinux from CI (#1776)
Since it breaks every now and then. This should be reverted when we start to install deps in a virtualenv
2023-07-04 00:11:28 +02:00
Disconnect3d 8d0ccbc3eb
vmmap.py: fix yama/ptrace_scope command suggestion (Fixes #1768) (#1769) 2023-06-26 15:46:48 +02:00
Disconnect3d 44d75e3bd6
Fix #1728: racing test (#1764) 2023-06-21 16:39:51 +02:00
Gulshan Singh 9d3198f7f8
Update gdb-pt-dump (#1763) 2023-06-19 10:00:15 +02:00
Gulshan Singh 1bdaed3db7
Fix vmmap for 32-bit kernels (#1739) 2023-06-12 08:51:55 -07:00
Tom Tan 79ade42184
Fix banner width for TUI mode with horizontal split for cmd window (#1752)
* Fix banner width for TUI mode with horizontal split for cmd window

* Fix lint

* Add doc string for get_cmd_window_size
2023-06-06 20:50:49 +02:00
Disconnect3d 9e85d0df93
Fix #1756: change cache ._reset() to .cache.clear() (#1757) 2023-06-05 14:23:39 +02:00
Matteo Rizzo 1d635f0860
slab: show per-node partial slabs (#1751)
SLUB keeps a per-NUMA node list of partial slabs in addition to the
per-CPU lists. Print the slabs on those lists as well.
2023-05-25 13:35:51 -07:00
Disconnect3d 9c64c0e6c3
Fix patch_list and patch_revert commands (#1750) 2023-05-25 12:44:04 +02:00
Gulshan Singh addf96f9bc
More type hints (#1746)
* More safe typehints from autotyping

* More aggressive type hints from autotyping
2023-05-24 18:16:34 -07:00
Gulshan Singh 772eddc51e
Upgrade dependencies (#1745) 2023-05-24 17:32:25 -07:00
Gulshan Singh 91f3081e4b
Add more type hints (#1743)
* Apply safe autotyping transformations

* Apply aggressive autotyping transformations

* Reformat

* Convert Python2 type hints to Python3

* Fix cache type hints

* Convert forward reference types to strings, as Python 3.6 doesn't support __future__.annotations
2023-05-24 15:43:19 -07:00
Gulshan Singh a3b66dae5b
Convert format strings to f-strings (#1738) 2023-05-24 04:33:24 -07:00
Disconnect3d 6e0d159273
Add +10min (30min) to qemu-tests CI build (#1737)
This is an attempt to mitigate: "Unit tests / qemu-tests (pull_request) Cancelled after 20m" that occurs in https://github.com/pwndbg/pwndbg/pull/1732
2023-05-24 12:48:32 +02:00
Gulshan Singh 37376c8ac7
Covert printf format strings to f-strings (#1735) 2023-05-24 03:47:56 -07:00
dan "smiley" murray 3016004a6c
Cleanup heap decorators #1208 (#1736)
* Remove use of OnlyWhenRunning when we already have OnlyWhenHeapInitialized

* Remove use of OnlyWhenHeapInitialized when we already have OnlyWithTcache
2023-05-24 03:33:18 -07:00
Gulshan Singh b5a1219e2f
Update QEMU image download URL (#1731) 2023-05-20 10:34:54 -07:00
theguy147 e830dcb500
Support slab command for all available cpus (#1725)
* feat: support slab command for all available cpus

* fix: remove todo comment

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-05-20 10:07:38 -07:00
dan "smiley" murray 10f33d11c3
Add OnlyWhenUserspace Decorator #1459 (#1729)
* Add OnlyWhenUserspace Decorator #1459

* The decorator is implemented as the inverse of OnlyWhenQemuKernel

* Apply the decorator to all of the heap commands and tls, auxv and environ/envp

* Update pwndbg/commands/__init__.py

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-05-20 10:01:33 -07:00
dan "smiley" murray 56d3e8509d
Add a test binary that has very long symbols (#1719) 2023-05-20 17:16:10 +02:00
theguy147 c40f143edd
address translation only works with debug symbols (#1723)
* test: skip address translation test when no debug symbols

* fix: add missing decorators to archops functions
2023-05-20 17:15:38 +02:00
Gulshan Singh 2ee664a0ea
Add codecov.yml (#1720) 2023-05-20 17:13:15 +02:00
theguy147 5280964448
Filter commands by category (#1726)
* feat: filter commands by category

* feat: list pwndbg command categories
2023-05-20 17:07:16 +02:00
dan "smiley" murray cd4217fa03
By default remove the context backtrace f prefix #1288 (#1727)
* Tests: update context backtrace test to respect the theme
2023-05-20 17:06:39 +02:00
dan "smiley" murray f996aaa2f1
Make args an alias for dumpargs (#1721) 2023-05-19 00:24:22 -07:00
theguy147 f9731bb04b
refactor: move slab business logic to gdblib (#1711)
* refactor: move slab business logic to gdblib

* refactor: minor improvements

* refactor: move slab contains logic to backend

* feat: add error catching wrapper for parse_and_eval

* fix: repair test after refactor

* tests: test slab info more extensively

* fix: correctly detect non-existant slabs

* fix: respect if slab objects have surrounding metadata

* fix: correctly detect non-existant slabs (2)

* style: update kconfig lookup
2023-05-18 02:11:44 -07:00
Disconnect3d 5d0e3ec067
Fix Ubuntu 22.04 CI build by installing libgcc-s1:i386 (#1716) 2023-05-18 03:29:39 +02:00
Alexandru Gabriel Bradatan d7c0e2aee7
Include opensuse-tumbleweed in setup.sh (#1710) 2023-05-17 00:12:16 +02:00
Unknown Sentinel 3b561cdc81
Updated version.py for bugreport command to display more information (#1709)
* Updated version.py for bugreport command to display more information

* Update version.py

* Update pwndbg/commands/version.py

---------

Co-authored-by: Unknown6334 <63234449+Unknown1934-del@users.noreply.github.com>
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-05-14 20:18:07 +02:00
theguy147 608fa83b04
Add `slab contains` command (#1707)
* feat: add slab contains command

* tests: add slab contains test

* fix: repair faulty 5lvl paging detection

* fix: remove typo

* fix: dereference compound_head

* fix: repair address translation for arm64

* fix: ensure kernel initialization has progressed for tests

* fix: adjust address range for valid slab objects

* tests: automatically find slab objects for tests

* fix: repair off-by-one error in address range
2023-05-14 19:40:03 +02:00
Unknown Sentinel 14bb546efe
Fix test command procinfo (#1706)
* Updated canary.py for better display

* Updated test_command_procinfo.py

* Revert "Updated canary.py for better display"

This reverts commit 802e243183.

* Fix lint issue

* Update test_command_procinfo.py

---------

Co-authored-by: Unknown6334 <63234449+Unknown1934-del@users.noreply.github.com>
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-05-14 19:26:37 +02:00
Czarna f402732a33
Optimize the vis_heap_chunks by creating VALID_CHARS once
This commit optimizes the `bin_ascii` function used by the `vis_heap_chunks` command.

That function executed the following line on each call:
```
    valid_chars = list(map(ord, set(printable) - set("\t\r\n\x0c\x0b")))
```

And it could be called thousand times, e.g. 90k on a benchmark.

This commit moves the creation of the `valid_chars` list to the global space so it is computed only once.

As a result, on a simple benchmark we improved the speed of `vis_heap_chunks` command from 4.6s to 3s.
2023-05-12 23:26:37 +02:00
Disconnect3d e77c6f5c2e
Fix stack.update caching bug (#1703)
The `pwndbg.gdblib.regs.sp` value is cached and its cache is cleared on a next stop, memory write or register write events.

We keep a dictionary of stacks in Pwndbg, that are updated on each stop by the `stack.update` functionality which reused a cached stack pointer (`gdblib.regs.sp`) value.

As a result, if we had more than one threads, the `pwndbg.gdblib.stacks.stacks` reported the same stack address for all threads and then the `canary` command printed the same addresses N times where N is the number of threads that were running.

This commit fixes this bug by clearing up the registers cache when we switch into a different thread in the loop in the `stacks.update` function.
2023-05-12 11:02:59 +02:00
peace-maker 3bc91c1cb2
Add heuristic to add executable base in qemu-user (#1695)
vmmap would try to add the executable to memory pages if the `info auxv`
command contained an address, but the memory maps would be accessed
recursively when trying to lookup the start of the ELF based on the
given address.

Since qemu doesn't provide memory map info, do a leap of faith and try
if the start of the page of the given address contains the ELF magic
header.

Since the program headers are more likely to be on the same page as the
ELF header than the program entrypoint, try both.
2023-05-11 18:35:17 +02:00
theguy147 6ffc3de08f
Repair slab info command (#1699)
* fix: repair slab info command

* CI: remove unnecessary assertion
2023-05-11 18:33:50 +02:00
Disconnect3d ed051af109
Honour Zach Riggle in README (#1702)
Adding a thank you to Zach Riggle to the readme. Zach, who started the pwndbg project, [passed away recently](https://twitter.com/halvarflake/status/1655961551403380736) :(
2023-05-09 23:04:11 +02:00
Disconnect3d fec8418b58
Increase killthreads timeout to 10s to fix CI issues (#1701) 2023-05-08 12:27:11 +02:00
Disconnect3d c19c6c324b
Fix enums from Python 3.11: use ReprEnum (#1700) 2023-05-08 11:58:17 +02:00
Gulshan Singh 487afacc7a
Switch from flake8 to ruff (#1696) 2023-05-04 00:42:40 -07:00
Disconnect3d 2f03a901e7
Optimize vis_heap_chunks command (#1678)
* Optimize vis_heap_chunks command

This commit optimizes the vis_heap_chunks command by:
1) precalculating bin labels instead of computing them on demand for each chunk
2) calling pwndbg.gdblib.memory.read once instead of twice in a hot loop

For `vis 2000` command ran when debugging python3 shell, the first change 
cut down the execution time from almost 20s to 5s.

Another benchmark, for both 1) and 2) changes showed 19.28s->4.14s timing.

The benchmark done is included in this commit in
profiling/benchmark_vis_heap_chunks/ so that it can be reproduced e.g.
to optimize the function further or to reproduce my results.
2023-05-03 00:24:17 +02:00
theguy147 6ff05bbcc8
Test more kernels (#1684) 2023-05-01 12:39:16 -07:00
theguy147 a9ec60c727
Fix and Improvements for ArchOps (#1676)
* fix: remove minor bugs and complete address translation

* feat: add 5lvl paging

* feat: add address translation tests

* fix: remove unnecessary comments

* fix: add references for magic values

* fix: add X86_FEATURE_LA57 reference

* fix: move x86 specific functions to x86_64Ops

* fix: extend tests and remove faulty code

* fix: only test address translation for lowmem

* fix: adjust arch_ops test to pytest

* fix: add reference for memory models in linux

* fix: do not memoize staticmethods
2023-05-01 02:48:21 +02:00
Disconnect3d 9bb0d91bec
Add pwndbg.lib.cache test (#1691) 2023-04-30 04:58:25 +02:00
Disconnect3d 0e0a293be6
New lib/cache.py: make caching great again (#1671)
* Fix and test ctx disasm when disassembly-flavor changes

* New lib/cache.py: make caching great again

This commit fixes bugs with old caching (memoize.py) and makes it more
readable.

See also https://github.com/pwndbg/pwndbg/issues/1453

* Update pwndbg/lib/cache.py

Co-authored-by: Gulshan Singh <gsingh2011@gmail.com>

* lib.cache: address PR comments and add debug mode

* Fix lint

* Remove leftover memoize usages

* Add cache benchmark

* fix lint

---------

Co-authored-by: Gulshan Singh <gsingh2011@gmail.com>
2023-04-29 16:44:23 +02:00
Gulshan Singh 89b22f4cf0
Add unit tests for which.py (#1686)
* Add unit tests for which.py

* Change ls path to /bin/ls

* Update tests.sh
2023-04-24 09:45:27 +02:00
Gulshan Singh 7720b81cc7
Fix unit tests (#1685) 2023-04-23 22:04:53 -07:00
MinimalEffort07 4fde3e898c
Issue #1667 Display OS Information In Bugreport (#1683) 2023-04-23 19:13:10 +02:00
theguy147 e1dad2e8c7
feat: make qemu-system tests more flexible (#1682) 2023-04-22 20:11:33 -07:00
theguy147 91c72a001e
feat: use pytest for qemu-system tests (#1679)
* feat: use pytest for qemu-system tests

* CI: update qemu workflow

* feat: make tests aware of ARCH and KERNEL_TYPE
2023-04-22 11:31:45 +02:00