This file is indexed.

/usr/lib/python2.7/dist-packages/rekall/plugins/windows/taskmods.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Rekall Memory Forensics
# Copyright (C) 2007-2011 Volatile Systems
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Additional Authors:
# Michael Cohen <scudette@users.sourceforge.net>
# Mike Auty <mike.auty@gmail.com>
#
# 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
#

# pylint: disable=protected-access

from rekall import testlib
from rekall import utils

from rekall.plugins.common import memmap
from rekall.plugins.windows import common


class WinPsList(common.WinProcessFilter):
    """List processes for windows."""

    __name = "pslist"

    eprocess = None

    table_header = [
        dict(type="_EPROCESS", name="_EPROCESS"),
        dict(name="ppid", width=6, align="r"),
        dict(name="thread_count", width=6, align="r"),
        dict(name="handle_count", width=8, align="r"),
        dict(name="session_id", width=6, align="r"),
        dict(name="wow64", width=6),
        dict(name="process_create_time", width=24),
        dict(name="process_exit_time", width=24)
    ]

    def column_types(self):
        result = self._row(self.session.profile._EPROCESS())
        result["handle_count"] = result["ppid"]
        result["session_id"] = result["ppid"]

        return result

    def _row(self, task):
        return dict(_EPROCESS=task,
                    ppid=task.InheritedFromUniqueProcessId,
                    thread_count=task.ActiveThreads,
                    handle_count=task.ObjectTable.m("HandleCount"),
                    session_id=task.SessionId,
                    wow64=task.IsWow64,
                    process_create_time=task.CreateTime,
                    process_exit_time=task.ExitTime)

    def collect(self):
        for task in self.filter_processes():
            yield self._row(task)


class WinDllList(common.WinProcessFilter):
    """Prints a list of dll modules mapped into each process."""

    __name = "dlllist"

    table_header = [
        dict(name="divider", type="Divider"),
        dict(name="_EPROCESS", hidden=True),
        dict(name="base", style="address"),
        dict(name="size", style="address"),
        dict(name="reason", width=30),
        dict(name="dll_path"),
    ]

    def collect(self):
        for task in self.filter_processes():
            pid = task.UniqueProcessId

            divider = "{0} pid: {1:6}\n".format(task.ImageFileName, pid)

            if task.Peb:
                divider += u"Command line : {0}\n".format(
                    task.Peb.ProcessParameters.CommandLine)

                divider += u"{0}\n\n".format(task.Peb.CSDVersion)
                yield dict(divider=divider)

                for m in task.get_load_modules():
                    yield dict(base=m.DllBase,
                               size=m.SizeOfImage,
                               reason=m.LoadReason,
                               dll_path=m.FullDllName,
                               _EPROCESS=task)
            else:
                yield dict(divider="Unable to read PEB for task.\n")


class WinMemMap(memmap.MemmapMixIn, common.WinProcessFilter):
    """Calculates the memory regions mapped by a process."""
    __name = "memmap"

    def _get_highest_user_address(self):
        return self.profile.get_constant_object(
            "MmHighestUserAddress", "Pointer").v()


class Threads(common.WinProcessFilter):
    """Enumerate threads."""
    name = "threads"

    table_header = [
        dict(name="_ETHREAD", style="address"),
        dict(name="pid", align="r", width=6),
        dict(name="tid", align="r", width=6),
        dict(name="start", style="address"),
        dict(name="start_symbol", width=30),
        dict(name="Process", width=16),
        dict(name="win32_start", style="address"),
        dict(name="win32_start_symb")
    ]

    def collect(self):
        cc = self.session.plugins.cc()
        with cc:
            for task in self.filter_processes():
                # Resolve names in the process context.
                cc.SwitchProcessContext(process=task)

                for thread in task.ThreadListHead.list_of_type(
                        "_ETHREAD", "ThreadListEntry"):

                    yield dict(_ETHREAD=thread,
                               pid=thread.Cid.UniqueProcess,
                               tid=thread.Cid.UniqueThread,
                               start=thread.StartAddress,
                               start_symbol=utils.FormattedAddress(
                                   self.session.address_resolver,
                                   thread.StartAddress),
                               Process=task.ImageFileName,
                               win32_start=thread.Win32StartAddress,
                               win32_start_symb=utils.FormattedAddress(
                                   self.session.address_resolver,
                                   thread.Win32StartAddress))


class WinMemDump(memmap.MemDumpMixin, common.WinProcessFilter):
    """Dump windows processes."""


class TestWinMemDump(testlib.HashChecker):
    """Test the pslist module."""

    PARAMETERS = dict(
        commandline="memdump %(pids)s --dump_dir %(tempdir)s",
        pid=2624)


class TestMemmap(testlib.SimpleTestCase):
    """Test the pslist module."""

    PARAMETERS = dict(
        commandline="memmap %(pids)s",
        pid=2624)


class TestMemmapCoalesce(testlib.SimpleTestCase):
    """Make sure that memmaps are coalesced properly."""

    PARAMETERS = dict(commandline="memmap %(pids)s --coalesce",
                      pid=2624)