Linux
Introduction
This section contains some useful commands that will help you enumerate the Linux system, obtaining helpful information for a later Privilege Escalation or Lateral movements.
User and group enumeration
Print real and effective user and group IDs from the current user:
id
List all users, groups and shells for each user:
cat /etc/passwd
List user accounts who does not require password:
List the allowed (and forbidden) commands for the invoking or specified (
-u
) user:sudo -l
List all existing groups:
cat /etc/group | sort
Print executed commands (Looking for credentials):
{cat ~/.bash_history} | {history}
Operative System
Architecture:
Environment variables:
Network Enumeration
List network interfaces:
ip -br a
List all connections:
netstat -putona
List only listening ports:
netstat pluton | ss -pltn
List hardcoded domains:
cat /etc/hosts
List iptables:
iptables -L
Outgoing connections to a specific IP:
ss -anpt | grep <NETWORK> | grep ESTAB
Real-time traffic monitoring:
tcpdump -i <if> -s0 -n -vv
Obtian WiFi passwords:
sudo grep psk= /etc/NetworkManager/system-connections/*
Files enumeration
Files owned by a user
There might be files owned by a specific user stored in hidden folders.
Modified files
There might be files being modified with a cronjob or during a workday.
Accessed files
There might be files being accessed with a cronjob or during a workday.
Disks
List mounted disks at Linux startup.
Password Enumeration
Look for files that contain passwords or keys.
Cronjobs
List scheduled jobs.
SSH
Find SSH keys:
Control Master
When ControlMaster is enabled, the initial SSH connection (the master connection) is established, and subsequent connections (slave connections) can reuse the existing master connection. This can lead to faster connection times and reduced resource usage, especially when connecting to the same remote server multiple times.
If an attacker gains access to a system where SSH ControlMaster is in use, they might exploit the existing master connection to execute commands or perform other malicious activities without the need to authenticate repeatedly.
Check if the file
~/.ssh/config
exists with the following configuration. Meaning, that ControlMaster is enabled.
Look for any active connection under
~/.ssh/controlmaster/
.
Use the existing connection to perform lateral movement.
User: If you are the user to whom the connection file belongs, simply SSH to the session.
Root:
SSH Agent Forwarding
SSH Agent Forwarding allows the SSH-Agent on a local machine to be used for authentication when connecting to remote servers.
If an attacker gains access to a machine where Agent Forwarding is active, they might abuse the forwarded agent connection to authenticate to other machines.
Check if ~/.ssh/config
contains ForwardAgent yes
or the SSH configuration /etc/ssh/sshd_config
on the server must have AllowAgentForwarding yes
. Then, check if there is any active connection.
User: If you are the user to whom the connection belongs, simply SSH to the session. Then, simply execute the SSH command to automatically access the other computer.
Root: Inspect processes with "ssh" in the name, we will find any open connections from the host. We can use the usernames listed in these connections with the pstree command to get the process ID (PID) values for the SSH processes.
Then, we extract the SSH_AUTH_SOCK
environment variable from their connection to obtain the stored SSH socket.
After that, we need to add it:
Finally, we can try to access the target we might have in mind that the victim is connecting to or look for clues in order to see where our victim is connecting to.
Kerberos
Kerberos tickets can also be found on Linux machines that belong to Active Directory domains. Enumerating the machine looking for Kerberos information can be crucial to perform lateral movement to other machines on the domain.
Obtain domain information from the kerberos configuration file.
Find KRB user cache credentials.
Impersonate user using
krb5cc_
files.
Find keytab files.
Extract keytab information like domain, service principal and NTLM hash.
List tickets currently stored in the userâs credential cache file.
Convert a Mimikatz ticket to ccache.
Last updated