-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhp_bios_enumeration.py
35 lines (31 loc) · 1.39 KB
/
hp_bios_enumeration.py
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
import win32com.client
import osquery
@osquery.register_plugin
class GenBIOSEnumerationTablePlugin(osquery.TablePlugin):
def name(self):
"""Table name to be used in SQL queries."""
return "hp_bios_enum"
def columns(self):
"""Defines the columns of your table."""
return [
osquery.TableColumn(name="name", type=osquery.STRING),
osquery.TableColumn(name="possible_values", type=osquery.STRING),
osquery.TableColumn(name="current_value", type=osquery.STRING),
]
def generate(self, context):
"""Generates the data for each row in your table."""
query_data = []
try:
wmi_service = win32com.client.GetObject("winmgmts:\\\\.\\root\\HP\\InstrumentedBIOS")
bios_enumerations = wmi_service.ExecQuery("SELECT * FROM HP_BIOSEnumeration")
for bios_enum in bios_enumerations:
query_data.append({
"name": bios_enum.name,
"possible_values": bios_enum.possible_values,
"current_value": bios_enum.current_value,
})
except Exception as e:
osquery.log(f"An error occurred while querying HP BIOS settings: {str(e)}")
return query_data
if __name__ == "__main__":
osquery.start_extension(name="hp_bios_enum_extension", version="1.0.0")