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 from rekall import testlib
27 from rekall_lib import utils
28
29 from rekall.plugins.common import memmap
30 from rekall.plugins.windows import common
31
32
34 """List processes for windows."""
35
36 __name = "pslist"
37
38 eprocess = None
39
40 table_header = [
41 dict(type="_EPROCESS", name="_EPROCESS"),
42 dict(name="ppid", width=6, align="r"),
43 dict(name="thread_count", width=6, align="r"),
44 dict(name="handle_count", width=8, align="r"),
45 dict(name="session_id", width=6, align="r"),
46 dict(name="wow64", width=6),
47 dict(name="process_create_time", width=24),
48 dict(name="process_exit_time", width=24)
49 ]
50
52 result = self._row(self.session.profile._EPROCESS())
53 result["handle_count"] = result["ppid"]
54 result["session_id"] = result["ppid"]
55
56 return result
57
58 - def _row(self, task):
59 return dict(_EPROCESS=task,
60 ppid=task.InheritedFromUniqueProcessId,
61 thread_count=task.ActiveThreads,
62 handle_count=task.ObjectTable.m("HandleCount"),
63 session_id=task.SessionId,
64 wow64=task.IsWow64,
65 process_create_time=task.CreateTime,
66 process_exit_time=task.ExitTime)
67
71
72
74 """Prints a list of dll modules mapped into each process."""
75
76 __name = "dlllist"
77
78 table_header = [
79 dict(name="divider", type="Divider"),
80 dict(name="_EPROCESS", hidden=True),
81 dict(name="base", style="address"),
82 dict(name="size", style="address"),
83 dict(name="reason", width=30),
84 dict(name="dll_path"),
85 ]
86
88 for task in self.filter_processes():
89 pid = task.UniqueProcessId
90
91 divider = "{0} pid: {1:6}\n".format(task.ImageFileName, pid)
92
93 if task.Peb:
94 divider += u"Command line : {0}\n".format(
95 task.Peb.ProcessParameters.CommandLine)
96
97 divider += u"{0}\n\n".format(task.Peb.CSDVersion)
98 yield dict(divider=divider)
99
100 for m in task.get_load_modules():
101 yield dict(base=m.DllBase,
102 size=m.SizeOfImage,
103 reason=m.LoadReason,
104 dll_path=m.FullDllName,
105 _EPROCESS=task)
106 else:
107 yield dict(divider="Unable to read PEB for task.\n")
108
109
110 -class WinMemMap(memmap.MemmapMixIn, common.WinProcessFilter):
111 """Calculates the memory regions mapped by a process."""
112 __name = "memmap"
113
117
118
119 -class Threads(common.WinProcessFilter):
120 """Enumerate threads."""
121 name = "threads"
122
123 table_header = [
124 dict(name="_ETHREAD", style="address"),
125 dict(name="pid", align="r", width=6),
126 dict(name="tid", align="r", width=6),
127 dict(name="start", style="address"),
128 dict(name="start_symbol", width=30),
129 dict(name="Process", width=16),
130 dict(name="win32_start", style="address"),
131 dict(name="win32_start_symb")
132 ]
133
135 cc = self.session.plugins.cc()
136 with cc:
137 for task in self.filter_processes():
138
139 cc.SwitchProcessContext(process=task)
140
141 for thread in task.ThreadListHead.list_of_type(
142 "_ETHREAD", "ThreadListEntry"):
143
144 yield dict(_ETHREAD=thread,
145 pid=thread.Cid.UniqueProcess,
146 tid=thread.Cid.UniqueThread,
147 start=thread.StartAddress,
148 start_symbol=utils.FormattedAddress(
149 self.session.address_resolver,
150 thread.StartAddress),
151 Process=task.ImageFileName,
152 win32_start=thread.Win32StartAddress,
153 win32_start_symb=utils.FormattedAddress(
154 self.session.address_resolver,
155 thread.Win32StartAddress,
156 ))
157
158
159 -class WinMemDump(memmap.MemDumpMixin, common.WinProcessFilter):
160 """Dump windows processes."""
161
162
164 """Test the pslist module."""
165
166 PARAMETERS = dict(
167 commandline="memdump %(pids)s --dump_dir %(tempdir)s",
168 pid=2624)
169
170
177
178
180 """Make sure that memmaps are coalesced properly."""
181
182 PARAMETERS = dict(commandline="memmap %(pids)s --coalesce",
183 pid=2624)
184