Eating Humble Pie
I use Linux every day but not to an advanced System Administrator capacity.
It's easy to "skip through" because I'm familiar with the environment.
Learn about Linux Administration
Resource: Linux Admin for Absolute Beginners
Author: Martin Stevenson
Skill 1: File / Folder Management
Microskill: Read the permission string
Concept: Files and folders have a long permission string.
Each letter has a different meaning
Why it's important:
Limit the actions of each file on the computer. Read, write, execute.
Where it can go wrong:
- Read - compromise privacy
- Example: Employment offer letters, secret keys
- Write - overwrite/delete important documents
- Example: Sales scripts, brand images
- Execute - potential malicious code or accidental running
- Example: Malicious file transferred from USB
- Example: Prevent students from running "update print quota" command
Learning
Here is an example:
drwxr-xr-x 3 kali kali 4096 Jul 6 05:02 .
drwxr-xr-x 22 kali kali 4096 Jul 6 04:23 ..
drwxr-xr-x 2 kali kali 4096 Jul 6 04:23 example_folder
-rwxr-xr-x 1 kali kali 0 Jul 6 04:24 sample_program
-rw-r--r-- 1 kali kali 0 Jul 6 04:24 sample.txt
- First character
- 'd' - directory
- '-' - plain file
- 'l' - symbolic link
- Permission types
- 'r' - read
- 'w' - write
- 'x' - execute
- Three groups of rwx.
- owner
- group
- world
Read it like this:
- sample.txt
- Everyone can read the file
- only the owner can write to the file
- The owner is the user "kali"
- sample_program
- Everyone can read the file
- Everyone can execute the file
- only the owner can write to the file
- The owner is the user "kali"
Values
Each permission type is given a value:
- r - 4
- w - 2
- x - 1
Total amount is 7 if you add them all up.
Use "chmod" to define the a digit for owner, group, world
Command to give full permissions will be:
chmod 777 filename
Practice this on the sample.txt file:
chmod 777 sample.txt
-rwxrwxrwx 1 kali kali 0 Jul 6 04:24 sample.txt
-rwxrwxrwx 1 kali kali 0 Jul 6 04:24 sample.txt
If you want infinite practice like me, I created a small bash script to create a file and challenge
After doing it 10 times, I'm getting used to setting the numbers for each permission.
What does this mean for cybersecurity?
These permissions are helpful to limit user's ability to interact with files on a Linux machine - like a server.
It doesn't really make too much sense when it's your own personal laptop.
However, when a company's server is online, you don't want everyone who has access to have "God Mode" privileges.
However, when a company's server is online, you don't want everyone who has access to have "God Mode" privileges.
You'll be assigning everyone their own login, permission roles etc.
That being said, if there was a hacker who infiltrated the system, they'll need to escalate their permissions before they can do nasty things on restricted files.
For example, if the account they used didn't have permission to write to a file, they won't be able to directly encrypt it in a ransomware attack.
Cyber Exercise
You are on the Red Team.
The login credentials for the Linux server was the admin's favourite basketball team and his birth year: Cavaliers2001
Easy.
You've masked your IP address using proxy chaining.
It's time to inject a little script to execute on their computer.
payload
You use scp to send it over using the credentials.
scp payload admin@X.X.X.X:/home/admin
When you send the payload over, it will not be executable by default.
We will need to change the file's permissions.
It's your turn to update it.
We will need to change the file's permissions.
It's your turn to update it.
Start with using ssh to log in and then use chmod.
Bonus marks if you can keep everything the same and only one execute for the world. (Sneaky sneaky!)
Answer at bottom.
Answer at bottom.
ssh admin@X.X.X.X
chmod 645 payload
Summary
At the end of this post, I am able to update the permissions of files and folders given the account I'm using has enough privileges over the file.
As a side benefit, I also got to start writing Bash scripts to automate things - in this case it was to write up a challenge program.
By creating a fake scenario for me to play out, it gives me more reason to understand this concept.
Comments
Post a Comment