Skip to content

Commit c68c00c

Browse files
committed
Merge branch 'beta' into dev
2 parents cfc021d + 2e86d8a commit c68c00c

34 files changed

+104
-84
lines changed

.github/workflows/android.yml

+18-8
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,21 @@ jobs:
66
android-test:
77
strategy:
88
matrix:
9-
python-version: [3.8]
9+
python-version: ['3.10']
1010
os: [ubuntu-latest]
1111
runs-on: ${{ matrix.os }}
1212
timeout-minutes: 30
1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
- name: Cache for pip
17-
uses: actions/cache@v4
18-
id: cache-pip
19-
with:
20-
path: ~/.cache/pip
21-
key: ${{ matrix.os }}-cache-pip
22-
2316
- name: Set up Python ${{ matrix.python-version }}
2417
uses: actions/setup-python@v5
2518
with:
2619
python-version: ${{ matrix.python-version }}
20+
cache: 'pip'
21+
cache-dependency-path: |
22+
**/pyproject.toml
23+
**/requirements*.txt
2724
2825
- name: Install Linux dependencies
2926
run: |
@@ -35,6 +32,19 @@ jobs:
3532
binutils-arm-linux-gnueabihf \
3633
libc6-dbg
3734
35+
- name: Cache for avd
36+
uses: actions/cache@v4
37+
id: cache-avd
38+
with:
39+
path: |
40+
~/.android
41+
/usr/local/lib/android/sdk/emulator
42+
/usr/local/lib/android/sdk/platform-tools
43+
/usr/local/lib/android/sdk/system-images
44+
key: ${{ matrix.os }}-cache-avd-${{ hashFiles('travis/setup_avd*.sh') }}
45+
restore-keys: |
46+
${{ matrix.os }}-cache-avd-
47+
3848
- name: Install Android AVD
3949
run: |
4050
sudo usermod -aG kvm $USER

.github/workflows/ci.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
python_version: ['2.7', '3.10']
8+
python_version: ['3.10', '3.12']
99
os: [ubuntu-latest]
10+
include:
11+
- python_version: '2.7'
12+
os: ubuntu-22.04
1013
runs-on: ${{ matrix.os }}
1114
timeout-minutes: 30
1215
steps:
@@ -21,23 +24,30 @@ jobs:
2124
2225
- name: Install RPyC for gdb
2326
run: |
24-
# The version packaged in python3-rpyc is too old on Ubuntu 22.04
27+
# The version packaged in python3-rpyc is too old on Ubuntu 24.04
28+
# We use ^6.0 from pip.
2529
sudo apt-get update && sudo apt-get install -y python3-pip gdb gdbserver
26-
/usr/bin/python -m pip install rpyc
30+
/usr/bin/python -m pip install --break-system-packages rpyc || /usr/bin/python -m pip install rpyc
2731
gdb --batch --quiet --nx --nh --ex 'py import rpyc; print(rpyc.version.version)'
2832
2933
- name: Cache for pip
3034
uses: actions/cache@v4
35+
if: matrix.python_version == '2.7'
3136
id: cache-pip
3237
with:
3338
path: ~/.cache/pip
34-
key: ${{ matrix.os }}-cache-pip
39+
key: ${{ matrix.os }}-${{ matrix.python_version }}-cache-pip-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }}
40+
restore-keys: ${{ matrix.os }}-${{ matrix.python_version }}-cache-pip-
3541

3642
- name: Set up Python ${{ matrix.python_version }}
3743
if: matrix.python_version != '2.7'
3844
uses: actions/setup-python@v5
3945
with:
4046
python-version: ${{ matrix.python_version }}
47+
cache: 'pip'
48+
cache-dependency-path: |
49+
**/pyproject.toml
50+
**/requirements*.txt
4151
4252
- name: Set up Python 2.7
4353
if: matrix.python_version == '2.7'
@@ -203,7 +213,7 @@ jobs:
203213
python -m build
204214
205215
- uses: actions/upload-artifact@v4
206-
if: matrix.python_version != '2.7'
216+
if: matrix.python_version == '3.10'
207217
with:
208218
name: packages
209219
path: dist/
@@ -252,7 +262,7 @@ jobs:
252262

253263
- name: Install coveralls
254264
run: |
255-
pip install tomli coveralls
265+
pip install --break-system-packages tomli coveralls
256266
257267
- name: Upload coverage to coveralls.io
258268
run: |

.github/workflows/lint.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ jobs:
55
lint:
66
strategy:
77
matrix:
8-
python-version: [3.8]
8+
python-version: ['3.10']
99
os: [ubuntu-latest]
1010
runs-on: ${{ matrix.os }}
1111
timeout-minutes: 30
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Cache for pip
15-
uses: actions/cache@v4
16-
id: cache-pip
17-
with:
18-
path: ~/.cache/pip
19-
key: ${{ matrix.os }}-cache-pip
2014

