-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDiscovery_RegKey_Example.tpl
41 lines (29 loc) · 1.09 KB
/
Discovery_RegKey_Example.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
tpl 1.15 module Traversys.RegKeyExample;
metadata
origin:= "Traversys";
_name:= "RegKey Example";
tree_path:= "Custom", "Traversys", "RegKey Example";
end metadata;
pattern RegKeyExample 1.0
""" Registry Query Example """
overview
tags traversys, example;
end overview;
triggers
on host := Host created, confirmed where os_type = "Windows";
end triggers;
body
wmi_results := discovery.wmiQuery(host, 'select LastLogon, Name, UserType from Win32_NetworkLoginProfile', raw 'root\CIMV2');
for result in wmi_results do
if "LastLogon" in result then
host.last_login := result.LastLogon;
model.addDisplayAttribute(host, "last_login");
break;
end if;
end for;
reg_query := raw 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner';
owner_key := discovery.registryKey(host, reg_query);
host.registered_owner := owner_key.value;
model.addDisplayAttribute(host, "registered_owner");
end body;
end pattern;