scr1++y

Writeups for CTF Challenges

View on GitHub

Box: Cap by InfoSecJack

IP = 10.10.10.245
Difficulty: Easy 
Machine OS: Linux
Learning Platform: hackthebox.eu
Finished on: Kali Linux VM 

Reconnaissance

Scoping and Preparation

Syntax: sudo vi /etc/hosts , then press i to enter insert mode and paste the machine IP and add name for that host. (I named it cap.htb)

Syntax: export IP=10.10.10.245

Preliminary Enumeration via nmap

PORT STATE SERVICE REASON VERSION
21/tcp open FTP syn-ack vsftpd 3.0.3
22/tcp open SSH syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
80/tcp open HTTP syn-ack gunicorn

Machine OS: Ubuntu Focal Fossa, based on OpenSSH version.

Enumeration

  1. Web Enumeration

    • Looking at the web page, we have a security dashboard as seen below.

    Security Dashboard

    • There is an interesting tab named Security Snapshot. We can navigate through that and we can see that it captures network traffic and lets us download it.

    PCAP Download

    • Looking closely at the URL, we can see that the pages are referenced via page numbers in URL. We can try to manipulate the page number in the URL and we might see interesting .pcap file.

    Page Number IDOR

    • Nice! We can see the page zero of the security snapshot!

    • We can download the .pcap file and use it against wireshark

    • Open 0.pcap on wireshark.

    Syntax: wireshark, then select the file tab and open the directory where the .pcap file reside.

    0

    • We could already see that there is a FTP traffic captured in the network.

    • FTP authentication is not encrypted, so we can see what’s happening in plain text and hopefully we can get some interesting finds here.

    • Voila! We found plaintext credentials on FTP authentication traffic!

    FTP Password

    • We can see the plaintext password of nathan user! We can now try to login to FTP of nathan user.
  2. FTP Enumeration

    • Logging to the FTP server, we can see what it seems the home directory of nathan.

    FTP

    Files named exploit.c, exploit, linenum.sh are all real user input because of shared instances in the box.

Possible Exploits

Exploitation

Credentials Found via Wireshark

nathan:Buck3tH4TF0RM3!

Privilege Escalation

Internal Enumeration
Vertical Privilege Escalation

Linux Capability

P.S. I highly recommend the linked webpage above because of knowledge you get in here when it comes to penetration testing!

To exploit the capability of a binary with cap_setuid (in this case python3.8):

Syntax: /usr/bin/python3.8 -c 'import os;os.setuid(0);os.system("/bin/bash");'

Explanation: runs python3.8 with a command that imports os library and sets the UID to 0 (root) and executes /bin/bash as root.

Nathan2Root

Congratulations!

STATUS: ROOTED

The next two steps are not necessary for completion of the machine but it completes the 5 Phases of Penetration Testing.

Post Exploitation / Maintaining Access

Clearing Tracks

Status: Finished

Feel free to reach out and if there is something wrong about the above post. Feedbacks are also appreciated :D

Donation Box

Not required but appreciated :D

ko-fi

"Buy Me A Coffee"

Socials

<– Go Back