當前位置: 首頁>>代碼示例>>Python>>正文


Python wkst.hNetrWkstaUserEnum方法代碼示例

本文整理匯總了Python中impacket.dcerpc.v5.wkst.hNetrWkstaUserEnum方法的典型用法代碼示例。如果您正苦於以下問題:Python wkst.hNetrWkstaUserEnum方法的具體用法?Python wkst.hNetrWkstaUserEnum怎麽用?Python wkst.hNetrWkstaUserEnum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在impacket.dcerpc.v5.wkst的用法示例。


在下文中一共展示了wkst.hNetrWkstaUserEnum方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_netloggedon

# 需要導入模塊: from impacket.dcerpc.v5 import wkst [as 別名]
# 或者: from impacket.dcerpc.v5.wkst import hNetrWkstaUserEnum [as 別名]
def get_netloggedon(self):
        self.loggedon = {}
        self.create_rpc_con(r'\wkssvc')
        try:
            resp = wkst.hNetrWkstaUserEnum(self.rpc_connection, 1)
        except DCERPCException as e:
            return list()

        results = list()
        for wksta_user in resp['UserInfo']['WkstaUserInfo']['Level1']['Buffer']:
            self.loggedon[wksta_user['wkui1_username'].strip('\x00')] = {
                                    'domain'    : wksta_user['wkui1_logon_domain'].strip('\x00'),
                                    'logon_srv' : wksta_user['wkui1_logon_server'].strip('\x00'),
                                    'user'      : wksta_user['wkui1_username'].strip('\x00'),
                                }

        self.rpc_connection.disconnect() 
開發者ID:m8r0wn,項目名稱:ActiveReign,代碼行數:19,代碼來源:rpc.py

示例2: test_hNetrWkstaUserEnum

# 需要導入模塊: from impacket.dcerpc.v5 import wkst [as 別名]
# 或者: from impacket.dcerpc.v5.wkst import hNetrWkstaUserEnum [as 別名]
def test_hNetrWkstaUserEnum(self):
        dce, rpctransport = self.connect()
        resp = wkst.hNetrWkstaUserEnum(dce, 0)
        resp.dump()

        resp = wkst.hNetrWkstaUserEnum(dce, 1)
        resp.dump() 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:9,代碼來源:test_wkst.py

示例3: get_netloggedon

# 需要導入模塊: from impacket.dcerpc.v5 import wkst [as 別名]
# 或者: from impacket.dcerpc.v5.wkst import hNetrWkstaUserEnum [as 別名]
def get_netloggedon(self):

        try:
            resp = wkst.hNetrWkstaUserEnum(self._rpc_connection, 1)
        except DCERPCException:
            return list()

        results = list()
        for wksta_user in resp['UserInfo']['WkstaUserInfo']['Level1']['Buffer']:
            results.append(rpcobj.WkstaUser(wksta_user))

        return results

    # TODO: if self._target_computer == self._domain_controller, check that
    # self._domain_controller is indeed a domain controller 
開發者ID:the-useless-one,項目名稱:pywerview,代碼行數:17,代碼來源:net.py

示例4: rpc_get_loggedon

# 需要導入模塊: from impacket.dcerpc.v5 import wkst [as 別名]
# 或者: from impacket.dcerpc.v5.wkst import hNetrWkstaUserEnum [as 別名]
def rpc_get_loggedon(self):
        """
        Query logged on users via RPC.
        Requires admin privs
        """
        binding = r'ncacn_np:%s[\PIPE\wkssvc]' % self.addr
        loggedonusers = set()
        dce = self.dce_rpc_connect(binding, wkst.MSRPC_UUID_WKST)
        if dce is None:
            logging.warning('Connection failed: %s', binding)
            return
        try:
            # 1 means more detail, including the domain
            resp = wkst.hNetrWkstaUserEnum(dce, 1)
            for record in resp['UserInfo']['WkstaUserInfo']['Level1']['Buffer']:
                # Skip computer accounts
                if record['wkui1_username'][-2] == '$':
                    continue
                # Skip sessions for local accounts
                if record['wkui1_logon_domain'][:-1].upper() == self.samname.upper():
                    continue
                domain = record['wkui1_logon_domain'][:-1].upper()
                domain_entry = self.ad.get_domain_by_name(domain)
                if domain_entry is not None:
                    domain = ADUtils.ldap2domain(domain_entry['attributes']['distinguishedName'])
                logging.debug('Found logged on user at %s: %s@%s' % (self.hostname, record['wkui1_username'][:-1], domain))
                loggedonusers.add((record['wkui1_username'][:-1], domain))
        except DCERPCException as e:
            if 'rpc_s_access_denied' in str(e):
                logging.debug('Access denied while enumerating LoggedOn on %s, probably no admin privs', self.hostname)
            else:
                logging.debug('Exception connecting to RPC: %s', e)
        except Exception as e:
            if 'connection reset' in str(e):
                logging.debug('Connection was reset: %s', e)
            else:
                raise e

        dce.disconnect()
        return list(loggedonusers) 
