-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocked users extension #37
base: master
Are you sure you want to change the base?
Conversation
Interesting; I assume the use case is in incident management, to contain the impact of a compromised endpoint. Some questions:
This would be a powerful capability, so we'd want to test to make sure it is safe and always reversible with osquery. |
That was the intention yes :).
usermod doesn't, as discussed on Slack a kill of all the user processes is needed.
usermod --lock alone will only block the password login. It works by prepending the encrypted password in the shadow file with '!' character, which can never appear in an encrypted password.
The system to lock the user out is pretty raw and basic, so I don't think so.
Unfortunately don't have a Mac to test this ^^'. |
I think to complete the feature in this PR, that we ought to also support the ability to immediately logout the user. Perhaps you could kill the user's session (via its parent process) rather than kill each individual process of the user? If I was using a CLI and I were in the sudoers group, I could logout the user named "bob" with
👍 Blocking SSH logins this way (expiring the account) sounds good to me. Also, it seems that this is the only way to ensure that the account is locked out for all configurations of PAM.
Ok, disregard my suggestion.
@alessandrogario said he could look into that later after this PR is merged. 😁 |
That was my thought too :).
So i tried a bit more with a graphical installation (Ubuntu 18.04) by killing the No idea why it does that, but I've found a way which works cleanly, using loginctl, which is a tool from systemd to manage sessions. Beyond having no dependencies with dlopen, I think I could also check for the presence of the systemd libraries, if there's some distro that has to be supported that doesn't have them; in that case I could use the fallback method only. |
- Add ShadowEntry and PasswdEntry which represent a parsed line in the respective files - Add ShadowFile to read the shadow file and hold all the ShadowEntry instances - The functions to access the shadow file and passwd file are now thread safe - insert and delete acquire a write lock, select acquires a read lock. This is to reduce the possibility of corrupting the files while modifying them
WORK IN PROGRESS
A simple extension to allow locking and unlocking of linux local user accounts.
Uses "usermod --lock --expiredate 1 " and "usermod --unlock --expiredate '' " to lock and unlock them.
Users can be specified through their username or uid.
Example usage: