-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUndocCall.py
More file actions
32 lines (25 loc) · 956 Bytes
/
Copy pathUndocCall.py
File metadata and controls
32 lines (25 loc) · 956 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 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),
]
print("INFO: Pulling DNS Cache Data from System")
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()))
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.contents.pNext, ctypes.pointer(DNS_CACHE_ENTRY))
except:
break