Commit Graph

1280 Commits

Author SHA1 Message Date
alufers d812acf55a
refactor: use .format() properly for displaying vmmap rows (#1316) 2022-10-21 17:12:49 -07:00
Gulshan Singh 5a323b4967
Fix bins command (#1313) 2022-10-20 20:46:06 -07:00
alufers e8a8e737c8
Add a header to the vmmap table (#1311)
* Add a header to the vmmap table

A simple header has been added to the output of vmmap which helps new users identify the columns.

* fix: lint

* fix: failing test

Adjust the length of expected vmmaps

* fix: tests again
2022-10-21 02:58:21 +02:00
Disconnect3d c74a551a6d
lint.sh: lint only pwndbg files (#1312) 2022-10-20 17:35:29 -07:00
Disconnect3d 20417c1b06
Fix parameter default values (#1307)
* Fix parameter default values

Before this commit the created gdb.Parameter default values were not set
properly. Now, we set the object's .value field properly with the
provided default value.

* fix issue with set/show docstring

* fix lint

* fix lint

* fix lint

* fix parameter further...

* fix flake8 lint
2022-10-21 02:18:42 +02:00
Disconnect3d 9a580eaa84
Fix setting empty ctx sections (#1310)
* Increase CI timeout to 20 minutes

* Fixes: set context-sections '' and add more opts to set empty sections

The `validate_context_sections` function started to receive a string of
`"''"` after the changes in eabab31. Before those changes, it always
received an empty string (`""`).

I am not sure why this behavior changed in that commit, but the current
behavior resembles the native GDB behavior more. We can see this here on
a GDB native parameter:

```
(gdb) set exec-wrapper ''
(gdb) show exec-wrapper
The wrapper for running programs is "''".
```

And so we will keep this native behavior for our config variables for
now. But since this changed, I want to keep the old behavior of: `set
context-sections ''` working, and so this commit brings it.

Additionally, we also now allow setting empty context via multiple
values: empty string, empty quotations or double quotations and with
strings like `-` or `none`.

...and this commit comes with tests for this behavior so it will be
harder to introduce such issues anymore :)
2022-10-21 01:03:36 +02:00
Disconnect3d dd26c60e7a
Fix invalid zig path in tests makefile & suppress compilation warning (#1308) 2022-10-20 23:07:36 +02:00
Disconnect3d 6af5d7d7ed
Increase CI timeout to 20 minutes (#1309) 2022-10-20 22:45:58 +02:00
Tingfeng Yu 177df59c12
integrated Bin classes (#1304)
* added Bin classes from old PR #1063 back

* added Bin classes from pr #1063

* added more properties to Arena class

* integrated Bin classes with the malloc_chunk command

* integrated Bin classes with vis and try_free. passed all heap tests

* very small change

* fixed lint

* fixed lint

* fixed lint..

* finally fixed lint

* Delete .err.txt

Co-authored-by: Gulshan Singh <gsingh2011@gmail.com>
Co-authored-by: Tingfeng Yu <tingfeng.yu@anu.edu.au>
2022-10-20 22:38:09 +02:00
Gulshan Singh 9427727485
Update developer docs (#1303) 2022-10-20 10:15:48 -07:00
Gulshan Singh 4be16dcd5d Fix heap_config 2022-10-19 15:17:26 -07:00
Gulshan Singh 78065e8ba9 Fix config and theme commands 2022-10-19 13:18:06 -07:00
Gulshan Singh eb18b04e54 fix coverage generation 2022-10-18 15:50:21 -07:00
Gulshan Singh f0ea79575d Add unit-test for find_fake_fast command 2022-10-18 15:06:33 -07:00
Gulshan Singh 9a67233cd1 Store coverage files in .cov directory 2022-10-18 14:21:22 -07:00
Gulshan Singh c73f79340c Move .coveragerc config to pyproject.toml 2022-10-18 13:34:19 -07:00
Gulshan Singh 8a417091b5 Add mocks 2022-10-18 12:05:05 -07:00
Gulshan Singh 8eabec5541 fixed coverage uploading 2022-10-18 11:00:30 -07:00
Gulshan Singh e63d289b95 Move tests/ to tests/gdb-tests/ 2022-10-18 11:00:30 -07:00
Gulshan Singh 295fe29b22
Cleanup before unit-tests (#1293) 2022-10-18 12:21:58 +02:00
alufers 1c06c52b47
fix: make mprotect command truly multi-arch (#1162)
* fix: make mprotect command truly multi-arch

Added register saving based on reg_sets defined for each processor architecture, additionally shellcraft is used to generate the arch-specific shellcode.

Unfortunately this command is not currently tested on platforms other than x86_64.

* Update pwndbg/commands/mprotect.py

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>

* mprotect: Add parsing, alignment to the addr argument

This change makes sure that the addr argument is parsed as an gdb expression (so you can use registers for example) and aligns it to the nearest page boundary.

* mprotect: Clean up register saving, print the result

Cleaned up saving of registers and added printing of the results, as per disconnect's sugesstions.

* Simplify the test for mprotect

Simplify the code and remove the useless binary

* Update tests/test_mprotect.py

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2022-10-18 02:12:10 +02:00
Disconnect3d c50ba4612e
Pwndbg configuration: do not set history expansion (#1292)
The `set history expansion on` setting we set seems to cause troubles if users want to execute a shell command by using the exclamation mark.

I do not like it, especially taking into account the recent shell command deprecation we did.
2022-10-18 01:46:05 +02:00
Gulshan Singh dac5340b18 Add tests for find_fake_fast --align 2022-10-16 13:18:47 -07:00
Gulshan Singh 9a783c08ce Cleanup find_fake_fast 2022-10-16 13:18:47 -07:00
Gulshan Singh e6574f447f
Add find_fake_fast test (#1286)
* Fix find_fake_fast test name

* Add more find_fake_fast tests
2022-10-16 11:31:47 +02:00
CptGibbon 1a0bbbf26a
Add multithreaded malloc_chunk tests (#1277)
* Add reset_on_thread decorator

* Apply reset_on_thread to Heap.multithreaded

* Add multithreaded malloc_chunk tests

* Clarify comment in C source

* Clarify expected thread number with assert in test
2022-10-16 10:53:23 +02:00
Gulshan Singh e5e73fa654 Fix symbol resolution 2022-10-13 21:16:18 -07:00
Alan Li b4cdcdfcfc
Unit tests and some bugs fix for the heap heuristics (#1283) 2022-10-13 21:07:07 -07:00
Gulshan Singh e456b317d7 Convert all vmmap references to pwndbg.gdblib.vmmap 2022-10-13 15:23:38 -07:00
Gulshan Singh 8b6deac4fd Move vmmap.py to gdblib 2022-10-13 15:23:38 -07:00
E. Rivas b5da3e8237
Add ignore command (from #1257) (#1276)
* Add ignore command (from #1257)

* Fix lint

* Apply changes suggested by disconnect3d on ignore command

* Add tests for ignore command
2022-10-14 00:07:02 +02:00
Gulshan Singh 026f3c0164 Fix reference to pwndbg.gdblib.config 2022-10-13 15:01:16 -07:00
Lonny Wong cf11443735 add test for max-visualize-chunk-size 2022-10-13 15:01:16 -07:00
Gulshan Singh 353c906a3f Move more gdb info commands to info.py 2022-10-13 14:14:13 -07:00
Gulshan Singh f792f00081 Move example strings to comments 2022-10-13 14:14:13 -07:00
Gulshan Singh 4647ccca57 Fix windbg test 2022-10-13 09:31:35 -07:00
Gulshan Singh 2220918866 Cleanup hexdump implementation 2022-10-13 09:31:35 -07:00
Gulshan Singh 084eb36813
Add a test for config triggers (#1225)
* Split config.py into lib/ and gdblib/

* Add test for config triggers
2022-10-13 14:54:45 +02:00
Gulshan Singh eabab316d2
Split config.py into lib/ and gdblib/ (#1134) 2022-10-13 14:50:20 +02:00
Gulshan Singh 2be84a9b4d Fix some mypy errors 2022-10-13 00:46:26 -07:00
Gulshan Singh fd5e722cbc Add hexdump test 2022-10-12 20:34:51 -07:00
Lonny Wong b218f34a36
add max display size for vis_heap_chunks (#1275) 2022-10-12 16:43:52 -07:00
Alan Li fbedf0b497
Add more comments about the changes in #1273 (#1274) 2022-10-12 14:17:35 +02:00
CptGibbon fc33d6fb7c
Develop Arena class (#1266)
* Develop Arena class

* Remove TODO comments

* Replace type() with isinstance()

* Use __slots__ in Chunk & Arena classes

* Remove unnecessary append()
2022-10-12 13:01:46 +02:00
Alan Li 42caec2552
Fix the bug in the heuristic for `main_arena` and `mp_` (#1273)
* Fix the bug when searching the struct of `main_arena` and `mp_` in the memory.
2022-10-12 12:32:07 +02:00
Alan Li 75ece8e2a8
Don't catch the error of the heap commands when `set exception-* on` (#1270)
* Don't catch the error of the heap commands for developers

* Use `pwndbg.config` and re-raise the error

See https://github.com/pwndbg/pwndbg/pull/1270#discussion_r992209956

* Update pwndbg/commands/__init__.py

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2022-10-12 12:30:23 +02:00
Disconnect3d 8da9c5b9f9
Fix #1189: fixes patch command's arch=... value (#1269)
Before this commit we passed `pwndbg.gdblib.arch.current` as `arch=...`
keyword argument to pwnlib functions like `asm` and `disasm`.

Since pwnlib has a concept of "context" that holds variables like
currently set architecture or number of bits, this commit starts using
those for the `patch` command implementation as we started to set pwnlib
context recently in 9e84c18c44
2022-10-11 13:43:26 +02:00
Alan Li db3a86abb4
Fix #1271 (#1272) 2022-10-11 13:42:46 +02:00
Disconnect3d 478a569cb3
Fix #1256: fixes next cmds hangs on segfaults (#1268)
* Fix #1256: fixes next cmds hangs on segfaults

Before this commit the next/step commands like `nextret`, `stepret`,
`nextsyscall`, `nextproginstr` etc. would hang if they approach a
segfault. This commit fixes it by checking for ANY signals by executing
the GDB's `info prog` command and parsing its output.

* fix lint
2022-10-11 09:33:09 +02:00
Disconnect3d d42444274e
allow setting gdblib.regs.<reg>=<val> (#1267)
This commit allows for setting the selected thread's registers by using
the pwndbg.gdblib.regs.<register-name> = <new-value> expressions. Before
this commit invoking such Python code would set the internal Pwndbg
register value, but not really the inferior value. This could lead to
weird issues when the displayed context shows the new register value but
e.g. `info reg rax` displays the old value.
2022-10-11 08:08:31 +02:00