Skip to content

Commit f28d3eb

Browse files
authoredOct 12, 2024··
Test Python version >= 3.10 in CI and fix tests on Python 3.12 (#2486)
* Bump tested python version to >= 3.10 Some workflows were using 3.8 still. Start testing on 3.12 too. * Fix installing rpyc in CI on ubuntu 24.04 `ubuntu-latest` now points to 24.04 which requires the --break-system-packages dance. * Test Python 2 on Ubuntu 22.04 Ubuntu 24.04 dropped the python2.7 packages. * Test on android-34 * Fix ARM binutils disassembly output test expectation It used to print "; 0x4" but changed to "@ 0x4" in some version. * Skip QEMU LD_PREFIX path test Ubuntu 24.04 seemed to have switched the qemu-user --help output to show `/usr/gnemul/qemu-$ARCH` instead of `/etc/qemu-binfmt`. Ignore the actual path in the test. * Fix x86 ascii shellcode encoder test The alphabet was using `\` escape sequences badly. <stdin>:1: SyntaxWarning: invalid escape sequence '\]' * Fix mips xor encoder unaligned memory access qemu throws a SIGBUS error when the shellcode tries to access unaligned memory since some version. Align the "stack" properly. * Fix util.lists.partition test output on Python 3.12 The __repr__ output of OrderedDict was changed to look like ordinary {} dicts. * Fix safeeval test on Python 3.12 There is a 151 RESUME opcode in Python 3.12 now. * Fix registering commandline subparsers multiple times for Python 3.11 Python 3.11 added a sanity check to argparse to prevent registering the same subparser multiple times. argparse.ArgumentError: argument command: conflicting subparser: cyclic Avoid importing the command twice. `python -m pwnlib.commandline.cyclic` failed on Python 3.11 triggered in CI when running the commandline tools while collecting coverage. * Fix pip cache in CI
1 parent 78dd777 commit f28d3eb

34 files changed

+106
-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

+18-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'
@@ -195,15 +205,17 @@ jobs:
195205
python -m build
196206
197207
- uses: actions/upload-artifact@v4
198-
if: matrix.python_version != '2.7'
208+
if: matrix.python_version == '3.10'
199209
with:
200210
name: packages
201211
path: dist/
212+
include-hidden-files: true
202213

203214
- uses: actions/upload-artifact@v4
204215
with:
205216
name: coverage-${{ matrix.python_version }}
206217
path: .coverage*
218+
include-hidden-files: true
207219

208220

209221
upload-coverage:
@@ -221,7 +233,7 @@ jobs:
221233

222234
- name: Install coveralls
223235
run: |
224-
pip install tomli coveralls
236+
pip install --break-system-packages tomli coveralls
225237
226238
- name: Upload coverage to coveralls.io
227239
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
@@ -855,8 +855,8 @@ def disasm(data, vma = 0, byte = True, offset = True, instructions = True):
855855
0: b8 17 00 00 00 mov eax, 0x17
856856
>>> print(disasm(unhex('48c7c017000000'), arch = 'amd64'))
857857
0: 48 c7 c0 17 00 00 00 mov rax, 0x17
858-
>>> print(disasm(unhex('04001fe552009000'), arch = 'arm'))
859-
0: e51f0004 ldr r0, [pc, #-4] ; 0x4
858+
>>> print(disasm(unhex('04001fe552009000'), arch = 'arm')) # doctest: +ELLIPSIS
859+
0: e51f0004 ldr r0, [pc, #-4] ...
860860
4: 00900052 addseq r0, r0, r2, asr r0
861861
>>> print(disasm(unhex('4ff00500'), arch = 'thumb', bits=32))
862862
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
@@ -38,4 +38,4 @@ def main(args):
3838
e = ELF(f.name)
3939

4040
if __name__ == '__main__':
41-
common.main(__file__)
41+
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
@@ -352,4 +352,4 @@ def main(args):
352352
args.out.write(code)
353353

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

‎pwnlib/commandline/template.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ def main(args):
122122
except OSError: pass
123123

124124
if __name__ == '__main__':
125-
pwnlib.commandline.common.main(__file__)
125+
pwnlib.commandline.common.main(__file__, main)
126126

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

‎pwnlib/commandline/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def main(a):
2929
log.info("Pwntools v%s" % version)
3030

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

‎pwnlib/encoders/i386/ascii_shellcode.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _get_allocator(self, size, vocab):
132132
Examples:
133133
134134
>>> context.update(arch='i386', os='linux')
135-
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
135+
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
136136
>>> encoders.i386.ascii_shellcode.encode._get_allocator(300, vocab)
137137
bytearray(b'TX-!!!!-!_``-t~~~P\\%!!!!%@@@@')
138138
"""
@@ -178,7 +178,7 @@ def _find_negatives(self, vocab):
178178
Examples:
179179
180180
>>> context.update(arch='i386', os='linux')
181-
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
181+
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
182182
>>> a, b = encoders.i386.ascii_shellcode.encode._find_negatives(vocab)
183183
>>> a & b
184184
0
@@ -212,7 +212,7 @@ def _get_subtractions(self, shellcode, vocab):
212212
213213
>>> context.update(arch='i386', os='linux')
214214
>>> sc = bytearray(b'ABCDEFGHIGKLMNOPQRSTUVXYZ')
215-
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
215+
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
216216
>>> encoders.i386.ascii_shellcode.encode._get_subtractions(sc, vocab)
217217
bytearray(b'-(!!!-~NNNP-!=;:-f~~~-~~~~P-!!!!-edee-~~~~P-!!!!-eddd-~~~~P-!!!!-egdd-~~~~P-!!!!-eadd-~~~~P-!!!!-eddd-~~~~P')
218218
"""
@@ -255,7 +255,7 @@ def _calc_subtractions(self, last, target, vocab):
255255
Examples:
256256
257257
>>> context.update(arch='i386', os='linux')
258-
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
258+
>>> vocab = bytearray(b'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
259259
>>> print(encoders.i386.ascii_shellcode.encode._calc_subtractions(bytearray(b'\x10'*4), bytearray(b'\x11'*4), vocab))
260260
[bytearray(b'!!!!'), bytearray(b'`___'), bytearray(b'~~~~')]
261261
>>> print(encoders.i386.ascii_shellcode.encode._calc_subtractions(bytearray(b'\x11\x12\x13\x14'), bytearray(b'\x15\x16\x17\x18'), vocab))

‎pwnlib/encoders/mips/xor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
b'\xff\xff\x08\x21', # addi t0,t0,-1
4242
b'\xff\xff\x10\x05', # bltzal t0,14 <next>
4343
b'\x82\x82\x08\x28', # slti t0,zero,-32126
44-
b'\xe2\xff\xfd\x23', # addi sp,ra,-30
44+
b'\xe0\xff\xfd\x23', # addi sp,ra,-32
4545
b'\x27\x58\x60\x01', # nor t3,t3,zero
4646
b'\x21\xc8\xeb\x03', # addu t9,ra,t3
4747
b'\x82\x82\x17\x28', # slti s7,zero,-32126
@@ -72,7 +72,7 @@
7272
b'\x21\x08\xff\xff', # addi t0,t0,-1
7373
b'\x05\x10\xff\xff', # bltzal t0,14 <next>
7474
b'\x28\x08\x82\x82', # slti t0,zero,-32126
75-
b'\x23\xfd\xff\xe2', # addi sp,ra,-30
75+
b'\x23\xfd\xff\xe0', # addi sp,ra,-32
7676
b'\x01\x60\x58\x27', # nor t3,t3,zero
7777
b'\x03\xeb\xc8\x21', # addu t9,ra,t3
7878
b'\x28\x17\x82\x82', # slti s7,zero,-32126

‎pwnlib/qemu.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def user_path():
139139
def ld_prefix(path=None, env=None):
140140
"""Returns the linker prefix for the selected qemu-user binary
141141
142-
>>> pwnlib.qemu.ld_prefix(arch='arm')
142+
>>> pwnlib.qemu.ld_prefix(arch='arm') # doctest: +SKIP
143143
'/etc/qemu-binfmt/arm'
144144
"""
145145
if context.os == 'baremetal':

‎pwnlib/util/lists.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def partition(lst, f, save_keys = False):
2525
2626
>>> partition([1,2,3,4,5], lambda x: x&1)
2727
[[1, 3, 5], [2, 4]]
28-
>>> partition([1,2,3,4,5], lambda x: x%3, save_keys=True)
29-
OrderedDict([(1, [1, 4]), (2, [2, 5]), (0, [3])])
28+
>>> partition([1,2,3,4,5], lambda x: x%3, save_keys=True) == collections.OrderedDict([(1, [1, 4]), (2, [2, 5]), (0, [3])])
29+
True
3030
"""
3131
d = collections.OrderedDict()
3232

‎pwnlib/util/safeeval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def _get_opcodes(codeobj):
2929
Extract the actual opcodes as a list from a code object
3030
3131
>>> c = compile("[1 + 2, (1,2)]", "", "eval")
32-
>>> _get_opcodes(c)
33-
[100, 100, 103, 83]
32+
>>> _get_opcodes(c) # doctest: +ELLIPSIS
33+
[...100, 100, 103, 83]
3434
"""
3535
import dis
3636
if hasattr(dis, 'get_instructions'):

‎travis/setup_avd_fast.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ set -ex
99
# - x86
1010
# - x86_64
1111
ANDROID_ABI='x86_64'
12-
ANDROIDV=android-24
12+
ANDROIDV=android-34
13+
export ANDROID_AVD_HOME="$HOME/.android/avd"
14+
mkdir -p "$ANDROID_AVD_HOME"
1315

1416
# Create our emulator Android Virtual Device (AVD)
1517
# --snapshot flag is deprecated, see bitrise-steplib/steps-create-android-emulator#18
16-
export PATH=$PATH:"$ANDROID_HOME"/cmdline-tools/latest/bin:"$ANDROID_HOME"/platform-tools
17-
yes | sdkmanager --sdk_root="$ANDROID_HOME" --install "system-images;$ANDROIDV;default;$ANDROID_ABI" "emulator" "platform-tools" "platforms;$ANDROIDV"
18+
export PATH=$PATH:"$ANDROID_HOME"/cmdline-tools/latest/bin:"$ANDROID_HOME"/platform-tools:"$ANDROID_HOME"/emulator
19+
yes | sdkmanager --sdk_root="$ANDROID_HOME" --install "system-images;$ANDROIDV;default;$ANDROID_ABI" "emulator" "platform-tools" # "platforms;$ANDROIDV"
1820
yes | sdkmanager --sdk_root="$ANDROID_HOME" --licenses
19-
echo no | avdmanager --silent create avd --name android-$ANDROID_ABI --force --package "system-images;$ANDROIDV;default;$ANDROID_ABI"
2021

21-
"$ANDROID_HOME"/emulator/emulator -avd android-$ANDROID_ABI -no-window -no-boot-anim -read-only -no-audio -no-window -no-snapshot -gpu off -accel off &
22+
echo no | avdmanager --verbose create avd --name android-$ANDROID_ABI --force --abi "default/$ANDROID_ABI" --package "system-images;$ANDROIDV;default;$ANDROID_ABI"
23+
emulator -avd android-$ANDROID_ABI -no-window -no-boot-anim -read-only -no-audio -no-window -no-snapshot -gpu off -accel off -no-metrics &
2224
adb wait-for-device
2325
adb shell id
2426
adb shell getprop

0 commit comments

Comments
 (0)
Please sign in to comment.