Linux
Enumeration
OS Version
Kernel Version
Running Services
$ ps aux | grep root
Installed Packages and Versions
Logged in users
$ ps au
User Home Directories
$ ls /home$ ls -la /home/stacey.jenkins/SSH Directory Contents
$ ls -l ~/.ssh
Bash history
$ history
Sudo Privileges
$ sudo -l
Configuration Files
search usernames and passwords in
*.confand*.config
Readable Shadow File
Password hashes in /etc/passwd
$ cat /etc/passwd
Cron Jobs
$ ls -la /etc/cron.daily/
Unmounted File systems and Additional Drives
$ lsblk
SETUID and SETGID Permissions
Writable Directories
$ find / -path /proc -prune -o -type d -perm -o+w 2>/dev/null
Writable Files
$ find / -path /proc -prune -o -type f -perm -o+w 2>/dev/null
Environment Enumeration
What user are we running
What groups does our user belong to
What is the server named. can we gather anything from the naming convention?
What subnet did we land in, does the host have additional NICs in other subnets?
What's the CPU type/version
Can our user run anything with sudo (as another user as root) without needing a password?
What OS and version is the machine
Is the $PATH misconfigured? Can we leverage anything in the $PATH?
Are there any stored credentials in the ENV?
What login shells exists on the server
Are there any harddisks, usb drives, optical drives?
Are there any active/queued print jobs that can we gain access to some sensitive info?
Can we mount an unmounted drive?
Mounted file systems?
Unmounted file systems?
Any interesting other networks are available via which interface.
What other hosts does the target has been communicating
Other users?
Users with login shells?
Existing groups?
List members of a group
All hidden files?
All hidden folders?
Temporary Files?
Find a file containing a string?
Find config files?
We should also check to see if any defenses are in place and we can enumerate any information about them. Some things to look for include:
Often we will not have the privileges to enumerate the configurations of these protections but knowing what, if any, are in place, can help us not to waste time on certain tasks.
Internals Enumeration
Network interfaces
Hosts
User's last login
Logged in users
Command history
Finding history files
Cron
Proc
Services Enumeration
Installed Packages
Sudo Version
Binaries
GTFObins
Trace System Calls
diagnostic tool on Linux-based operating systems to track and analyze system calls and signal processing.
Configuration Files
Scripts
Running Services by User
Credential Hunting
These may be found in configuration files (.conf, .config, .xml, etc.), shell scripts, a user's bash history file, backup (.bak) files, within database files or even in text files.
In wpconfig.php
*config files
SSH Keys
Linux Hardening
Updates and patching
Use the unattended-upgrades package installed in linux
Configuration management
Audit writable files and directories and any binaries set with the SUID bit.
Ensure that any cron jobs and sudo privileges specify any binaries using the absolute path.
Do not store credentials in cleartext in world-readable files.
Clean up home directories and bash history.
Ensure that low-privileged users cannot modify any custom libraries called by programs.
Remove any unnecessary packages and services that potentially increase the attack surface.
Consider implementing SELinux, which provides additional access controls on the system.
User management
We should limit the number of user accounts and admin accounts on each system, ensure that logon attempts (valid/invalid) are logged and monitored. It is also a good idea to enforce a strong password policy, rotate passwords periodically, and restrict users from reusing old passwords by using the /etc/security/opasswd file with the PAM module. We should check that users are not placed into groups that give them excessive rights not needed for their day-to-day tasks and limit sudo rights based on the principle of least privilege.
Templates exist for configuration management automation tools such as Puppet, SaltStack, Zabbix and Nagios to automate such checks and can be used to push messages to a Slack channel or email box as well as via other methods. Remote actions (Zabbix) and Remediation Actions (Nagios) can be used to find and auto correct these issues over a fleet of nodes. Tools such as Zabbix also feature functions such as checksum verification, which can be used for both version control and to confirm sensitive binaries have not been tampered with. For example, via the vfs.file.cksum file.
Audit
One useful tool for auditing Unix-based systems (Linux, macOS, BDS, etc.) is Lynis.
Last updated