1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """
20 @author: Andrew Case
21 @license: GNU General Public License 2.0 or later
22 @contact: atcuno@gmail.com
23 @organization: Digital Forensics Solutions
24 """
25 from rekall import testlib
26 from rekall_lib import utils
27 from rekall.plugins import core
28 from rekall.plugins.addrspaces import intel
29 from rekall.plugins.common import pfn
30 from rekall.plugins.linux import common
31
32
34 """Gathers process maps for linux."""
35
36 __name = "maps"
37
38 table_header = [
39 dict(name="divider", type="Divider"),
40 dict(name="task", hidden=True),
41 dict(name="start", style="address"),
42 dict(name="end", style="address"),
43 dict(name="flags", width=6),
44 dict(name="pgoff", style="address"),
45 dict(name="major", width=6),
46 dict(name="minor", width=6),
47 dict(name="inode", width=13),
48 dict(name="file_path"),
49 ]
50
51
53 for task in self.filter_processes():
54 if not task.mm:
55 continue
56
57 yield dict(divider="Proc %s (%s)" % (task.name, task.pid))
58
59 for vma in task.mm.mmap.walk_list("vm_next"):
60 if vma.vm_file:
61 inode = vma.vm_file.dentry.d_inode
62 major, minor = inode.i_sb.major, inode.i_sb.minor
63 ino = inode.i_ino
64 pgoff = vma.vm_pgoff << 12
65 fname = task.get_path(vma.vm_file)
66 else:
67 (major, minor, ino, pgoff) = [0] * 4
68
69 if (vma.vm_start <= task.mm.start_brk and
70 vma.vm_end >= task.mm.brk):
71 fname = "[heap]"
72 elif (vma.vm_start <= task.mm.start_stack and
73 vma.vm_end >= task.mm.start_stack):
74 fname = "[stack]"
75 else:
76 fname = ""
77
78 yield dict(task=task,
79 start=vma.vm_start,
80 end=vma.vm_end,
81 flags=vma.vm_flags,
82 pgoff=pgoff,
83 major=major,
84 minor=minor,
85 inode=ino,
86 file_path=fname)
87
88
94
95
96 -class LinVadDump(core.DirectoryDumperMixin, common.LinProcessFilter):
97 """Dump the VMA memory for a process."""
98
99 __name = "vaddump"
100
102 for task in self.filter_processes():
103 if not task.mm:
104 continue
105
106 renderer.format("Pid: {0:6}\n", task.pid)
107
108
109 task_space = task.get_process_address_space()
110 name = task.comm
111
112 for vma in task.mm.mmap.walk_list("vm_next"):
113 if not vma.vm_file:
114 continue
115
116 filename = "{0}.{1}.{2:08x}-{3:08x}.dmp".format(
117 name, task.pid, vma.vm_start, vma.vm_end)
118
119 renderer.format(u"Writing {0}, pid {1} to {2}\n",
120 task.comm, task.pid, filename)
121
122 with renderer.open(directory=self.dump_dir,
123 filename=filename,
124 mode='wb') as fd:
125 self.CopyToFile(task_space, vma.vm_start, vma.vm_end, fd)
126
127
129 mode = "mode_linux_memory"
130
131 PARAMETERS = dict(
132 commandline="vaddump --proc_regex %(proc_name)s --dump_dir %(tempdir)s",
133 proc_name="bash"
134 )
135
136
137
138 -class LinuxVADMap(pfn.VADMapMixin, common.LinProcessFilter):
139 """Inspect each page in the VAD and report its status.
140
141 This allows us to see the address translation status of each page in the
142 VAD.
143 """
144
156
176