Skip to content

Commit 7b32dd0

Browse files
authored
Merge branch 'Gallopsled:dev' into ssh_disabled_algorithms
2 parents 9e76184 + 636b3b2 commit 7b32dd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3654
-269
lines changed

.github/ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Thanks for contributing to Pwntools!
44

55
When reporting an issue, be sure that you are running the latest released version of pwntools (`pip install --upgrade pwntools`).
66

7-
Please verify that your issue occurs on 64-bit Ubuntu 14.04. You can use the Dockerfile on `docker.io` for quick testing.
7+
Please verify that your issue occurs on 64-bit Ubuntu 22.04. You can use the Dockerfile on `docker.io` for quick testing.
88

99
```
1010
$ docker pull pwntools/pwntools:stable

.github/workflows/ci.yml

+8-35
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
python_version: ['3.10', '3.12']
8+
python_version: ['3.10', '3.12', '3.13']
99
os: [ubuntu-latest]
10-
include:
11-
- python_version: '2.7'
12-
os: ubuntu-22.04
1310
runs-on: ${{ matrix.os }}
1411
timeout-minutes: 30
1512
services:
@@ -36,7 +33,7 @@ jobs:
3633
run: |
3734
git fetch origin
3835
git log --oneline --graph -10
39-
36+
4037
- name: Fix libcdb-cache permissions
4138
id: fix-perms
4239
run: |
@@ -66,17 +63,8 @@ jobs:
6663
sudo apt-get update && sudo apt-get install -y python3-pip gdb gdbserver
6764
/usr/bin/python -m pip install --break-system-packages rpyc || /usr/bin/python -m pip install rpyc
6865
gdb --batch --quiet --nx --nh --ex 'py import rpyc; print(rpyc.version.version)'
69-
70-
- name: Cache for pip
71-
uses: actions/cache@v4
72-
if: matrix.python_version == '2.7'
73-
with:
74-
path: ~/.cache/pip
75-
key: ${{ matrix.os }}-${{ matrix.python_version }}-cache-pip-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }}
76-
restore-keys: ${{ matrix.os }}-${{ matrix.python_version }}-cache-pip-
7766
7867
- name: Set up Python ${{ matrix.python_version }}
79-
if: matrix.python_version != '2.7'
8068
uses: actions/setup-python@v5
8169
with:
8270
python-version: ${{ matrix.python_version }}
@@ -85,17 +73,6 @@ jobs:
8573
**/pyproject.toml
8674
**/requirements*.txt
8775
88-
- name: Set up Python 2.7
89-
if: matrix.python_version == '2.7'
90-
run: |
91-
sudo apt-get update
92-
sudo apt-get install -y \
93-
python2.7 python2.7-dev python2-pip-whl
94-
sudo ln -sf python2.7 /usr/bin/python
95-
export PYTHONPATH=`echo /usr/share/python-wheels/pip-*py2*.whl`
96-
sudo --preserve-env=PYTHONPATH python -m pip install --upgrade pip setuptools wheel
97-
sudo chown -R $USER /usr/local/lib/python2.7
98-
9976
10077
- name: Verify tag against version
10178
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
@@ -125,11 +102,12 @@ jobs:
125102
binutils-s390x-linux-gnu \
126103
binutils-sparc64-linux-gnu \
127104
binutils-riscv64-linux-gnu \
105+
binutils-loongarch64-linux-gnu \
128106
gcc-multilib \
129107
libc6-dbg \
130108
elfutils \
131109
patchelf
132-
110+
133111
- name: Testing Corefiles
134112
run: |
135113
ulimit -a
@@ -155,10 +133,6 @@ jobs:
155133
- name: Install documentation dependencies
156134
run: pip install -r docs/requirements.txt
157135

158-
- name: Manually install non-broken Unicorn
159-
if: matrix.python_version == '2.7'
160-
run: pip install unicorn==2.0.0rc7
161-
162136
- name: Disable yama ptrace_scope
163137
run: |
164138
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope # required by some gdb doctests
@@ -244,7 +218,6 @@ jobs:
244218
pwn libcdb hash b229d1da1e161f95e839cf90cded5f719e5de308
245219
246220
- name: Build source and wheel distributions
247-
if: matrix.python_version != '2.7'
248221
run: |
249222
python -m build
250223
@@ -260,7 +233,7 @@ jobs:
260233
name: coverage-${{ matrix.python_version }}
261234
path: .coverage*
262235
include-hidden-files: true
263-
236+
264237
- name: Fix libcdb-cache permissions
265238
run: |
266239
container_id=$(docker ps --filter volume=/home/runner/libcdb-cache --no-trunc --format "{{.ID}}")
@@ -283,15 +256,15 @@ jobs:
283256
run: |
284257
pip install --upgrade pip
285258
pip install --upgrade --editable .
286-
259+
287260
- name: Install documentation dependencies
288261
run: pip install -r docs/requirements.txt
289-
262+
290263
- name: Sanity checks
291264
run: |
292265
python -bb -c 'from pwn import *'
293266
python -bb examples/text.py
294-
267+
295268
- name: Coverage doctests
296269
run: |
297270
python -bb -m coverage run -m sphinx -b doctest docs/source docs/build/doctest

CHANGELOG.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,32 @@ The table below shows which release corresponds to each branch, and what date th
7474

7575
## 5.0.0 (`dev`)
7676

77+
- [#2519][2519] Drop Python 2.7 support / Require Python 3.10
7778
- [#2507][2507] Add `+LINUX` and `+WINDOWS` doctest options and start proper testing on Windows
7879
- [#2522][2522] Support starting a kitty debugging window with the 'kitten' command
7980
- [#2524][2524] Raise EOFError during `process.recv` when stdout closes on Windows
8081
- [#2526][2526] Properly make use of extra arguments in `packing` utilities. `sign` parameter requires keyword syntax to specify it.
8182
- [#2517][2517] Allow to passthru kwargs on `ssh.__getattr__` convenience function to fix SSH motd problems
83+
- [#2527][2527] Allow setting debugger path via `context.gdb_binary`
84+
- [#2530][2530] Do NOT error when passing directory arguments in `checksec` commandline tool.
85+
- [#2529][2529] Add LoongArch64 support
86+
- [#2506][2506] ROP: fix `ROP(ELF(exe)).leave` is `None` in some ELF
87+
- [#2504][2504] doc: add example case for `tuple` (host, port pair) in `gdb.attach`
8288

89+
[2519]: https://github.com/Gallopsled/pwntools/pull/2519
8390
[2507]: https://github.com/Gallopsled/pwntools/pull/2507
8491
[2522]: https://github.com/Gallopsled/pwntools/pull/2522
8592
[2524]: https://github.com/Gallopsled/pwntools/pull/2524
8693
[2526]: https://github.com/Gallopsled/pwntools/pull/2526
8794
[2517]: https://github.com/Gallopsled/pwntools/pull/2517
95+
[2527]: https://github.com/Gallopsled/pwntools/pull/2527
96+
[2530]: https://github.com/Gallopsled/pwntools/pull/2530
97+
[2529]: https://github.com/Gallopsled/pwntools/pull/2529
98+
[2506]: https://github.com/Gallopsled/pwntools/pull/2506
99+
[2504]: https://github.com/Gallopsled/pwntools/pull/2504
88100

89101
## 4.15.0 (`beta`)
102+
90103
- [#2508][2508] Ignore a warning when compiling with asm on nix
91104
- [#2471][2471] Properly close spawned kitty window
92105
- [#2358][2358] Cache output of `asm()`
@@ -123,6 +136,14 @@ The table below shows which release corresponds to each branch, and what date th
123136
[2476]: https://github.com/Gallopsled/pwntools/pull/2476
124137
[2364]: https://github.com/Gallopsled/pwntools/pull/2364
125138

139+
## 4.14.1
140+
141+
- [#2533][2533] Fix installation on Python 3.5 and lower
142+
- [#2518][2518] fix: update apport coredump path handling for CorefileFinder
143+
144+
[2533]: https://github.com/Gallopsled/pwntools/pull/2533
145+
[2518]: https://github.com/Gallopsled/pwntools/pull/2518
146+
126147
## 4.14.0 (`stable`)
127148

128149
- [#2356][2356] Add local libc database provider for libcdb
@@ -194,7 +215,7 @@ The table below shows which release corresponds to each branch, and what date th
194215
- [#2308][2308] Fix WinExec shellcraft to make sure it's 16 byte aligned
195216
- [#2279][2279] Make `pwn template` always set context.binary
196217
- [#2310][2310] Add support to start a process on Windows
197-
- [#2335][2335] Add lookup optimizations in DynELF
218+
- [#2335][2335] Add lookup optimizations in DynELF
198219
- [#2334][2334] Speed up disasm commandline tool with colored output
199220
- [#2328][2328] Lookup using $PATHEXT file extensions in `which` on Windows
200221
- [#2189][2189] Explicitly define p64/u64 functions for IDE support
@@ -281,7 +302,7 @@ The table below shows which release corresponds to each branch, and what date th
281302

282303
## 4.11.0
283304

284-
- [#2185][2185] make fmtstr module able to create payload without $ notation
305+
- [#2185][2185] make fmtstr module able to create payload without $ notation
285306
- [#2103][2103] Add search for libc binary by leaked function addresses `libcdb.search_by_symbol_offsets()`
286307
- [#2177][2177] Support for RISC-V 64-bit architecture
287308
- [#2186][2186] Enhance `ELF.nx` and `ELF.execstack`

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ To get you started, we've provided some example solutions for past CTF challenge
3232

3333
# Installation
3434

35-
Pwntools is best supported on 64-bit Ubuntu LTS releases (18.04, 20.04, 22.04, and 24.04). Most functionality should work on any Posix-like distribution (Debian, Arch, FreeBSD, OSX, etc.).
35+
Pwntools is best supported on 64-bit Ubuntu LTS releases (22.04 and 24.04). Most functionality should work on any Posix-like distribution (Debian, Arch, FreeBSD, OSX, etc.).
3636

37-
Python3 is suggested, but Pwntools still works with Python 2.7. Most of the functionality of pwntools is self-contained and Python-only. You should be able to get running quickly with
37+
Pwntools supports Python 3.10+ since version 5.0.0. Use Pwntools 4.x for older versions as well as Python 2.7. Most of the functionality of pwntools is self-contained and Python-only. You should be able to get running quickly with
3838

3939
```sh
4040
sudo apt-get update

TESTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Pwntools makes extensive use of unit tests and integration tests to ensure every
44

55
## Test Suite
66

7-
To run the test suite, it is best to use Ubuntu 12.04 or 14.04, and run the following commands. **Be aware** that this will add a user to the machine, and create a public key for SSH login!
7+
To run the test suite, it is best to use Ubuntu 22.04 or 24.04, and run the following commands. **Be aware** that this will add a user to the machine, and create a public key for SSH login!
88

99
```sh
1010
bash travis/install.sh
@@ -15,7 +15,7 @@ PWNLIB_NOTERM=1 make -C docs doctest
1515

1616
## Testing in Docker
1717

18-
A `Dockerfile` has been provided which has a clean testing environment with Ubuntu Xenial. It is very similar to the online Travis CI testing environment, but uses a more modern version of Ubuntu.
18+
A `Dockerfile` has been provided which has a clean testing environment with Ubuntu Jammy. It is very similar to the online Github Actions CI testing environment, but uses a more modern version of Ubuntu.
1919

2020
See `travis/docker/README.md` for more information.
2121

docs/requirements.txt

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@ capstone
22
coverage[toml]
33
python-dateutil
44
doc2dash
5-
docutils<0.18; python_version<'3'
6-
docutils>=0.18; python_version>='3'
5+
docutils>=0.18
76
intervaltree
87
isort
98
mako>=1.0.0
109
paramiko>=1.15.2
1110
pip>=6.0.8
12-
pyelftools>=0.29, <0.30; python_version<'3'
13-
pyelftools>=0.29; python_version>='3'
11+
pyelftools>=0.29
1412
pygments>=2.0
1513
pypandoc
1614
pyserial>=2.7
1715
pysocks
1816
psutil
1917
requests>=2.5.1
2018
ropgadget>=5.3
21-
sphinx==1.8.6; python_version<'3'
22-
sphinx>=8.1.3, <9; python_version>='3'
19+
sphinx>=8.1.3, <9
2320
sphinx_rtd_theme
2421
sphinxcontrib-autoprogram<=0.1.5

docs/source/conf.py

+8-47
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def __setattr__(self, name, value):
9999
travis_ci = os.environ.get('USER') == 'travis'
100100
local_doctest = os.environ.get('USER') == 'pwntools'
101101
skip_android = True
102-
is_python2 = six.PY2
103102
'''
104103

105104
autoclass_content = 'both'
@@ -388,16 +387,13 @@ def linkcode_resolve(domain, info):
388387

389388

390389
# -- Customization to Sphinx autodoc generation --------------------------------------------
391-
import sphinx.ext.autodoc
392390

393391
# Test hidden members (e.g. def _foo(...))
394392
def dont_skip_any_doctests(app, what, name, obj, skip, options):
395393
return None
396394

397395
autodoc_default_options = {'special-members': None, 'private-members': None}
398396

399-
class _DummyClass(object): pass
400-
401397
# doctest optionflags for platform-specific tests
402398
# they are skipped on other platforms
403399
WINDOWS = doctest.register_optionflag('WINDOWS')
@@ -407,33 +403,6 @@ class _DummyClass(object): pass
407403
# doctest optionflag for tests that haven't been looked at yet
408404
TODO = doctest.register_optionflag('TODO')
409405

410-
class Py2OutputChecker(_DummyClass, doctest.OutputChecker):
411-
def check_output(self, want, got, optionflags):
412-
sup = super(Py2OutputChecker, self).check_output
413-
if sup(want, got, optionflags):
414-
return True
415-
try:
416-
rly_want = pwnlib.util.safeeval.const(want)
417-
if sup(repr(rly_want), got, optionflags):
418-
return True
419-
rly_got = pwnlib.util.safeeval.const(got)
420-
if rly_want == rly_got:
421-
return True
422-
except ValueError:
423-
pass
424-
rly_want = ' '.join(x[:2].replace('b"','"').replace("b'","'")+x[2:] for x in want.replace('\n','\n ').split(' ')).replace('\n ','\n')
425-
if sup(rly_want, got, optionflags):
426-
return True
427-
rly_want = ' '.join(x[:2].replace('b"',' "').replace("b'"," '")+x[2:] for x in want.replace('\n','\n ').split(' ')).replace('\n ','\n')
428-
if sup(rly_want, got, optionflags):
429-
return True
430-
for wantl, gotl in six.moves.zip_longest(want.splitlines(), got.splitlines(), fillvalue=''):
431-
rly_want1 = '['.join(x[:2].replace('b"','"').replace("b'","'")+x[2:] for x in wantl.split('['))
432-
rly_want2 = ' '.join(x[:2].replace('b"',' "').replace("b'"," '")+x[2:] for x in wantl.split(' '))
433-
if not sup(rly_want1, gotl, optionflags) and not sup(rly_want2, gotl, optionflags):
434-
return False
435-
return True
436-
437406
import sphinx.ext.doctest
438407

439408
class PlatformDocTestRunner(sphinx.ext.doctest.SphinxDocTestRunner):
@@ -471,24 +440,16 @@ def test_runner(self):
471440
def test_runner(self, value):
472441
self._test_runner = PlatformDocTestRunner(value._checker, value._verbose, value.optionflags)
473442

474-
def py2_doctest_init(self, checker=None, verbose=None, optionflags=0):
475-
if checker is None:
476-
checker = Py2OutputChecker()
477-
doctest.DocTestRunner.__init__(self, checker, verbose, optionflags)
478-
479443
if 'doctest' in sys.argv:
444+
def setup(app):
445+
app.add_builder(PlatformDocTestBuilder, override=True)
446+
# app.connect('autodoc-skip-member', dont_skip_any_doctests)
447+
# monkey patching paramiko due to https://github.com/paramiko/paramiko/pull/1661
448+
import paramiko.client
449+
import binascii
450+
paramiko.client.hexlify = lambda x: binascii.hexlify(x).decode()
451+
paramiko.util.safe_string = lambda x: '' # function result never *actually used*
480452

481-
if sys.version_info[:1] < (3,):
482-
sphinx.ext.doctest.SphinxDocTestRunner.__init__ = py2_doctest_init
483-
else:
484-
def setup(app):
485-
app.add_builder(PlatformDocTestBuilder, override=True)
486-
# app.connect('autodoc-skip-member', dont_skip_any_doctests)
487-
# monkey patching paramiko due to https://github.com/paramiko/paramiko/pull/1661
488-
import paramiko.client
489-
import binascii
490-
paramiko.client.hexlify = lambda x: binascii.hexlify(x).decode()
491-
paramiko.util.safe_string = lambda x: '' # function result never *actually used*
492453
class EndlessLoop(Exception): pass
493454
if hasattr(signal, 'alarm'):
494455
def alrm_handler(sig, frame):

docs/source/install.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Installation
22
============
33

4-
Pwntools is best supported on 64-bit Ubuntu LTS releases (14.04, 16.04, 18.04, and 20.04). Most functionality should work on any Posix-like distribution (Debian, Arch, FreeBSD, OSX, etc.).
4+
Pwntools is best supported on 64-bit Ubuntu LTS releases (22.04 and 24.04). Most functionality should work on any Posix-like distribution (Debian, Arch, FreeBSD, OSX, etc.).
55

66
Prerequisites
77
-------------
@@ -21,11 +21,13 @@ Note: For Mac OS X you will need to have cmake ``brew install cmake`` and pkg-co
2121
Released Version
2222
-----------------
2323

24-
pwntools is available as a ``pip`` package for both Python2 and Python3.
24+
pwntools is available as a ``pip`` package for Python3. Version v5.0.0 supports Python3.10 or later. Use v4 if you use earlier versions of Python.
2525

2626
Python3
2727
^^^^^^^
2828

29+
The Python version required for installing Pwntools is kept as low as possible on a best-effort basis. However, new features target Python3.10 and later.
30+
2931
.. code-block:: bash
3032
3133
$ sudo apt-get update
@@ -37,6 +39,8 @@ Python3
3739
Python2 (Deprecated)
3840
^^^^^^^^^^^^^^^^^^^^
3941

42+
Python2 support has been removed in Pwntools v5.0.0. The last version to support Python2 was v4.15.0.
43+
4044
NOTE: Pwntools maintainers STRONGLY recommend using Python3 for all future Pwntools-based scripts and projects.
4145

4246
Additionally, due to `pip` dropping support for Python2, a specfic version of `pip` must be installed.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. testsetup:: *
2+
3+
from pwn import *
4+
context.clear(arch='loongarch64')
5+
6+
import doctest
7+
doctest_additional_flags = doctest.OPTIONFLAGS_BY_NAME['LINUX']
8+
9+
:mod:`pwnlib.shellcraft.loongarch64` --- Shellcode for LoongArch64
10+
==========================================================
11+
12+
:mod:`pwnlib.shellcraft.loongarch64`
13+
--------------------------------
14+
15+
.. automodule:: pwnlib.shellcraft.loongarch64
16+
:members:
17+
18+
:mod:`pwnlib.shellcraft.loongarch64.linux`
19+
--------------------------------------
20+
21+
.. automodule:: pwnlib.shellcraft.loongarch64.linux
22+
:members:

0 commit comments

Comments
 (0)