1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """
21 @author: Andrew Case
22 @license: GNU General Public License 2.0
23 @contact: atcuno@gmail.com
24 @organization:
25 """
26
27 from rekall.plugins.linux import common
28
29
31 """Shows the parent/child relationship between processes.
32
33 This plugin prints a parent/child relationship tree by walking the
34 task_struct.children and task_struct.sibling members.
35 """
36 __name = "pstree"
37
39 renderer.table_header([("Pid", "pid", ">6"),
40 ("Ppid", "ppid", ">6"),
41 ("Uid", "uid", ">6"),
42 ("", "depth", "0"),
43 ("Name", "name", "<30"),
44 ])
45
46 root_task = self.profile.get_constant_object(
47 "init_task", target="task_struct")
48
49 for task, level in self.recurse_task(root_task, 0):
50 renderer.table_row(
51 task.pid, task.parent.pid, task.uid,
52 "." * level, task.commandline)
53
55 """Yields all the children of this task."""
56 yield task, level
57
58 for child in task.children.list_of_type("task_struct", "sibling"):
59 for subtask, sublevel in self.recurse_task(child, level + 1):
60 yield subtask, sublevel
61