Module 2 ยท Lesson 3 ยท 30 minutes

๐Ÿ” Access Rights and Root

What does "root" mean, where passwords live, what is chmod 755. The basis for attacks on Linux servers.

๐Ÿ“– Story Hook

In 2024, a hacker named NCSC hacked a large company's mail server. The method was simple: they found a file /etc/shadow with permissions 644 instead of 600.

This means - an ordinary user could read it. Inside - hashes of all passwords. After 2 hours, hashcat decrypted 80% of the passwords.

One digit in the access rights cost the company millions. This lesson is about that digit.

๐Ÿง  Main Point: Linux is a Multi-User System

In Windows, you're usually the only user. In Linux - there are dozens. root, kali, www-data, mysql, postgres. Each has their own files and permissions.

Command to see all users:

cat /etc/passwd

Will show lines like:

root:x:0:0:root:/root:/bin/bash
kali:x:1000:1000:Kali Linux User:/home/kali:/bin/bash
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin

Each line is a user. UID 0 = root (all-powerful admin). All others are ordinary users.

๐Ÿ‘‘ Who is Root

โš ๏ธ Main Linux Security Rule

Root can DO ANYTHING. Delete system files. Read any data. Install any software. Run any program.

If a hacker gets root - the game is over. The server is theirs. That's why the entire pentest comes down to one thing: how to get from an ordinary user to root.

This process is called Privilege Escalation (privilege escalation). We'll learn about it in Module 8.

๐Ÿ“ Where Passwords Live

In Linux, passwords are stored in two files:

๐Ÿ“„ /etc/passwd

User list. Anyone can read (permissions 644). In modern systems, passwords are not stored here - there's an x placeholder instead.

๐Ÿ” /etc/shadow

Real password hashes. Only root can read (permissions 640). If a hacker gets it - they can try to crack the hashes with hashcat.

Check your /etc/shadow:

ls -l /etc/shadow

Should be:

-rw-r----- 1 root shadow 1234 May 22 09:00 /etc/shadow

These letters -rw-r----- - are the permissions. Now let's figure out what they mean.

๐ŸŽฏ Decoding Permissions: rwx and Numbers

Each file in Linux has permissions for 3 categories:

And 3 types of permissions:

When you see -rw-r--r--:

-  rw-  r--  r--
โ†‘   โ†‘    โ†‘    โ†‘
file type Owner Group Others

It turns out:

๐Ÿ”ข Numeric Notation (Most Important)

It's more convenient to write permissions in numbers:

NumberBinaryPermissionsMeans
0000---nothing
1001--xonly execute
2010-w-only write
3011-wxwrite + execute
4100r--only read
5101r-xread + execute
6110rw-read + write
7111rwxEVERYTHING

Remember as a sum: r=4, w=2, x=1.

๐ŸŽฏ Standard Permissions

chmodLettersWhen to Use
755rwxr-xr-xExecutable files and directories (standard)
644rw-r--r--Regular files (documents, configs)
600rw-------Private files (SSH keys, passwords)
700rwx------Private directories and scripts
777rwxrwxrwxNEVER in production - this is a hole

๐Ÿ›  Commands in Practice

Create a test file:

cd ~
echo "test" > myfile.txt
ls -l myfile.txt

You'll see something like:

-rw-r--r-- 1 kali kali 5 May 22 09:00 myfile.txt

Change permissions:

chmod 700 myfile.txt   # only owner can do everything
ls -l myfile.txt
# -rwx------ 1 kali kali 5 ...

chmod 755 myfile.txt   # standard for script
chmod +x myfile.txt    # alternative syntax: add execute
chmod -w myfile.txt    # remove write from everyone

๐Ÿ”“ sudo - Your Key to Root

In everyday life, you're kali. To temporarily become root - use sudo.

sudo apt update           # update packages (needs root)
sudo cat /etc/shadow      # read protected file
sudo -i                   # become root completely (exit: exit)
sudo whoami               # root

How it works:

  1. You enter sudo ...
  2. Linux checks - are you in the /etc/sudoers file
  3. Asks for your password (not root's)
  4. Executes the command as root
  5. Remembers for 15 minutes - next sudo without password
โš ๏ธ Privilege Escalation 101

If you find a way to execute ONE command as root (e.g. through a hole in a web application) - you've already won. The first command is usually:

sudo -i        # or
sudo /bin/bash # give yourself a root shell

This will be in Module 8.

๐ŸŽฏ Final Exercise

  1. cd ~ - go to your directory
  2. echo "secret data" > secrets.txt - create a file
  3. chmod 600 secrets.txt - private mode
  4. ls -l secrets.txt - check permissions (-rw-------)
  5. su - www-data -c "cat /home/kali/secrets.txt" - try to read as another user
  6. Get Permission denied - permissions work!
  7. sudo cat /etc/shadow - and root can read (nothing is hidden from them)
  8. chmod 644 secrets.txt - open reading to everyone (counterexample: don't do this)

๐Ÿค– Vibe-task: Ask Claude

Open Claude and ask:

Explain in simple terms how the SUID bit works in Linux
and why it's important for privilege escalation attacks.
Give 3 examples of commands that help find SUID files on the training VM:
"find / -perm -4000 ..." and decode each.

SUID is a special case of chmod. In Module 8, it will be our main tool for escalating privileges.

๐Ÿ’ก Main Conclusion of Module 2

๐ŸŽ“ What You Can Do Now

1. You have a working Kali Linux in a virtual machine

2. You're not afraid of the terminal - you know 10 basic commands

3. You understand permissions, root, sudo

4. You can read most pentest tutorials (90% of work is in Linux)

This is the foundation. Next - we'll learn how the NETWORK is arranged.

๐ŸŽฌ What's Next

Module 3: How the Internet Works. IP addresses, ports, protocols (TCP/UDP, HTTP, DNS). In simple terms. Without jargon. By the end of the module, you'll understand how a data packet flies from you to Google and back.

โ† Lesson 2.2 Module 3: How the Internet Works โ†’