Commit Graph

27 Commits

Author SHA1 Message Date
patryk4815 c80793f41e
add python3.10, add debian12, drop python3.8, drop ubuntu20.04, drop debian11 (#2421)
* drop ubuntu-20.04

* bump debian11->debian12

* bump python3.8->3.10

* bump py3.10 dependencies

* fix mypy/lint errors
2024-09-05 13:55:16 +02:00
OBarronCS 1438fc0616
Qemu user test structure (#2275)
* Initial version of qemu-user tests

* Refactor testing files to reduce file duplication, introduce qemu-user-tests

* lint and edit github actions workflow file. Move old qemu-user tests to seperate directory

* Add iproute2 so ss command is available

* test ubuntu 24

* funkiness with current working directory...

* Further remote old test_qemu.sh and integrate into a Pytest fixture

* lint

* Disable ASLR, add test for aarch64 jumps

* Use Popen.kill() function to make sure it closes.

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

* qemu.kill() on the other fixture as well

* comment

* comment

* lint

* system test path stuff

* remove old try-catch block

* revert

* revert path change

* Use os._exit to pass return code, and move qemu-user tests above system tests because they run significantly faster

* lint

* Flush stdout before os._exit

* Comment out flaky check for the address of main in old qemu tests

* rename qemu-user to cross-arch

* rename qemu-user to cross-arch and hotfix to not run pytest when
cross-arch is used

* remove todo comment

* another comment

* Test pwndbg.gdblib.symbol.address is not None and revert setarch -R

* Revert os.exit change

* Revert os.exit change

* Revert os.exit change

* readd os.exit in new exit places

* lint

* rebase

* delete file introduced in rebase

* break up tests into 3 files to invoke separately. Update GitHub workflow, remove code duplication in existing test

* code coverage

* fix code coverage

* lint

* test difference between Ubuntu 22 and 24 in Kernel tests

* lint

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2024-08-17 01:49:45 +02: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
卂フ卂ㄚ Ҝㄖ卩卩卂Ҝ卂 919d740415
Using Poetry to install all dependencies (#2221)
* Switch to Poetry for dependency management in setup

* Added curl dependency and removed python-pip and python3-pip

---------

Co-authored-by: B1N4RY-P4R45173 <kopakaajay123@gmail.com>
2024-06-11 08:15:16 -07:00
Aaron Adams 68c648bee0
Make shebangs and other bash usage portable (#2179) 2024-05-22 13:24:59 +02:00
Gulshan Singh 477e73ac91
Only ask to install git hook if it doesn't exist (#2129) 2024-04-24 19:10:24 -07:00
Aryaman Sharma 87c042d077
fedora support for dev setup (#2124)
* fedora support for dev setup

* Update setup-dev.sh

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2024-04-24 22:24:55 +02:00
Divyansh Singh f1f8fa0e43
make prepush hook executable (#2076) 2024-03-19 17:11:00 +01:00
Gulshan Singh da817b2378
Install dev dependencies with poetry (#2065)
* Add dev dependencies to pyproject.toml

* Add poetry.toml file

* Remove dev-requirements and install dev dependencies with poetry

* Update pwndbg.nix
2024-03-11 17:42:16 +01:00
smiley 8a2aa7f74f
add missing install dep for shfmt (#2025)
* add missing install dep for shfmt

* if we're given an ubuntu version and its not 20.04.. then install shfmt

* fix broken check for if no argument was passed to install_apt
2024-02-25 01:21:09 +01:00
Aaron Adams 2441ae9402 avoid breaking pacman.conf if entries already exist 2023-08-16 18:55:38 +02:00
Xeonacid 4fdd72e4f6
pacman: only install not-installed deps (#1845)
Signed-off-by: Xeonacid <h.dwwwwww@gmail.com>
2023-07-29 23:58:42 +02:00
duckl1ng 835c77cbdc
Fix golang check (#1825)
* Fix golang check

* Fix golang check in setup-dev.sh
2023-07-22 00:09:20 +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
peace-maker a6cc19aa5c
Improve RISCV support (#1770)
* Improve RISCV support

This is a resurrection of #829

Co-authored-by: Tobias Faller <faller@endiio.com>

* Silence bogus vermin warning

* Fix relative backwards jump calculations

The target address wouldn't be truncated to the pointer size.

* Add basic qemu-user test

* Run qemu-user tests in CI

* Make shfmt happy

* Fix pwntools < 4.11.0 support

* Support RISCV32 for pwntools < 4.11.0 as well

---------

Co-authored-by: Tobias Faller <faller@endiio.com>
2023-07-04 14:05:35 +02:00
CptGibbon b6e742ce38
Bump Zig version (#1629) 2023-03-16 18:16:49 +01:00
Gulshan Singh b9c9f12efc Add qemu tests to CI 2023-01-25 03:32:17 -08:00
Disconnect3d f78e3250c7
Fix archlinux ci tests (#1411)
* Fix Arch CI: install missing netcat (#1400)

The arch linux test_command_procinfo was failing bcoz the netcat was not
installed on arch build. This commit fixes it by:
1) installing gnu-netcat for arch linux setup-dev.sh
2) asserting that nc is available in the test itself, to prevent similar
   regressions from happening on future/newer images

* Fix Arch CI: the load binary tests (#1400)

Before this commit we asserted whether the loaded binary in tests report
to find or not find debug symbols but this is irrelevant for the thing
we want to test there which is: pwndbg loading. What eventually cares is
whether Pwndbg got loaded and didn't raise an exception.

This commit fixes those tests so they should now work also on ArchLinux
CI and on all CI builds.

Additionally, it removes the `compile_binary` test utility function
which was redundant as we compile all test binaries via a makefile.

* fix lint

* cleanup tests/binaries/div_zero_binary
2022-12-03 17:10:08 +01:00
Disconnect3d c6ab8dc671
Fix vmmap coredump test (#1391)
* fix shlint

* Fix crash when unable to get ehdr and fix vmmap coredump test

This commit fixes two issues and test them.

1. It changes the reads in `get_ehdr` to partial reads so that inability
   to read the `vmmap.start` address there will not crash Pwndbg with
`gdb.error` but instead we will simply return `None` as expected from
this function. This crash could happen on Debian 10 (GDB 8.2.1) and
Ubuntu 18.04 (not sure which GDB) when you did:
- gdb ./binary-that-crashes
- `run`
- `generate-core-file /tmp/core`
- `file` - to unload the binary
- `core-file /tmp/core` - to load the generated core

At this point I think we may have preserved the old vmmap info and use
it in `get_ehdr` maybe, which then crashed? I am not sure, but this fix
here works.

To test this behavior properly I also added the `unload_file`
parametrization to the
`test_command_vmmap_on_coredump_on_crash_simple_binary` test.

2. We fix the vmmap coredump test case when the `info proc mappings` returns nothing on core
   dumps on old GDBs. In such case we are missing the vmmap info about
the binary mapping, so now we properly remove it in the test.
2022-11-22 21:15:39 +01:00
Disconnect3d 117e69f842
tests reference-binary.c: dont rely on connect to 1.1.1.1 (#1390) 2022-11-22 21:02:42 +01:00
Xeonacid 1224cf75ef
Support Arch Linux docker test (#1378)
* Specify dockerfile for ubuntu/debian

To add Dockerfile.arch later

* Support Arch Linux docker test

* Fix setup-dev supported distro

* Create set_zigpath function

* Download zig from upstream for archlinux

* Add hash as part of key for docker cache

as https://github.com/satackey/action-docker-layer-caching#inputs notes.
2022-11-22 19:21:40 +01:00
Gulshan Singh ac5a6ebe64
Minor lint and pre-hook changes (#1349) 2022-10-25 17:46:53 -07:00
ruijia-zhou 6252b3f666
Install a git pre-push lint hook as part of setup-test-tools.sh (#1345)
* Update windbg.py

* Update hexdump.py

* Update hexdump.py

* Update hexdump.py

* Update hexdump.py

* Update hexdump.py

* Update hexdump.py

* Update windbg.py

* Update windbg.py

* Update hexdump.py

* Update hexdump.py

* Update typeinfo.py

* Update hexdump.py

* Update windbg.py

* Update setup-dev.sh

* Update setup-dev.sh

* Update setup-dev.sh

* Update setup-dev.sh

* Update hexdump.py

* Update typeinfo.py

* Update windbg.py

* Update setup-dev.sh

* Update setup-dev.sh
2022-10-25 09:05:57 -07:00
Gulshan Singh f94bc27cb1
Run tests in parallel with GNU parallel (#1332) 2022-10-23 17:21:24 -07:00
Gulshan Singh 7efaa33b0c
Install shfmt on Ubuntu 22.04, otherwise skip running linter (#1323) 2022-10-23 01:33:00 +02:00
Gulshan Singh b0b6a8fa30
Rename setup-test-tools.sh to setup-dev.sh (#1320) 2022-10-22 09:50:48 -07:00