-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDnsGetCacheDataTable.py
More file actions
32 lines (24 loc) · 898 Bytes
/
DnsGetCacheDataTable.py
File metadata and controls
32 lines (24 loc) · 898 Bytes
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
import ctypes
from ctypes.wintypes import HANDLE,DWORD,LPWSTR
khandle = ctypes.WinDLL('kernel32.dll')
dhandle = ctypes.WinDLL('DNSAPI.dll')
class dnscacheentry(ctypes.Structure):
_fields_ = [
("pNext", HANDLE),
("recName", LPWSTR),
("wType", DWORD),
("wDataLength", DWORD),
("dwFlags",DWORD)
]
dnsentry = dnscacheentry()
dnsentry.wDataLength = 1024
response = dhandle.DnsGetCacheDataTable(ctypes.byref(dnsentry))
if response == 0:
print("failed due error {0}".format(khandle.GetLastError()))
dnsentry = ctypes.cast(dnsentry.pNext , ctypes.POINTER(dnscacheentry))
while True:
try:
print("Dns Entry is {0} with type {1}".format(dnsentry.contents.recName , dnsentry.contents.wType))
dnsentry = ctypes.cast(dnsentry.contents.pNext , ctypes.POINTER(dnscacheentry))
except:
break