2019-02-23 16:42:05 +01:00
# LinPE - Linux Privilege Escalation (one-liner)
2019-01-13 21:14:35 +01:00
The goal of this script is to enumerate fast a linux machine.
This script was designed so you only have to copy and paste the code inside the **sh** or **bash** console and all the output will be redirected to a file (by default /tmp/fels, but feel free to change it).
There is only one exception, the last command executed is *sudo -l* so this commands needs you to write the password of your user (if you know it).
2019-02-23 16:39:02 +01:00
## Checks
2019-02-23 16:34:58 +01:00
- **System Information**
- [x] SO, kernel version & sudo version
- [x] Date, time, selinux & env
- [x] Useful software installed
- [x] Capabilities
- [x] Processes (top, current, executed within a minute, binary permissions)
- [x] Scheduled tasks
- [x] sd* disk in /dev, storage info, ummounted file-sys, printers
2019-02-23 16:39:02 +01:00
2019-02-23 16:34:58 +01:00
- **Network Information**
- [x] Hostname, hosts & dns
- [x] Intefaces, networks and neightbours
- [x] Active ports and files used
- [x] Sniff permissions
2019-02-23 16:39:02 +01:00
2019-02-23 16:34:58 +01:00
- **Users Information**
- [x] Info about me (whoami, groups, sudo, PGPkeys)
- [x] List of superusers
- [x] Login info
- [x] Available users with console
2019-02-23 16:39:02 +01:00
- [x] List of all users
2019-02-23 16:34:58 +01:00
- **Interesting Files**
- [x] SUID & SGID files
- [x] Reduced list of files inside home
- [x] Files inside any .ssh directory
- [x] Mails
- [x] NFS exports
- [x] Hashes (passwd, shadow & master.passwd)
- [x] Try to read root dir
- [x] Check if Docker or LXC container
- [x] List ALL writable file for current users (global, user and groups)
- [x] *_history, profile, bashrc files
2019-02-23 16:39:02 +01:00
- [x] List of all hidden files
2019-02-23 16:34:58 +01:00
- [x] Inside /tmp, /var/tmp and /var/backups
- [x] Web files
- [x] Possible backup files
- [x] IPs inside logs
- [x] "password" and "passw" inside files
2019-02-23 16:39:02 +01:00
2019-02-23 16:34:58 +01:00
- [x] Sudo -l (so you can introduce your password if known)
2019-02-23 16:39:02 +01:00
## One liner
Here you have the script in one line, **just copy and paste it** ;)
2019-02-23 16:34:58 +01:00
2019-02-23 16:44:59 +01:00
The defult file where all the data is recorded is: */tmp/linPE* (you can change it at the beginning of the script)
2019-01-13 21:16:36 +01:00
2019-02-23 16:34:58 +01:00
``file="/tmp/linPE";RED='\033[0;31m';Y='\033[0;33m';B='\033[0;34m';NC='\033[0m';rm -rf $file;echo "File: $file";echo "[+]Gathering system information...";printf $B"[*] "$RED"BASIC SYSTEM INFO\n"$NC >> $file ;echo "" >> $file;printf $Y"[+] "$RED"Operative system\n"$NC >> $file;(cat /proc/version || uname -a ) 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"PATH\n"$NC >> $file;echo $PATH 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Date\n"$NC >> $file;date 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Sudo version\n"$NC >> $file;sudo -V 2>/dev/null| grep "Sudo ver" >> $file;echo "" >> $file;printf $Y"[+] "$RED"selinux enabled?\n"$NC >> $file;sestatus 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Useful software?\n"$NC >> $file;which nc ncat netcat wget curl ping gcc make gdb base64 socat python python2 python3 python2.7 python2.6 python3.6 python3.7 perl php ruby xterm 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Capabilities\n"$NC >> $file;getcap -r / 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Environment\n"$NC >> $file;(set || env) 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Top and cleaned proccesses\n"$NC >> $file;top -n 1 2>/dev/null | head -n 13 >> $file;ps aux 2>/dev/null | grep -v "\[" >> $file;echo "" >> $file;printf $Y"[+] "$RED"Binary processes permissions\n"$NC >> $file;ps aux 2>/dev/null | awk '{print $11}'|xargs -r ls -la 2>/dev/null |awk '!x[$0]++' 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Different processes executed during 1 min (HTB)\n"$NC >> $file;if [ "`ps -e --format cmd`" ]; then for i in {1..121}; do ps -e --format cmd >> $file.tmp1; sleep 0.5; done; sort $file.tmp1 | uniq | grep -v "\[" | sed '/^.\{500\}./d' >> $file; rm $file.tmp1; fi;echo "" >> $file;printf $Y"[+] "$RED"Proccesses binary permissions\n"$NC >> $file;ps aux 2>/dev/null | awk '{print $11}'|xargs -r ls -la 2>/dev/null |awk '!x[$0]++' 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Scheduled tasks\n"$NC >> $file;crontab -l 2>/dev/null >> $file;ls -al /etc/cron* 2>/dev/null >> $file;cat /etc/cron* /etc/at* /etc/anacrontab /var/spool/cron/crontabs/root /var/spool/anacron 2>/dev/null | grep -v "^#" >> $file;echo "" >> $file;printf $Y"[+] "$RED"Any sd* disk in /dev?\n"$NC >> $file;ls /dev 2>/dev/null | grep -i "sd" >> $file;echo "" >> $file;printf $Y"[+] "$RED"Storage information\n"$NC >> $file;df -h 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Unmounted file-system?\n"$NC >> $file;cat /etc/fstab 2>/dev/null | grep -v "^#" >> $file;echo "" >> $file;printf $Y"[+] "$RED"Printer?\n"$NC >> $file;lpstat -a 2>/dev/null >> $file;echo "" >> $file;echo "" >> $file;echo "[+]Gathering network information...";printf $B"[*] "$RED"NETWORK INFO\n"$NC >> $file ;echo "" >> $file;printf $Y"[+] "$RED"Hostname, hosts and DNS\n"$NC >> $file;cat /etc/hostname /etc/hosts /etc/resolv.conf 2>/dev/null | grep -v "^#" >> $file;dnsdomainname 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Networks and neightbours\n"$NC >> $file;cat /etc/networks 2>/dev/null >> $file;(ifconfig || ip a) 2>/dev/null >> $file;iptables -L 2>/dev/null >> $file;(arp -e || arp -a || ip n) 2>/dev/null >> $file;route 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Ports\n"$NC >> $file;(netstat -punta || ss -t; ss -u) 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Files in use by network services\n"$NC >> $file;lsof -i 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Can I sniff with tcpdump?\n"$NC >> $file;timeout 1 tcpdump >> $file 2>&1; echo "" >> $file;echo "" >> $file;echo "[+]Gathering users information...";printf $B"[*] "$RED"USERS INFO\n"$NC >> $file ;echo "" >> $file;printf $Y"[+] "$RED"Me\n"$NC >> $file;(id || (whoami && groups)) 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Sudo -l without password\n"$NC >> $file;echo '' | sudo -S -l -k 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Do I have PGP keys?\n"$NC >> $file;gpg --list-keys 2>/dev/null >> $file;echo "" >> $file;printf $Y"[+] "$RED"Superus