-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnDocCall.py
34 lines (25 loc) · 921 Bytes
/
UnDocCall.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
import ctypes
from ctypes.wintypes import DWORD, HANDLE, LPWSTR
k_handle = ctypes.WinDLL("Kernel32.dll")
d_handle = ctypes.WinDLL("DNSAPI.dll")
class DNS_CACHE_ENTRY(ctypes.Structure):
_fields_ = [
("pNext", HANDLE),
("recName", LPWSTR),
("wType", DWORD),
("wDataLength", DWORD),
("dwFlags", DWORD)
]
DNS_Entry = DNS_CACHE_ENTRY()
DNS_Entry.wDataLength = 1024
response = d_handle.DnsGetCacheDataTable(ctypes.byref(DNS_Entry))
if response == 0:
print("Error Code {0}".format(k_handle.GetLastError()))
exit(1)
DNS_Entry = ctypes.cast(DNS_Entry.pNext, ctypes.POINTER(DNS_CACHE_ENTRY))
while True:
try:
print("DNS ENTRY {0} - Type {1}".format(DNS_Entry.contents.recName, DNS_Entry.contents.wType))
DNS_Entry = ctypes.cast(DNS_Entry.pNext, ctypes.POINTER(DNS_CACHE_ENTRY))
except:
break