Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.

Commit 59dc2ba

Browse files
committed
Fixed a bug in OSX.
Also updated more windows plugins to typed output. [email protected] Review URL: https://codereview.appspot.com/297350043 .
1 parent 5b036cd commit 59dc2ba

7 files changed

Lines changed: 85 additions & 106 deletions

File tree

rekall-core/rekall/obj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ def __iter__(self):
10221022
if not self.obj_vm.is_valid_address(self.obj_offset):
10231023
return
10241024

1025-
for position in xrange(0, self.count):
1025+
for position in utils.xrange(0, self.count):
10261026
# Since we often calculate array counts it is possible to
10271027
# calculate huge arrays. This will then spin here
10281028
# uncontrollably. We use max_count as a safety to break out

rekall-core/rekall/plugins/common/search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def collect(self):
176176
for producer in which.collect():
177177
# We know the producer plugin implements 'produce' because
178178
# 'which_plugin' guarantees it.
179+
self.session.logging.debug("Producing %s from producer %r",
180+
self.type_name, producer)
179181
for result in producer.produce():
180182
previous = results.get(result.indices)
181183
if previous:

rekall-core/rekall/plugins/overlays/darwin/darwin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,9 @@ def list_of_type(self, type, member):
628628
yield item
629629
if item.obj_offset in seen:
630630
return
631-
631+
seen.add(item.obj_offset)
632632
item = item.m(member).next.dereference_as(type)
633-
633+
634634

635635
class sockaddr_dl(obj.Struct):
636636
def __unicode__(self):

rekall-core/rekall/plugins/windows/handles.py

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,33 @@ class Handles(common.WinProcessFilter):
3030

3131
__name = "handles"
3232

33-
@classmethod
34-
def args(cls, parser):
35-
"""Declare the command line args we need."""
36-
super(Handles, cls).args(parser)
37-
parser.add_argument(
38-
"-t", "--object_types", type="ArrayStringParser",
39-
help="Types of objects to show.")
40-
parser.add_argument(
41-
"--named_only", type="Boolean",
42-
help="Output only handles with a name .")
43-
44-
def __init__(self, *args, **kwargs):
45-
"""Lists the handles for processes.
46-
47-
Args:
48-
object_types: Show these object types (An array of Object Types -
49-
for example: object_types=["Process", "File"]).
50-
silent: Suppress less meaningful results
51-
"""
52-
self.object_list = kwargs.pop("object_types", None)
53-
self.silent = kwargs.pop("silent", False)
54-
self.named_only = kwargs.pop("named_only", False)
55-
56-
super(Handles, self).__init__(*args, **kwargs)
33+
__args = [
34+
dict(name="object_types", type="ArrayStringParser",
35+
help="Types of objects to show."),
36+
dict(name="named_only", type="Boolean",
37+
help="Output only handles with a name ."),
38+
]
39+
40+
table_header = [
41+
dict(name="_OBJECT_HEADER", cname="offset_v", style="address"),
42+
dict(name="_EPROCESS", type="_EPROCESS", cname="_EPROCESS"),
43+
dict(name="Handle", cname="handle", style="address"),
44+
dict(name="Access", cname="access", style="address"),
45+
dict(name="Type", cname="obj_type", width=16),
46+
dict(name="Details", cname="details")
47+
]
5748

5849
def enumerate_handles(self, task):
5950
if task.ObjectTable.HandleTableList:
6051
for handle in task.ObjectTable.handles():
61-
name = ""
52+
name = u""
6253
object_type = handle.get_object_type(self.kernel_address_space)
6354

6455
if object_type == None:
6556
continue
6657

67-
if self.object_list and object_type not in self.object_list:
58+
if (self.plugin_args.object_types and
59+
object_type not in self.plugin_args.object_types):
6860
continue
6961

7062
elif object_type == "File":
@@ -86,41 +78,28 @@ def enumerate_handles(self, task):
8678
thrd_obj.Cid.UniqueProcess)
8779

8880
elif handle.NameInfo.Name == None:
89-
name = ""
81+
name = u""
9082
else:
9183
name = handle.NameInfo.Name
9284

93-
if not name and self.named_only:
85+
if not name and self.plugin_args.named_only:
9486
continue
9587

9688
yield handle, object_type, name
9789

