Python win32net.NetUserEnum() Examples
The following are 7
code examples of win32net.NetUserEnum().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32net
, or try the search function
.
Example #1
Source File: authorizers.py From oss-ftp with MIT License | 7 votes |
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]]
Example #2
Source File: authorizers.py From oss-ftp with MIT License | 5 votes |
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]]
Example #3
Source File: windows.py From cloudbase-init with Apache License 2.0 | 5 votes |
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
Example #4
Source File: authorizers.py From script-languages with MIT License | 5 votes |
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]]
Example #5
Source File: authorizers.py From pyftpdlib with MIT License | 5 votes |
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]]
Example #6
Source File: win32netdemo.py From ironpython2 with Apache License 2.0 | 4 votes |
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"
Example #7
Source File: windows_enumeration_users.py From locasploit with GNU General Public License v2.0 | 4 votes |
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