1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-26 17:41:08 +01:00

Land #596, Remove references to wintypes

This commit is contained in:
adfoster-r7 2022-11-07 21:45:23 +00:00 committed by GitHub
commit 78ba9ee8d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,9 +21,6 @@ except ImportError:
has_ctypes = False has_ctypes = False
has_windll = False has_windll = False
if has_windll:
from ctypes import wintypes
try: try:
import pty import pty
has_pty = True has_pty = True
@ -362,8 +359,8 @@ if has_ctypes:
class LUID(ctypes.Structure): class LUID(ctypes.Structure):
_fields_ = [ _fields_ = [
('LowPart', wintypes.DWORD), ('LowPart', ctypes.c_uint32),
('HighPart', wintypes.LONG) ('HighPart', ctypes.c_long)
] ]
def __eq__(self, __o): def __eq__(self, __o):
@ -375,12 +372,12 @@ if has_ctypes:
class LUID_AND_ATTRIBUTES(ctypes.Structure): class LUID_AND_ATTRIBUTES(ctypes.Structure):
_fields_ = [ _fields_ = [
('Luid', LUID), ('Luid', LUID),
('Attributes', wintypes.DWORD) ('Attributes', ctypes.c_uint32)
] ]
class TOKEN_PRIVILEGES(ctypes.Structure): class TOKEN_PRIVILEGES(ctypes.Structure):
_fields_ = [ _fields_ = [
('PrivilegeCount', wintypes.DWORD), ('PrivilegeCount', ctypes.c_uint32),
('Privileges', LUID_AND_ATTRIBUTES * 0), ('Privileges', LUID_AND_ATTRIBUTES * 0),
] ]
def get_array(self): def get_array(self):
@ -1037,21 +1034,21 @@ def enable_privilege(name, enable=True):
SE_PRIVILEGE_ENABLED = 0x00000002 SE_PRIVILEGE_ENABLED = 0x00000002
GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess
GetCurrentProcess.restype = wintypes.HANDLE GetCurrentProcess.restype = ctypes.c_void_p
OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken
OpenProcessToken.argtypes = [wintypes.HANDLE, wintypes.DWORD, ctypes.POINTER(wintypes.HANDLE)] OpenProcessToken.argtypes = [ctypes.c_void_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_void_p)]
OpenProcessToken.restype = wintypes.BOOL OpenProcessToken.restype = ctypes.c_bool
LookupPrivilegeValue = ctypes.windll.advapi32.LookupPrivilegeValueW LookupPrivilegeValue = ctypes.windll.advapi32.LookupPrivilegeValueW
LookupPrivilegeValue.argtypes = [wintypes.LPCWSTR, wintypes.LPCWSTR, ctypes.POINTER(LUID)] LookupPrivilegeValue.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.POINTER(LUID)]
LookupPrivilegeValue.restype = wintypes.BOOL LookupPrivilegeValue.restype = ctypes.c_bool
AdjustTokenPrivileges = ctypes.windll.advapi32.AdjustTokenPrivileges AdjustTokenPrivileges = ctypes.windll.advapi32.AdjustTokenPrivileges
AdjustTokenPrivileges.argtypes = [wintypes.HANDLE, wintypes.BOOL, PTOKEN_PRIVILEGES, wintypes.DWORD, PTOKEN_PRIVILEGES, ctypes.POINTER(wintypes.DWORD)] AdjustTokenPrivileges.argtypes = [ctypes.c_void_p, ctypes.c_bool, PTOKEN_PRIVILEGES, ctypes.c_uint32, PTOKEN_PRIVILEGES, ctypes.POINTER(ctypes.c_uint32)]
AdjustTokenPrivileges.restype = wintypes.BOOL AdjustTokenPrivileges.restype = ctypes.c_bool
token = wintypes.HANDLE() token = ctypes.c_void_p()
success = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, token) success = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, token)
if not success: if not success:
return False return False