開發者ID:fox-it,項目名稱:BloodHound.py,代碼行數:42,代碼來源:computer.py

示例5: getLoggedIn

# 需要導入模塊: from impacket.dcerpc.v5 import wkst [as 別名]
# 或者: from impacket.dcerpc.v5.wkst import hNetrWkstaUserEnum [as 別名]
def getLoggedIn(self, target):
        if self.__targets[target]['Admin'] is False:
            return

        if self.__targets[target]['WKST'] is None:
            stringWkstBinding = r'ncacn_np:%s[\PIPE\wkssvc]' % target
            rpctransportWkst = transport.DCERPCTransportFactory(stringWkstBinding)
            if hasattr(rpctransportWkst, 'set_credentials'):
                # This method exists only for selected protocol sequences.
                rpctransportWkst.set_credentials(self.__username, self.__password, self.__domain, self.__lmhash,
                                                 self.__nthash, self.__aesKey)
                rpctransportWkst.set_kerberos(self.__doKerberos, self.__kdcHost)

            dce = rpctransportWkst.get_dce_rpc()
            dce.connect()
            dce.bind(wkst.MSRPC_UUID_WKST)
            self.__maxConnections -= 1
        else:
            dce = self.__targets[target]['WKST']

        try:
            resp = wkst.hNetrWkstaUserEnum(dce,1)
        except Exception, e:
            if str(e).find('Broken pipe') >= 0:
                # The connection timed-out. Let's try to bring it back next round
                self.__targets[target]['WKST'] = None
                self.__maxConnections += 1
                return
            elif str(e).upper().find('ACCESS_DENIED'):
                # We're not admin, bye
                dce.disconnect()
                self.__maxConnections += 1
                self.__targets[target]['Admin'] = False
                return
            else:
                raise 
開發者ID:tholum,項目名稱:PiBunny,代碼行數:38,代碼來源:netview.py

示例6: sessions

# 需要導入模塊: from impacket.dcerpc.v5 import wkst [as 別名]
# 或者: from impacket.dcerpc.v5.wkst import hNetrWkstaUserEnum [as 別名]
def sessions(self, targets):
		for target in targets:
			users = []
			try:
				target_computer = target
				self._create_rpc_connection(target_computer)
				print target_computer
				print "-----------------"
				smb = SMBConnection('*SMBSERVER', target_computer, sess_port=445, timeout=5)
				smb.login(self._user, self._password, self._domain)
				try:
					sess = wkst.hNetrWkstaUserEnum(self._rpc_connection, 1)
				except DCERPCException, e:
					users = []
					print colors.RD + "     [-]" + colors.NRM + " User does not have access"
					continue
				for wksta_user in sess['UserInfo']['WkstaUserInfo']['Level1']['Buffer']:
					userName = wksta_user['wkui1_username'][:-1]
					logonDomain = wksta_user['wkui1_logon_domain'][:-1]
					if "$" in userName:
						pass
					else:
						user = '%s\%s' % (logonDomain, userName)
						if user in users:
							pass
						else:
							users.append(user)
				print "  Currently Logged On"
				print "  -------------------"
				for user in users:
					print "     " + colors.GRN + "[+] " + colors.NRM + user
				del users
				share = 'C$'
				path = '\\Users\\*'
				read = smb.listPath(share, path)
				print "\n  Users Who Have Logged On"
				print "  -------------------------"
				for r in read:
					if r.get_longname() == "Public" or r.get_longname() == "All Users" or r.get_longname() == "Default" or r.get_longname() == "Default User" or r.get_longname() == "." or r.get_longname() == "..":
						pass
					else:
						if r.is_directory():
							print  colors.GRN + "     [+] " + colors.NRM + r.get_longname() + " lastlogon: " + time.ctime(float(r.get_mtime_epoch()))
			except UnboundLocalError as e:
				print target
				users = []
				print e
				print colors.RD + "     [-] " + colors.NRM + "User does not have access"
				continue 
開發者ID:Tylous,項目名稱:Vibe,代碼行數:51,代碼來源:smb.py


注:本文中的impacket.dcerpc.v5.wkst.hNetrWkstaUserEnum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。