This file is indexed.

/usr/lib/python2.7/dist-packages/rekall/plugins/renderers/virtualization.py is in python-rekall-core 1.6.0+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Rekall Memory Forensics
# Copyright 2014 Google Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

"""This module implements renderers specific to virtualization."""

from rekall import utils
from rekall.ui import renderer
from rekall.ui import text
from rekall.ui import json_renderer
from rekall.plugins import hypervisors
from rekall.plugins.renderers import data_export
from rekall.plugins.renderers import json_storage


class VTxPagedMemoryObjectRenderer(
    json_storage.BaseAddressSpaceObjectRenderer):
    renders_type = "VTxPagedMemory"

    def GetState(self, item, **options):
        state = super(VTxPagedMemoryObjectRenderer, self).GetState(
            item, **options)
        state["dtb"] = item.dtb
        state["ept"] = item.ept

        return state

class VirtualMachine_DataExportRenderer(data_export.DataExportObjectRenderer):
    renders_type = "VirtualMachine"

    def EncodeToJsonSafe(self, vm, **options):
        result = super(VirtualMachine_DataExportRenderer,
                       self).EncodeToJsonSafe(vm)
        result["ept"] = vm.ept
        result["host_rip"] = vm.host_rip
        result["name"] = vm.name
        result["_quick"] = options.pop("quick", False)
        result["guest_arch"] = vm.guest_arch
        result["num_cores"] = vm.num_cores
        # The VMCSs are stored in a set.
        result["vmcss"] = list(vm.vmcss)
        result["virtual_machines"] = list(vm.virtual_machines)

        return json_renderer.JsonObjectRenderer.EncodeToJsonSafe(self, result)

    def Summary(self, vm, **_):
        if vm.get("_quick"):
            return "VM [?? vCORE(s), {1}]".format(vm.get("guest_arch"))
        else:
            return "VM [{0} vCORE(s), {1}]".format(
                vm.get("num_cores"), vm.get("guest_arch"))


class VirtualMachine_JsonObjectRenderer(json_renderer.StateBasedObjectRenderer):
    renders_type = "VirtualMachine"

    def DecodeFromJsonSafe(self, state, options):
        super_obj = super(VirtualMachine_JsonObjectRenderer, self)
        state = super_obj.DecodeFromJsonSafe(state, options)

        vm = hypervisors.VirtualMachine(host_rip=state.get("host_rip"),
                                        ept=state.get("ept"),
                                        parent=state.get("parent"),
                                        name=state.get("name"),
                                        session=state.get("base_session"))

        vm.vmcss = state.get("vmcss", [])
        vm.vmcs_validation = state.get("vmcs_validation", {})

        # Decode each nested VirtualMachine
        for vm in state.get("virtual_machines", []):
            unserialized_vm = self.DecodeFromJsonSafe(vm, options)
            unserialized_vm.parent = vm
            vm.virtual_machines.update([unserialized_vm])
        return vm

    def GetState(self, item, **options):
        state = super(VirtualMachine_JsonObjectRenderer, self).GetState(
            item, **options)
        state["_quick"] = options.pop("quick", False)
        state["ept"] = item.ept
        state["host_rip"] = item.host_rip
        state["name"] = item.name
        state["base_session"] = item.base_session
        # The validation state is stored as a dict of vmcs:state pairs.
        state["vmcs_validation"] = item.vmcs_validation
        # The VMCSs are stored in a set.
        state["vmcss"] = list(item.vmcss)
        state["virtual_machines"] = list(item.virtual_machines)
        return state


class VirtualizationNode_TextObjectRenderer(text.TextObjectRenderer):
    """Virtualization nodes can be Hypervisors, VirtualMachine or VMCS."""
    renders_type = "VirtualizationNode"
    renderers = ["TextRenderer", "WebConsoleRenderer", "TestRenderer"]

    def __init__(self, *args, **options):
        self.quick = options.pop("quick", False)
        super(VirtualizationNode_TextObjectRenderer, self).__init__(
            *args, **options)

        self.table = text.TextTable(
            columns=[
                dict(name="description"),
                dict(name="name", width=20),
                dict(name="valid", type="bool"),
                dict(name="ept")],
            renderer=self.renderer,
            session=self.session)

    def render_header(self, **options):
        result = text.Cell("Description", width=40)
        result.append_line("-" * result.width)

        return result

    def render_row(self, target, **options):
        if isinstance(target, hypervisors.VirtualMachine):
            return text.Cell("VM [{0:s} vCORE(s), {1:s}]".format(
                (self.quick and "??") or str(target.num_cores),
                target.guest_arch))
        elif "VMCS" in target.__class__.__name__:
            return text.Cell("VMCS @ {0:08X} vCORE {1:x}".format(
                target.obj_offset, target.m("VPID")))