• 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/phd.py
1
#!/usr/bin/env python2
UNCOV
2
from __future__ import absolute_import
×
UNCOV
3
from __future__ import division
×
4

UNCOV
5
import argparse
×
UNCOV
6
import os
×
UNCOV
7
import signal
×
UNCOV
8
import sys
×
UNCOV
9
import io
×
10

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

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

UNCOV
17
parser = common.parser_commands.add_parser(
×
18
    'phd',
19
    help = 'Pretty hex dump',
20
    description = 'Pretty hex dump'
21
)
22

UNCOV
23
parser.add_argument(
×
24
    'file',
25
    metavar='file',
26
    nargs='?',
27
    help='File to hexdump.  Reads from stdin if missing.',
28
    type=argparse.FileType('rb'),
29
    default=getattr(sys.stdin, 'buffer', sys.stdin)
30
)
31

UNCOV
32
parser.add_argument(
×
33
    "-w", "--width",
34
    help="Number of bytes per line.",
35
    default='16',
36
)
37

UNCOV
38
parser.add_argument(
×
39
    "-l", "--highlight",
40
    help="Byte to highlight.",
41
    nargs="*",
42
)
43

UNCOV
44
parser.add_argument(
×
45
    "-s", "--skip",
46
    help="Skip this many initial bytes.",
47
    default='0',
48
)
49

UNCOV
50
parser.add_argument(
×
51
    "-c", "--count",
52
    help="Only show this many bytes.",
53
    default='-1',
54
)
55

UNCOV
56
parser.add_argument(
×
57
    "-o", "--offset",
58
    help="Addresses in left hand column starts at this address.",
59
    default='0',
60
)
61

UNCOV
62
parser.add_argument(
×
63
    "--color",
64
    nargs='?',
65
    help="Colorize the output.  When 'auto' output is colorized exactly when stdout is a TTY.  Default is 'auto'.",
66
    choices = ('always', 'never', 'auto'),
67
    default='auto',
68
)
69

UNCOV
70
def asint(s):
×
UNCOV
71
    if   s.startswith('0x'):
×
UNCOV
72
        return int(s, 16)
×
UNCOV
73
    elif s.startswith('0'):
×
UNCOV
74
        return int(s, 8)
×
75
    else:
UNCOV
76
        return int(s, 10)
×
77

UNCOV
78
def main(args):
×
UNCOV
79
    infile = args.file
×
UNCOV
80
    width  = asint(args.width)
×
UNCOV
81
    skip   = asint(args.skip)
×
UNCOV
82
    count  = asint(args.count)
×
UNCOV
83
    offset = asint(args.offset)
×
84

85
    # if `--color` has no argument it is `None`
UNCOV
86
    color = args.color or 'always'
×
UNCOV
87
    text.when = color
×
88

UNCOV
89
    if skip:
×
UNCOV
90
        try:
×
UNCOV
91
            infile.seek(skip, os.SEEK_CUR)
×
UNCOV
92
        except IOError:
×
UNCOV
93
            infile.read(skip)
×
94

UNCOV
95
    if count != -1:
×
UNCOV
96
        infile = io.BytesIO(infile.read(count))
×
97

UNCOV
98
    hl = []
×
UNCOV
99
    if args.highlight:
×
UNCOV
100
        for hs in args.highlight:
×
UNCOV
101
            for h in hs.split(','):
×
UNCOV
102
                hl.append(asint(h))
×
103

UNCOV
104
    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
×
105

UNCOV
106
    try:
×
UNCOV
107
        for line in hexdump_iter(infile, width, highlight = hl, begin = offset + skip):
×
108
            print(line)
×
109
    except (KeyboardInterrupt, IOError):
×
UNCOV
110
        pass
×
111

UNCOV
112
if __name__ == '__main__':
×
UNCOV
113
    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