[connection] neff: review I

Signed-off-by: Xiaoli Chan <2209553467@qq.com>
main
Xiaoli Chan 2023-08-30 01:24:56 +08:00
parent e3c734c186
commit ad5debaa4c
4 changed files with 8 additions and 27 deletions

View File

@ -108,10 +108,7 @@ class CMEModule:
else:
context.log.fail(str(e))
pass
try:
wmi_rdp._rdp_WMI__dcom.disconnect()
except:
pass
class rdp_SMB:
def __init__(self, context, connection):
@ -262,11 +259,8 @@ class rdp_WMI:
self.__iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
except Exception as e:
self.logger.fail(f'Unexpected wmi error: {str(e)}, please try to use "-o" with "METHOD=smb"')
try:
self.__dcom.disconnect()
except:
pass
self.__dcom.disconnect()
def rdp_Wrapper(self, action, old=False):
if old == False:
# According to this document: https://learn.microsoft.com/en-us/windows/win32/termserv/win32-tslogonsetting

View File

@ -1241,10 +1241,7 @@ class smb(connection):
self.logger.fail(error_msg) if not flag else self.logger.debug(error_msg)
# Make it force break function
try:
dcom.disconnect()
except:
pass
dcom.disconnect()
iWbemLevel1Login = IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin(namespace , NULL, NULL)
iWbemLevel1Login.RemRelease()
@ -1265,11 +1262,7 @@ class smb(connection):
raise e
else:
break
try:
dcom.disconnect()
except:
pass
return records if records else False
def spider(

View File

@ -111,11 +111,8 @@ class MMCEXEC:
error_msg = "MMCEXEC: Dcom initialization failed: can't get target stringbinding, maybe cause by IPv6 or any other issues, please check your target again"
self.logger.fail(error_msg) if not flag else self.logger.debug(error_msg)
try:
# Make it force break function
self.__dcom.disconnect()
except:
pass
# Make it force break function
self.__dcom.disconnect()
iMMC = IDispatch(iInterface)
resp = iMMC.GetIDsOfNames(("Document",))
@ -182,8 +179,8 @@ class MMCEXEC:
dispParams["cNamedArgs"] = 0
self.__quit[0].Invoke(self.__quit[1], 0x409, DISPATCH_METHOD, dispParams, 0, [], [])
except:
pass
except Exception as e:
self.logger.fail(f"Unexpect dcom error when doing exit() function in mmcexec: {str(e)}")
return True
def execute_remote(self, data):

View File

@ -83,10 +83,7 @@ class WMIEXEC:
self.logger.fail(error_msg) if not flag else self.logger.debug(error_msg)
# Make it force break function
try:
self.__dcom.disconnect()
except:
pass
self.__dcom.disconnect()
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices = iWbemLevel1Login.NTLMLogin("//./root/cimv2", NULL, NULL)
iWbemLevel1Login.RemRelease()