• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Gallopsled / pwntools / 11306887291

12 Oct 2024 03:48PM UTC coverage: 74.245% (-0.09%) from 74.334%
11306887291

push

github

web-flow
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

3678 of 6140 branches covered (59.9%)

20 of 34 new or added lines in 22 files covered. (58.82%)

36 existing lines in 4 files now uncovered.

12972 of 17472 relevant lines covered (74.24%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.9
/pwnlib/commandline/elfdiff.py
1
from __future__ import absolute_import
1✔
2
from __future__ import division
1✔
3

4
import shutil
1✔
5
from argparse import ArgumentParser
1✔
6
from subprocess import CalledProcessError
1✔
7
from subprocess import check_output
1✔
8
from tempfile import NamedTemporaryFile
1✔
9

10
import pwnlib.args
1✔
11
pwnlib.args.free_form = False
1✔
12

13
from pwn import *
1✔
14
from pwnlib.commandline import common
1✔
15

16

17
def dump(objdump, path):
1✔
18
    n = NamedTemporaryFile(delete=False)
×
19
    o = check_output([objdump,'-d','-x','-s',path])
×
20
    n.write(o)
×
21
    n.flush()
×
22
    return n.name
×
23

24
def diff(a,b):
1✔
25
    try: return check_output(['diff',a,b], universal_newlines=True)
×
26
    except CalledProcessError as e:
×
27
        return e.output
×
28

29
p = common.parser_commands.add_parser(
1✔
30
    'elfdiff',
31
    help = 'Compare two ELF files',
32
    description = 'Compare two ELF files'
33
)
34

35
p.add_argument('a')
1✔
36
p.add_argument('b')
1✔
37

38
def main(a):
1✔
39
    with context.silent:
×
40
        x = ELF(a.a)
×
41
        y = ELF(a.b)
×
42

43
    if x.arch != y.arch:
×
44
        log.error("Architectures are not the same: %s vs %s" % (x.arch, y.arch))
×
45

46
    context.arch = x.arch
×
47

48
    objdump = pwnlib.asm.which_binutils('objdump')
×
49

50
    tmp = NamedTemporaryFile()
×
51
    name = tmp.name
×
52

53
    shutil.copy(x.path, name)
×
54
    x = dump(objdump, name)
×
55

56
    shutil.copy(y.path, name)
×
57
    y = dump(objdump, name)
×
58

59
    print(diff(x, y))
×
60

61
if __name__ == '__main__':
1!
NEW
62
    pwnlib.commandline.common.main(__file__, main)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc