Skip to content

Commit 69980db

Browse files
authored
Merge branch 'dev' into windbg
2 parents 09caa9c + 4ac98cd commit 69980db

Some content is hidden

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

45 files changed

+672
-308
lines changed

.github/workflows/ci.yml

+11-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 \
@@ -112,6 +118,10 @@ jobs:
112118
113119
- name: Coverage doctests
114120
run: |
121+
# Python version installed using setup-python interferes with gdb's python
122+
# by setting LD_LIBRARY_PATH and gdb's python becoming unable to load built-in modules
123+
# like _socket. This is a workaround.
124+
unset LD_LIBRARY_PATH
115125
PWNLIB_NOTERM=1 python -bb -m coverage run -m sphinx -b doctest docs/source docs/build/doctest
116126
117127
- name: Coverage running examples

CHANGELOG.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ 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.0](#4120-stable) | `stable` | Feb 22, 2024
15+
| [4.11.1](#4111) | | Nov 14, 2023
1516
| [4.11.0](#4110) | | Sep 15, 2023
1617
| [4.10.0](#4100) | | May 21, 2023
1718
| [4.9.0](#490) | | Dec 29, 2022
@@ -68,7 +69,19 @@ The table below shows which release corresponds to each branch, and what date th
6869
| [3.0.0](#300) | | Aug 20, 2016
6970
| [2.2.0](#220) | | Jan 5, 2015
7071

71-
## 4.13.0 (`dev`)
72+
## 4.14.0 (`dev`)
73+
74+
- [#2360][2360] Add offline parameter for `search_by_hash` series function
75+
- [#2356][2356] Add local libc database provider for libcdb
76+
- [#2374][2374] libcdb.unstrip_libc: debug symbols are fetched only if not present
77+
- [#2327][2327] Add basic support to debug processes on Windows
78+
79+
[2360]: https://github.com/Gallopsled/pwntools/pull/2360
80+
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
81+
[2374]: https://github.com/Gallopsled/pwntools/pull/2374
82+
[2327]: https://github.com/Gallopsled/pwntools/pull/2327
83+
84+
## 4.13.0 (`beta`)
7285

7386
- [#2242][2242] Term module revamp: activating special handling of terminal only when necessary
7487
- [#2277][2277] elf: Resolve more relocations into GOT entries
@@ -97,7 +110,7 @@ The table below shows which release corresponds to each branch, and what date th
97110
- [#2341][2341] Launch GDB correctly in iTerm on Mac
98111
- [#2268][2268] Add a `flatten` argument to `ssh.libs`
99112
- [#2347][2347] Fix/workaround Unicorn Engine 1GB limit that calls exit()
100-
- [#2327][2327] Add basic support to debug processes on Windows
113+
- [#2233][2233] Fix gdb.debug: exe parameter now respected, allow empty argv
101114

102115
[2242]: https://github.com/Gallopsled/pwntools/pull/2242
103116
[2277]: https://github.com/Gallopsled/pwntools/pull/2277
@@ -123,9 +136,9 @@ The table below shows which release corresponds to each branch, and what date th
123136
[2341]: https://github.com/Gallopsled/pwntools/pull/2341
124137
[2268]: https://github.com/Gallopsled/pwntools/pull/2268
125138
[2347]: https://github.com/Gallopsled/pwntools/pull/2347
126-
[2327]: https://github.com/Gallopsled/pwntools/pull/2327
139+
[2233]: https://github.com/Gallopsled/pwntools/pull/2233
127140

128-
## 4.12.0 (`beta`)
141+
## 4.12.0 (`stable`)
129142

130143
- [#2202][2202] Fix `remote` and `listen` in sagemath
131144
- [#2117][2117] Add -p (--prefix) and -s (--separator) arguments to `hex` command
@@ -134,6 +147,8 @@ The table below shows which release corresponds to each branch, and what date th
134147
- [#2212][2212] Add `--libc libc.so` argument to `pwn template` command
135148
- [#2257][2257] Allow creation of custom templates for `pwn template` command
136149
- [#2225][2225] Allow empty argv in ssh.process()
150+
- [#2349][2349] Fix term.readline omitting a trailing \n
151+
- [#2352][2352] add `RETURN_CONST` as an allowed `_const_code` in safeeval
137152

138153
[2202]: https://github.com/Gallopsled/pwntools/pull/2202
139154
[2117]: https://github.com/Gallopsled/pwntools/pull/2117
@@ -142,8 +157,10 @@ The table below shows which release corresponds to each branch, and what date th
142157
[2212]: https://github.com/Gallopsled/pwntools/pull/2212
143158
[2257]: https://github.com/Gallopsled/pwntools/pull/2257
144159
[2225]: https://github.com/Gallopsled/pwntools/pull/2225
160+
[2349]: https://github.com/Gallopsled/pwntools/pull/2349
161+
[2352]: https://github.com/Gallopsled/pwntools/pull/2352
145162

146-
## 4.11.1 (`stable`)
163+
## 4.11.1
147164

148165
- [#2271][2271] FIX: Generated shebang with path to python invalid if path contains spaces
149166
- [#2272][2272] Fix `tube.clean_and_log` not logging buffered data
@@ -1124,4 +1141,4 @@ are mentioned here.
11241141
- Added a lots of shellcodes
11251142
- Stuff we forgot
11261143
- Lots of documentation fixes
1127-
- Lots of bugfixes
1144+
- 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
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ Each of the ``pwntools`` modules is documented here.
8383
:hidden:
8484

8585
testexample
86-
rop/call
8786

8887
.. only:: not dash
8988

docs/source/install.rst

+4-6
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ Command-Line Tools
5151

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

54-
However, if you run as an unprivileged user, you may see a warning message that looks like this:
54+
However, if you run as an unprivileged user, you may see a warning message that looks like this::
5555

56-
.. code-block::
57-
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.
56+
WARNING: The scripts asm, checksec, common, constgrep, cyclic, debug, disablenx, disasm,
57+
elfdiff, elfpatch, errno, hex, main, phd, pwn, pwnstrip, scramble, shellcraft, template,
58+
unhex, update and version are installed in '/home/user/.local/bin' which is not on PATH.
6159

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

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/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)

pwnlib/context/__init__.py

+28
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ class ContextType(object):
360360
'endian': 'little',
361361
'gdbinit': "",
362362
'kernel': None,
363+
'local_libcdb': "/var/lib/libc-database",
363364
'log_level': logging.INFO,
364365
'log_file': _devnull(),
365366
'log_console': sys.stdout,
@@ -830,6 +831,7 @@ def bits(self, bits):
830831
The default value is ``32``, but changes according to :attr:`arch`.
831832
832833
Examples:
834+
833835
>>> context.clear()
834836
>>> context.bits == 32
835837
True
@@ -1070,6 +1072,32 @@ def log_console(self, stream):
10701072
stream = open(stream, 'wt')
10711073
return stream
10721074

1075+
@_validator
1076+
def local_libcdb(self, path):
1077+
"""
1078+
Sets path to local libc-database, get more information for libc-database:
1079+
https://github.com/niklasb/libc-database
1080+
1081+
Works in :attr:`pwnlib.libcdb` when searching by local database provider.
1082+
1083+
The default value is ``/var/lib/libc-database``.
1084+
1085+
Sets `context.local_libcdb` to empty string or `None` will turn off local libc-database integration.
1086+
1087+
Examples:
1088+
1089+
>>> context.local_libcdb = pwnlib.data.elf.path
1090+
>>> context.local_libcdb = 'foobar'
1091+
Traceback (most recent call last):
1092+
...
1093+
AttributeError: 'foobar' does not exist, please download libc-database first
1094+
"""
1095+
1096+
if not os.path.isdir(path):
1097+
raise AttributeError("'%s' does not exist, please download libc-database first" % path)
1098+
1099+
return path
1100+
10731101
@property
10741102
def mask(self):
10751103
return (1 << self.bits) - 1

pwnlib/elf/elf.py

+3
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ def vaddr_to_offset(self, address):
13461346
or :const:`None`.
13471347
13481348
Examples:
1349+
13491350
>>> bash = ELF(which('bash'))
13501351
>>> bash.vaddr_to_offset(bash.address)
13511352
0
@@ -1496,6 +1497,7 @@ def write(self, address, data):
14961497
that it stays in the same segment.
14971498
14981499
Examples:
1500+
14991501
>>> bash = ELF(which('bash'))
15001502
>>> bash.read(bash.address+1, 3)
15011503
b'ELF'
@@ -2387,6 +2389,7 @@ def set_interpreter(exepath, interpreter_path):
23872389
A new ELF instance is returned after patching the binary with the external ``patchelf`` tool.
23882390
23892391
Example:
2392+
23902393
>>> tmpdir = tempfile.mkdtemp()
23912394
>>> ls_path = os.path.join(tmpdir, 'ls')
23922395
>>> _ = shutil.copy(which('ls'), ls_path)

0 commit comments

Comments
 (0)