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

Gallopsled / pwntools / 1

16 Jun 2020 04:28AM UTC coverage: 0.0% (-69.4%) from 69.405%
1

push

github

heapcrash
Re-enable UI tests in Github Actions

I suspect this will not work because of curses failing to initialize in GHA

0 of 15570 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
2
from __future__ import absolute_import
×
3
from __future__ import division
×
4
from __future__ import print_function
×
5

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

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

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

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

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

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

37

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

46

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

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

61

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

73

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

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

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

90
            print(o,b,i)
×
91
        return
×
92

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

95
if __name__ == '__main__':
×
96
    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