当前位置: 首页>>代码示例>>Python>>正文


Python win32net.NetUserEnum方法代码示例

本文整理汇总了Python中win32net.NetUserEnum方法的典型用法代码示例。如果您正苦于以下问题:Python win32net.NetUserEnum方法的具体用法?Python win32net.NetUserEnum怎么用?Python win32net.NetUserEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32net的用法示例。


在下文中一共展示了win32net.NetUserEnum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: UserEnum

# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def UserEnum():
    "Enumerates all the local users"
    resume = 0
    nuser = 0
    while 1:
        data, total, resume = win32net.NetUserEnum(server, 3, win32netcon.FILTER_NORMAL_ACCOUNT, resume)
        verbose("Call to NetUserEnum obtained %d entries of %d total" % (len(data), total))
        for user in data:
            verbose("Found user %s" % user['name'])
            nuser = nuser + 1
        if not resume:
            break
    assert nuser, "Could not find any users!"
    print "Enumerated all the local users" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:win32netdemo.py

示例2: _get_system_users

# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def _get_system_users(cls):
            """Return all users defined on the Windows system."""
            # XXX - Does Windows allow usernames with chars outside of
            # ASCII set? In that case we need to convert this to unicode.
            return [entry['name'] for entry in
                    win32net.NetUserEnum(None, 0)[0]] 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:8,代码来源:authorizers.py

示例3: enum_users

# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def enum_users(self):
        usernames = []
        resume_handle = 0
        while True:
            try:
                users_info, total, resume_handle = win32net.NetUserEnum(
                    None, 0, win32netcon.FILTER_NORMAL_ACCOUNT, resume_handle)
            except win32net.error as ex:
                raise exception.CloudbaseInitException(
                    "Enumerating users failed: %s" % ex.args[2])

            usernames += [u["name"] for u in users_info]
            if not resume_handle:
                return usernames 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:16,代码来源:windows.py

示例4: run

# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def run(self):
        silent = positive(self.parameters['SILENT'].value)
        activeroot = self.parameters['ACTIVEROOT'].value
        import win32net
        ip = get_address_from_active_root(activeroot)
        if ip is None:
            log.err('Cannot get proper address for active root.')
            return None
       
        # get all users
        rh = 0
        while True:
            users = win32net.NetUserEnum(ip, 1, rh)
            unixusers = [] # prepare list of unix-style values
            for user in users[0]:
                username = user['name']
                uid = str(win32net.NetUserGetInfo(ip, username, 4)['user_sid'])[6:].split('-')[-1]
                admin = is_admin(username, self.parameters['ACTIVEROOT'].value)
                if not silent:
                    if admin:
                        log.ok('User %s - %s (Administrator)' % (uid, username))
                    else:
                        log.ok('User %s - %s' % (uid, username))
                unixusers.append([username, None, uid, None, None, None, None, admin])
                #db['analysis'].add_user(activeroot, uid, username, admin)
            result = db['analysis'].add_users(activeroot, unixusers, USERS_UNIXLIKE)
            if result == DB_ERROR:
                log.err('Cannot insert users into DB.')
            else:
                if not silent:
                    log.ok('%d users added/updated.' % (len(unixusers)))
                #groups = win32net.NetLocalGroupEnum(ip, 1)
                #groups = win32net.NetUserGetLocalGroups(ip, username, 2)
                # TODO how to get GID????
                #for group in groups[0]:
                #    print(group)
                #    print(win32net.NetLocalGroupGetInfo(ip, group['name'], 1))
                
                # insert ug
            if rh == 0:
                break
            
        return None 
开发者ID:lightfaith,项目名称:locasploit,代码行数:45,代码来源:windows_enumeration_users.py


注:本文中的win32net.NetUserEnum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。