m0rin09ma3 user_finder 20130717-151144


Posted:

This program will read /etc/passwd info and output user who can do aproper login.

$ python user_finder.py

A link to the source code.

Sample output:

['root', 'm0rin09ma3', 'git']

Explanation

In the main function, use regular expression to filter out users who has /bin/false or /sbin/nologin default shell. Then output the rest of users.

all_user = pwd.getpwall()
#print all_user

notvalid = re.compile('.*/(nologin|false)')
print [user.pw_name for user in all_user if not notvalid.match(user.pw_s    hell)]
Contents © 2013 dgplug - Powered by Nikola
Share
UA-42392315-1