Commit Graph

44 Commits

Author SHA1 Message Date
patryk4815 620f38008c
fix nix + charset + bump dependencies (#2355)
* fix charset issues

* use '.skip-venv' in nix'ed pwndbg

* bump nix & python dependencies, gdb15.1, python3.12.4
2024-08-14 00:19:23 +02:00
OBarronCS b74fcdde97
use os._exit() (#2295) 2024-07-08 20:55:57 +02:00
Gulshan Singh 95dd553ab7
Start migrating to Python logging and add log_level command (#2230)
* Start migrating to Python logging and add log_level command

* Add debug log messages to gdbinit.py
2024-06-28 13:37:53 -07:00
Gulshan Singh dc9c87254a
Exit with non-zero code from gdbinit.py if an exception occurs (#2242)
* Exit with non-zero code from gdbinit.py if an exception occurs

* Update gdbinit.py

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2024-06-25 01:46:01 +02:00
Matt 7dbc5472d8
Move GDB initialization and basic startup functionality to a new Debugger-agnostic API (#2243) 2024-06-21 19:58:29 -07:00
Gulshan Singh f21000356f
More gdbinit cleanup (#2246)
* Move global gdbinit.py initialization to main function

* Disable pagination on venv updates
2024-06-20 18:39:57 -07:00
Gulshan Singh 6cb96632a4
Cleanup gdbinit.py (#2239) 2024-06-19 22:25:55 -07:00
卂フ卂ㄚ Ҝㄖ卩卩卂Ҝ卂 a1c4bb47e7
Using full PATH length to install poetry (#2238)
Co-authored-by: B1N4RY-P4R45173 <kopakaajay123@gmail.com>
Co-authored-by: Gulshan Singh <gsingh2011@gmail.com>
2024-06-19 13:36:32 -07:00
卂フ卂ㄚ Ҝㄖ卩卩卂Ҝ卂 180102bf17
Auto-update dependencies after a git pull (#2203)
* Added a file to mark dev installation and also modified gdbinit.py to calculate and verify the hash of poetry.lock

---------

Co-authored-by: B1N4RY-P4R45173 <kopakaajay123@gmail.com>
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2024-06-16 03:47:16 -07:00
Disconnect3d adee7ba896
Hopefully fix UTF-8/unicode issues once and for all (#2139)
Note that `set charset UTF-8` in GDB requires a GDB compiled with
`libiconv` but I doubt we ever support such GDB in Pwndbg now or in the
past.
2024-04-28 21:57:48 +02:00
jetchirag ebcff7cd59
WIP: Fix Flake8 warnings (#2101)
* Fix F811

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>

* A003 doesn't flag anymore, rule was changed

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>

* W505

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>

* Revert "W505"

This reverts commit 2494a34c20.

* Revert "A003 doesn't flag anymore, rule was changed"

This reverts commit d342ac7aae.

* Removed a commented line

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>

* Mistakenly modified another variable

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>

* Replace not None assertion to not empty string

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>

---------

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com>
2024-04-12 14:55:50 +02:00
Disconnect3d c4b71af356
Typing fixes (#1970)
* FIX: updating type hints batch 1

* FIX: linter errors

* FIX: more type hints update

* FIX: more type hints update

* FIX: more type hints update

* FIX: more type hints update

* FIX: more type hints update

* FIX: revert gdb.execute fixes

* FIX: revert return pid

* FIX: revert gdb.execute fixes

* FIX: fixing suggestions

* FIX: reverting type changes

* FIX: reverting some logic changes that I did

* FIX: minor fixes

* FIX: more reverts

* FIX: revert logic fix

* FIX: revert logic fix

* FIX: revert changes

* FIX: temporarily silent the mypy error exit status

* Update proc.py

* Update config.py

Removing a redundant self.triggers key setting since its a defaultdict!

* Update lint.sh

* Fix some mypy lint issues

* fix mypy lints

* fix mypy lints

* fix mypy lints

* fix mypy lints

* fix mypy lint

* Fix mypy lint

* fix mypy lints

* fix mypy lint

* ignore mypy lint

* ignore mypy lint

* typing fixes

* reformat

---------

Co-authored-by: HackSys Team <ashfaq_ansari1989@hotmail.com>
2024-01-02 19:17:09 +01:00
Levente Polyak 139b7542cd fix: allow site installation without enforcing a venv
Currently the only way to circumvent the venv checks is setting an
environment variable. However, this is not sufficient for distro site
packaging:
- if the variable is not set, its a rather bad and unexpected user
  experience to somehow magically set PWNDBG_PLEASE_SKIP_VENV
- if the variable is set globally as login shell profile, this means
  skipping venv is always enforced which means if gdb is loaded with a
  pwndbg gdbinit.py from a git clone, its rather unexpected to skip the
  venv

This patch checks for a `.skip-venv` file alongside the `gdbinit.py`
which means for site installations that use de-vendored dependencies
like during distro packaging, this file can simply be touched. It would
skip the venv when pwndbg is loaded from the site installation but at
the same time would not skip loading the venv when pwndbg is started
from a git clone.
2023-11-25 11:59:14 +01:00
psondej ab96e1a9b9 - remove gdb-pt-dump from all files
- remove submodules from all files
- bump flake.lock
- add gdb-pt-dump as dependency
- fix building Dockerfile
- fix gdb-pt-dump was broken on portable packages
2023-11-02 03:10:36 +01:00
FalcoGer 5e5f911b9c Fixes #1870
Puts virtualenv site-packages in front of locally installed user packages
2023-08-16 23:11:29 +02:00
Patryk Sondej f3914e2696 init add portable pwndbg using nix, package for rpm,deb,arch,alpine
Signed-off-by: Patryk Sondej <patryk.sondej@gmail.com>
2023-08-06 16:16:53 +02:00
Disconnect3d 9e9f328ccc
Update code to Python >= 3.8 (#1840)
* isort: import __future__ annotations & pyupgrade to 3.8

* dev-requirements.txt: update vermin to 1.5.2 & dont use --quiet

* pyupgrade 3.8 fixes

* fixes

* update vermin to 3.8-
2023-07-26 02:08:39 +02:00
intrigus-lgtm f7cb2f9cb9
Bringt back Archlinux CI. Fixes #1772, closes #1783 (#1800)
* Only run arch for testing

* Remove outdated arch repo

* Actually build the docker image

* Do not include site packages in sys.path

* Ignore `.relr.dyn` section; skip lines w/o spaces

Newer binaries can contain a `.relr.dyn` section to compress `R_X86_64_RELATIVE` relocation entries.
These binaries can be found for example on archlinux but also on Debian 12 for example.
`readelf` prints the content of the section similarly to this:
```
Relocation section '.relr.dyn' at offset 0x25220 contains 35 entries:
  1198 offsets
00000000001ce8d0
00000000001ce8e0
```
Compared to `00000000001d2000  0000000000000025 R_X86_64_IRELATIVE                        9f330` for
`.rela.plt`.

Pwndbg now chokes on the new format because it expects a space seperator where there is none.
It might be, that this is actually an upstream problem with binutils, because llvm-readelf prints this:
```
Relocation section '.relr.dyn' at offset 0x25220 contains 1198 entries:
    Offset             Info             Type               Symbol's Value  Symbol's Name
00000000001ce8d0  0000000000000008 R_X86_64_RELATIVE
00000000001ce8e0  0000000000000008 R_X86_64_RELATIVE
```

Nevertheless, we aren't actually interested in `R_X86_64_RELATIVE` relocations so I guess it's fine to
just skip all lines that contain no spaces at all.

`.relr.dyn` can only containt `R_X86_64_RELATIVE` relocations as far as I understand
https://maskray.me/blog/2021-10-30-relative-relocations-and-relr

* Accept Full RELRO in test

Archlinux has libc and ld with Full RELRO.
We now just accept Partial and Full RELRO.

* Do not copy binaries from host to docker

The `Dockerfile` copies the whole pwndbg folder to the image.
If we have built binaries on the host before, these binaries will contain references to
the host system and *copied*  to the image.
If we now run `context code` (inside docker) to have a look at the source code this will
fail, because we will try to refer to a path on the host system.

* Do not use loop index after loop

Do not use loop index after the loop. The tests assumed that the loop in line 186
would run at least once, thereby *resetting* `i` to zero. If we never enter the
loop, `i` will *continue* to have the value it had at the end of line 172.
This will cause the test to fail in mysterious ways because `i` is now not reset
to zero but still has the value `31` for example.

The solution is to never use `i` outside of a loop.

* Re-enable archlinux and temporarily disabled ones
2023-07-16 21:51:41 +02:00
Disconnect3d 976363a3d8
Setup.sh use virtualenv (#1780)
* Change setup.sh to create & use Python virtualenv

The `setup.sh` script now creates a `.venv` directory during execution and installs all dependencies into that directory. Then, `gdbinit.py` will adds the proper `site-packages` directory as the first item of `sys.path`.

Fixes #1634.
2023-07-05 13:11:59 +02:00
Gulshan Singh a3b66dae5b
Convert format strings to f-strings (#1738) 2023-05-24 04:33:24 -07:00
Gulshan Singh 37376c8ac7
Covert printf format strings to f-strings (#1735) 2023-05-24 03:47:56 -07:00
Disconnect3d ee832c80d2
Fix plt and gotplt commands (#1576)
* Fix plt and gotplt commands

* Add plt gotplt commands tests

* Fix got and plt commands and test them

* Revert accidental change

* Extend system path

* Hopefully fix PATH problems once and for all?

* fix import

* remove redundant part
2023-02-20 18:49:44 +01:00
Disconnect3d 606ad31300
gdbinit.py: fix message when locales are wrong (#1573)
* gdbinit.py: fix message when locales are wrong

Apparently the suggested solution is not great:

```
nix@33843c903468:~$ locale -a
C
C.UTF-8
POSIX
en_US.utf8
nix@33843c903468:~$ LC_ALL=en_US.UTF-8 PYTHONIOENCODING=UTF-8 pwndbg
/nix/store/qqa28hmysc23yy081d178jfd9a1yk8aw-bash-5.2-p15/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
******
Your encoding (ANSI_X3.4-1968) is different than UTF-8. pwndbg might not work properly.
You might try launching gdb with:
    LC_ALL=en_US.UTF-8 PYTHONIOENCODING=UTF-8 gdb
Make sure that en_US.UTF-8 is activated in /etc/locale.gen and you called locale-gen
******
pwndbg: loaded 164 pwndbg commands and 42 shell commands. Type pwndbg [--shell | --all] [filter] for a list.
pwndbg: created $rebase, $ida gdb functions (can be used with print/break)
Traceback (most recent call last):
  File "/nix/store/x2yncb885vd33dgigwfwc6qamjxs4d7h-pwndbg-2022.12.19/share/pwndbg/gdbinit.py", line 84, in <module>
    import pwndbg  # noqa: F401
  File "/nix/store/x2yncb885vd33dgigwfwc6qamjxs4d7h-pwndbg-2022.12.19/share/pwndbg/pwndbg/__init__.py", line 113, in <module>
    config_mod.init_params()
  File "/nix/store/x2yncb885vd33dgigwfwc6qamjxs4d7h-pwndbg-2022.12.19/share/pwndbg/pwndbg/gdblib/config.py", line 114, in init_params
    Parameter(p)
  File "/nix/store/x2yncb885vd33dgigwfwc6qamjxs4d7h-pwndbg-2022.12.19/share/pwndbg/pwndbg/gdblib/config.py", line 46, in __init__
    self.value = param.value
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
------- tip of the day (disable with set show-tips off) -------
Use the procinfo command for better process introspection (than the GDB's info proc command)
pwndbg>

quit
nix@33843c903468:~$ LC_ALL=C.UTF-8 PYTHONIOENCODING=UTF-8 pwndbg
pwndbg: loaded 164 pwndbg commands and 42 shell commands. Type pwndbg [--shell | --all] [filter] for a list.
pwndbg: created $rebase, $ida gdb functions (can be used with print/break)
------- tip of the day (disable with set show-tips off) -------
Want to display each context panel in a separate tmux window? See https://github.com/pwndbg/pwndbg/blob/dev/FEATURES.md#splitting--layouting-context
pwndbg>

quit
nix@33843c903468:~$ LC_ALL=C.UTF-8 pwndbg
pwndbg: loaded 164 pwndbg commands and 42 shell commands. Type pwndbg [--shell | --all] [filter] for a list.
pwndbg: created $rebase, $ida gdb functions (can be used with print/break)
------- tip of the day (disable with set show-tips off) -------
Use the telescope command to dereference a given address/pointer multiple times (if the dereferenced value is a valid ptr; see config telescope to configure its behavior)
pwndbg>

quit
```

* fix lint
2023-02-09 00:51:28 +01:00
Disconnect3d b39c63bb19
gdbinit.py: improve virtualenv detection and warnings (#1489) 2023-01-03 00:31:31 -08: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
Disconnect3d 446f5d5ae2
add patch command (#1150)
* add patch command

This commit adds the `patch`, `patch_list` and `patch_revert` commands
and adds the `pwntools==4.8.0` as Pwndbg dependency.

The current implementation could be further improved by:
- adding tests :)
- maybe moving `patch_list` and `patch_revert` to `patch --list` and
  `patch --revert` flags?
- better handling of incorrect args/pwnlib exceptions

* lint
2022-09-20 00:30:45 +02:00
Gulshan Singh ccc56b9a58
Remove unused imports (#1139) 2022-09-09 04:56:26 +02:00
Gulshan Singh 544ea0eab7
Linting/formatting improvements (#1138)
* Fix flake8 F403 warnings

* Fix more flake8 errors and warnings

* Run isort on the root directory
2022-09-09 04:46:46 +02:00
Disconnect3d b3a560eff0
black all da code (#1103) 2022-08-30 02:53:00 +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
Your Name f8860ec936 fix path 2022-07-28 04:10:07 +02:00
disconnect3d 34f6cb2800 Make virtualenv warning more robust 2022-07-16 09:25:15 -07:00
Wiktor f21d568576 [#1035] Use virtualenv when available 2022-07-16 17:00:26 +01:00
Disconnect3d 301012abf2
Py3k (#817)
* Py3k

* Dont run py2 on CI

* Don't launch futurize on CI

* Move to latest isort options

* Modernize imports (isort>=5)

* Fix removed jump dir
2020-08-15 21:27:47 +02:00
Zach Riggle efe6c8b148 Sort inputs 2017-02-10 14:38:27 -05:00
Disconnect3d 94bc5910d9 Add check for UTF-8 encoding (#131) (#135)
Also moved workaround from #117 to common place - gdbinit.py
2016-11-18 09:43:33 -08:00
Zach Riggle eae961289c Add shebang and encoding to each file 2016-09-12 19:35:46 -07:00
Zach Riggle 373272aecd sixize 2016-06-14 12:32:22 -07:00
Zach Riggle d97847b872 Add isort, config, and pre-CI hook 2016-06-14 12:31:56 -07:00
Zach Riggle d13b9e85ce Add print_function to everything 2016-05-06 19:26:42 -07:00
Zach Riggle 1b36cbc5a3 Sort imports 2015-04-13 16:22:08 -04:00
Zach Riggle 27180e0dfa Rename module to pwndbg 2015-03-09 19:55:33 -07:00
Zach Riggle ca801c0d6d wip 2015-02-22 13:34:13 -08:00
Zach Riggle bc849f4e40 First commit, very dirty 2015-02-13 08:08:56 -08:00