2115
- name: Set up Python ${{ matrix.python-version }}
2216
uses: actions/setup-python@v5
2317
with:
2418
python-version: ${{ matrix.python-version }}
19+
cache: 'pip'
20+
cache-dependency-path: |
21+
**/pyproject.toml
22+
**/requirements*.txt
2523
2624
- name: Critical lint
2725
run: |

.github/workflows/pylint.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ jobs:
55
build:
66
strategy:
77
matrix:
8-
python-version: [3.8]
8+
python-version: ['3.10']
99
os: [ubuntu-latest]
1010
runs-on: ${{ matrix.os }}
1111
timeout-minutes: 30
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Cache for pip
15-
uses: actions/cache@v4
16-
id: cache-pip
17-
with:
18-
path: ~/.cache/pip
19-
key: ${{ matrix.os }}-cache-pip
2014

2115
- name: Set up Python ${{ matrix.python-version }}
2216
uses: actions/setup-python@v5
2317
with:
2418
python-version: ${{ matrix.python-version }}
19+
cache: 'pip'
20+
cache-dependency-path: |
21+
**/pyproject.toml
22+
**/requirements*.txt
2523
2624
- name: PyLint
2725
run: |

pwnlib/adb/adb.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def current_device(any=False):
123123
124124
>>> device = adb.current_device(any=True)
125125
>>> device # doctest: +ELLIPSIS
126-
AdbDevice(serial='emulator-5554', type='device', port='emulator', product='sdk_...phone_...', model='...', device='generic...')
126+
AdbDevice(serial='emulator-5554', type='device', port='emulator', product='sdk_...phone..._...', model='...', device='...')
127127
>>> device.port
128128
'emulator'
129129
"""
@@ -259,7 +259,7 @@ class AdbDevice(Device):
259259
>>> device.os
260260
'android'
261261
>>> device.product # doctest: +ELLIPSIS
262-
'sdk_...phone_...'
262+
'sdk_...phone..._...'
263263
>>> device.serial
264264
'emulator-5554'
265265
"""
@@ -880,7 +880,7 @@ def which(name, all = False, *a, **kw):
880880
>>> adb.which('sh')
881881
'/system/bin/sh'
882882
>>> adb.which('sh', all=True)
883-
['/system/bin/sh']
883+
['/system/bin/sh', '/vendor/bin/sh']
884884
885885
>>> adb.which('foobar') is None
886886
True
@@ -988,7 +988,7 @@ def proc_exe(pid):
988988
:skipif: skip_android
989989
990990
>>> adb.proc_exe(1)
991-
b'/init'
991+
b'/system/bin/init'
992992
"""
993993
with context.quiet:
994994
io = process(['realpath','/proc/%d/exe' % pid])
@@ -1365,7 +1365,7 @@ def compile(source):
13651365
>>> filename = adb.compile(temp)
13661366
>>> sent = adb.push(filename, "/data/local/tmp")
13671367
>>> adb.process(sent).recvall() # doctest: +ELLIPSIS
1368-
b'... /system/lib64/libc.so\n...'
1368+
b'... /system/lib64/libc++.so\n...'
13691369
"""
13701370

13711371
ndk_build = misc.which('ndk-build')

