1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """This module defines interpolators for the common OSs.
20
21 Globs and Artifacts may expand interpolations from the KnowledgeBase. This
22 module provides a live, on demand, KnowledgeBase.
23 """
24 import os
25 import re
26 import platform
27
28 from rekall import kb
29 from rekall_lib import registry
39
42 @registry.memoize
44 homedirs = []
45
46 for user in open("/etc/passwd"):
47 user = user.strip()
48 homedirs.append(user.split(":")[5])
49
50 return homedirs
51
53 if variable == "%%users.homedir%%":
54 return self._get_users_homedir()
55
56 self.session.logging.warn("Unable to interpolate %s", variable)
57 return []
58
61 @registry.memoize
74
75 @registry.memoize
77 """On windows the homedirs are the paths of the user's profile."""
78 result = []
79 for artifact_hit in self.session.plugins.artifact_collector(
80 "WindowsRegistryProfiles"):
81 for hit_result in artifact_hit.get("result", []):
82 profile_path = hit_result.get("value")
83 if profile_path:
84 result.append(profile_path)
85
86 return result
87
89 if variable == "%%users.sid%%":
90 return self._get_sids()
91
92 if variable == "%%users.homedir%%":
93 return self._get_homedirs()
94
95 if variable == "%%environ_systemroot%%":
96 return [os.environ["systemroot"]]
97
98 return []
99
102 name = "knowledge_base"
103
109