Methodology · Infrastructure and AD pentesting · Red teaming
Active Directory config review
Defensive Active Directory review checklist for audits: privileged accounts, krbtgt, delegation, LAPS, legacy protocols, GPOs, ADCS and logging.
Published
Cheatsheet · Infrastructure and AD pentesting
Read-only Linux host configuration review: system, accounts, sudo, SUID, services, cron, SSH and permissions, then a Lynis audit and reading its report.
Official website: Lynis
This cheatsheet describes a configuration review of a Linux server: what the system exposes, who can do what on it, and what departs from hardening best practice. It is a configuration audit, not exploitation: every command reads the system’s state without changing it. They run with an account supplied by the client on a host within the scope agreed in the penetration test scoping checklist. Example names (alice, target.example, 10.0.0.12) are fictitious.
# Distribution and version
cat /etc/os-release
# Kernel and architecture
uname -a
# Uptime: a host that has been up for a very long time has probably not applied its kernel patches
uptime
# Pending updates (depending on the distribution family)
apt list --upgradable 2>/dev/null
dnf check-update
Compare the distribution version with the vendor’s end-of-support date, and the running kernel (uname -r) with the installed one: an outdated kernel stays active until the server reboots. On a production environment, install and update nothing.
# Current identity and groups
id
# Sudo rights of the current account (may ask for its password)
sudo -l
# Accounts with an interactive shell
grep -vE '(nologin|false)$' /etc/passwd
# Accounts with UID 0 (only root should have it)
awk -F: '$3 == 0 {print $1}' /etc/passwd
# Members of administration groups
getent group sudo wheel adm docker
# Accounts with no password (reads /etc/shadow: needs administrator access)
sudo awk -F: '$2 == "" {print $1}' /etc/shadow
Points to watch: several UID 0 accounts, generic or old accounts still active, NOPASSWD: ALL rules, members of the docker group (equivalent to root access on the host), service accounts given an interactive shell. For every account’s sudo rules, read /etc/sudoers and /etc/sudoers.d/ with the administrator access you were given, never by editing them.
# SUID and SGID binaries on the local filesystem
find / -xdev -type f \( -perm -4000 -o -perm -2000 \) -ls 2>/dev/null
# World-writable files
find / -xdev -type f -perm -0002 -ls 2>/dev/null
# World-writable directories without the sticky bit
find / -xdev -type d -perm -0002 ! -perm -1000 -ls 2>/dev/null
Most SUID binaries are normal (passwd, sudo, mount): compare the list with the distribution’s standard installation and flag unusual binaries, especially in /home, /opt or /usr/local. -xdev avoids crossing into other filesystems (network, /proc); find over the whole disk loads the machine, so run it outside peak hours on a production server.
# Listening TCP and UDP sockets, with the process (full process names with administrator access)
ss -tulpn
# Established connections
ss -tnp state established
# Active services managed by systemd
systemctl list-units --type=service --state=running
Distinguish services listening on all interfaces (0.0.0.0, [::]) from those bound to 127.0.0.1. A database, cache or administration service reachable from the network is a finding. Match this list against the local firewall (nft list ruleset or iptables -S with administrator access) and an external scan authorised by the agreement, as described in the Nmap cheatsheet.
# System cron jobs
ls -l /etc/cron.d /etc/cron.daily /etc/cron.hourly /etc/crontab
# Current account's crontab
crontab -l
# systemd timers
systemctl list-timers --all
Look for tasks run as root that call a script or binary writable by an unprivileged account (use the listings above and ls -l on the file named): a classic permissions flaw. An unexpected job in /etc/cron.d is worth asking the client about.
# Effective configuration (administrator required)
sudo sshd -T | grep -Ei 'permitrootlogin|passwordauthentication|pubkeyauthentication|permitemptypasswords|x11forwarding|maxauthtries|allowusers|allowgroups|ciphers|macs|kexalgorithms'
# Source file, if administrator access is not available
grep -vE '^\s*(#|$)' /etc/ssh/sshd_config
ls -l /etc/ssh/sshd_config.d/
Values to examine: permitrootlogin yes, passwordauthentication yes on an exposed server, permitemptypasswords yes, no allowusers or allowgroups on a restricted-access host. sshd -T gives the configuration actually applied, including included files: it takes precedence over reading sshd_config alone. Cipher lists are judged against the client’s policy.
# Owner and permissions in octal
stat -c '%a %U:%G %n' /etc/passwd /etc/shadow /etc/group /etc/sudoers /etc/ssh/sshd_config
# Private keys and credential files readable by others
find /home /root /etc -xdev -type f \( -name 'id_rsa' -o -name 'id_ed25519' -o -name '*.pem' -o -name '.env' \) -ls 2>/dev/null
# Home directory and authorised keys
ls -ld /home/alice /home/alice/.ssh
ls -l /home/alice/.ssh/authorized_keys
Usual expectations: /etc/passwd at 644, /etc/shadow at 640, 600 or even 000 (depending on the distribution), /etc/sudoers at 440, private keys at 600. A credential file readable by everyone, or a .ssh directory open to other accounts, is a finding. Do not read the contents of keys or credential files: record their presence and permissions.
Lynis reviews the system (kernel, authentication, services, firewall, logging, cryptography…) and produces warnings and suggestions along with a hardening index. It installs from the distribution’s repository or the official archive, and does not change the configuration.
# Full audit (administrator privileges recommended: some tests depend on them)
sudo lynis audit system
# Without waiting for user input (useful in scripts)
sudo lynis audit system --quick
# Without administrator rights (reduced coverage)
lynis audit system --pentest
# List of commands
lynis show commands
The --pentest option runs the audit unprivileged: coverage is lower, but it matches what a standard account can observe. A full audit takes a few minutes, with moderate load on the host.
# Detailed log and structured report (default locations with administrator rights)
less /var/log/lynis.log
grep -E '^(warning|suggestion)\[\]' /var/log/lynis-report.dat
# Hardening index
grep hardening_index /var/log/lynis-report.dat
# Details of a test from its identifier
lynis show details SSH-7440
At the end of the run, Lynis prints a summary: hardening index (out of 100), warnings (warning) and suggestions (suggestion), each with its test identifier (for example SSH-7440). Sort the warnings first, then the suggestions touching authentication, networking and patching. The index measures the gap to Lynis’s own benchmark, not the level of risk: a high score does not rule out an application flaw, and a middling score on a deliberately minimal server is not alarming. Put suggestions in the client’s context before they enter the report. Lynis writes its files under /var/log with administrator rights; without them the location differs and Lynis states it at the end of the run: collect them as evidence and delete local copies at the end of the engagement.
find /) on a production server at peak hours.sudo commands, reads of /etc/shadow and running Lynis leave traces in authentication logs.Methodology · Infrastructure and AD pentesting · Red teaming
Defensive Active Directory review checklist for audits: privileged accounts, krbtgt, delegation, LAPS, legacy protocols, GPOs, ADCS and logging.
Published
Cheatsheet · Infrastructure and AD pentesting · Red teaming
Authenticated AD enumeration for an internal test: domain, accounts, groups, password policy, shares, LDAP queries and BloodHound collection.
Published
AI prompt · Infrastructure and AD pentesting · OSINT · Cloud
Prompt that analyses an asset inventory from the authorised scope (domains, IPs, services, cloud) to prioritise testing: exposure, criticality, checks.
Published
BEAROPS
BEAROPS experts test your applications, infrastructure and cloud, black box or grey box, following OWASP, NIST and ANSSI guidance.