Skip to content

Commit 07b55f5

Browse files
authored
Merge branch 'Gallopsled:dev' into cx-multi-shellcraft-cmd
2 parents 1a75035 + 27366fd commit 07b55f5

Some content is hidden

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

80 files changed

+5637
-340
lines changed

.github/workflows/ci.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ jobs:
1919
git fetch origin
2020
git log --oneline --graph -10
2121
22+
- name: Install RPyC for gdb
23+
run: |
24+
# The version packaged in python3-rpyc is too old on Ubuntu 22.04
25+
sudo apt-get update && sudo apt-get install -y python3-pip gdb gdbserver
26+
/usr/bin/python -m pip install rpyc
27+
gdb --batch --quiet --nx --nh --ex 'py import rpyc; print(rpyc.version.version)'
28+
2229
- name: Cache for pip
2330
uses: actions/cache@v4
2431
id: cache-pip
@@ -62,7 +69,6 @@ jobs:
6269
sudo apt-get update
6370
sudo apt-get install -y --no-install-recommends -o Acquire::Retries=3 \
6471
ash bash-static dash ksh mksh zsh \
65-
python3-rpyc \
6672
gdb gdbserver socat \
6773
binutils-multiarch qemu-user-static \
6874
binutils-aarch64-linux-gnu \
@@ -72,6 +78,7 @@ jobs:
7278
binutils-powerpc-linux-gnu \
7379
binutils-s390x-linux-gnu \
7480
binutils-sparc64-linux-gnu \
81+
binutils-riscv64-linux-gnu \
7582
gcc-multilib \
7683
libc6-dbg \
7784
elfutils \
@@ -112,6 +119,10 @@ jobs:
112119
113120
- name: Coverage doctests
114121
run: |
122+
# Python version installed using setup-python interferes with gdb's python
123+
# by setting LD_LIBRARY_PATH and gdb's python becoming unable to load built-in modules
124+
# like _socket. This is a workaround.
125+
unset LD_LIBRARY_PATH
115126
PWNLIB_NOTERM=1 python -bb -m coverage run -m sphinx -b doctest docs/source docs/build/doctest
116127
117128
- name: Coverage running examples

CHANGELOG.md

+45-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ The table below shows which release corresponds to each branch, and what date th
99