98-
def render(self, renderer):
99-
renderer.table_header([("_OBJECT_HEADER", "offset_v", "[addrpad]"),
100-
dict(name="_EPROCESS", type="_EPROCESS",
101-
cname="_EPROCESS"),
102-
("Handle", "handle", "[addr]"),
103-
("Access", "access", "[addr]"),
104-
("Type", "obj_type", "16"),
105-
("Details", "details", "")])
106-
90+
def collect(self):
10791
for task in self.filter_processes():
10892
for count, (handle, object_type, name) in enumerate(
10993
self.enumerate_handles(task)):
11094

11195
self.session.report_progress("%s: %s handles" % (
11296
task.ImageFileName, count))
11397

114-
if self.silent:
115-
if len(utils.SmartUnicode(name).replace("'", "")) == 0:
116-
continue
117-
118-
renderer.table_row(
119-
handle,
120-
task,
121-
handle.HandleValue,
122-
handle.GrantedAccess,
123-
object_type, name)
98+
yield (handle,
99+
task,
100+
handle.HandleValue,
101+
handle.GrantedAccess,
102+
object_type, utils.SmartUnicode(name))
124103

125104

126105
class TestHandles(testlib.SimpleTestCase):

rekall-core/rekall/plugins/windows/modules.py

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121
#
2222

23-
import bisect
2423
import re
2524

26-
from rekall import obj
2725
from rekall import plugin
2826
from rekall import scan
27+
from rekall import utils
2928
from rekall.plugins.windows import common
3029

3130

@@ -34,25 +33,29 @@ class Modules(common.WindowsCommandPlugin):
3433

3534
__name = "modules"
3635

37-
@classmethod
38-
def args(cls, parser):
39-
"""Declare the command line args we need."""
40-
super(Modules, cls).args(parser)
41-
parser.add_argument("--name_regex",
42-
help="Filter module names by this regex.")
36+
__args = [
37+
dict(name="name_regex", type="RegEx",
38+
help="Filter module names by this regex.")
39+
]
4340

44-
def __init__(self, name_regex=None, **kwargs):
45-
"""List kernel modules by walking the PsLoadedModuleList."""
46-
super(Modules, self).__init__(**kwargs)
47-
self.name_regex = re.compile(name_regex or ".", re.I)
41+
table_header = [
42+
dict(name="_LDR_DATA_TABLE_ENTRY", cname="offset_v", style="address"),
43+
dict(name="Name", cname="file_name", width=20),
44+
dict(name='Base', cname="module_base", style="address"),
45+
dict(name='Size', cname="module_size", style="address"),
46+
dict(name='File', cname="path")
47+
]
4848

4949
def lsmod(self):
5050
""" A Generator for modules (uses _KPCR symbols) """
51-
for module in self.session.GetParameter("PsLoadedModuleList").list_of_type(
52-
"_LDR_DATA_TABLE_ENTRY", "InLoadOrderLinks"):
51+
for module in self.session.GetParameter(
52+
"PsLoadedModuleList").list_of_type(
53+
"_LDR_DATA_TABLE_ENTRY", "InLoadOrderLinks"):
5354

5455
# Skip modules which do not match.
55-
if not self.name_regex.search(str(module.FullDllName)):
56+
if (self.plugin_args.name_regex and
57+
not self.plugin_args.name_regex.search(
58+
utils.SmartUnicode(module.FullDllName))):
5659
continue
5760

5861
yield module
@@ -61,24 +64,15 @@ def addresses(self):
6164
"""Returns a list of module addresses."""
6265
return sorted(self.mod_lookup.keys())
6366

64-
def render(self, renderer):
67+
def collect(self):
6568
object_tree_plugin = self.session.plugins.object_tree()
6669

67-
renderer.table_header(
68-
[("_LDR_DATA_TABLE_ENTRY", "offset_v", "[addrpad]"),
69-
("Name", "file_name", "20"),
70-
('Base', "module_base", "[addrpad]"),
71-
('Size', "module_size", "[addr]"),
72-
('File', "path", "")
73-
])
74-
7570
for module in self.lsmod():
76-
renderer.table_row(
77-
module.obj_offset,
78-
module.BaseDllName,
79-
module.DllBase,
80-
module.SizeOfImage,
81-
object_tree_plugin.FileNameWithDrive(module.FullDllName.v()))
71+
yield (module,
72+
module.BaseDllName,
73+
module.DllBase,
74+
module.SizeOfImage,
75+
object_tree_plugin.FileNameWithDrive(module.FullDllName.v()))
8276

