Skip to content

Commit 122d1c0

Browse files
committed
Merge branch 'dev' into optional-deps
2 parents 3c1b453 + 81d17c7 commit 122d1c0

25 files changed

+238
-153
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
# Check for updates to GitHub Actions every week
8+
interval: "weekly"

.github/workflows/android.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
timeout-minutes: 30
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515

1616
- name: Cache for pip
1717
uses: actions/cache@v3

.github/workflows/changelog.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
timeout-minutes: 5
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
timeout-minutes: 30
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 20
1616

@@ -182,12 +182,12 @@ jobs:
182182
run: |
183183
python -m build
184184
185-
- uses: actions/upload-artifact@v2
185+
- uses: actions/upload-artifact@v3
186186
with:
187187
name: packages
188188
path: dist/
189189

190-
- uses: actions/upload-artifact@v2
190+
- uses: actions/upload-artifact@v3
191191
with:
192192
name: coverage
193193
path: .coverage*
@@ -197,11 +197,11 @@ jobs:
197197
runs-on: ubuntu-latest
198198
needs: test
199199
steps:
200-
- uses: actions/checkout@v3
200+
- uses: actions/checkout@v4
201201
with:
202202
fetch-depth: 20
203203

204-
- uses: actions/download-artifact@v2
204+
- uses: actions/download-artifact@v3
205205
with:
206206
name: coverage
207207
path: .
@@ -221,7 +221,7 @@ jobs:
221221
if: github.repository_owner == 'Gallopsled' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/heads/') && endsWith(github.event.ref, '-staging')
222222
needs: test
223223
steps:
224-
- uses: actions/checkout@v2
224+
- uses: actions/checkout@v4
225225
with:
226226
fetch-depth: 20
227227
- name: Push changes to protected branch
@@ -243,7 +243,7 @@ jobs:
243243
needs: test
244244
steps:
245245
- name: Download artifacts
246-
uses: actions/download-artifact@v2
246+
uses: actions/download-artifact@v3
247247
with:
248248
name: packages
249249
path: dist

.github/workflows/docker.yml

+13-23
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,56 @@ on:
99
jobs:
1010
publish:
1111
runs-on: ubuntu-latest
12+
if: github.repository_owner == 'Gallopsled'
1213
steps:
13-
- name: Docker meta
14-
id: meta
15-
uses: docker/metadata-action@v4
16-
with:
17-
images: |
18-
pwntools/pwntools
19-
tags: |
20-
type=ref,event=branch
21-
2214
# Required for subdirectories in Git context
2315
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v2
16+
uses: docker/setup-buildx-action@v3
2517

2618
- name: Login to Docker Hub
27-
uses: docker/login-action@v2
19+
uses: docker/login-action@v3
2820
with:
2921
username: ${{ secrets.DOCKERHUB_USERNAME }}
3022
password: ${{ secrets.DOCKERHUB_PASSWORD }}
3123

3224
- name: Build and push base image
33-
uses: docker/build-push-action@v4
25+
uses: docker/build-push-action@v5
3426
if: github.event_name == 'workflow_dispatch'
3527
with:
3628
context: "{{defaultContext}}:extra/docker/base"
3729
push: true
3830
tags: pwntools/pwntools:base
3931

4032
- name: Build and push stable image
41-
uses: docker/build-push-action@v4
33+
uses: docker/build-push-action@v5
4234
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/stable')
4335
with:
4436
context: "{{defaultContext}}:extra/docker/stable"
4537
push: true
46-
tags: ${{ steps.meta.outputs.tags }}
47-
labels: ${{ steps.meta.outputs.labels }}
38+
tags: pwntools/pwntools:stable
4839

4940
- name: Build and push beta image
50-
uses: docker/build-push-action@v4
41+
uses: docker/build-push-action@v5
5142
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/beta')
5243
with:
5344
context: "{{defaultContext}}:extra/docker/beta"
5445
push: true
55-
tags: ${{ steps.meta.outputs.tags }}
56-
labels: ${{ steps.meta.outputs.labels }}
46+
tags: pwntools/pwntools:beta
5747

5848
- name: Build and push dev image
59-
uses: docker/build-push-action@v4
49+
uses: docker/build-push-action@v5
6050
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
6151
with:
6252
context: "{{defaultContext}}:extra/docker/dev"
6353
push: true
64-
tags: ${{ steps.meta.outputs.tags }}
65-
labels: ${{ steps.meta.outputs.labels }}
54+
tags: |
55+
pwntools/pwntools:dev
56+
pwntools/pwntools:latest
6657
6758
- name: Build and push ci image
68-
uses: docker/build-push-action@v4
59+
uses: docker/build-push-action@v5
6960
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
7061
with:
7162
context: "{{defaultContext}}:travis/docker"
7263
push: true
7364
tags: pwntools/pwntools:ci
74-
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
timeout-minutes: 30
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
- name: Cache for pip
1515
uses: actions/cache@v3
1616
id: cache-pip