1010
| Version | Branch | Release Date |
1111
| ---------------- | -------- | ---------------------- |
12-
| [4.13.0](#4130-dev) | `dev` |
13-
| [4.12.0](#4120-beta) | `beta` |
14-
| [4.11.1](#4111-stable) | `stable` | Nov 14, 2023
12+
| [4.14.0](#4140-dev) | `dev` |
13+
| [4.13.0](#4130-beta) | `beta` |
14+
| [4.12.1](#4121) | |
15+
| [4.12.0](#4120-stable) | `stable` | Feb 22, 2024
16+
| [4.11.1](#4111) | | Nov 14, 2023
1517
| [4.11.0](#4110) | | Sep 15, 2023
1618
| [4.10.0](#4100) | | May 21, 2023
1719
| [4.9.0](#490) | | Dec 29, 2022
@@ -68,7 +70,29 @@ The table below shows which release corresponds to each branch, and what date th
6870
| [3.0.0](#300) | | Aug 20, 2016
6971
| [2.2.0](#220) | | Jan 5, 2015
7072

71-
## 4.13.0 (`dev`)
73+
## 4.14.0 (`dev`)
74+
75+
- [#2360][2360] Add offline parameter for `search_by_hash` series function
76+
- [#2356][2356] Add local libc database provider for libcdb
77+
- [#2374][2374] libcdb.unstrip_libc: debug symbols are fetched only if not present
78+
- [#2327][2327] Add basic support to debug processes on Windows
79+
- [#2322][2322] Add basic RISCV64 shellcraft support
80+
- [#2330][2330] Change `context.newline` when setting `context.os` to `"windows"`
81+
- [#2389][2389] Fix passing bytes to `context.log_file` and `crc.BitPolynom`
82+
- [#2391][2391] Fix error message when passing invalid kwargs to `xor`
83+
- [#2376][2376] Return buffered data on first EOF in tube.readline()
84+
85+
[2360]: https://github.com/Gallopsled/pwntools/pull/2360
86+
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
87+
[2374]: https://github.com/Gallopsled/pwntools/pull/2374
88+
[2327]: https://github.com/Gallopsled/pwntools/pull/2327
89+
[2322]: https://github.com/Gallopsled/pwntools/pull/2322
90+
[2330]: https://github.com/Gallopsled/pwntools/pull/2330
91+
[2389]: https://github.com/Gallopsled/pwntools/pull/2389
92+
[2391]: https://github.com/Gallopsled/pwntools/pull/2391
93+
[2376]: https://github.com/Gallopsled/pwntools/pull/2376
94+
95+
## 4.13.0 (`beta`)
7296

7397
- [#2242][2242] Term module revamp: activating special handling of terminal only when necessary
7498
- [#2277][2277] elf: Resolve more relocations into GOT entries
@@ -97,6 +121,7 @@ The table below shows which release corresponds to each branch, and what date th
97121
- [#2341][2341] Launch GDB correctly in iTerm on Mac
98122
- [#2268][2268] Add a `flatten` argument to `ssh.libs`
99123
- [#2347][2347] Fix/workaround Unicorn Engine 1GB limit that calls exit()
124+
- [#2233][2233] Fix gdb.debug: exe parameter now respected, allow empty argv
100125

101126
[2242]: https://github.com/Gallopsled/pwntools/pull/2242
102127
[2277]: https://github.com/Gallopsled/pwntools/pull/2277
@@ -122,8 +147,17 @@ The table below shows which release corresponds to each branch, and what date th
122147
[2341]: https://github.com/Gallopsled/pwntools/pull/2341
123148
[2268]: https://github.com/Gallopsled/pwntools/pull/2268
124149
[2347]: https://github.com/Gallopsled/pwntools/pull/2347
150+
[2233]: https://github.com/Gallopsled/pwntools/pull/2233
125151

126-
## 4.12.0 (`beta`)
152+
## 4.12.1
153+
154+
- [#2373][2373] Fix displaying bright color variation in terminal output
155+
- [#2378][2378] Don't go though a shell in `gdb.debug`
156+
157+
[2373]: https://github.com/Gallopsled/pwntools/pull/2373
158+
[2378]: https://github.com/Gallopsled/pwntools/pull/2378
159+
160+
## 4.12.0 (`stable`)
127161

128162
- [#2202][2202] Fix `remote` and `listen` in sagemath
129163
- [#2117][2117] Add -p (--prefix) and -s (--separator) arguments to `hex` command
@@ -132,6 +166,8 @@ The table below shows which release corresponds to each branch, and what date th
132166
- [#2212][2212] Add `--libc libc.so` argument to `pwn template` command
133167
- [#2257][2257] Allow creation of custom templates for `pwn template` command
134168
- [#2225][2225] Allow empty argv in ssh.process()
169+
- [#2349][2349] Fix term.readline omitting a trailing \n
170+
- [#2352][2352] add `RETURN_CONST` as an allowed `_const_code` in safeeval
135171

136172
[2202]: https://github.com/Gallopsled/pwntools/pull/2202
137173
[2117]: https://github.com/Gallopsled/pwntools/pull/2117
@@ -140,8 +176,10 @@ The table below shows which release corresponds to each branch, and what date th
140176
[2212]: https://github.com/Gallopsled/pwntools/pull/2212
141177
[2257]: https://github.com/Gallopsled/pwntools/pull/2257
142178
[2225]: https://github.com/Gallopsled/pwntools/pull/2225
179+
[2349]: https://github.com/Gallopsled/pwntools/pull/2349
180+
[2352]: https://github.com/Gallopsled/pwntools/pull/2352
143181

144-
## 4.11.1 (`stable`)
182+
## 4.11.1
145183

146184
- [#2271][2271] FIX: Generated shebang with path to python invalid if path contains spaces
147185
- [#2272][2272] Fix `tube.clean_and_log` not logging buffered data
@@ -1122,4 +1160,4 @@ are mentioned here.
11221160
- Added a lots of shellcodes
11231161
- Stuff we forgot
11241162
- Lots of documentation fixes
1125-
- Lots of bugfixes
1163+
- Lots of bugfixes

docs/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ isort
88
mako>=1.0.0
99
paramiko>=1.15.2
1010
pip>=6.0.8
11-
pyelftools>=0.2.3
11+
pyelftools>=0.29, <0.30; python_version<'3'
12+
pyelftools>=0.29; python_version>='3'
1213
pygments>=2.0
1314
pypandoc
1415
pyserial>=2.7

docs/source/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def filter(self, record):
7171
import sys, os
7272
os.environ['PWNLIB_NOTERM'] = '1'
7373
os.environ['PWNLIB_RANDOMIZE'] = '0'
74+
import six
7475
import pwnlib.update
7576
import pwnlib.util.fiddling
7677
import logging
@@ -97,8 +98,8 @@ def __setattr__(self, name, value):
9798
github_actions = os.environ.get('USER') == 'runner'
9899
travis_ci = os.environ.get('USER') == 'travis'
99100
local_doctest = os.environ.get('USER') == 'pwntools'
100-
branch_dev = os.environ.get('GITHUB_BASE_REF') == 'dev'
101101
skip_android = True
102+
is_python2 = six.PY2
102103
'''
103104

104105
autoclass_content = 'both'

docs/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ Each of the ``pwntools`` modules is documented here.
7777
update
7878
useragents
7979
util/*
80+
windbg
8081

8182
.. toctree::
8283
:hidden:
8384

8485
testexample
85-
rop/call
8686

8787
.. only:: not dash
8888

docs/source/install.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ following system libraries installed.
1515

1616
install/*
1717

18+
19+
Note: For Mac OS X you will need to have cmake ``brew install cmake`` and pkg-config ``brew install pkg-config`` installed.
20+
1821
Released Version
1922
-----------------
2023

@@ -51,13 +54,11 @@ Command-Line Tools
5154

5255
When installed with ``sudo`` the above commands will install Pwntools' command-line tools to somewhere like ``/usr/bin``.
5356

54-
However, if you run as an unprivileged user, you may see a warning message that looks like this:
55-
56-
.. code-block::
57+
However, if you run as an unprivileged user, you may see a warning message that looks like this::
5758

58-
WARNING: The scripts asm, checksec, common, constgrep, cyclic, debug, disablenx, disasm,
59-
elfdiff, elfpatch, errno, hex, main, phd, pwn, pwnstrip, scramble, shellcraft, template,
60-
unhex, update and version are installed in '/home/user/.local/bin' which is not on PATH.
59+
WARNING: The scripts asm, checksec, common, constgrep, cyclic, debug, disablenx, disasm,
60+
elfdiff, elfpatch, errno, hex, main, phd, pwn, pwnstrip, scramble, shellcraft, template,
61+
unhex, update and version are installed in '/home/user/.local/bin' which is not on PATH.
6162

6263
Follow the instructions listed and add ``~/.local/bin`` to your ``$PATH`` environment variable.
6364

docs/source/install/binutils.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ Mac OS X
3232
^^^^^^^^^^^^^^^^
3333

3434
Mac OS X is just as easy, but requires building binutils from source.
35-
However, we've made ``homebrew`` recipes to make this a single command.
35+
However, we've made ``homebrew`` recipes to make this just two commands.
3636
After installing `brew <https://brew.sh>`__, grab the appropriate
3737
recipe from our `binutils
3838
repo <https://github.com/Gallopsled/pwntools-binutils/>`__.
3939

4040
.. code-block:: bash
4141
42-
$ brew install https://raw.githubusercontent.com/Gallopsled/pwntools-binutils/master/macos/binutils-$ARCH.rb
42+
$ wget https://raw.githubusercontent.com/Gallopsled/pwntools-binutils/master/macos/binutils-$ARCH.rb
43+
$ brew install ./binutils-$ARCH.rb
4344
4445
Alternate OSes
4546
^^^^^^^^^^^^^^^^

docs/source/shellcraft/riscv64.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. testsetup:: *
2+
3+
from pwn import *
4+
context.clear(arch='riscv64')
5+
6+
:mod:`pwnlib.shellcraft.riscv64` --- Shellcode for RISCV64
7+
===========================================================
8+
9+
:mod:`pwnlib.shellcraft.riscv64`
10+
-------------------------------
11+
12+
.. automodule:: pwnlib.shellcraft.riscv64
13+
:members:
14+
15+
:mod:`pwnlib.shellcraft.riscv64.linux`
16+
---------------------------------------
17+
18+
.. automodule:: pwnlib.shellcraft.riscv64.linux
19+
:members:

docs/source/windbg.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. testsetup:: *
2+
3+
from pwn import *
4+
5+
:mod:`pwnlib.windbg` --- Working with WinDbg
6+
======================================
7+
8+
.. automodule:: pwnlib.windbg
9+
:members:

extra/docker/base/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ RUN apt-get update \
4040
patchelf \
4141
&& locale-gen en_US.UTF-8 \
4242
&& update-locale LANG=en_US.UTF-8 \
43-
&& PYTHONPATH=`echo /usr/share/python-wheels/pip-*.whl` python2.7 -m pip install --upgrade pip setuptools wheel \
44-
&& python2.7 -m pip install --upgrade pwntools \
45-
&& python3 -m pip install --upgrade pip \
46-
&& python3 -m pip install --upgrade pwntools \
43+
&& PYTHONPATH=`echo /usr/share/python-wheels/pip-*.whl` python2.7 -m pip install --no-cache-dir --upgrade pip setuptools wheel \
44+
&& python2.7 -m pip install --no-cache-dir --upgrade pwntools \
45+
&& python3 -m pip install --no-cache-dir --upgrade pip \
46+
&& python3 -m pip install --no-cache-dir --upgrade pwntools \
4747
&& PWNLIB_NOTERM=1 pwn update \
4848
&& useradd -m pwntools \
4949
&& passwd --delete --unlock pwntools \

extra/docker/beta/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM pwntools/pwntools:stable
22

33
USER root
4-
RUN python2.7 -m pip install --upgrade git+https://github.com/Gallopsled/pwntools@beta \
5-
&& python3 -m pip install --force-reinstall --upgrade git+https://github.com/Gallopsled/pwntools@beta
4+
RUN python2.7 -m pip install --no-cache-dir --upgrade git+https://github.com/Gallopsled/pwntools@beta \
5+
&& python3 -m pip install --no-cache-dir --force-reinstall --upgrade git+https://github.com/Gallopsled/pwntools@beta
66
RUN PWNLIB_NOTERM=1 pwn update
77
USER pwntools

extra/docker/buster/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ RUN apt-get -y dist-upgrade
55
RUN apt-get -y install python3 python3-pip
66
RUN apt-get -y install git wget unzip
77

8-
RUN pip3 install --upgrade git+https://github.com/Gallopsled/pwntools@dev
8+
RUN pip3 install --no-cache-dir --upgrade git+https://github.com/Gallopsled/pwntools@dev

extra/docker/stable/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM pwntools/pwntools:base
22

33
USER root
4-
RUN python2.7 -m pip install --upgrade git+https://github.com/Gallopsled/pwntools@stable \
5-
&& python3 -m pip install --force-reinstall --upgrade git+https://github.com/Gallopsled/pwntools@stable
4+
RUN python2.7 -m pip install --no-cache-dir --upgrade git+https://github.com/Gallopsled/pwntools@stable \
5+
&& python3 -m pip install --no-cache-dir --force-reinstall --upgrade git+https://github.com/Gallopsled/pwntools@stable
66
RUN PWNLIB_NOTERM=1 pwn update
77
USER pwntools

pwnlib/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'util',
3737
'update',
3838
'version',
39+
'windbg',
3940
]
4041

4142
from . import args

pwnlib/args.py

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ def STDERR(v):
159159
"""Sends logging to ``stderr`` by default, instead of ``stdout``"""
160160
context.log_console = sys.stderr
161161

162+
def LOCAL_LIBCDB(v):
163+
"""Sets path to local libc-database via ``context.local_libcdb``, e.g.
164+
``LOCAL_LIBCDB='/path/to/libc-databse'``"""
165+
context.local_libcdb = v
166+
162167
hooks = {
163168
'LOG_LEVEL': LOG_LEVEL,
164169
'LOG_FILE': LOG_FILE,
@@ -170,6 +175,7 @@ def STDERR(v):
170175
'NOASLR': NOASLR,
171176
'NOPTRACE': NOPTRACE,
172177
'STDERR': STDERR,
178+
'LOCAL_LIBCDB': LOCAL_LIBCDB,
173179
}
174180

175181
def initialize():

pwnlib/commandline/template.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ def detect_missing_binaries(args):
4747
else:
4848
if os.access(filename, os.X_OK):
4949
other_files.append(filename)
50-
if len(other_files) == 1:
51-
exe = other_files[0]
52-
elif len(other_files) > 1:
53-
log.warning("Failed to find challenge binary. There are multiple binaries in the current directory: %s", other_files)
50+
if not exe:
51+
if len(other_files) == 1:
52+
exe = other_files[0]
53+
elif len(other_files) > 1:
54+
log.warning("Failed to find challenge binary. There are multiple binaries in the current directory: %s", other_files)
5455

5556
if exe != args.exe:
5657
log.success("Found challenge binary %r", exe)

0 commit comments

Comments
 (0)