Commit Graph

1154 Commits

Author SHA1 Message Date
disconnect3d cf2c3eede8 bump version 2022-08-30 04:39:27 +02:00
Disconnect3d d4850beecc
fix #1098: dX cmds trunc out on x86 binaries (#1104)
* fix #1098: dX cmds trunc out on x86 binaries

* fix black
2022-08-30 04:06:41 +02:00
Gulshan Singh 1df714d700
Fix PEP8 violations and add flake8 to CI (#1102)
* Add flake8 config to setup.cfg

* Fix W291 PEP8 warnings

* Fix W605 PEP8 warnings

* Fix E711 PEP8 error

* Fix E713 PEP8 errors

* Fix E262 PEP8 errors

* Fix E714 PEP8 error

* Fix E712 PEP8 errors

* Add flake8 to CI
2022-08-30 03:19:30 +02:00
Disconnect3d b3a560eff0
black all da code (#1103) 2022-08-30 02:53:00 +02:00
Gulshan Singh d8b589d823
Add black to CI (#1101)
* Add black to CI

* Rename linter step
2022-08-30 02:34:34 +02:00
disconnect3d 015888684b Fix test_vis_heap_chunk_command on Ubuntu 18.04 2022-08-30 02:20:09 +02:00
disconnect3d 697c32e84b Move pytest to dev-requirements 2022-08-28 23:12:00 +02:00
Gulshan Singh 2bde0cc1d8
Update CI to test 18.04, 20.04, and 22.04 (#1100)
* Fix requirements.txt for Python 3.6

* Install coverage from setup-test-tools.sh

* Update CI to test Ubuntu 18.04, 20.04, and 22.04
2022-08-28 23:11:16 +02:00
Gulshan Singh 7c53bdeaa8
Minor test cleanup (#1099)
* Silence nonnull warning when building heap_vis.c

* Fix checking ptrace_scope in test_attachp.py

* Fix .gitignore

* tests.sh cleanup

* Fixed coverage generation
2022-08-25 16:57:16 +02:00
NT Sleep 5d358585b1
Add support for telescope to show previous addresses #1047 (#1094)
* Added -r argument to telescope command (#1047)

* Added tests for telescope command (#1047)
2022-08-24 00:31:20 +02:00
Disconnect3d 890e314f2f
tests.sh: add [filter] and --pdb (#1092) 2022-08-24 00:05:57 +02:00
alufers c0b3f88f53
Fix zig not being installed when installed system-wide (#1093) 2022-08-24 00:05:43 +02:00
Disconnect3d e8109b98c1
Remove QuietSloppyParsedCommand once and for all (#1091)
This commit cleans up the commands/__init__.py a bit by removing the
`QuietSloppyParsedCommand` that we do not use anymore.

The last command that used it was `brva` which was just an alias for
`breakrva`, so now we just set it as an alias using the
`ArgparsedCommand` as it should be done.
2022-08-23 23:06:39 +02:00
Artur Czepiel 4ee225b115
Make ZIGPATH configurable and provide defaults (#1090)
* Make ZIGPATH configurable and provide defaults

Mostly fixes docker/docker-compose environment where building zig into
$pwd/.zig doesn't work well because it is later overwritten by mounting
the volume in /pwndbg.

With current approach during the docker build zig is put in /opt/zig
instead, and when you run it without docker it's possible to configure a
different path (with sane defaults)

* remove Makefile

* add ZIGPATH to tests.sh for CI

* move ZIGPATH setting before make in tests
2022-08-23 23:02:12 +02:00
alufers 36ee7d238d
tools: change zig to install from a tarball (fixes: #1085) (#1089)
* tools: change zig to install from a tarball

Migrate from using snap, we install from a cheksumed tarball

* fix: add sudo

* fix: install zig to .zig in PWD

Co-authored-by: Albert Koczy <albert.koczy@asseco.pl>
2022-08-23 21:43:17 +02:00
Disconnect3d d111c8ddcf
Fix heap test binaries build (#1087)
* Fix heap test binaries build

* Compile some heap test binaries with zig cc
2022-08-23 03:53:51 +02:00
Disconnect3d 546d6ffa19
fix vis_heap_chunk test on CI? (#1086)
* fix vis_heap_chunk test on CI?

* add libc6-dev for tests/CI for vis_heap_chunk test

* fix heap_vis.out build
2022-08-23 02:48:27 +02:00
disconnect3d 902d732816 add vis_heap_chunk testcase 2022-08-23 01:55:50 +02:00
Disconnect3d b51b07de77
Revert "Refactor heap code (#1063)" (#1084)
This reverts commit a0f3744743.
2022-08-22 22:38:05 +02:00
Gulshan Singh a0f3744743
Refactor heap code (#1063)
* Add Bins classes and refactor allocator methods to return them

* Refactor bins() and related commands

* Refactor malloc_chunk

* Use chunk_size_nomask in top_chunk()

* Refactor vis_heap_chunks

* Rename read_chunk to read_chunk_from_gdb and move to ptmalloc.py

* Add get_first_chunk_in_heap and use it in heap and vis_heap_chunks commands

* Move some methods from DebugSymsHeap to Heap base class

* Strip type hints from heap.py and ptmalloc.py

* Set heap_region before using it

* Fix test_heap_bins test

* Fix try_free
2022-08-22 14:39:55 +02:00
Gulshan Singh 8cb3d807c5
Fix test runner script for parallel make builds (#1083) 2022-08-22 14:37:46 +02:00
disconnect3d e7b4515e46 fix vmmap for qemu user targets 2022-08-20 23:38:02 +02:00
Arusekk 023a1c19b7
Avoid bare catch-all except blocks (#1080)
This was done with:

    grep -rl 'except:' | xargs sed -i 's/except:/except Exception:/'

Not tested, but I believe this could be useful.
2022-08-20 23:22:43 +02:00
Disconnect3d c10c8f840b
Fix coredump debugging (#1079)
* Fix coredump debugging

This commit fixes our headaches with core files debugging.

The TL;DR is that we will now try to parse `info proc mappings` and
`maintenance info sections` to give users best possible UX/vmmaps
information.

Related:
* https://sourceware.org/bugzilla/show_bug.cgi?id=29508
* https://github.com/pwndbg/pwndbg/issues/985
* https://github.com/pwndbg/pwndbg/issues/954

* cleanup

* cleanup

* Fix core dbg when EHDR map is not mapped
2022-08-20 22:35:45 +02:00
Disconnect3d a00ba56872
small refactor of vmmap module (#1078) 2022-08-20 01:46:56 +02:00
Disconnect3d 51bc5e2245
Fixes #1068 2022-08-18 00:46:01 +02:00
Disconnect3d 87114367c1
Revert "Remove shell commands registration (#1064)" (#1073)
This reverts commit 06cc17b6b4.
2022-08-18 00:37:14 +02:00
Takumi Akiyama 19d59d521f
Replace with IDA 7.x API (#1024)
* Replace with IDA 7.x API

* Drop support for IDA 6.x to clean up code

* Disable logging to speed up IDA integration
2022-08-17 23:10:58 +02:00
Disconnect3d 6dd25c3617
Improve search --next speed and add --trunc-out flag (#1066)
This commit improves the `search --next ...` speed by making it so that
only the saved addresses are checked. Previously, the command performed
a full search even in the presence of `--next` flag and only afterwards
filtered the results. That resulted in extremely slow execution e.g.
when debugging processes with gigabytes of allocated memory.

The commit also adds a `--trunc-out` argument which makes it so that
only 20 results are displayed. This is helpful when performing a
CheatEngine-style search when we try to locate a given field/value
address in memory by first finding its known value, then changing its
value in the program and then re-searching the space.

The `--trunc-out` argument could further be improved by enabling it
default and making users aware that the results were truncated.
2022-08-17 22:59:41 +02:00
Disconnect3d 06cc17b6b4
Remove shell commands registration (#1064)
This PR removes ~40 commands that could be used to run shell programs.

I am removing this since GDB has the support for running shell programs
with either `shell <command...>` or `<!command...>` and so we do not
need this feature in Pwndbg anymore.

This feature also bloated Pwndbg a little bit and made more interesting
commands harder to find e.g. through the `pwndbg` command.
2022-08-14 23:32:10 +02:00
Lukasz Taczuk d99e15985c
Adds documentation for debugging with PyCharm (#1058) 2022-08-14 22:34:36 +02:00
Alan Li 2c15d03899
Add support to use heap commands without debug symbols (#1029)
* Add support to use heap commands without debug symbols

* Fix a possible bugs when getting heap boundaries via heuristic

See https://github.com/pwndbg/pwndbg/pull/1029#issuecomment-1189841299

* Fix typo causing issues in `c_malloc_par_2_25`

See https://github.com/pwndbg/pwndbg/pull/1029#issuecomment-1189841299

* Fix a bug for `tcache_perthread_struct` and refactor some codes in `structs.py`

* The bug: `tcache_perthread_struct` for GLIBC < 2.30 is using `char` instead of `uint16_t` for `counts` field

* Fix some bugs about handling `thread_arena` and `tcache` with multithreaded

* Re-initialize the heap when the process stop or the file changed

By doing this, we can attach to another architecture in GDB without any bugs.

* Add guard code for unsupported architectures

* Support heuristic for arm and aarch64

Note: thread_arena and thread_cache for arm still can not work

* Update .pylintrc

* Ignore `import-error` error for `import gdb`
* Ignore `no-member` error for `pwndbg.typeinfo.*`, because most of its members are dynamically generated.
* Ignore `protected-access` warning for `_fields_`, `_type_`, `_length_`, because ctypes don't have other ways to access them.

* Refactor some code and comment to fit pep8 and lint check

* Add a feature to enable users set symbol addresses manually

For example, by using `set main_arena 0xdeadbeaf`, pwndbg will try to find main_arena at 0xdeadbeaf when using heuristic

* Use `__errno_location` to find TLS base for arm

By doing this, we can get `thread_arena` and `tcache` address

* Block other thread before `__errno_location()`

* Fix a bug for arm32 and a typo-caused bug

* Some wrong field names inside `c_heap_info` may cause some bugs in the future if we want to access it

* `pad` size of `heap_info` for arm32 is 0 byte, only i386 is 8 bytes, so I fixed it in a hard-coded way temporary

* Fix #1044 related issues

* Refactor the code about heap related config

* Use `int(address_str, 0)` to auto determine the format (https://github.com/pwndbg/pwndbg/pull/1029#discussion_r939569382)

* Use `OnlyWithResolvedHeapSyms` instead of `OnlyWithLibcDebugSyms` (https://github.com/pwndbg/pwndbg/pull/1029#discussion_r939568687)

* Use `resolve-heap-via-heuristic` instead of `resolve-via-heuristic` (https://github.com/pwndbg/pwndbg/pull/1029#discussion_r939569076)

* Update the description of `resolve-heap-via-heuristic` config (https://github.com/pwndbg/pwndbg/pull/1029#discussion_r939569069)

* Move heap related config into `heap` scope, and add a new command, `heap_config`, to show the config in that scope (https://github.com/pwndbg/pwndbg/pull/1029#discussion_r939569260)

* Refactor code about the config of heap related symbols

* Fix the logic when thread_arena is not found

* Use errno trick as a fallback for i386 and x86-64

* Update pwndbg/heap/ptmalloc.py

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2022-08-14 22:33:52 +02:00
Artur Czepiel a4eb1e6610
Fix xor and memfrob (#1057)
* added basic xor and memfrob tests

* refactor xor and memforb + add more tests
2022-08-11 12:15:12 +02:00
Artur Cygan f2e5c98f23
Fix context args crash on missing instruction (#1055) 2022-08-11 00:00:48 +02:00
Gulshan Singh 214f993047
Add tip about $heap_base to tips.py (#1053) 2022-08-10 23:57:20 +02:00
Artur Cygan b27a59729f
Fix aarch64 regs display (#1054) 2022-08-10 23:11:19 +02:00
Lonny Wong 23b5ab0380
fix context showing unexpectedly on first command (#1042) 2022-08-10 22:53:51 +02:00
Gulshan Singh 9f5c514d3f
Add $heap_base variable after running the heap command (#1051) 2022-08-10 22:47:52 +02:00
Janusz Kamieński 4a7f9ada3d
Remove Python 2 legacy code (#1052)
* remove py2 coding notations from files

* remove six package use and replace with proper py3 code

* remove py2 futures use

* replace unicode string literals with string literals

* remove python2 urlparse import in favor of python3 urllib.parse

* keep ida_script in py2 version

* remove hashbang python lines as the files are never ran directly
2022-08-10 22:47:09 +02:00
egoism 5e78222d50
nearpc: convert pc to pointer (#1048)
* nearpc: convert pc to pointer

* misc: soothe isort
2022-08-08 15:59:22 +02:00
Disconnect3d e867d1db0c
colorful tip of the day & more tips (#1046) 2022-08-06 23:22:15 +02:00
disconnect3d ee6e9f7526 Merge branch 'dev' of github.com:pwndbg/pwndbg into dev
* 'dev' of github.com:pwndbg/pwndbg:
  Aarch64 regs: add X30
2022-08-06 22:30:42 +02:00
disconnect3d a9b4aa205c tips: add a tip about command 2022-08-06 22:29:41 +02:00
disconnect3d 3d7d2bed4f tips: add a tip about `vmmap` 2022-08-06 22:27:14 +02:00
disconnect3d dbdda35c94 tips: add a tip about Pwndbg instruction emulation for better ctx display 2022-08-06 22:26:17 +02:00
disconnect3d efeb90579d tips: add a tip about context display 2022-08-06 22:24:03 +02:00
disconnect3d 26d90e8f97 tips: inform about the `procinfo` command 2022-08-06 22:20:44 +02:00
disconnect3d 5b7202ed2f tips: inform about the `canary` command 2022-08-06 22:19:30 +02:00
disconnect3d a66b95e7d2 tips: add tip about how we resolve kernel memory maps 2022-08-06 22:14:56 +02:00
Disconnect3d d2b2523695
Aarch64 regs: add X30
Add missing X30 register to the aarch64 register set.

Note that we do not list X29 because it is the SP (stack frame pointer)
2022-08-06 22:09:48 +02:00