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

Gallopsled / pwntools / 13475084749

22 Feb 2025 05:29PM UTC coverage: 70.912% (-0.1%) from 71.055%
13475084749

push

github

tesuji
change checksec=False on ELF class

There is no need to print checksec details every time. Most usecases
only need to view checksec once in a while.

Here is the `checksec=False` set before this patch:

```
> rg '\sELF\(' | rg checksec
pwnlib/libcdb.py:    local_libc = ELF(shell_path, checksec=False).libc
pwnlib/libcdb.py:    libc = ELF(filename, checksec=False)
pwnlib/libcdb.py:        >>> libc_path = ELF(which('ls'), checksec=False).libc.path
pwnlib/libcdb.py:    libc = ELF(libc_path, checksec=False)
pwnlib/elf/elf.py:                return ELF(lib, self._print_checksec)
pwnlib/elf/elf.py:        return ELF(exepath, checksec=False)
pwnlib/elf/elf.py:        return ELF(exepath, checksec=False)
pwnlib/commandline/libcdb.py:            exe = ELF(path, checksec=False)
pwnlib/commandline/checksec.py:            e = ELF(f)
pwnlib/data/templates/pwnup.mako:       ctx.binary = ELF(binary, checksec=False)
```

3600 of 6410 branches covered (56.16%)

10 of 19 new or added lines in 8 files covered. (52.63%)

29 existing lines in 4 files now uncovered.

12833 of 18097 relevant lines covered (70.91%)

0.71 hits per line

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

61.9
/pwnlib/commandline/elfpatch.py
1
from __future__ import absolute_import
1✔
2
from __future__ import division
1✔
3

4
import sys
1✔
5

6
import pwnlib.args
1✔
7
pwnlib.args.free_form = False
1✔
8

9
from pwn import *
1✔
10
from pwnlib.commandline import common
1✔
11

12
p = common.parser_commands.add_parser(
1✔
13
    'elfpatch',
14
    help = 'Patch an ELF file',
15
    description = 'Patch an ELF file'
16
)
17

18
p.add_argument('elf',help="File to patch")
1✔
19
p.add_argument('offset',help="Offset to patch in virtual address (hex encoded)")
1✔
20
p.add_argument('bytes',help='Bytes to patch (hex encoded)')
1✔
21

22

23
def main(a):
1✔
24
    if not a.offset.startswith('0x'):
×
25
        a.offset = '0x' + a.offset
×
26

27
    offset = int(a.offset, 16)
×
28
    bytes  = unhex(a.bytes)
×
29

NEW
30
    elf    = ELF(a.elf, checksec=False)
×
31
    elf.write(offset, bytes)
×
32
    getattr(sys.stdout, 'buffer', sys.stdout).write(elf.get_data())
×
33

34
if __name__ == '__main__':
1!
35
    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