Privilegeescalation

12 min read2,334 words

PRIVILEGE ESCALATION

Privilege escalation is one of the most important skills in penetration testing because getting initial access is often not the end of the attack.

Privilege escalation = turning limited access into higher-level access by abusing a weakness, misconfiguration, excessive permission, credential exposure, or software flaw.

Practice only on systems you own, CTFs, labs, or explicitly authorized targets.

The Basic Concept

Imagine you compromise a Linux server and obtain:

www-data

But:

root

has much greater privileges.

Your situation is:

SERVER │ ┌────────┴────────┐ │ │ www-data root LOW PRIV HIGH PRIV

Privilege escalation asks:

www-data ↓ What can this user access? ↓ What permissions exist? ↓ What credentials/secrets exist? ↓ What software/services run? ↓ Is anything misconfigured? ↓ Can privileges be elevated? ↓ root

Two Types of Privilege Escalation

Horizontal Privilege Escalation

You move from one user to another user with similar privileges.

User A ↓ User B

Example:

alice → bob

Both may be normal users.

Vertical Privilege Escalation

You move from a low-privileged user to a higher-privileged account.

Normal User ↓ Administrator

Linux:

user ↓ root

Windows:

standard user ↓ Administrator / SYSTEM

This is usually the more significant form.

Why Privilege Escalation Happens

Common causes include:

Weak permissions Misconfigured sudo SUID binaries Cron jobs Exposed credentials Weak Windows services Unquoted service paths Insecure scheduled tasks Kernel vulnerabilities Weak file permissions Dangerous capabilities Secrets in configuration files PATH manipulation

The important lesson:

Privilege escalation is usually an enumeration problem before it becomes an exploitation problem.

The Privilege Escalation Methodology

Memorize this workflow:

Initial Access ↓ Identify Current User ↓ System Enumeration ↓ Permission Enumeration ↓ Credential/Secret Enumeration ↓ Process & Service Enumeration ↓ Find Attack Path ↓ Validate Weakness ↓ Controlled Exploitation ↓ Higher Privilege ↓ Evidence + Cleanup

🐧 Linux Privilege Escalation

Let's start with Linux because it is extremely important for CTFs and penetration testing.

Suppose you have:

www-data

Your first job is enumeration.

Identify Current User

Basic commands:

whoami
id
groups

You may discover:

uid=33(www-data) gid=33(www-data) groups=www-data

Now you know your starting position.

System Information

Check:

uname -a

and:

cat /etc/os-release

You're trying to understand:

Kernel Distribution Version Architecture

For example:

Ubuntu Debian Kali CentOS Rocky Linux

Hostname

hostname

This may help identify:

Server role Machine name Environment CTF target

Current Environment

Check:

pwd
env
echo $PATH

Environment variables can sometimes contain useful configuration or secrets.

Be careful when reporting sensitive information.

Sudo

One of the first things to check:

sudo -l

This tells you what commands the current user may execute through sudo.

Example:

User www-data may run: /usr/bin/some-program

Now the question becomes:

Why can this user execute that program with elevated privileges?

Why Sudo Misconfiguration Matters

Imagine:

Normal User │ │ sudo ▼ Privileged Program │ ▼ Potentially higher privilege

The dangerous situation isn't simply:

“sudo exists.”

It's:

“This user can execute something with elevated privileges, and that program provides an unsafe path to higher privilege.”

SUID

SUID is extremely important in Linux privilege escalation.

Find SUID files in an authorized lab:

find / -perm -4000 -type f 2>/dev/null

SUID means a program can execute with the privileges of its file owner.

Conceptually:

Executable owned by root + SUID ↓ Program may execute with root privileges

That doesn't automatically mean vulnerability.

You must determine:

Is the binary expected? Is its behavior dangerous? Can user-controlled data influence it? Can it execute another program? Is it a known vulnerable binary?

File Permissions

Linux permissions look like:

-rwxr-xr--

Think:

Owner Group Others

For example:

rwx

means:

r = read w = write x = execute

You need to understand permissions extremely well.

Dangerous Writable Files

Suppose a privileged process uses:

/opt/scripts/backup.sh

and you discover:

-rwxrwxrwx

That should immediately make you investigate.

Why?

Low privilege user ↓ Can modify script ↓ Privileged process executes script ↓ Potential privilege escalation

This is a classic attack pattern.

Cron Jobs

Linux systems may use scheduled jobs.

Check cron configuration in your lab:

cat /etc/crontab

and inspect relevant cron directories.

Conceptually:

Cron ↓ Runs script periodically ↓ Script runs as root

If a low-privileged user can modify that script:

User ↓ Modify script ↓ Cron executes it ↓ Higher privilege

