-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Useradd #18194
Useradd #18194
Conversation
This functionality seems interesting. Probably more of a future enhancement idea thinking about what is does and what already exist in Framework, I wonder if it would be helpful to have a generic |
I whole heartedly agree that a means to launch a payload onto an already existing session should exits rather than a somewhat nonintuitive generate -> exploit -z -> session -i ? -c and that needs to happen. Thinking that the payload is enough however is not good enough. I made that payload, and it was designed to complete the task in the smallest form possible. This means that its dirty and obvious. That payload puts the new users password in |
Co-authored-by: adfoster-r7 <[email protected]>
Co-authored-by: adfoster-r7 <[email protected]>
All suggestions should be finished, Anything else before we are clear to land? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this module @rad10. I left some comments and suggestions for you to review when you get a chance.
Would it be possible to break down the run
method in smaller methods with descriptive names? This would make the code easier to read and help any future maintenance.
Co-authored-by: Christophe De La Fuente <[email protected]>
Hi @rad10, thanks for these updates. I'm just checking in, do you plan to push more changes? I noticed there are still a few pending comments. |
So, I can put in more changes. I just noticed just how much is having to be done in order to have it work as I planned. I am still working on it. In fact, I am taking a completely new approach and starting nearly from scratch. My terrifying plan is to build the post module to imitate all the actions that useradd does from a source level. I am rebuilding the module based on the source from the shadow package. I've already gotten groups and getting the correct GID finished. I just need to finish up UID and a few other aspects and create some new checks. The idea of this round is that not a single shell command should be run and it should use only the base linux files in the same manner shadow does. If there is any advice to give, or even sympathies for having to read the shadow source code. I'll take them as soon as possible. I'm hoping to have this finished by the middle of october however at the very most |
So I have been looking at the source code for a long while now, and I now realize that... This thing will be at best a nightmare to put into a module and at worst impossible to do. This mainly stems from how many ways that a user can be added to a system. You can send it in through PAM, you can write it to /etc/passwd, you can add the change to the audit log, you can utilize tcb (Dont really know what that is at all, but its entirely separate from the users). Now labeling all of this should be easier, but migrating this over becomes impossible because these options are baked into the binary and I cannot find an external file that ensures/guarantees whether a given route is used or not. Because of this were back to the binary fiasco. Theres no clean way of implementing this by following the source code. I could keep it as simple as possible and only interact with Which would be preferred? |
Hi @rad10 , thank you for looking into this. I understand it is getting very complex, almost impossible to cover every user cases. I believe your first idea/implementation was good enough for now. This can still be improved later, if the need to do so arises. |
In that case, yes. This module is ready to go. It should cover all of the bases given. I tested using containers and vms. |
Sure! It looks good to me. I retested and it works as expected. I just added a last minute commit to fix some typos. Thank you again for your contribution!
|
Release NotesThis adds a post module that creates a new user on the target OS. It tries to use standard tools already available on the system, but it's also able to directly updates the plaintext database files ( |
Vulnerable Application
This module creates a new user using the standard (or non-standard) means of
creating a new user on the victim OS. This module requires root privileges
in order to run as it needs access to /etc/shadow.
Tested Versions
Verification Steps
use post/linux/manage/adduser
set session <id>
Options
USERNAME
Provide the username that can be used. Linux has a standardization that means
that password have to follow this regex to be able to be used as a username
^[a-z][a-z0-9_-]{0,31}$
PASSWORD
Provides a password for your new user.
SHELL
Define the shell that is to be used. Defaults to
/bin/sh
but can be changedto a shell that exists.
HOME
Speficy the home directory of the new user. An empty value specifies that the
home directory does not exist.
GROUPS
Specify what groups the new user should be under. Takes one or multiple values
to provide what groups the new user will have.
Advanced Options
SudoMethod
Sets the method that the new user will get root access. This can be done
through multiple methods provided below:
the groups option)
/etc/sudoers
file in order toprevent being removed from sudoers group
UseraddBinary
Set the binary used to add the user. The two main binaries concerned with are
useradd
andadduser
. If you want to overwrite which binary is used or givean absolute path rather than a relative path, you can override it here. Or you
can set it to
MANUAL
to make the module skip using a binary entirely and edit/etc/passwd
directly.MissingGroups
This option decides how to manage groups requested that are missing on the victim.
The possible options are provided as such:
them to the missing groups
to them
Scenarios