8377

8478
class RSDSScanner(scan.BaseScanner):
@@ -94,6 +88,13 @@ class ModVersions(Modules):
9488

9589
__name = "version_modules"
9690

91+
table_header = [
92+
dict(name="Offset (V)", cname="offset_v", style="address"),
93+
dict(name="Name", cname="file_name", width=20),
94+
dict(name='GUID/Version', cname="guid", width=33),
95+
dict(name="PDB", cname="pdb")
96+
]
97+
9798
def ScanVersions(self):
9899
pe_profile = self.session.LoadProfile("pe")
99100
scanner = RSDSScanner(address_space=self.kernel_address_space,
@@ -108,19 +109,12 @@ def ScanVersions(self):
108109
guid = "%s%x" % (rsds.GUID.AsString, rsds.Age)
109110
yield module, rsds, guid
110111

111-
def render(self, renderer):
112-
renderer.table_header(
113-
[("Offset (V)", "offset_v", "[addrpad]"),
114-
("Name", "file_name", "20"),
115-
('GUID/Version', "guid", "33"),
116-
("PDB", "pdb", "")])
117-
112+
def collect(self):
118113
for module, rsds, guid in self.ScanVersions():
119-
renderer.table_row(
120-
rsds,
121-
module.BaseDllName,
122-
guid,
123-
rsds.Filename)
114+
yield (rsds,
115+
module.BaseDllName,
116+
guid,
117+
rsds.Filename)
124118

125119

126120
class VersionScan(plugin.PhysicalASMixin, plugin.Command):
@@ -191,7 +185,14 @@ class UnloadedModules(common.WindowsCommandPlugin):
191185

192186
name = "unloaded_modules"
193187

194-
def render(self, renderer):
188+
table_header = [
189+
dict(name="Name", cname="name", width=20),
190+
dict(name="Start", cname="start", style="address"),
191+
dict(name="End", cname="end", style="address"),
192+
dict(name="Time", cname="time")
193+
]
194+
195+
def collect(self):
195196
unloaded_table = self.profile.get_constant_object(
196197
"MmUnloadedDrivers",
197198
target="Pointer",
@@ -210,21 +211,18 @@ def render(self, renderer):
210211
mistate = self.profile.get_constant_object(
211212
"MiState", target="_MI_SYSTEM_INFORMATION")
212213

213-
unloaded_table = mistate.UnloadedDrivers.dereference_as(
214+
unloaded_table = mistate.multi_m(
215+
"UnloadedDrivers",
216+
"Vs.UnloadedDrivers"
217+
).dereference_as(
214218
"Array",
215219
target_args=dict(
216220
target="_UNLOADED_DRIVERS",
217221
count=mistate.LastUnloadedDriver)
218222
)
219223

220-
221-
renderer.table_header([("Name", "name", "20"),
222-
("Start", "start", "[addrpad]"),
223-
("End", "end", "[addrpad]"),
224-
("Time", "time", "")])
225-
226224
for driver in unloaded_table:
227-
renderer.table_row(driver.Name,
228-
driver.StartAddress.v(),
229-
driver.EndAddress.v(),
230-
driver.CurrentTime)
225+
yield (driver.Name,
226+
driver.StartAddress.v(),
227+
driver.EndAddress.v(),
228+
driver.CurrentTime)

tools/installers/winbuild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def main():
144144

145145
print "Copy resources into the package."
146146
# Recent versions of Pyinstaller already copy resources they know about.
147-
# copy("rekall-core/resources/*", "dist/rekal/resources")
147+
copy("rekall-core/resources", "dist/rekal")
148148
copy("rekall-gui/manuskript", "dist/rekal")
149149
copy("rekall-gui/rekall_gui/plugins/webconsole",
150150
"dist/rekal/rekall_gui/plugins")

tools/pmem/pmem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License.
1616
#ifndef TOOLS_PMEM_PMEM_H_
1717
#define TOOLS_PMEM_PMEM_H_
1818

19-
#define PMEM_VERSION "2.1.post3";
19+
#define PMEM_VERSION "2.1.post4";
2020

2121
#include <aff4/libaff4.h>
2222
#include <aff4/aff4_imager_utils.h>

0 commit comments

Comments
 (0)