Linux Shell

#!/bin/bash

echo "Current user:"
whoami

echo "Contents of current directory:"
ls -la

echo "Command history:"
history

echo "System information:"
uname -a

echo "Checking for known kernel exploits (Last Resort):"
# Add your kernel exploit checking command here

echo "Checking sudo privileges (If you have credentials):"
sudo -l

echo "Searching for files with specific name and setuid permissions:"
find / -type f -name "*WHATEVER*" -perm -4000 -ls 2>/dev/null

echo "Searching for files with 'flag' in the name:"
find / -type f -name "*flag*" -exec ls -l {} + 2>/dev/null

echo "Contents of system-wide crontab:"
cat /etc/crontab

echo "Contents of user's crontab:"
crontab -e

echo "Checking system path:"
echo $PATH

echo "Contents of NFS exports (if applicable):"
cat /etc/exports

echo "Checking file capabilities:"
getcap -r / 2>/dev/null

# Add any additional Linux enumerating commands below:

# Example:
# echo "Checking system users:"
# cat /etc/passwd

# Example:
# echo "Checking system services:"
# systemctl list-units --type=service

# Example:
# echo "Checking open network ports:"
# netstat -tuln

echo "Contents of /var/log:"
ls -la /var/log

echo "Contents of /var/adm:"
ls -la /var/adm

echo "Contents of /var/spool:"
ls -la /var/spool

echo "Last logged in users:"
last

echo "Last logins for all users:"
lastlog

echo "ARP table:"
arp -an

echo "Routing table:"
route print

echo "Network connections:"
netstat -nap

echo "Open files:"
lsof -l

echo "Contents of /etc/passwd:"
more /etc/passwd

echo "Contents of /etc/crontab:"
more /etc/crontab

echo "Contents of /etc/cron.*:"
ls -la /etc/cron.*

echo "Contents of /var/at/jobs:"
ls -la /var/at/jobs

echo "Contents of /etc/resolv.conf:"
more /etc/resolv.conf

echo "Contents of /etc/hosts:"
more /etc/hosts

echo "Verify integrity of installed packages:"
rpm -Va

echo "List of services and their states:"
chkconfig -list

echo "List of running processes:"
ps aux

echo "List of running processes (detailed):"
ps -ef

echo "List files and directories (sorted by modification time, within the last 2 days):"
find / -mtime -2d -ls

echo "List of system users (excluding comments):"
grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1 }'

echo "Information about users currently logged in:"
finger

echo "Information about users currently logged in (compact format):"
pinky

echo "List of currently logged in users:"
users

echo "System activity and login records:"
who -a

echo "Current system status and activity:"
w

echo "List of sudo privileges for the current user:"
sudo -l

echo "List of command history files in the user's home directory:"
ls -la ~/.*_history

echo "List of command history files in the root user's directory:"
ls -al /root/.*_history

echo "Current user's command history:"
history

echo "Contents of current user's bash history:"
cat ~/.bash_history

Last updated