Revision 76b200cf image_creator/os_type/windows.py
b/image_creator/os_type/windows.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from image_creator.os_type import OSBase |
35 | 35 |
|
36 |
import hivex |
|
37 |
import tempfile |
|
38 |
import os |
|
39 |
|
|
36 | 40 |
|
37 | 41 |
class Windows(OSBase): |
38 | 42 |
"""OS class for Windows""" |
39 |
pass |
|
43 |
def __init__(self, rootdev, ghandler, output): |
|
44 |
super(Windows, self).__init__(rootdev, ghandler, output) |
|
45 |
|
|
46 |
self.meta["USERS"] = " ".join(self._get_users()) |
|
47 |
|
|
48 |
def _get_users(self): |
|
49 |
samfd, sam = tempfile.mkstemp() |
|
50 |
try: |
|
51 |
systemroot = self.g.inspect_get_windows_systemroot(self.root) |
|
52 |
path = "%s/system32/config/sam" % systemroot |
|
53 |
path = self.g.case_sensitive_path(path) |
|
54 |
self.g.download(path, sam) |
|
55 |
|
|
56 |
h = hivex.Hivex(sam) |
|
57 |
|
|
58 |
key = h.root() |
|
59 |
|
|
60 |
# Navigate to /SAM/Domains/Account/Users/Names |
|
61 |
for child in ('SAM', 'Domains', 'Account', 'Users', 'Names'): |
|
62 |
key = h.node_get_child(key, child) |
|
63 |
|
|
64 |
users = [h.node_name(x) for x in h.node_children(key)] |
|
65 |
|
|
66 |
finally: |
|
67 |
os.unlink(sam) |
|
68 |
|
|
69 |
# Filter out the guest account |
|
70 |
return filter(lambda x: x != "Guest", users) |
|
40 | 71 |
|
41 | 72 |
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai : |
Also available in: Unified diff