.github/workflows/merge-conflict.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
timeout-minutes: 5
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 0
1919

.github/workflows/pylint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
timeout-minutes: 30
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
- name: Cache for pip
1515
uses: actions/cache@v3
1616
id: cache-pip

CHANGELOG.md

+19-10
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.12.0](#4120) | `dev` |
13-
| [4.11.0](#4110) | `beta` |
14-
| [4.10.0](#4100) | `stable` | May 21, 2023
12+
| [4.13.0](#4130-dev) | `dev` |
13+
| [4.12.0](#4120-beta) | `beta` |
14+
| [4.11.0](#4110-stable) | `stable` | Sep 15, 2023
15+
| [4.10.0](#4100) | | May 21, 2023
1516
| [4.9.0](#490) | | Dec 29, 2022
1617
| [4.8.0](#480) | | Apr 21, 2022
1718
| [4.7.1](#471) | | Apr 20, 2022
@@ -66,38 +67,46 @@ The table below shows which release corresponds to each branch, and what date th
6667
| [3.0.0](#300) | | Aug 20, 2016
6768
| [2.2.0](#220) | | Jan 5, 2015
6869

69-
## 4.12.0 (`dev`)
70+
## 4.13.0 (`dev`)
71+
72+
73+
74+
## 4.12.0 (`beta`)
7075
- [#2202][2202] Fix `remote` and `listen` in sagemath
7176
- [#2117][2117] Add -p (--prefix) and -s (--separator) arguments to `hex` command
7277
- [#2221][2221] Add shellcraft.sleep template wrapping SYS_nanosleep
7378
- [#2219][2219] Fix passing arguments on the stack in shellcraft syscall template
7479
- [#2212][2212] Add `--libc libc.so` argument to `pwn template` command
80+
- [#2257][2257] Allow creation of custom templates for `pwn template` command
81+
- [#2225][2225] Allow empty argv in ssh.process()
7582

7683
[2202]: https://github.com/Gallopsled/pwntools/pull/2202
7784
[2117]: https://github.com/Gallopsled/pwntools/pull/2117
7885
[2221]: https://github.com/Gallopsled/pwntools/pull/2221
7986
[2219]: https://github.com/Gallopsled/pwntools/pull/2219
8087
[2212]: https://github.com/Gallopsled/pwntools/pull/2212
88+
[2257]: https://github.com/Gallopsled/pwntools/pull/2257
89+
[2225]: https://github.com/Gallopsled/pwntools/pull/2225
8190

82-
## 4.11.0 (`beta`)
91+
## 4.11.0 (`stable`)
8392

8493
- [#2185][2185] make fmtstr module able to create payload without $ notation
8594
- [#2103][2103] Add search for libc binary by leaked function addresses `libcdb.search_by_symbol_offsets()`
8695
- [#2177][2177] Support for RISC-V 64-bit architecture
8796
- [#2186][2186] Enhance `ELF.nx` and `ELF.execstack`
8897
- [#2129][2129] Handle `context.newline` correctly when typing in `tube.interactive()`
98+
- [#2214][2214] Fix bug at ssh.py:`download` and `download_file` with relative paths
99+
- [#2241][2241] Fix ssh.process not setting ssh_process.cwd attribute
100+
- [#2261][2261] Fix corefile module after pyelftools update
89101

90102
[2185]: https://github.com/Gallopsled/pwntools/pull/2185
91103
[2103]: https://github.com/Gallopsled/pwntools/pull/2103
92104
[2177]: https://github.com/Gallopsled/pwntools/pull/2177
93105
[2186]: https://github.com/Gallopsled/pwntools/pull/2186
94106
[2129]: https://github.com/Gallopsled/pwntools/pull/2129
95-
96-
## 4.10.1 (`stable`)
97-
98-
- [#2214][2214] Fix bug at ssh.py:`download` and `download_file` with relative paths
99-
100107
[2214]: https://github.com/Gallopsled/pwntools/pull/2214
108+
[2241]: https://github.com/Gallopsled/pwntools/pull/2241
109+
[2261]: https://github.com/Gallopsled/pwntools/pull/2261
101110

102111
## 4.10.0
103112

extra/docker/base/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN apt-get update \
2626
python3 \
2727
python3-pip \
2828
python3-dev \
29+
python-is-python3 \
2930
qemu-user-static \
3031
binutils-arm-linux-gnueabihf \
3132
binutils-aarch64-linux-gnu \
@@ -34,6 +35,7 @@ RUN apt-get update \
3435
binutils-powerpc-linux-gnu \
3536
binutils-powerpc64-linux-gnu \
3637
binutils-sparc64-linux-gnu \
38+
binutils-riscv64-linux-gnu \
3739
tmux \
3840
patchelf \
3941
&& locale-gen en_US.UTF-8 \

extra/docker/develop/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN python2.7 -m pip install -U ipython ipdb \
3434
ARG DEBIAN_FRONTEND=noninteractive
3535
ENV TZ="UTC"
3636
RUN sudo apt-get update && sudo -E apt-get install -y \
37-
tzdata \
37+
tzdata \
3838
ash \
3939
bash \
4040
bash-static \

pwnlib/adb/adb.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,10 @@ def uninstall(package, *arguments):
15911591
@context.quietfunc
15921592
def packages():
15931593
"""Returns a list of packages installed on the system"""
1594-
packages = process(['pm', 'list', 'packages']).recvall()
1594+
# Decodes the received bytes as UTF-8 per:
1595+
# https://developer.android.com/reference/java/nio/charset/Charset#defaultCharset()
1596+
# where it is specified that UTF-8 is the default charset for Android.
1597+
packages = process(['pm', 'list', 'packages']).recvall().decode('utf-8')
15951598
return [line.split('package:', 1)[-1] for line in packages.splitlines()]
15961599

15971600
@context.quietfunc

pwnlib/commandline/template.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
from pwn import *
66
from pwnlib.commandline import common
77

8-
from mako.lookup import TemplateLookup
8+
from mako.lookup import TemplateLookup, Template
99

1010
parser = common.parser_commands.add_parser(
1111
'template',
1212
help = 'Generate an exploit template',
1313
description = 'Generate an exploit template'
1414
)
1515

16+
# change path to hardcoded one when building the documentation
17+
printable_data_path = "pwnlib/data" if 'sphinx' in sys.modules else pwnlib.data.path
18+
1619
parser.add_argument('exe', nargs='?', help='Target binary')
1720
parser.add_argument('--host', help='Remote host / SSH server')
1821
parser.add_argument('--port', help='Remote port / SSH port', type=int)
@@ -22,10 +25,17 @@
2225
parser.add_argument('--path', help='Remote path of file on SSH server')
2326
parser.add_argument('--quiet', help='Less verbose template comments', action='store_true')
2427
parser.add_argument('--color', help='Print the output in color', choices=['never', 'always', 'auto'], default='auto')
28+
parser.add_argument('--template', help='Path to a custom template. Tries to use \'~/.config/pwntools/templates/pwnup.mako\', if it exists. '
29+
'Check \'%s\' for the default template shipped with pwntools.' %
30+
os.path.join(printable_data_path, "templates", "pwnup.mako"))
2531

2632
def main(args):
33+
2734
lookup = TemplateLookup(
28-
directories = [os.path.join(pwnlib.data.path, 'templates')],
35+
directories = [
36+
os.path.expanduser('~/.config/pwntools/templates/'),
37+
os.path.join(pwnlib.data.path, 'templates')
38+
],
2939
module_directory = None
3040
)
3141

@@ -48,7 +58,12 @@ def main(args):
4858
if not args.exe:
4959
args.exe = os.path.basename(args.path)
5060

51-
template = lookup.get_template('pwnup.mako')
61+
62+
if args.template:
63+
template = Template(filename=args.template) # Failing on invalid file is ok
64+
else:
65+
template = lookup.get_template('pwnup.mako')
66+
5267
output = template.render(args.exe,
5368
args.host,
5469
args.port,
@@ -77,3 +92,4 @@ def main(args):
7792

7893
if __name__ == '__main__':
7994
pwnlib.commandline.common.main(__file__)
95+

pwnlib/elf/corefile.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
from io import BytesIO, StringIO
7777

7878
import elftools
79-
from elftools.common.py3compat import bytes2str
8079
from elftools.common.utils import roundup
8180
from elftools.common.utils import struct_parse
8281
from elftools.construct import CString
@@ -94,6 +93,7 @@
9493
from pwnlib.util.fiddling import unhex
9594
from pwnlib.util.misc import read
9695
from pwnlib.util.misc import write
96+
from pwnlib.util.packing import _decode
9797
from pwnlib.util.packing import pack
9898
from pwnlib.util.packing import unpack_many
9999

@@ -134,12 +134,13 @@ def iter_notes(self):
134134
self.stream.seek(offset)
135135
# n_namesz is 4-byte aligned.
136136
disk_namesz = roundup(note['n_namesz'], 2)
137-
note['n_name'] = bytes2str(
138-
CString('').parse(self.stream.read(disk_namesz)))
139-
offset += disk_namesz
137+
with context.local(encoding='latin-1'):
138+
note['n_name'] = _decode(
139+
CString('').parse(self.stream.read(disk_namesz)))
140+
offset += disk_namesz
140141

141-
desc_data = bytes2str(self.stream.read(note['n_descsz']))
142-
note['n_desc'] = desc_data
142+
desc_data = _decode(self.stream.read(note['n_descsz']))
143+
note['n_desc'] = desc_data
143144
offset += roundup(note['n_descsz'], 2)
144145
note['n_size'] = offset - note['n_offset']
145146
yield note

0 commit comments

Comments
 (0)