Adversaries may attempt to get a listing of local system or domain accounts.Example commands that can acquire this information are
net user
,net group
, andnet localgroup
using the Net utility or through use of dsquery. If adversaries attempt to identify the primary user, currently logged in user, or set of users that commonly uses a system, System Owner/User Discovery may apply.On Mac, groups can be enumerated through the
groups
andid
commands. In mac specifically,dscl . list /Groups
anddscacheutil -q group
can also be used to enumerate groups and users.On Linux, local users can be enumerated through the use of the
/etc/passwd
file which is world readable. In mac, this same file is only used in single-user mode in addition to the/etc/master.passwd
file.Also, groups can be enumerated through the
groups
andid
commands.With authenticated access there are several tools that can be used to find accounts. The
Get-MsolRoleMember
PowerShell cmdlet can be used to obtain account names given a role or permissions group.(Citation: Microsoft msolrolemember)(Citation: GitHub Raindance)Azure CLI (AZ CLI) also provides an interface to obtain user accounts with authenticated access to a domain. The command
az ad user list
will list all users within a domain.(Citation: Microsoft AZ CLI)(Citation: Black Hills Red Teaming MS AD Azure, 2018)The
Get-GlobalAddressList
PowerShell cmdlet can be used to obtain email addresses and accounts from a domain using an authenticated session.(Citation: Microsoft getglobaladdresslist)(Citation: Black Hills Attacking Exchange MailSniper, 2016)
Enumerate all accounts by copying /etc/passwd to another file
Supported Platforms: Linux, macOS
Name | Description | Type | Default Value |
---|---|---|---|
output_file | Path where captured results will be placed | Path | /tmp/T1087.txt |
cat /etc/passwd > #{output_file}
cat #{output_file}
rm -f #{output_file}
(requires root)
Supported Platforms: Linux, macOS
Name | Description | Type | Default Value |
---|---|---|---|
output_file | Path where captured results will be placed | Path | /tmp/T1087.txt |
cat /etc/sudoers > #{output_file}
cat #{output_file}
rm -f #{output_file}
View accounts wtih UID 0
Supported Platforms: Linux, macOS
Name | Description | Type | Default Value |
---|---|---|---|
output_file | Path where captured results will be placed | Path | /tmp/T1087.txt |
grep 'x:0:' /etc/passwd > #{output_file}
cat #{output_file} 2>/dev/null
rm -f #{output_file} 2>/dev/null
List opened files by user
Supported Platforms: Linux, macOS
username=$(echo $HOME | awk -F'/' '{print $3}') && lsof -u $username
Show if a user account has ever logged in remotely
Supported Platforms: Linux
Name | Description | Type | Default Value |
---|---|---|---|
output_file | Path where captured results will be placed | Path | /tmp/T1087.txt |
lastlog > #{output_file}
cat #{output_file}
rm -f #{output_file}
if [ -x "$(command -v lastlog)" ]; then exit 0; else exit 1;
echo "Install lastlog on the machine to run the test."; exit 1;
Utilize groups and id to enumerate users and groups
Supported Platforms: Linux, macOS
groups
id
Utilize local utilities to enumerate users and groups
Supported Platforms: macOS
dscl . list /Groups
dscl . list /Users
dscl . list /Users | grep -v '_'
dscacheutil -q group
dscacheutil -q user
Enumerate all accounts Upon exection, multiple enumeration commands will be run and their output displayed in the PowerShell session
Supported Platforms: Windows
net user
net user /domain
dir c:\Users\
cmdkey.exe /list
net localgroup "Users"
net localgroup
Enumerate all accounts via PowerShell. Upon execution, lots of user account and group information will be displayed.
Supported Platforms: Windows
net user
net user /domain
get-localuser
get-localgroupmember -group Users
cmdkey.exe /list
ls C:/Users
get-childitem C:\Users\
dir C:\Users\
get-aduser -filter *
get-localgroup
net localgroup
Enumerate logged on users. Upon exeuction, logged on users will be displayed.
Supported Platforms: Windows
query user
Enumerate logged on users via PowerShell. Upon exeuction, logged on users will be displayed.
Supported Platforms: Windows
query user
ADRecon extracts and combines information about an AD environement into a report. Upon execution, an Excel file with all of the data will be generated and its path will be displayed.
Supported Platforms: Windows
Name | Description | Type | Default Value |
---|---|---|---|
adrecon_path | Path of ADRecon.ps1 file | Path | $env:TEMP\ADRecon.ps1 |
Invoke-Expression #{adrecon_path}
Remove-Item #{adrecon_path} -Force -ErrorAction Ignore | Out-Null
Get-ChildItem $env:TEMP -Recurse -Force | Where{$_.Name -Match "^ADRecon-Report-"} | Remove-Item -Force -Recurse
if (Test-Path #{adrecon_path}) {exit 0} else {exit 1}
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/sense-of-security/ADRecon/38e4abae3e26d0fa87281c1d0c65cabd4d3c6ebd/ADRecon.ps1" -OutFile #{adrecon_path}