Again, the vulnerability is the permission/configuration weakness, not simply the existence of cron.

PATH Hijacking

Consider:

backup

instead of:

/usr/local/bin/backup

The system searches directories defined in:

echo $PATH

If a privileged process relies on an unsafe PATH configuration, an attacker may potentially influence which executable is found.

Conceptually:

Privileged program ↓ Runs "backup" ↓ PATH lookup ↓ Unexpected executable

This is why understanding environment variables matters.

Linux Capabilities

Linux capabilities divide certain root privileges into smaller privileges.

You may encounter:

cap_net_raw cap_setuid cap_dac_override

Find capabilities in a lab:

getcap -r / 2>/dev/null

The important question is:

Does a privileged capability assigned to an executable create an unintended path to higher privilege?

Don't assume every capability is exploitable.

Running Processes

Look at processes:

ps aux

or:

ps -ef

You're looking for:

Root processes Custom applications Scripts Unusual services Weak configurations Credentials in command lines

Conceptually:

Process ↓ Who owns it? ↓ What does it execute? ↓ Can I influence it?

Services

Check services:

systemctl list-units --type=service

You want to understand:

Which services run? Which user runs them? Where are their binaries? What configuration do they use? Can low-privileged users modify them?

Configuration Files

Important locations may include:

/etc/ /opt/ /var/www/ /home/ /usr/local/ /var/log/

Web servers are especially interesting.

For example:

/var/www/html

may contain:

config.php .env database configuration API credentials application source

Never assume a secret is harmless just because it is stored in a configuration file.

Credential Hunting

Credentials may accidentally appear in:

Configuration files Source code Environment variables Shell history Backup files Logs Scripts Application files

For example:

history

may reveal commands containing sensitive information.

Professional testing requires careful handling of discovered credentials.

SSH Keys

User home directories may contain:

~/.ssh/

Possible files:

authorized_keys known_hosts config private keys

You should understand the security implications of improperly protected private keys.

Linux Enumeration Cheat Sheet

A basic lab enumeration sequence:

whoami id hostname uname -a cat /etc/os-release sudo -l groups ps aux ss -tulpn ip addr ip route env echo $PATH find / -perm -4000 -type f 2>/dev/null getcap -r / 2>/dev/null cat /etc/crontab

Don't just run commands.

For every result ask:

“What does this tell me about my possible attack paths?”

🪟 Windows Privilege Escalation

Windows privilege escalation follows the same fundamental methodology.

Initial User ↓ System Enumeration ↓ Privileges ↓ Services ↓ Scheduled Tasks ↓ Files ↓ Credentials ↓ Misconfigurations ↓ Administrator/SYSTEM

Windows Identity

Useful commands:

whoami
whoami /priv
whoami /groups

These tell you:

Current account Privileges Group membership

Windows System Information

systeminfo

Look for:

Windows version Build Architecture Hotfixes System type

This helps determine whether known vulnerabilities might be relevant.

Windows Users

net user

To inspect a particular account:

net user <username>

Groups:

net localgroup

This helps build your privilege map.

Windows Services

Services are a major attack surface.

You can inspect them using:

sc query

or PowerShell:

Get-Service

Ask:

Who runs the service? Where is the executable? Who can modify the executable? Who can modify the service configuration?

Weak Service Permissions

Conceptually:

Service runs as SYSTEM ↓ Low-privileged user can modify service binary/configuration ↓ Service restarts ↓ Modified code executes as SYSTEM

The vulnerability is the weak permission boundary.

Unquoted Service Paths

A classic Windows concept.

Suppose a service uses an executable path containing spaces but doesn't properly quote it.

Conceptually:

C:\Program Files\Example App\service.exe

Under certain conditions, Windows may resolve executable paths unexpectedly.

This can create a privilege-escalation opportunity if an attacker can place a malicious executable at the relevant location.

This should be studied in a dedicated Windows lab rather than tested on real machines.

Scheduled Tasks

Windows scheduled tasks can execute programs periodically.

Conceptually:

Scheduled Task ↓ Runs as privileged user ↓ Executes file

If a low-privileged user can modify that executable or script:

Modify ↓ Task executes ↓ Higher privilege

Windows Registry

The registry contains extensive system configuration.

Privilege-escalation investigations can involve:

Service configuration Startup configuration Application configuration Credentials/secrets

But registry entries should always be interpreted in context.

Windows Tokens

Windows uses security tokens to represent:

Identity Groups Privileges Security context

Important concepts include:

Access tokens Impersonation Delegation Privilege assignment

This becomes more advanced later when you study Active Directory.

UAC

User Account Control (UAC) helps prevent unauthorized administrative actions.

Important distinction:

Administrator account ≠ Every process automatically running fully elevated

UAC affects how Windows handles elevation.

You should learn:

Standard user Administrator Elevation prompt Integrity levels UAC

Kernel Exploitation

Sometimes the operating system itself contains a vulnerability.

Conceptually:

Low privilege ↓ Vulnerable kernel ↓ Kernel exploit ↓ Higher privilege

But kernel exploits should be your last option, not your first.

Why?

They can:

Crash the machine Corrupt data Create instability Break the lab

Professional methodology prefers safer misconfiguration-based paths when available.

Automated Enumeration Tools

Once you understand manual enumeration, tools can accelerate it.

Common tools include:

Linux

LinPEAS LinEnum pspy

Windows

WinPEAS PowerUp Seatbelt

These tools can identify potential:

Misconfigurations Credentials Services Permissions SUID files Scheduled tasks Interesting files

But remember:

Enumeration tool ≠ vulnerability confirmation.

A tool may produce dozens of findings.

You must determine which one actually provides a viable attack path.

Manual + Automated Workflow

Professional approach:

Automated enumeration ↓ Potential findings ↓ Manual verification ↓ Attack-path analysis ↓ Controlled exploitation

Not:

Run tool ↓ Copy everything ↓ Call it hacked

Example Linux Attack Path

Imagine:

Initial access: www-data

Enumeration discovers:

/opt/backup.sh

Permissions:

www-data can modify it

Cron:

root executes /opt/backup.sh

Attack path:

www-data ↓ Writable backup script ↓ Root cron executes script ↓ root

This is an excellent example of attack-path reasoning.

Example Windows Attack Path

Imagine:

Initial access: Standard User

Enumeration:

Service runs as SYSTEM

Then:

Service executable ↓ Writable by standard user

Attack path:

Standard User ↓ Modify service executable ↓ SYSTEM service executes it ↓ SYSTEM

Again:

Finding → Relationship → Attack path

Privilege Escalation Is About Relationships

Don't memorize:

SUID = exploit Cron = exploit Service = exploit

Instead:

Permission + Privileged execution + User control = Potential privilege escalation

For example:

Writable file alone ↓ Not necessarily vulnerable

But:

Writable file + Root executes it ↓ Potential escalation

This distinction is extremely important.

🧪 Your Practical Lab

Build:

KALI │ ┌───────┴───────┐ │ │ Linux Lab Windows Lab │ │ ▼ ▼ Low-priv user Standard user │ │ ▼ ▼ Enumeration Enumeration │ │ ▼ ▼ Attack Path Attack Path │ │ ▼ ▼ ROOT SYSTEM/ADMIN

Good learning platforms include intentionally vulnerable machines from TryHackMe, Hack The Box, and similar legal labs.

🎯 Your First PrivEsc Practice

For a Linux lab, don't immediately use an automated tool.

Start manually:

whoami id hostname uname -a cat /etc/os-release sudo -l ps aux ss -tulpn ip addr ip route env echo $PATH find / -perm -4000 -type f 2>/dev/null getcap -r / 2>/dev/null cat /etc/crontab

Then create a table:

FindingOwnerWritable?Privileged?Interesting?
File ArootNoYesMaybe
Script BrootYesYesYes
Service CuserYesNoLow
SUID DrootNoYesInvestigate

This teaches you to analyze, not just execute commands.

🧠 Privilege Escalation Mindset

When you obtain a shell, don't immediately think:

“How do I become root?”

Think:

WHO AM I? ↓ WHAT CAN I ACCESS? ↓ WHAT CAN I MODIFY? ↓ WHAT RUNS WITH MORE PRIVILEGE? ↓ CAN I INFLUENCE IT? ↓ IS THERE A SAFE ATTACK PATH? ↓ CAN I PROVE IT?

The core principle is:

Find something you control that a more privileged process trusts.

That single idea explains a huge amount of privilege escalation.

📚 Roadmap Progress

01. Methodology ✅ 02. Reconnaissance ✅ 03. Scanning ✅ 04. Vulnerability Assessment ✅ 05. Web Hacking ✅ 06. Exploitation ✅ 0rivilege Escalation ✅ 08. Active Directory ← NEXT 09. Wireless 10. Post-Exploitation 11. Specialized Security 12. Analysis 13. Bug Bounty & CTF 14. Professional Pentesting

Next: 8. Active Directory

This will be a major topic. We'll cover Windows domains, Domain Controllers, users/groups, Kerberos, LDAP, SMB, DNS, Group Policy, domain enumeration, BloodHound, authentication, NTLM, Kerberoasting, AS-REP Roasting, credential attacks, lateral movement, delegation, privilege escalation, and AD attack paths—with the focus on understanding why each attack works, not simply running tools.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy