2. Environment enum

Refer to intro OS Version Kernel Version Running services

https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS https://github.com/rebootuser/LinEnum

Situational awareness: After revshell, gain persistence.

Regardless of system, having a thorough and repeatable process is key. Typically a series of whoami, id, hostname, ifconfig or ip -a , and sudo -l answers:

Including SS of above info can be helpful in clientg report to provide evidence of successful RCE and clearly identify affected system.

Step-by-step enumeration: System OS and version we're dealing with:

cat /etc/os-release

PATH - Where linux system loosk every time cmd is executed, for any executables to match name of what we type - If this is misconfigured it's leveragable to escalate privileges.

echo $PATH

ENV - All env vars set for our current user - May get lucky and find something sensitive in there such as a password.

env

Kernel version

cat /proc/version
uname -a

CPU type / version

lscpu

What login shells exist on the server?

cat /etc/shells

Defenses? Some things to look for include:

Drives and shares

lsblk
lpstat

Check for mounted / unmounted drives. Can we mount unmounted and gain access to sensitive data? Find any creds in fstab for mounted drives by grepping common words i.e. password username credential etc in /etc/fstab?

cat /etc/fstab

Route table

route
netstat -rn

Determines what other networks are available via which interface. In domain environment we definitely want to check /etc/resolv.conf - if host is configured to use internal DNS we may be able to use this as a starting point to query AD environment. Also, check ARP table to see other hosts target has communicated with

arp -a

Users Environment enumeration also includes knowledge about users that exist on tgt system. This is because individ users often configured during installation of applications and svcs to limit service's privileges. The reason for this is to maintain sec of sys itself. If svc run as root, and this is brought under control by an attacker, the attacker automatically has highest rights over entire system. All users are stored in /etc/passwd file.

Keep note if hashes are available in /etc/passwd and /etc/shadow. Crackable. Not common, but can be seen on embedded devicews and routers.

Hash identifiers

Algorithm Hash
Salted MD5 $1$...
SHA-256 $5$...
SHA-512 $6$...
BCrypt $2a$...
Scrypt $7$...
Argon2 $argon2i$...

Check what users have login shells. Once we see what shells are on system we can check each version for vulnerabilities. Outdated versions are vulnerable to certain exploits. (i.e. bash version 4.1 = shellshock)

Each user in linux assigned to a specific group or groups and thus receives special privs. For example if a folder named dev only for developers, user assigned to dev group for access. Check /etc/group https://man7.org/linux/man-pages/man1/getent.1.html getent cmd to list members of any interesting groups.

getent group sudo

Home directory

Conf files - Low hanging fruit

find / ! -path "*/proc/*" -iname "*config*" -type f 2>/dev/null
find / -type f \( -name "*.conf" -o -name "*.config" \) 2>/dev/null

 You can recursively search within files with grep and then list the filenames that match your search query to find the flag.

You can do this with:

grep -r -l 'search-query-here' /path/to/search

Mounted file systems

df -h
cat /etc/fstab | grep -v "#" | column -t

All hidden files

find / -type f -name ".*" -exec ls -l {} \; 2>/dev/null | grep htb-student

All hidden directories

find / -type d -name ".*" -ls 2>/dev/null

Temporary files

ls -l /tmp /var/tmp /dev/shm

It's worth running LINPEAS at this point in a real-world assessment to have as much data to dig through as possible. Oftentimes we can find an easy win but having this output handy can sometimes uncover nuanced issues that our manual enum missed. In practice, manual enumerate as much as possible and create our own cheat sheet of commands (and alternatives for other linux OS) Develop your own style, command preference, and even see some areas we can script ourselves. Tools are great and have their place but many fall short in being able to perform a given task when tool fails or are unable to use it on a given system.