pwnlib/asm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ def disasm(data, vma = 0, byte = True, offset = True, instructions = True):
908908
0: b8 17 00 00 00 mov eax, 0x17
909909
>>> print(disasm(unhex('48c7c017000000'), arch = 'amd64'))
910910
0: 48 c7 c0 17 00 00 00 mov rax, 0x17
911-
>>> print(disasm(unhex('04001fe552009000'), arch = 'arm'))
912-
0: e51f0004 ldr r0, [pc, #-4] ; 0x4
911+
>>> print(disasm(unhex('04001fe552009000'), arch = 'arm')) # doctest: +ELLIPSIS
912+
0: e51f0004 ldr r0, [pc, #-4] ...
913913
4: 00900052 addseq r0, r0, r2, asr r0
914914
>>> print(disasm(unhex('4ff00500'), arch = 'thumb', bits=32))
915915
0: f04f 0005 mov.w r0, #5

pwnlib/commandline/asm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ def main(args):
137137
args.output.write(b'\n')
138138

139139
if __name__ == '__main__':
140-
pwnlib.commandline.common.main(__file__)
140+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/checksec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def main(args):
4141
print("{name}: {error}".format(name=f.name, error=e))
4242

4343
if __name__ == '__main__':
44-
common.main(__file__)
44+
common.main(__file__, main)

pwnlib/commandline/common.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@ def context_arg(arg):
2525
prog='pwn')
2626
parser_commands = parser.add_subparsers(dest='command')
2727

28-
def main(file=sys.argv[0]):
29-
import pwnlib.commandline.main
28+
def main(file=sys.argv[0], command_main=None):
3029
name = os.path.splitext(os.path.basename(file))[0]
30+
if command_main is None:
31+
import importlib
32+
command_main = importlib.import_module('pwnlib.commandline.%s' % name).main
3133
sys.argv.insert(1, name)
32-
pwnlib.commandline.main.main()
34+
entrypoint({name: command_main})
35+
36+
def entrypoint(commands):
37+
if len(sys.argv) < 2:
38+
parser.print_usage()
39+
sys.exit()
40+
args = parser.parse_args()
41+
with context.local(log_console = sys.stderr):
42+
commands[args.command](args)

pwnlib/commandline/constgrep.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ def main(args):
133133
print('(%s) == %s' % (' | '.join(k for v, k in good), args.constant))
134134

135135
if __name__ == '__main__':
136-
pwnlib.commandline.common.main(__file__)
136+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/cyclic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ def main(args):
107107
out.write(b'\n')
108108

109109
if __name__ == '__main__':
110-
pwnlib.commandline.common.main(__file__)
110+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/debug.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ def main(args):
102102
gdb.debug(target, gdbscript=gdbscript, sysroot=args.sysroot).interactive()
103103

104104
if __name__ == '__main__':
105-
pwnlib.commandline.common.main(__file__)
105+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/disablenx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def main(args):
2424
ELF(e.path)
2525

2626
if __name__ == '__main__':
27-
pwnlib.commandline.common.main(__file__)
27+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/disasm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ def main(args):
110110
print(disasm(dat, vma=safeeval.const(args.address)))
111111

112112
if __name__ == '__main__':
113-
pwnlib.commandline.common.main(__file__)
113+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/elfdiff.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ def main(a):
5959
print(diff(x, y))
6060

6161
if __name__ == '__main__':
62-
pwnlib.commandline.common.main(__file__)
62+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/elfpatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ def main(a):
3434
getattr(sys.stdout, 'buffer', sys.stdout).write(elf.get_data())
3535

3636
if __name__ == '__main__':
37-
pwnlib.commandline.common.main(__file__)
37+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/errno.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ def main(args):
4646
print(os.strerror(value))
4747

4848
if __name__ == '__main__':
49-
common.main(__file__)
49+
common.main(__file__, main)

pwnlib/commandline/hex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ def main(args):
5050
print(encoded)
5151

5252
if __name__ == '__main__':
53-
common.main(__file__)
53+
common.main(__file__, main)

pwnlib/commandline/libcdb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,4 @@ def main(args):
248248
log.indented('%25s = %#x', symbol, translate_offset(exe.symbols[symbol], args, exe))
249249

250250
if __name__ == '__main__':
251-
pwnlib.commandline.common.main(__file__)
251+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/main.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import absolute_import
22

3-
import sys
4-
53
from pwnlib.commandline import asm
64
from pwnlib.commandline import checksec
75
from pwnlib.commandline import common
@@ -23,8 +21,7 @@
2321
from pwnlib.commandline import unhex
2422
from pwnlib.commandline import update
2523
from pwnlib.commandline import version
26-
from pwnlib.commandline.common import parser
27-
from pwnlib.context import context
24+
from pwnlib.commandline.common import parser as parser
2825

2926
commands = {
3027
'asm': asm.main,
@@ -50,12 +47,7 @@
5047
}
5148

5249
def main():
53-
if len(sys.argv) < 2:
54-
parser.print_usage()
55-
sys.exit()
56-
args = parser.parse_args()
57-
with context.local(log_console = sys.stderr):
58-
commands[args.command](args)
50+
common.entrypoint(commands)
5951

6052
if __name__ == '__main__':
6153
main()

pwnlib/commandline/phd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ def main(args):
109109
pass
110110

111111
if __name__ == '__main__':
112-
pwnlib.commandline.common.main(__file__)
112+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/pwnstrip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ def main(args):
5353
args.output.write(result)
5454

5555
if __name__ == '__main__':
56-
pwnlib.commandline.common.main(__file__)
56+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/scramble.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ def main(args):
110110

111111

112112
if __name__ == '__main__':
113-
pwnlib.commandline.common.main(__file__)
113+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/shellcraft.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,4 @@ def main(args):
384384
args.out.write(code)
385385

386386
if __name__ == '__main__':
387-
pwnlib.commandline.common.main(__file__)
387+
pwnlib.commandline.common.main(__file__, main)

pwnlib/commandline/template.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,5 @@ def main(args):
210210
except OSError: pass
211211

212212
if __name__ == '__main__':
213-
pwnlib.commandline.common.main(__file__)
213+
pwnlib.commandline.common.main(__file__, main)
214214

pwnlib/commandline/unhex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def main(args):
3030
raise
3131

3232
if __name__ == '__main__':
33-
common.main(__file__)
33+
common.main(__file__, main)

pwnlib/commandline/update.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def main(a):
3030
subprocess.check_call(result, shell=False)
3131

3232
if __name__ == '__main__':
33-
pwnlib.commandline.common.main(__file__)
33+
pwnlib.commandline.common.main(__file__, main)

0 commit comments

Comments
 (0)