本文整理汇总了Python中impacket.dcerpc.v5.dcom.wmi.CLSID_WbemLevel1Login方法的典型用法代码示例。如果您正苦于以下问题:Python wmi.CLSID_WbemLevel1Login方法的具体用法?Python wmi.CLSID_WbemLevel1Login怎么用?Python wmi.CLSID_WbemLevel1Login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类impacket.dcerpc.v5.dcom.wmi
的用法示例。
在下文中一共展示了wmi.CLSID_WbemLevel1Login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_IWbemServices_ExecQuery
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemServices_ExecQuery(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('\\\\%s\\root\\cimv2' % self.machine, NULL, NULL)
classes = [ 'Win32_Account', 'Win32_UserAccount', 'Win32_Group', 'Win32_SystemAccount', 'Win32_Service']
for classn in classes:
print "Reading %s " % classn
try:
iEnumWbemClassObject = iWbemServices.ExecQuery('SELECT * from %s' % classn)
done = False
while done is False:
try:
iEnumWbemClassObject.Next(0xffffffff,1)
except Exception, e:
if str(e).find('S_FALSE') < 0:
print e
else:
done = True
pass
except Exception, e:
if str(e).find('S_FALSE') < 0:
print e
示例2: test_IWbemServices_ExecQuery
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemServices_ExecQuery(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('\\\\%s\\root\\cimv2' % self.machine, NULL, NULL)
#classes = [ 'Win32_Account', 'Win32_UserAccount', 'Win32_Group', 'Win32_SystemAccount', 'Win32_Service']
classes = [ 'Win32_Service']
for classn in classes:
print("Reading %s " % classn)
try:
iEnumWbemClassObject = iWbemServices.ExecQuery('SELECT * from %s' % classn)
done = False
while done is False:
try:
iEnumWbemClassObject.Next(0xffffffff,1)
except Exception as e:
if str(e).find('S_FALSE') < 0:
print(e)
else:
done = True
pass
except Exception as e:
if str(e).find('S_FALSE') < 0:
print(e)
dcom.disconnect()
示例3: tes_activation
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def tes_activation(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLoginClientID)
dcom.disconnect()
示例4: test_IWbemLevel1Login_EstablishPosition
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemLevel1Login_EstablishPosition(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
resp = iWbemLevel1Login.EstablishPosition()
print resp
dcom.disconnect()
示例5: test_IWbemLevel1Login_RequestChallenge
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemLevel1Login_RequestChallenge(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
try:
resp = iWbemLevel1Login.RequestChallenge()
print resp
except Exception, e:
if str(e).find('WBEM_E_NOT_SUPPORTED') < 0:
dcom.disconnect()
raise
示例6: test_IWbemLevel1Login_WBEMLogin
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemLevel1Login_WBEMLogin(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
try:
resp = iWbemLevel1Login.WBEMLogin()
print resp
except Exception, e:
if str(e).find('E_NOTIMPL') < 0:
dcom.disconnect()
raise
示例7: test_IWbemLevel1Login_NTLMLogin
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemLevel1Login_NTLMLogin(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
resp = iWbemLevel1Login.NTLMLogin('\\\\%s\\root\\cimv2' % self.machine, NULL, NULL)
print resp
dcom.disconnect()
示例8: test_IWbemServices_GetObject
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def test_IWbemServices_GetObject(self):
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('\\\\%s\\root\\cimv2' % self.machine, NULL, NULL)
iWbemLevel1Login.RemRelease()
classObject,_ = iWbemServices.GetObject('Win32_Process')
dcom.disconnect()
示例9: _getwin32process
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def _getwin32process(self):
if self.conn.kerberos:
self.log.debug("Trying to authenticate using kerberos ticket")
else:
self.log.debug("Trying to authenticate using : {}\\{}:{}".format(
self.conn.domain_name,
self.conn.username,
self.conn.password)
)
try:
self.dcom = DCOMConnection(
self.conn.hostname,
self.conn.username,
self.conn.password,
self.conn.domain_name,
self.conn.lmhash,
self.conn.nthash,
self.conn.aesKey,
oxidResolver=True,
doKerberos=self.conn.kerberos,
kdcHost=self.conn.dc_ip
)
iInterface = self.dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login, wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
self.iWbemServices = iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL)
iWbemLevel1Login.RemRelease()
self.win32Process, _ = self.iWbemServices.GetObject('Win32_Process')
except KeyboardInterrupt as e:
self.dcom.disconnect()
raise KeyboardInterrupt(e)
except Exception as e:
raise Exception("WMIEXEC not supported on host %s : %s" % (self.conn.hostname, e))
示例10: run
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def run(self, addr):
if self.__noOutput is False:
smbConnection = SMBConnection(addr, addr)
smbConnection.login(self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash)
dialect = smbConnection.getDialect()
if dialect == SMB_DIALECT:
color.echo("[*] SMBv1 dialect used", GREEN)
elif dialect == SMB2_DIALECT_002:
color.echo("[*] SMBv2.0 dialect used", GREEN)
elif dialect == SMB2_DIALECT_21:
color.echo("[*] SMBv2.1 dialect used", GREEN)
else:
color.echo("[*] SMBv3.0 dialect used", GREEN)
else:
smbConnection = None
dcom = DCOMConnection(addr, self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash, oxidResolver = True)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL)
iWbemLevel1Login.RemRelease()
win32Process,_ = iWbemServices.GetObject('Win32_Process')
try:
self.shell = RemoteShell(self.__share, win32Process, smbConnection)
if self.__command != ' ':
self.shell.onecmd(self.__command)
else:
self.shell.cmdloop()
except (Exception, KeyboardInterrupt), e:
#import traceback
#traceback.print_exc()
if smbConnection is not None:
smbConnection.logoff()
dcom.disconnect()
sys.stdout.flush()
示例11: _create_wmi_connection
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def _create_wmi_connection(self, namespace='root\\cimv2'):
try:
self._dcom = DCOMConnection(self._target_computer, self._user, self._password,
self._domain, self._lmhash, self._nthash)
except DCERPCException:
self._dcom = None
else:
i_interface = self._dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,
wmi.IID_IWbemLevel1Login)
i_wbem_level1_login = wmi.IWbemLevel1Login(i_interface)
self._wmi_connection = i_wbem_level1_login.NTLMLogin(ntpath.join('\\\\{}\\'.format(self._target_computer), namespace),
NULL, NULL)
示例12: __init__
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def __init__(self, target, share_name, username, password, domain, smbconnection, doKerberos=False, aesKey=None, kdcHost=None, hashes=None, share=None):
self.__target = target
self.__username = username
self.__password = password
self.__domain = domain
self.__lmhash = ''
self.__nthash = ''
self.__share = share
self.__smbconnection = smbconnection
self.__output = None
self.__outputBuffer = b''
self.__share_name = share_name
self.__shell = 'cmd.exe /Q /c '
self.__pwd = 'C:\\'
self.__aesKey = aesKey
self.__kdcHost = kdcHost
self.__doKerberos = doKerberos
self.__retOutput = True
if hashes is not None:
#This checks to see if we didn't provide the LM Hash
if hashes.find(':') != -1:
self.__lmhash, self.__nthash = hashes.split(':')
else:
self.__nthash = hashes
if self.__password is None:
self.__password = ''
self.__dcom = DCOMConnection(self.__target, self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash, self.__aesKey, oxidResolver=True, doKerberos=self.__doKerberos, kdcHost=self.__kdcHost)
iInterface = self.__dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL)
iWbemLevel1Login.RemRelease()
self.__win32Process,_ = iWbemServices.GetObject('Win32_Process')
示例13: __wmiExec
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def __wmiExec(self, command):
# Convert command to wmi exec friendly format
command = command.replace('%COMSPEC%', 'cmd.exe')
username, password, domain, lmhash, nthash, aesKey, _, _ = self.__smbConnection.getCredentials()
dcom = DCOMConnection(self.__smbConnection.getRemoteHost(), username, password, domain, lmhash, nthash, aesKey,
oxidResolver=False, doKerberos=self.__doKerberos, kdcHost=self.__kdcHost)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL)
iWbemLevel1Login.RemRelease()
win32Process,_ = iWbemServices.GetObject('Win32_Process')
win32Process.Create(command, '\\', None)
dcom.disconnect()
示例14: tes_IWbemServices_OpenNamespace
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def tes_IWbemServices_OpenNamespace(self):
# Not working
dcom = DCOMConnection(self.machine, self.username, self.password, self.domain, self.lmhash, self.nthash)
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices= iWbemLevel1Login.NTLMLogin('//./ROOT', NULL, NULL)
try:
resp = iWbemServices.OpenNamespace('__Namespace')
print resp
except Exception, e:
dcom.disconnect()
raise
示例15: run
# 需要导入模块: from impacket.dcerpc.v5.dcom import wmi [as 别名]
# 或者: from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login [as 别名]
def run(self, addr, osArch='64'):
dcom = DCOMConnection(addr, self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash, self.__aesKey, oxidResolver=True, doKerberos=self.__doKerberos, kdcHost=self.__kdcHost)
try:
iInterface = dcom.CoCreateInstanceEx(wmi.CLSID_WbemLevel1Login,wmi.IID_IWbemLevel1Login)
iWbemLevel1Login = wmi.IWbemLevel1Login(iInterface)
iWbemServices=iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL)
iWbemLevel1Login.RemRelease()
win32Process,_ = iWbemServices.GetObject('Win32_Process')
self.shell = RemoteShell(self.__share, win32Process, self.__smbConnection)
# Delete Procdump
cmd = "del procdump%s.exe" % (osArch)
logging.info("%s Deleting ProcDump on %s..." % (debugBlue, addr))
if logging.getLogger().getEffectiveLevel() > 10:
with suppress_std():
self.shell.onecmd(cmd)
else:
self.shell.onecmd(cmd)
# Delete Dumps
cmd = "del SPRAY_*.dmp"
logging.info("%s Deleting dumps on %s..." % (debugBlue, addr))
if logging.getLogger().getEffectiveLevel() > 10:
with suppress_std():
self.shell.onecmd(cmd)
else:
self.shell.onecmd(cmd)
finally:
if self.__smbConnection is not None:
self.__smbConnection.logoff()
dcom.disconnect()
sys.stdout.flush()