-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries.py
69 lines (64 loc) · 2.16 KB
/
queries.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#Stated all the queries as functions (WMI based on WQL for getting the device details).
import wmi
import data
import gc
def getnicinfo():
c = wmi.WMI()
wql = "SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter=true AND Manufacturer != 'Microsoft' AND NOT PNPDeviceID LIKE 'ROOT\\%'"
temp = c.query(wql)
deviceList = list()
gc.enable()
print("\nreturns physical NIC")
for J in temp:
x = data.device()
x.ProductName = J.ProductName
x.PNPDeviceID = J.PNPDeviceID
x.Manufacturer = J.Manufacturer
x.Name = J.Name
deviceList.append(x)
return deviceList
def getPnpDeviceInfo():
c = wmi.WMI()
wql = "SELECT * FROM Win32_PnPEntity WHERE Manufacturer != 'Microsoft' AND NOT PNPDeviceID LIKE 'ROOT\\%'"
temp = c.query(wql)
deviceList = list()
print("\n returns physical PNP device")
gc.enable()
for J in temp:
x = data.device()
x.PNPDeviceID = J.PNPDeviceID
x.Manufacturer = J.Manufacturer
x.Name = J.Name
x.Caption = J.Caption
deviceList.append(x)
return deviceList
def getUnknownPnpDeviceInfo():
c = wmi.WMI()
wql = "SELECT * FROM Win32_PnPEntity WHERE Manufacturer != 'Microsoft' AND (Status != 'OK' AND Status !='') AND NOT PNPDeviceID LIKE 'ROOT\\%'"
temp = c.query(wql)
deviceList = list()
gc.enable()
print("\n returns physical unknown PNP dervice")
for J in temp:
x = data.device()
x.PNPDeviceID = J.PNPDeviceID
x.Manufacturer = J.Manufacturer
x.Name = J.Name
x.Caption = J.Caption
deviceList.append(x)
return deviceList
def getUnknownNetworkAdapterInfo():
c = wmi.WMI()
wql = "SELECT * FROM Win32_NetworkAdapter WHERE Manufacturer != 'Microsoft' AND Installed = FALSE AND NOT PNPDeviceID LIKE 'ROOT\\%'"
temp = c.query(wql)
deviceList = list()
gc.enable()
print("\n returns unknown physical NIC")
for J in temp:
x = data.device()
x.ProductName = J.ProductName
x.PNPDeviceID = J.PNPDeviceID
x.Manufacturer = J.Manufacturer
x.Name = J.Name
deviceList.append(x)
return deviceList