1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """The plugins in this module are mainly used to visually test renderers."""
20
21 __author__ = "Adam Sindelar <adamsh@google.com>"
22
23 import itertools
24
25 from rekall import plugin
26 from rekall import algo
27 from rekall_lib import utils
28
29 from rekall.plugins.renderers import visual_aides
30
31
33 """Renders Bessy the cow and some beer.
34
35 This is a text renderer stress-test. It uses multiple features at the
36 same time:
37
38 - Multiple coloring rules per line (this was a doozy).
39 - Two columns with colors next to each other.
40 - Text with its own newlines isn't rewrapped.
41 - It still wraps if it overflows the cell.
42 - Bovine readiness and international spirit.
43 """
44 __name = "moo"
45
47 renderer.table_header([
48 dict(name="Dogma", width=35, style="full"),
49 dict(name="Bessy", width=65, type="bool", style="cow"),
50 dict(name="Pilsner", width=50, style="full"),
51 dict(name="Nowrap", width=10, nowrap=True)])
52
53 fixtures = self.session.LoadProfile("tests/fixtures")
54 beer = fixtures.data["ascii_art"]["beer"]
55 phys_map = fixtures.data["fixtures"]["phys_map"]
56
57 renderer.table_row(
58 ("This is a renderer stress-test. The flags should have correct"
59 " colors, the beer should be yellow and the cell on the left"
60 " should not bleed into the cell on the right.\n"
61 "This is a really "
62 "long column of text with its own newlines in it!\n"
63 "This bovine experience has been brought to you by Rekall."),
64 True,
65 utils.AttributedString("\n".join(beer["ascii"]),
66 beer["highlights"]),
67 ("This is a fairly long line that shouldn't get wrapped.\n"
68 "The same row has another line that shouldn't get wrapped."))
69
70 renderer.section("Heatmap test:")
71 cells = []
72 for digit in itertools.islice(algo.EulersDecimals(), 0xff):
73 cells.append(dict(heat=float(digit + 1) * .1, value=digit))
74
75 randomized = visual_aides.Heatmap(
76 caption="Offset (p)",
77
78
79 column_headers=["%0.2x" % x for x in xrange(0, 0xff, 0x10)],
80 row_headers=["0x%0.6x" % x for x
81 in xrange(0x0, 0xfffff, 0x10000)],
82 cells=cells,
83 greyscale=False)
84
85 gradual = visual_aides.Heatmap(
86 caption="Offset (v)",
87 column_headers=["%0.2x" % x for x in xrange(0, 0xff, 0x10)],
88 row_headers=["0x%0.6x" % x for x
89 in xrange(0x0, 0xfffff, 0x10000)],
90 cells=[dict(value="%x" % x, heat=x / 255.0) for x in xrange(256)],
91 greyscale=False)
92
93 ranges_legend = visual_aides.MapLegend(phys_map["ranges_legend"])
94
95 ranges = visual_aides.RunBasedMap(
96 caption="Offset (p)",
97 legend=ranges_legend,
98 runs=phys_map["runs"])
99
100 renderer.table_header([dict(name="Random Heatmap", style="full",
101 width=60, align="c"),
102 dict(name="Gradual Heatmap", style="full",
103 width=60, align="c"),
104 dict(name="Legend", style="full",
105 orientation="horizontal")])
106 renderer.table_row(randomized, gradual, visual_aides.HeatmapLegend())
107
108 renderer.table_header([dict(name="Greyscale Random", style="full",
109 width=60, align="c"),
110 dict(name="Memory Ranges", style="full",
111 width=80, align="c"),
112 dict(name="Ranges Legend", style="full",
113 width=30, orientation="vertical")])
114
115 randomized.greyscale = True
116 renderer.table_row(randomized, ranges, ranges_legend)
117