-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
hex.py
27 lines (18 loc) · 777 Bytes
/
hex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from . import base
from mitmproxy.utils import strutils
class ViewHexDump(base.View):
name = "Hex Dump"
@staticmethod
def _format(data):
for offset, hexa, s in strutils.hexdump(data):
yield [("offset", offset + " "), ("text", hexa + " "), ("text", s)]
def __call__(self, data, **metadata):
return "Hexdump", self._format(data)
def render_priority(self, data: bytes, **metadata) -> float:
return 0.2 * strutils.is_mostly_bin(data)
class ViewHexStream(base.View):
name = "Raw Hex Stream"
def __call__(self, data, **metadata):
return "Raw Hex Stream", base.format_text(data.hex())
def render_priority(self, data: bytes, **metadata) -> float:
return 0.15 * strutils.is_mostly_bin(data)