#!/bin/bash

echo "=== IDENTITY ==="
id
whoami
groups
cat /proc/1/cgroup 2>/dev/null | head -5
systemd-detect-virt 2>/dev/null || echo "No systemd-detect-virt"
capsh --print 2>/dev/null || echo "No capsh"
getenforce 2>/dev/null || echo "SELinux not active"
aa-status 2>/dev/null || echo "AppArmor not available"

echo -e "
=== CREDENTIALS ==="
find /home /root -name "id_*sa" 2>/dev/null | head -20
find /home /root -name ".git-credentials" -o -name ".netrc" -o -name ".aws" 2>/dev/null | head -20
find / -name "*.pem" -o -name "*.key" 2>/dev/null | grep -v "/proc/" | head -20
env | grep -iE 'password|token|key|secret|api'
find /var/www /opt -type f -name "*.conf" -o -name "*.ini" -o -name ".env" 2>/dev/null | head -20

echo -e "
=== NETWORK ==="
ip -br addr
ip route show
ss -tupan 2>/dev/null || netstat -tupan 2>/dev/null
ip neigh show
cat /etc/resolv.conf
cat /etc/hosts | grep -v "^#"

echo -e "
=== PERSISTENCE ==="
crontab -l 2>/dev/null || echo "No user crontab"
ls -la /etc/cron* 2>/dev/null | head -30
ls -la /var/spool/cron/crontabs/ 2>/dev/null
systemctl list-timers --all 2>/dev/null | head -20
cat /etc/rc.local 2>/dev/null
ls -la /etc/init.d/ 2>/dev/null | head -20

echo -e "
=== SYSTEM INFO ==="
uname -a
cat /etc/os-release 2>/dev/null
df -h
ps aux | head -20

echo -e "
=== SUID/SGID ==="
find / -perm -4000 -type f 2>/dev/null | head -30
find / -perm -2000 -type f 2>/dev/null | head -30

echo -e "
=== WRITABLE ==="
find /etc /var /opt -writable -type f 2>/dev/null | head -30
find /etc /var /opt -writable -type d 2>/dev/null | head -30
