-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* beta: Merge dev to beta (#506) Better exception msg (#300) handle window resize event and set width accordingly (#291) Remove pwndbg/linkmap.py and malloc.py (#303) Fix got command (#306) Fire isort so travis won't complain (#302) extend next_call to take optional symbol/target to break on (#290) got command: possibility to filter results (#284) ROPGadget: return when not installed (#283) Fix parsed commands (#282) added command 'got' to display status of the GOT table (#256) Clean up some unnecessary closures in pwndbg.commands (#278) Fix missing exception in pwndbg/exception.py (#277) Fix input issue after screen resize: pagination off (#276) Simplify command exception debugging and make stdio work correctly (#251) Add Command.repeat property for repeated commands (#272) support for multiple arenas (#262) Fix Python2 long types and inthook (#250) fixed GDB remote get command (#241) Add CONTRIBUTING and ISSUE_TEMPLATE (#238)
- Loading branch information
Showing
122 changed files
with
4,207 additions
and
2,830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Contributing | ||
|
||
Contributions to Pwndbg are always welcome! If you want to get more familiar with project idea/structure/whatever - [here are some developer notes](./DEVELOPING.md). If something is not clear, feel free to ask in a github issue! | ||
|
||
If you want to help, fork the project, hack your changes and create a pull request. | ||
|
||
If this is something big/new feature or a bug, consider creating an issue first. | ||
|
||
|
||
Some guides: | ||
* [Fork a project](https://help.github.com/articles/fork-a-repo/) | ||
* [Pull requests](https://help.github.com/articles/about-pull-requests/) | ||
|
||
### Versioning and releases | ||
|
||
* There are three branches: `stable`, `beta` and `dev` | ||
* Each developer works on his own fork | ||
* Only bug-fixes will be merged into either `stable` or `beta` | ||
* Every release, merges are cascaded `stable -> beta -> dev` | ||
* After merging, a new minor-point-release (`1.X`) is created for `stable` | ||
* Releases occur on predetermined schedule | ||
* Bugs _are not fixed_ on releases older than the current `stable` (i.e. `0.9` is never fixed) | ||
* Mid-cycle releases get a patch version bump (`1.1.X`) when bugs affecting `stable` or `beta` are found | ||
* Pull requests which fix bugs target the oldest branch they affect (e.g. `stable`). | ||
* There might be occassional cherry-picks if something is fixed in a later branch and we don't notice/forget that it should really target an earlier branch. | ||
* Documentation fixes, travis fixes, CHANGELOG/README fixes and other tiny fixes does not trigger a new point release. | ||
|
||
### Contact | ||
|
||
If you want to talk with other contributors and pwndbg users | ||
join us at our irc channel: #pwndbg at freenode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
Before reporting a new issue, make sure that we do not have any duplicates already open. | ||
If there is one it might be good to take part in the discussion there. | ||
Please make sure you have checked that the issue persists on LATEST pwndbg version. | ||
Below is a template for BUG REPORTS. | ||
Don't include it if this is a FEATURE REQUEST. | ||
--> | ||
|
||
|
||
### Description | ||
|
||
<!-- | ||
Briefly describe the problem you are having in a few paragraphs. | ||
--> | ||
|
||
### Steps to reproduce | ||
|
||
<!-- | ||
What do we have to do to reproduce the problem? | ||
If this is connected to particular C/asm code, | ||
please provide the smallest C code that reproduces the issue. | ||
--> | ||
|
||
### My setup | ||
|
||
<!-- | ||
Show us your gdb/python/pwndbg/OS/IDA Pro version (depending on your case). | ||
NOTE: We are currently supporting only Ubuntu installations. | ||
It is known that pwndbg is not fully working e.g. on Arch Linux (the heap stuff is not working there). | ||
If you would like to change this situation - help us improving pwndbg and supporting other distros! | ||
This can be displayed in pwndbg through `version` command. | ||
If it is somehow unavailable, use: | ||
* `show version` - for gdb | ||
* `py import sys; print(sys.version)` - for python | ||
* pwndbg version/git commit id | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Random developer notes | ||
|
||
Feel free to update the list below! | ||
|
||
* If you want to play with pwndbg functions under GDB, you can always use GDB's `pi` which launches python interpreter or just `py <some python line>`. | ||
|
||
* If there is possibility, don't use `gdb.execute` as this requires us to parse the string and so on; there are some cases in which there is no other choice. Most of the time we try to wrap GDB's API to our own/easier API. | ||
|
||
* We have our own `pwndbg.config.Parameter` (which extends `gdb.Parameter`) - all of our parameters can be seen using `config` or `theme` commands. If we want to do something when user changes config/theme - we can do it defining a function and decorating it with `pwndbg.config.Trigger`. | ||
|
||
* The dashboard/display/context we are displaying is done by `pwndbg/commands/context.py` which is invoked through GDB's prompt hook (which we defined in `pwndbg/prompt.py` as `prompt_hook_on_stop`). | ||
|
||
* All commands should be defined in `pwndbg/commands` - most of them lie in seperate files but some files contains many of them (e.g. commands corresponding to windbg debugger - in `windbg.py` or some misc commands in `misc.py`). We would also want to make all of them to use `ArgparsedCommand` (instead of `Command` or `ParsedCommand` decorators). | ||
|
||
* We change a bit GDB settings - this can be seen in `pwndbg/__init__.py` - there are also imports for all pwndbg submodules | ||
|
||
* We have a wrapper for GDB's events in `pwndbg/events.py` - thx to that we can e.g. invoke something based upon some event | ||
|
||
* We have a caching mechanism (["memoization"](https://en.wikipedia.org/wiki/Memoization)) which we use through Python's decorators - those are defined in `pwndbg/memoize.py` - just check its usages | ||
|
||
* To block a function before the first prompt was displayed use the `pwndbg.decorators.only_after_first_prompt` decorator. | ||
|
||
* Memory accesses should be done through `pwndbg/memory.py` functions | ||
|
||
* Process properties can be retrieved thx to `pwndbg/proc.py` - e.g. using `pwndbg.proc.pid` will give us current process pid | ||
|
||
* We have an inthook to make it easier to work with Python 2 and gdb.Value objects - see the docstring in `pwndbg/inthook.py` . Specifically, it makes it so that you can call `int()` on a `gdb.Value` instance and get what you want. | ||
|
||
* We have a wrapper for handling exceptions that are thrown by commands - defined in `pwndbg/exception.py` - current approach seems to work fine - by using `set exception-verbose on` - we get a stacktrace. If we want to debug stuff we can always do `set exception-debugger on`. | ||
|
||
* Some of pwndbg's functionality - e.g. memory fetching - require us to have an instance of proper `gdb.Type` - the problem with that is that there is no way to define our own types - we have to ask gdb if it detected particular type in this particular binary (that sucks). We do it in `pwndbg/typeinfo.py` and it works most of the time. The known bug with that is that it might not work properly for Golang binaries compiled with debugging symbols. | ||
|
||
* We would like to add proper tests for pwndbg - see tests framework PR if you want to help on that. | ||
|
||
# Testing | ||
|
||
Our tests are written using [pytest](https://docs.pytest.org/en/latest/). It uses some magic so that Python's `assert` can be used for asserting things in tests and it injects dependencies which are called fixtures, into test functions. | ||
|
||
The fixtures should be defined in [tests/conftest.py](tests/conftest.py). If you need help with writing tests, feel free to reach out on gitub issues/pr or on our irc channel on freenode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,3 @@ python-ptrace>=0.8 | |
six | ||
future | ||
unicorn>=1.0.0 | ||
capstone |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test | ||
stats | ||
stats.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# Benchmark context command | ||
make test > /dev/null | ||
git log --abbrev-commit --pretty=oneline HEAD^..HEAD | ||
gdb ./test \ | ||
-ex "source ../gdbinit.py" \ | ||
-ex "b main" -ex "r" \ | ||
-ex "python import timeit; print(' 1ST RUN:', timeit.repeat('pwndbg.commands.context.context()', repeat=1, number=1, globals=globals())[0])" \ | ||
-ex "si" \ | ||
-ex "python import timeit; print(' 2ND RUN:', timeit.repeat('pwndbg.commands.context.context()', repeat=1, number=1, globals=globals())[0])" \ | ||
-ex "si" \ | ||
-ex "python import timeit; print('MULTIPLE RUNS:', timeit.repeat('pwndbg.commands.context.context()', repeat=1, number=10, globals=globals())[0] / 10)" \ | ||
-ex "quit" | grep 'RUNS*:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# Quick and dirty script to profile pwndbg using cProfile. | ||
make test > /dev/null | ||
git log --abbrev-commit --pretty=oneline HEAD^..HEAD | ||
# To profile first run, remove -ex "context". | ||
gdb ./test \ | ||
-ex "source ../gdbinit.py" \ | ||
-ex "b main" -ex "r" \ | ||
-ex "context" \ | ||
-ex "python import cProfile; cProfile.run('pwndbg.commands.context.context()', 'stats')" \ | ||
-ex "quit" | ||
|
||
python3 -c " | ||
import pstats | ||
p = pstats.Stats('stats') | ||
p.strip_dirs().sort_stats('tottime').print_stats(20) | ||
" | ||
[ -x /usr/local/bin/pyprof2calltree ] && command -v kcachegrind >/dev/null 2>&1 && /usr/local/bin/pyprof2calltree -k -i stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int main() { | ||
while(1); | ||
} |
Oops, something went wrong.