/usr/lib/python2.7/dist-packages/rekall/plugins/renderers/windows.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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | # 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 windows structures."""
from rekall import utils
from rekall.ui import text
from rekall.ui import json_renderer
from rekall.plugins.renderers import data_export
class EPROCESSDataExport(data_export.DataExportBaseObjectRenderer):
renders_type = "_EPROCESS"
def EncodeToJsonSafe(self, task, **_):
result = super(EPROCESSDataExport, self).EncodeToJsonSafe(task)
process_params = task.Peb.ProcessParameters
result["Cybox"] = dict(
type=u"ProcessObj:ProcessObjectType",
Name=task.name,
PID=task.pid,
Creation_Time=task.CreateTime,
Parent_PID=task.InheritedFromUniqueProcessId,
Image_Info=dict(
type=u"ProcessObj:ImageInfoType",
Path=process_params.ImagePathName,
Command_Line=process_params.CommandLine,
TrustedPath=task.FullPath,
File_Name=task.SeAuditProcessCreationInfo.ImageFileName.Name,
)
)
res = json_renderer.JsonObjectRenderer.EncodeToJsonSafe(self, result)
return res
def Summary(self, item, **_):
return "%s (%s)" % (item.get("Cybox", {}).get("Name", ""),
item.get("Cybox", {}).get("PID", ""))
class UNICODE_STRING_Text(text.TextObjectRenderer):
renders_type = "_UNICODE_STRING"
renderers = ["TextRenderer", "TestRenderer", "WideTextRenderer"]
def render_compact(self, target, width=None, **_):
return text.Cell(unicode(target), width=width)
class SID_Text(UNICODE_STRING_Text):
renders_type = "_SID"
class UNICODE_STRINGDataExport(data_export.DataExportBaseObjectRenderer):
renders_type = "_UNICODE_STRING"
def EncodeToJsonSafe(self, item, **_):
return unicode(item)
class STRINGDataExport(UNICODE_STRINGDataExport):
renders_type = "String"
def EncodeToJsonSafe(self, item, **_):
return utils.SmartStr(item)
class EPROCESS_TextObjectRenderer(text.TextObjectRenderer):
renders_type = "_EPROCESS"
renderers = ["TextRenderer", "TestRenderer"]
def __init__(self, *args, **options):
"""We make a sub table for rendering the _EPROCESS."""
self.name = options.pop("name", "_EPROCESS")
super(EPROCESS_TextObjectRenderer, self).__init__(*args, **options)
# pstree requests light output so we ovverride the style
self.output_style = options.pop("style", self.output_style)
if self.output_style == "full":
self.table = text.TextTable(
columns=[
dict(name=self.name,
formatstring="[addrpad]"),
dict(name="name", width=20),
dict(name="fullpath", width=60),
dict(name="pid", width=5, align="r"),
dict(name="ppid", width=5, align="r")],
renderer=self.renderer,
session=self.session)
else:
self.table = text.TextTable(
columns=[
dict(name=self.name,
formatstring="[addrpad]"),
dict(name="name", width=20),
dict(name="pid", width=5, align="r")],
renderer=self.renderer,
session=self.session)
def render_header(self, **options):
if self.output_style in ["full", "concise"]:
return self.table.render_header()
else:
result = text.Cell(self.name, width=40)
result.append_line("-" * result.width)
return result
def render_row(self, target, **options):
if self.output_style == "full":
return self.table.get_row(
target.obj_offset, target.name, target.FullPath, target.pid,
target.InheritedFromUniqueProcessId)
elif self.output_style == "concise":
return self.table.get_row(target.obj_offset, target.name,
target.pid)
else:
return text.Cell(u"%s %s (%d)" % (
self.format_address(target.obj_offset),
target.name, target.pid))
class EPROCESS_WideTextObjectRenderer(EPROCESS_TextObjectRenderer):
renders_type = "_EPROCESS"
renderers = ["WideTextRenderer"]
def render_row(self, target, **_):
return text.Cell(
self.formatter.format(u"{0:s} Pid: {1:s} (@{2:#x})",
target.name, target.pid, target))
class MMVAD_FLAGS_TextRenderer(text.TextObjectRenderer):
renders_type = ("_MMVAD_FLAGS", "_MMVAD_FLAGS2", "_MMSECTION_FLAGS")
renderers = ["TextRenderer", "TestRenderer"]
def render_compact(self, target, **_):
result = []
for name in sorted(target.members):
if name.endswith("Enum"):
continue
try:
attribute = getattr(target, name)
if attribute.v():
result.append(u"%s: %s" % (name, attribute))
except AttributeError:
pass
return text.Cell(", ".join(result))
|