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

Gallopsled / pwntools / 1

28 Jan 2022 10:58AM UTC coverage: 0.0% (-73.8%) from 73.823%
1

push

github

web-flow
Fix CI after Groovy Gorilla went away for libc unstrip test (#2025)

* Fix CI after Groovy Gorilla went away for libc unstrip test

Build elfutils 0.181 from source since we can't use builds
from a newer ubuntu version anymore.

* Install python wheels in CI

0 of 1 new or added line in 1 file covered. (0.0%)

13713 existing lines in 142 files now uncovered.

0 of 16559 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/pwnlib/commandline/disasm.py
1
#!/usr/bin/env python2
UNCOV
2
from __future__ import absolute_import
×
UNCOV
3
from __future__ import division
×
UNCOV
4
from __future__ import print_function
×
5

UNCOV
6
import argparse
×
UNCOV
7
import string
×
UNCOV
8
import sys
×
9

UNCOV
10
import pwnlib.args
×
UNCOV
11
pwnlib.args.free_form = False
×
12

UNCOV
13
from pwn import *
×
UNCOV
14
from pwnlib.commandline import common
×
15

UNCOV
16
parser = common.parser_commands.add_parser(
×
17
    'disasm',
18
    help = 'Disassemble bytes into text format',
19
    description = 'Disassemble bytes into text format'
20
)
21

UNCOV
22
parser.add_argument(
×
23
    'hex',
24
    metavar = 'hex',
25
    nargs = '*',
26
    help = 'Hex-string to disassemble. If none are supplied, then it uses stdin in non-hex mode.'
27
)
28

UNCOV
29
parser.add_argument(
×
30
    '-c', '--context',
31
    metavar = 'arch_or_os',
32
    action = 'append',
33
    type   = common.context_arg,
34
    choices = common.choices,
35
    help = 'The os/architecture/endianness/bits the shellcode will run in (default: linux/i386), choose from: %s' % common.choices,
36
)
37

38

UNCOV
39
parser.add_argument(
×
40
    "-a","--address",
41
    metavar='address',
42
    help="Base address",
43
    type=str,
44
    default='0'
45
)
46

47

UNCOV
48
parser.add_argument(
×
49
    '--color',
50
    help="Color output",
51
    action='store_true',
52
    default=sys.stdout.isatty()
53
)
54

UNCOV
55
parser.add_argument(
×
56
    '--no-color',
57
    help="Disable color output",
58
    action='store_false',
59
    dest='color'
60
)
61

62

UNCOV
63
def main(args):
×
UNCOV
64
    if len(args.hex) > 0:
×
UNCOV
65
        dat = ''.join(args.hex).encode('utf-8', 'surrogateescape')
×
UNCOV
66
        dat = dat.translate(None, string.whitespace.encode('ascii'))
×
UNCOV
67
        if not set(string.hexdigits.encode('ascii')) >= set(dat):
×
68
            print("This is not a hex string")
×
69
            exit(-1)
×
UNCOV
70
        dat = unhex(dat)
×
71
    else:
72
        dat = getattr(sys.stdin, 'buffer', sys.stdin).read()
×
73

74

UNCOV
75
    if args.color:
×
UNCOV
76
        from pygments import highlight
×
UNCOV
77
        from pygments.formatters import TerminalFormatter
×
UNCOV
78
        from pwnlib.lexer import PwntoolsLexer
×
79

UNCOV
80
        offsets = disasm(dat, vma=safeeval.const(args.address), instructions=False, byte=False)
×
UNCOV
81
        bytes   = disasm(dat, vma=safeeval.const(args.address), instructions=False, offset=False)
×
UNCOV
82
        instrs  = disasm(dat, vma=safeeval.const(args.address), byte=False, offset=False)
×
83
        # instrs  = highlight(instrs, PwntoolsLexer(), TerminalFormatter())
84

UNCOV
85
        for o,b,i in zip(*map(str.splitlines, (offsets, bytes, instrs))):
×
UNCOV
86
            b = b.replace('00', text.red('00'))
×
UNCOV
87
            b = b.replace('0a', text.red('0a'))
×
UNCOV
88
            i = highlight(i.strip(), PwntoolsLexer(), TerminalFormatter()).strip()
×
89
            i = i.replace(',',', ')
×
90

UNCOV
91
            print(o,b,i)
×
UNCOV
92
        return
×
93

UNCOV
94
    print(disasm(dat, vma=safeeval.const(args.address)))
×
95

UNCOV
96
if __name__ == '__main__':
×
UNCOV
97
    pwnlib.commandline.common.main(__file__)
×
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